using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("vithamonsta")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("simple wind plugin")]
[assembly: AssemblyFileVersion("0.0.47.0")]
[assembly: AssemblyInformationalVersion("0.0.47")]
[assembly: AssemblyProduct("wind")]
[assembly: AssemblyTitle("Simple Wind Plugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.47.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace visSpace
{
[BepInProcess("h3vr.exe")]
[BepInPlugin("wind", "Simple Wind Plugin", "0.0.47")]
public class WindPlugin : BaseUnityPlugin
{
public static Vector3 WindVector;
public static Vector3 ActiveGustVector = Vector3.zero;
internal static float WindStrength;
internal static float WindChangeTime;
internal static Vector3 GustVector;
internal static float GustSpeed;
internal static float GustRand;
internal static float GustFreq;
internal static float GustDuration;
internal static bool AffectsRb;
internal static ConfigEntry<float> WindStrConfig;
internal static ConfigEntry<float> WindTimeConfig;
internal static ConfigEntry<float> WindGustRandConfig;
internal static ConfigEntry<float> WindGustIntConfig;
internal static ConfigEntry<float> WindGustFreqConfig;
internal static ConfigEntry<float> WindGustDurConfig;
internal static ConfigEntry<bool> WindRBConfig;
public const string Id = "wind";
internal static ManualLogSource Logger { get; private set; }
public static string Name => "Simple Wind Plugin";
public static string Version => "0.0.47";
private void LoadConfig()
{
WindStrConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Wind Settings", "Wind Strength", 6f, "Controls the strength of the wind effect.");
WindTimeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Wind Settings", "Wind Change Time", 150f, "Controls how often wind direction changes in minimum seconds.");
WindRBConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Wind Settings", "Wind Affects Rigidbodies", false, "Controls if wind affects all objects and not only bullets. EXPENSIVE, possibly annoying.");
WindGustRandConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Wind Settings", "Gust Randomness", 0.25f, "How random gusts are");
WindGustIntConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Wind Settings", "Gust Intensity", 3f, "How strong gusts are maximum");
WindGustFreqConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Wind Settings", "Gust Frequency", 5f, "How often gusts occur minimum");
WindGustDurConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Wind Settings", "Gust Duration", 2.5f, "How long gusts last minimum");
AffectsRb = WindRBConfig.Value;
WindStrength = WindStrConfig.Value;
WindChangeTime = WindTimeConfig.Value;
GustRand = WindGustRandConfig.Value;
GustSpeed = WindGustIntConfig.Value;
GustFreq = WindGustFreqConfig.Value;
GustDuration = WindGustDurConfig.Value;
WindStrConfig.SettingChanged += OnSettingChanged;
WindRBConfig.SettingChanged += OnSettingChanged;
WindTimeConfig.SettingChanged += OnSettingChanged;
WindGustIntConfig.SettingChanged += OnSettingChanged;
WindGustRandConfig.SettingChanged += OnSettingChanged;
WindGustFreqConfig.SettingChanged += OnSettingChanged;
WindGustDurConfig.SettingChanged += OnSettingChanged;
}
private void OnSettingChanged(object sender, EventArgs e)
{
WindStrength = WindStrConfig.Value;
AffectsRb = WindRBConfig.Value;
WindChangeTime = WindTimeConfig.Value;
GustRand = WindGustRandConfig.Value;
GustSpeed = WindGustIntConfig.Value;
GustFreq = WindGustFreqConfig.Value;
GustDuration = WindGustDurConfig.Value;
}
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
new Harmony("com.vi.windplugin").PatchAll();
LoadConfig();
GenerateWind();
((MonoBehaviour)this).StartCoroutine(UpdateWind());
((MonoBehaviour)this).StartCoroutine(UpdateGustVector());
((MonoBehaviour)this).StartCoroutine(ManageRBWind());
}
private void OnDestroy()
{
WindStrConfig.SettingChanged -= OnSettingChanged;
WindRBConfig.SettingChanged -= OnSettingChanged;
WindTimeConfig.SettingChanged -= OnSettingChanged;
WindGustRandConfig.SettingChanged -= OnSettingChanged;
WindGustIntConfig.SettingChanged -= OnSettingChanged;
WindGustFreqConfig.SettingChanged -= OnSettingChanged;
WindGustDurConfig.SettingChanged -= OnSettingChanged;
}
private IEnumerator UpdateGustVector()
{
while (true)
{
GustRand = WindGustRandConfig.Value;
GustSpeed = WindGustIntConfig.Value;
GustFreq = WindGustFreqConfig.Value;
GustDuration = WindGustDurConfig.Value;
GustVector = WindVector;
Vector3 val = new Vector3(Random.Range(-1f, 1f), Random.Range(-0.1f, 0.1f), Random.Range(-1f, 1f));
Vector3 val2 = ((Vector3)(ref val)).normalized * (((Vector3)(ref GustVector)).magnitude * GustRand);
GustVector += val2;
float num = Random.Range(0.01f, GustSpeed);
GustVector *= num;
yield return ((MonoBehaviour)this).StartCoroutine(SmoothDoGust(Random.Range(GustDuration, GustDuration * 4f)));
yield return (object)new WaitForSeconds(Random.Range(GustFreq, GustFreq * 4f));
}
}
private IEnumerator SmoothDoGust(float duration)
{
Vector3 startValue = ActiveGustVector;
float elapsedTime2 = 0f;
float num = Random.Range(duration / 5f, duration - duration / 5f);
float num2 = Random.Range(duration / 5f, duration - duration / 5f);
float attackTime = Mathf.Min(num, num2);
float sustainTime = Mathf.Max(num, num2) - attackTime;
float decayTime = duration - (attackTime + sustainTime);
while (elapsedTime2 < attackTime)
{
ActiveGustVector = Vector3.Slerp(startValue, GustVector, elapsedTime2 / attackTime);
elapsedTime2 += Time.deltaTime;
yield return null;
}
yield return (object)new WaitForSeconds(sustainTime);
elapsedTime2 = 0f;
while (elapsedTime2 < decayTime)
{
ActiveGustVector = Vector3.Slerp(ActiveGustVector, startValue, elapsedTime2 / decayTime);
elapsedTime2 += Time.deltaTime;
yield return null;
}
ActiveGustVector *= 0f;
}
private IEnumerator SmoothChangeWind(Vector3 targetValue, float duration)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
Vector3 startValue = WindVector;
float elapsedTime = 0f;
while (elapsedTime < duration)
{
WindVector = Vector3.Lerp(startValue, targetValue, elapsedTime / duration);
elapsedTime += Time.deltaTime;
yield return null;
}
WindVector = targetValue;
}
private IEnumerator ManageRBWind()
{
float updateTime = 1f;
while (true)
{
AffectsRb = WindRBConfig.Value;
if (AffectsRb)
{
Rigidbody[] array = Object.FindObjectsOfType<Rigidbody>();
foreach (Rigidbody val in array)
{
if ((double)val.mass > 0.001)
{
((MonoBehaviour)this).StartCoroutine(ApplyWindForce(val, updateTime));
}
}
}
yield return (object)new WaitForSeconds(updateTime);
}
}
private IEnumerator ApplyWindForce(Rigidbody rb, float time)
{
float elapsedTime = 0f;
float surfaceArea = GetColliderSurfaceArea(rb);
if (!((double)surfaceArea > 0.007))
{
yield break;
}
for (; elapsedTime < time; elapsedTime += Time.fixedDeltaTime)
{
if ((Object)(object)rb == (Object)null)
{
break;
}
if (!rb.IsSleeping() && !rb.isKinematic)
{
Vector3 val = WindVector + ActiveGustVector;
Vector3 normalized = ((Vector3)(ref val)).normalized;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
float num = Vector3.Dot(rb.velocity, normalized);
float num2 = Mathf.Max(0f, sqrMagnitude - num * num);
if (num2 > 0f)
{
Vector3 val2 = normalized * Mathf.Sqrt(num2) * surfaceArea;
rb.AddForce(val2, (ForceMode)0);
}
}
yield return (object)new WaitForFixedUpdate();
}
}
private float GetColliderSurfaceArea(Rigidbody rb)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
Collider[] components = ((Component)rb).GetComponents<Collider>();
foreach (Collider val in components)
{
BoxCollider val2 = (BoxCollider)(object)((val is BoxCollider) ? val : null);
if (val2 != null)
{
Vector3 size = val2.size;
num += 2f * (size.x * size.y + size.x * size.z + size.y * size.z);
continue;
}
SphereCollider val3 = (SphereCollider)(object)((val is SphereCollider) ? val : null);
if (val3 != null)
{
float radius = val3.radius;
num += (float)Math.PI * 4f * radius * radius;
continue;
}
CapsuleCollider val4 = (CapsuleCollider)(object)((val is CapsuleCollider) ? val : null);
if (val4 != null)
{
float radius2 = val4.radius;
float num2 = val4.height - 2f * radius2;
num += (float)Math.PI * 2f * radius2 * radius2 + (float)Math.PI * 2f * radius2 * num2;
continue;
}
MeshCollider val5 = (MeshCollider)(object)((val is MeshCollider) ? val : null);
if (val5 != null && (Object)(object)val5.sharedMesh != (Object)null)
{
Bounds bounds = val5.sharedMesh.bounds;
Vector3 val6 = Vector3.Scale(((Bounds)(ref bounds)).size, ((Component)val5).transform.lossyScale);
num += 2f * (val6.x * val6.y + val6.x * val6.z + val6.y * val6.z);
}
}
return num;
}
private IEnumerator UpdateWind()
{
while (true)
{
float num = Random.Range(-1f, 1f);
float num2 = Random.Range(-0.1f, 0.1f);
float num3 = Random.Range(-1f, 1f);
Vector3 newWind = new Vector3(num, num2, num3) * Random.Range(0.01f, WindStrength);
float randTime = WindChangeTime * (float)Random.Range(1, 4);
yield return ((MonoBehaviour)this).StartCoroutine(SmoothChangeWind(newWind, randTime));
if (Logger != null)
{
Logger.LogInfo((object)$"Generated Wind Vector: {newWind}");
}
yield return (object)new WaitForSeconds(randTime / (float)Random.Range(1, 16));
}
}
public static void GenerateWind()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
float num = Random.Range(-1f, 1f);
float num2 = Random.Range(-0.1f, 0.1f);
float num3 = Random.Range(-1f, 1f);
WindVector = new Vector3(num, num2, num3) * Random.Range(0.01f, WindStrength);
if (Logger != null)
{
Logger.LogInfo((object)$"Generated Wind Vector: {WindVector}");
}
}
}
}
namespace visSpace.Patches
{
[HarmonyPatch(typeof(BallisticProjectile), "ApplyDrag")]
public class BulletDragPatch
{
[HarmonyPrefix]
public static void Prefix(ref Vector3 velocity, ref float time)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
velocity += (WindPlugin.ActiveGustVector + WindPlugin.WindVector) * time;
}
}
}