Decompiled source of WeatherBias80 v1.5.0

Always Rain.dll

Decompiled a day 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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Always Rain")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Always Rain")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e510e1b6-7a70-4e67-ad1f-ac2d3883b930")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WeatherBias80;

[BepInPlugin("com.yourname.weatherbias80", "Weather Bias 80%", "1.5.0")]
public class WeatherBias80 : BaseUnityPlugin
{
	private ConfigEntry<float> RainChance;

	private ConfigEntry<float> SnowChance;

	private ConfigEntry<bool> ShowOverlay;

	private ConfigEntry<KeyboardShortcut> ToggleKey;

	private ConfigEntry<float> OverlayX;

	private ConfigEntry<float> OverlayY;

	private Rect _windowRect;

	private static readonly string[] RainEnvs = new string[5] { "Rain", "LightRain", "ThunderStorm", "SwampRain", "Ashrain" };

	private static readonly string[] SnowEnvs = new string[2] { "Snow", "Blizzard" };

	private string _lastEnv = "";

	private void Awake()
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		RainChance = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "RainChance", 0.8f, "Chance of forcing rain in non-mountain biomes (0–1).");
		SnowChance = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "SnowChance", 0.8f, "Chance of forcing snow/blizzard in mountain biomes (0–1).");
		ShowOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Overlay", "ShowOverlay", true, "Show on-screen overlay with time and weather.");
		ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Overlay", "ToggleKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Key to toggle the overlay on/off.");
		OverlayX = ((BaseUnityPlugin)this).Config.Bind<float>("Overlay", "OverlayX", (float)Screen.width / 2f - 130f, "Overlay X position on screen.");
		OverlayY = ((BaseUnityPlugin)this).Config.Bind<float>("Overlay", "OverlayY", 20f, "Overlay Y position on screen.");
		_windowRect = new Rect(OverlayX.Value, OverlayY.Value, 260f, 100f);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Weather Bias 80% loaded (Configurable Overlay Position + Draggable).");
	}

	private void Update()
	{
		//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_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: 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_00a6: Invalid comparison between Unknown and I4
		KeyboardShortcut value = ToggleKey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			ShowOverlay.Value = !ShowOverlay.Value;
		}
		if ((Object)(object)EnvMan.instance == (Object)null)
		{
			return;
		}
		EnvSetup currentEnvironment = EnvMan.instance.GetCurrentEnvironment();
		if (currentEnvironment == null)
		{
			return;
		}
		string name = currentEnvironment.m_name;
		if (name == _lastEnv)
		{
			return;
		}
		_lastEnv = name;
		Biome val = (Biome)((!Object.op_Implicit((Object)(object)Player.m_localPlayer)) ? 1 : ((int)Player.m_localPlayer.GetCurrentBiome()));
		bool flag = (int)val == 4;
		float value2 = Random.value;
		if (flag)
		{
			if (value2 <= SnowChance.Value)
			{
				string text = SnowEnvs[Random.Range(0, SnowEnvs.Length)];
				((Terminal)Console.instance).TryRunCommand("env " + text, false, false);
			}
			else
			{
				((Terminal)Console.instance).TryRunCommand("resetenv", false, false);
			}
		}
		else if (value2 <= RainChance.Value)
		{
			string text2 = RainEnvs[Random.Range(0, RainEnvs.Length)];
			((Terminal)Console.instance).TryRunCommand("env " + text2, false, false);
		}
		else
		{
			((Terminal)Console.instance).TryRunCommand("resetenv", false, false);
		}
	}

	private void OnGUI()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0034: 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_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		if (ShowOverlay.Value)
		{
			Rect windowRect = GUI.Window(424242, _windowRect, new WindowFunction(DrawOverlayWindow), "Weather Info");
			if (((Rect)(ref windowRect)).position != ((Rect)(ref _windowRect)).position)
			{
				_windowRect = windowRect;
				OverlayX.Value = ((Rect)(ref _windowRect)).x;
				OverlayY.Value = ((Rect)(ref _windowRect)).y;
				((BaseUnityPlugin)this).Config.Save();
			}
		}
	}

	private void DrawOverlayWindow(int id)
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		string inGameTime12h = GetInGameTime12h();
		EnvMan instance = EnvMan.instance;
		string text = ((instance == null) ? null : instance.GetCurrentEnvironment()?.m_name) ?? "Unknown";
		string facingDirection = GetFacingDirection();
		GUI.Label(new Rect(10f, 25f, 240f, 25f), "In‑Game Time: " + inGameTime12h);
		GUI.Label(new Rect(10f, 50f, 240f, 25f), "Current Weather: " + text);
		GUI.Label(new Rect(10f, 75f, 240f, 25f), "Facing: " + facingDirection);
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
	}

	private string GetInGameTime12h()
	{
		EnvMan instance = EnvMan.instance;
		float num = ((instance != null) ? instance.GetDayFraction() : 0f);
		float num2 = num * 24f * 60f;
		int num3 = Mathf.FloorToInt(num2 / 60f);
		int num4 = Mathf.FloorToInt(num2 % 60f);
		string arg = ((num3 >= 12) ? "PM" : "AM");
		int num5 = num3 % 12;
		if (num5 == 0)
		{
			num5 = 12;
		}
		return $"{num5}:{num4:00} {arg}";
	}

	private string GetFacingDirection()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: 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_0045: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return "Unknown";
		}
		Vector3 forward = ((Component)Player.m_localPlayer).transform.forward;
		forward.y = 0f;
		((Vector3)(ref forward)).Normalize();
		float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f;
		if (num < 0f)
		{
			num += 360f;
		}
		if (num >= 315f || num < 45f)
		{
			return "North";
		}
		if (num >= 45f && num < 135f)
		{
			return "East";
		}
		if (num >= 135f && num < 225f)
		{
			return "South";
		}
		return "West";
	}
}