using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using An0n_Patches.Patches;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("An0n_Patches")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("An0n_Patches")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("415f18a2-c213-4036-b3f0-7673c0a38c58")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace An0n_Patches
{
[BepInPlugin("com.an0n.fairStorms", "An0n Fair Storms", "1.0.6")]
public class An0n_Patch_Plugin : BaseUnityPlugin
{
public const string pluginGUID = "com.an0n.fairStorms";
private const string pluginName = "An0n Fair Storms";
private const string pluginVersion = "1.0.6";
public static ConfigEntry<bool> manageRootWinds;
public static ConfigEntry<bool> manageAlpineWinds;
public static ConfigEntry<float> objectDistAlpine;
public static ConfigEntry<float> objectDistRoots;
public static ManualLogSource mls = Logger.CreateLogSource("com.an0n.fairStorms");
private Harmony harmony = new Harmony("com.an0n.fairStorms");
public static An0n_Patch_Plugin instance;
private Harmony patcher;
private void Awake()
{
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
manageRootWinds = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fair Roots Wind Enable", true, "Enable if we manage the Roots wind the same way we do with Alpine.");
manageAlpineWinds = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fair Alpine Wind Enable", true, "Enable if we manage the Roots wind the same way we do with Alpine.");
objectDistAlpine = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Winter Object Distance", 10f, "How far away a wall/tree/rock/object is to consider you shielded from the wind in ALPINE biome. (Lower = you need to be closer)");
objectDistRoots = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Roots Object Distance", 10f, "How far away a wall/tree/rock/object is to consider you shielded from the wind in ROOTS. (Lower = you need to be closer)");
instance = this;
Debug.Log((object)"[An0nPatch] An0n Fair Storms Plugin 1.0.6 Loaded!");
patcher = new Harmony("com.an0n.fairStorms");
patcher.PatchAll(typeof(WindPatch));
manageRootWinds.SettingChanged += delegate
{
WindPatch.refreshEnableSettings();
};
manageAlpineWinds.SettingChanged += delegate
{
WindPatch.refreshEnableSettings();
};
}
}
}
namespace An0n_Patches.Patches
{
public static class WindPatch
{
public static class WindProtection
{
public static bool IsPlayerProtectedFromWind(Vector3 player, string stormType)
{
//IL_0009: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
Vector3 val = default(Vector3);
if (stormType == "SnowStorm")
{
num = An0n_Patch_Plugin.objectDistAlpine.Value;
val = (Vector3)Traverse.Create((object)alpineWind).Field("currentWindDirection").GetValue();
}
if (stormType == "WindStorm")
{
num = An0n_Patch_Plugin.objectDistRoots.Value;
val = (Vector3)Traverse.Create((object)rootsWind).Field("currentWindDirection").GetValue();
}
Vector3 val2 = -((Vector3)(ref val)).normalized;
RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[1];
int num2 = Physics.RaycastNonAlloc(player, val2, array, num, -1, (QueryTriggerInteraction)1);
if (num2 > 0)
{
return true;
}
return false;
}
}
public static string[] validStorms = new string[2] { "SnowStorm", "WindStorm" };
public static WindChillZone alpineWind;
public static WindChillZone rootsWind;
private static int checkNum = 0;
private static bool wasProtected = false;
[HarmonyPostfix]
[HarmonyPatch(typeof(StormVisual), "Start")]
public static void AwakePatchWind(WindChillZone __instance)
{
refreshEnableSettings();
alpineWind = GameObject.Find("SnowStorm").GetComponent<WindChillZone>();
rootsWind = GameObject.Find("WindStorm").GetComponent<WindChillZone>();
}
public static void refreshEnableSettings()
{
validStorms = new string[2] { "SnowStorm", "WindStorm" };
if (!An0n_Patch_Plugin.manageRootWinds.Value)
{
validStorms = validStorms.Where((string s) => s != "WindStorm").ToArray();
}
if (!An0n_Patch_Plugin.manageAlpineWinds.Value)
{
validStorms = validStorms.Where((string s) => s != "SnowStorm").ToArray();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(WindChillZone), "AddWindForceToCharacter", new Type[]
{
typeof(Character),
typeof(float)
})]
public static bool manageWind(WindChillZone __instance)
{
if (validStorms.Contains(((Object)__instance).name))
{
if (wasProtected)
{
return false;
}
return true;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(WindChillZone), "ApplyStatus")]
public static bool isProtectCheck(WindChillZone __instance)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if (validStorms.Contains(((Object)__instance).name))
{
if (checkNum == 10)
{
checkNum = 0;
if (validStorms.Contains(((Object)__instance).name))
{
if (WindProtection.IsPlayerProtectedFromWind(Character.localCharacter.Center, ((Object)__instance).name))
{
wasProtected = true;
__instance.localCharacterInsideBounds = false;
return false;
}
wasProtected = false;
}
}
checkNum++;
if (wasProtected)
{
return false;
}
return true;
}
return true;
}
}
}