using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using SettingsExtender;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.SceneManagement;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.pharmacomaniac.WeatherStormController")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.pharmacomaniac.WeatherStormController")]
[assembly: AssemblyTitle("WeatherStormController")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 ConfigurableStormController
{
[BepInPlugin("com.example.configurablestormcontroller", "Configurable Storm Controller", "4.2.4")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.example.configurablestormcontroller";
public const string PLUGIN_NAME = "Configurable Storm Controller";
public const string PLUGIN_VERSION = "4.2.4";
public const string SETTINGS_PAGE_NAME = "Storm Controller";
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
SettingsRegistry.Register("Storm Controller");
SceneManager.sceneLoaded += OnSceneLoaded;
Log.LogInfo((object)"Configurable Storm Controller is loaded and ready.");
}
private void Start()
{
SettingsHandler instance = SettingsHandler.Instance;
instance.AddSetting((Setting)(object)new EnableModSetting());
instance.AddSetting((Setting)(object)new EnableRainSetting());
instance.AddSetting((Setting)(object)new RainFrequencySetting());
instance.AddSetting((Setting)(object)new RainDurationSetting());
instance.AddSetting((Setting)(object)new EnableSnowSetting());
instance.AddSetting((Setting)(object)new SnowFrequencySetting());
instance.AddSetting((Setting)(object)new SnowDurationSetting());
Log.LogInfo((object)"Added all storm settings to the in-game UI.");
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).name.StartsWith("Level_"))
{
Log.LogInfo((object)("Game scene '" + ((Scene)(ref scene)).name + "' loaded. Initializing Storm Controller..."));
StormController.Initialize();
}
}
}
public static class StormController
{
private static WindChillZone _rainZone;
private static WindChillZone _snowZone;
private static Vector2 _defaultRainOn;
private static Vector2 _defaultRainOff;
private static Vector2 _defaultSnowOn;
private static Vector2 _defaultSnowOff;
private static bool _isInitialized;
public static void Initialize()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Invalid comparison between Unknown and I4
//IL_0086: 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_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
WindChillZone[] array = Object.FindObjectsByType<WindChillZone>((FindObjectsSortMode)0);
_rainZone = null;
_snowZone = null;
WindChillZone[] array2 = array;
foreach (WindChillZone val in array2)
{
StormVisual componentInChildren = ((Component)val).GetComponentInChildren<StormVisual>(true);
if ((int)componentInChildren.stormType == 0)
{
_rainZone = val;
}
else if ((int)componentInChildren.stormType == 1)
{
_snowZone = val;
}
}
if ((Object)(object)_rainZone == (Object)null || (Object)(object)_snowZone == (Object)null)
{
Plugin.Log.LogError((object)"Failed to find both Rain and Snow storm controllers!");
_isInitialized = false;
return;
}
_defaultRainOn = _rainZone.windTimeRangeOn;
_defaultRainOff = _rainZone.windTimeRangeOff;
_defaultSnowOn = _snowZone.windTimeRangeOn;
_defaultSnowOff = _snowZone.windTimeRangeOff;
_isInitialized = true;
Plugin.Log.LogInfo((object)"Storm Controller initialized successfully.");
ApplyAllSettings();
}
public static void ApplyAllSettings()
{
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
if (!_isInitialized)
{
return;
}
SettingsHandler instance = SettingsHandler.Instance;
bool value = ((BoolSetting)instance.GetSetting<EnableModSetting>()).Value;
Plugin.Log.LogInfo((object)("Applying all settings. Master switch is " + (value ? "ON" : "OFF") + "."));
if (!value)
{
RestoreVanillaValues();
return;
}
if (((BoolSetting)instance.GetSetting<EnableRainSetting>()).Value)
{
float value2 = ((FloatSetting)instance.GetSetting<RainFrequencySetting>()).Value;
float value3 = ((FloatSetting)instance.GetSetting<RainDurationSetting>()).Value;
_rainZone.windTimeRangeOff = new Vector2(_defaultRainOff.x / value2, _defaultRainOff.y / value2);
_rainZone.windTimeRangeOn = new Vector2(value3 * 0.9f, value3 * 1.1f);
}
else
{
_rainZone.windTimeRangeOff = new Vector2(float.MaxValue, float.MaxValue);
if (_rainZone.windActive)
{
_rainZone.windActive = false;
}
}
if (((BoolSetting)instance.GetSetting<EnableSnowSetting>()).Value)
{
float value4 = ((FloatSetting)instance.GetSetting<SnowFrequencySetting>()).Value;
float value5 = ((FloatSetting)instance.GetSetting<SnowDurationSetting>()).Value;
_snowZone.windTimeRangeOff = new Vector2(_defaultSnowOff.x / value4, _defaultSnowOff.y / value4);
_snowZone.windTimeRangeOn = new Vector2(value5 * 0.9f, value5 * 1.1f);
}
else
{
_snowZone.windTimeRangeOff = new Vector2(float.MaxValue, float.MaxValue);
if (_snowZone.windActive)
{
_snowZone.windActive = false;
}
}
}
private static void RestoreVanillaValues()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_0030: 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_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references)
if (_isInitialized)
{
Plugin.Log.LogInfo((object)"Restoring vanilla storm behavior.");
_rainZone.windTimeRangeOn = _defaultRainOn;
_rainZone.windTimeRangeOff = _defaultRainOff;
_snowZone.windTimeRangeOn = _defaultSnowOn;
_snowZone.windTimeRangeOff = _defaultSnowOff;
}
}
}
public class EnableModSetting : BoolSetting, IExposedSetting
{
public override LocalizedString OffString => null;
public override LocalizedString OnString => null;
public string GetDisplayName()
{
return "Enable Storm Controller";
}
protected override bool GetDefaultValue()
{
return true;
}
public string GetCategory()
{
return SettingsRegistry.GetPageId("Storm Controller");
}
public override void ApplyValue()
{
StormController.ApplyAllSettings();
}
}
public abstract class StepFloatSetting : FloatSetting, IExposedSetting
{
protected abstract float GetStep();
public override float Clamp(float value)
{
float step = GetStep();
if (step > 0f)
{
value = Mathf.Round(value / step) * step;
}
return ((FloatSetting)this).Clamp(value);
}
public abstract string GetDisplayName();
public string GetCategory()
{
return SettingsRegistry.GetPageId("Storm Controller");
}
public override void ApplyValue()
{
StormController.ApplyAllSettings();
}
}
public abstract class StormToggleSetting : BoolSetting, IExposedSetting
{
public override LocalizedString OffString => null;
public override LocalizedString OnString => null;
public abstract string GetDisplayName();
public string GetCategory()
{
return SettingsRegistry.GetPageId("Storm Controller");
}
public override void ApplyValue()
{
StormController.ApplyAllSettings();
}
}
public class EnableRainSetting : StormToggleSetting
{
public override string GetDisplayName()
{
return "Enable Rain";
}
protected override bool GetDefaultValue()
{
return true;
}
}
public class RainFrequencySetting : StepFloatSetting
{
public override string GetDisplayName()
{
return "Rain Frequency";
}
protected override float GetDefaultValue()
{
return 1f;
}
protected override float2 GetMinMaxValue()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return new float2(0.1f, 2f);
}
protected override float GetStep()
{
return 0.1f;
}
public override string Expose(float result)
{
return result.ToString("F1") + "x";
}
}
public class RainDurationSetting : StepFloatSetting
{
public override string GetDisplayName()
{
return "Rain Duration";
}
protected override float GetDefaultValue()
{
return 30f;
}
protected override float2 GetMinMaxValue()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return new float2(15f, 90f);
}
protected override float GetStep()
{
return 5f;
}
public override string Expose(float result)
{
return result.ToString("F0") + "s";
}
}
public class EnableSnowSetting : StormToggleSetting
{
public override string GetDisplayName()
{
return "Enable Snow";
}
protected override bool GetDefaultValue()
{
return true;
}
}
public class SnowFrequencySetting : StepFloatSetting
{
public override string GetDisplayName()
{
return "Snow Frequency";
}
protected override float GetDefaultValue()
{
return 1f;
}
protected override float2 GetMinMaxValue()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return new float2(0.1f, 2f);
}
protected override float GetStep()
{
return 0.1f;
}
public override string Expose(float result)
{
return result.ToString("F1") + "x";
}
}
public class SnowDurationSetting : StepFloatSetting
{
public override string GetDisplayName()
{
return "Snow Duration";
}
protected override float GetDefaultValue()
{
return 20f;
}
protected override float2 GetMinMaxValue()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return new float2(15f, 90f);
}
protected override float GetStep()
{
return 5f;
}
public override string Expose(float result)
{
return result.ToString("F0") + "s";
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}