Decompiled source of WindAtYourBack v0.3.0

plugins/WindFix_BepInEx.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("WindFix_BepInEx")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindFix_BepInEx")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5BB61B5E-CB54-4F45-917F-81B918E92FB6")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyVersion("0.3.0.0")]
namespace WindFix_BepInEx;

[BepInPlugin("xnm.WindFix", "WindFix", "0.3.0")]
public class BepInExPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(EnvMan), "Awake")]
	private static class EnvMan_Awake_Patch
	{
		private static void Postfix()
		{
			PrintOut("Mod Loaded");
		}
	}

	[HarmonyPatch(typeof(EnvMan), "SetTargetWind")]
	private class EnvMan_SetTargetWind_Patch
	{
		private static void Prefix(ref Vector3 dir, ref float intensity)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_001a: Invalid comparison between Unknown and I4
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Ship localShip = Ship.GetLocalShip();
			if (!Object.op_Implicit((Object)(object)localShip))
			{
				return;
			}
			Speed speedSetting = localShip.GetSpeedSetting();
			if ((int)speedSetting == 3 || (int)speedSetting == 4)
			{
				Vector3 forward = ((Component)localShip).transform.forward;
				if (useAngle.Value)
				{
					float num = (Vector3.SignedAngle(Vector3.forward, forward, Vector3.up) + angle.Value) * (float)Math.PI / 180f;
					dir.x = Mathf.Sin(num);
					dir.z = Mathf.Cos(num);
				}
				else
				{
					dir.x = forward.x;
					dir.z = forward.z;
				}
			}
		}
	}

	private static readonly bool isDebug = true;

	private static BepInExPlugin context;

	private static ConfigEntry<int> nexusID;

	private static ConfigEntry<bool> modEnabled;

	private static ConfigEntry<bool> useAngle;

	private static ConfigEntry<float> angle;

	public static void Dbgl(string str = "", bool pref = true)
	{
		if (isDebug)
		{
			Debug.Log((object)((pref ? (typeof(BepInExPlugin).Namespace + " ") : "") + str));
		}
	}

	private void Awake()
	{
		context = this;
		modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod");
		nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 282, "Nexus mod ID for updates");
		useAngle = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseAngle", false, "Want to set a specific angle?");
		angle = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Angle", 0f, "Wind angle relative to ship");
		if (modEnabled.Value)
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}

	public static void PrintOut(string log)
	{
		Console instance = Console.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			string text = "[WindFix]" + ": " + log;
			instance.Print(text);
		}
	}
}