Decompiled source of OnTogether Day and Night v1.0.3

BepInEx/plugins/On-Together_Day_and_Night/On-Together_Day_and_Night.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace OnTogetherDayAndNight;

internal sealed class ActivityPattern
{
	public string Id;

	public string Main;

	public string Accent;

	public string Loop;

	public float Gain;

	public float GapMin;

	public float GapMax;

	public int BurstMin;

	public int BurstMax;

	public float StepMin;

	public float StepMax;

	public float AccentChance;

	public float AccentDelayMin;

	public float AccentDelayMax;

	public ActivityPattern(string id, string main, string accent, float gain, float gapMin, float gapMax, int burstMin, int burstMax, float stepMin, float stepMax, float accentChance, float accentDelayMin, float accentDelayMax)
	{
		Id = id;
		Main = main;
		Accent = accent;
		Gain = gain;
		GapMin = gapMin;
		GapMax = gapMax;
		BurstMin = burstMin;
		BurstMax = burstMax;
		StepMin = stepMin;
		StepMax = stepMax;
		AccentChance = accentChance;
		AccentDelayMin = accentDelayMin;
		AccentDelayMax = accentDelayMax;
	}

	public static ActivityPattern Looping(string id, string loop, float gain)
	{
		ActivityPattern activityPattern = new ActivityPattern(id, null, null, gain, 0f, 0f, 0, 0, 0f, 0f, 0f, 0f, 0f);
		activityPattern.Loop = loop;
		return activityPattern;
	}
}
internal static class ActivitySynth
{
	private sealed class Rng
	{
		private readonly Random _random;

		public Rng(int seed)
		{
			_random = new Random(seed);
		}

		public float Next()
		{
			return (float)_random.NextDouble();
		}

		public float Range(float a, float b)
		{
			return a + (b - a) * (float)_random.NextDouble();
		}

		public int Int(int minInclusive, int maxExclusive)
		{
			return _random.Next(minInclusive, maxExclusive);
		}

		public float Noise()
		{
			return (float)_random.NextDouble() * 2f - 1f;
		}
	}

	private sealed class Biquad
	{
		private float _b0;

		private float _b1;

		private float _b2;

		private float _a1;

		private float _a2;

		private float _z1;

		private float _z2;

		public static Biquad LowPass(float frequency, float q)
		{
			Biquad biquad = new Biquad();
			biquad.Set(0, frequency, q);
			return biquad;
		}

		public static Biquad HighPass(float frequency, float q)
		{
			Biquad biquad = new Biquad();
			biquad.Set(1, frequency, q);
			return biquad;
		}

		public static Biquad BandPass(float frequency, float q)
		{
			Biquad biquad = new Biquad();
			biquad.Set(2, frequency, q);
			return biquad;
		}

		public void SetBandPass(float frequency, float q)
		{
			Set(2, frequency, q);
		}

		private void Set(int kind, float frequency, float q)
		{
			double num = Math.PI * 2.0 * (double)Math.Min(frequency, 19845f) / 44100.0;
			double num2 = Math.Cos(num);
			double num3 = Math.Sin(num) / (double)(2f * q);
			double num4 = 1.0 + num3;
			double num5;
			double num6;
			double num7;
			switch (kind)
			{
			case 0:
				num5 = (1.0 - num2) / 2.0;
				num6 = 1.0 - num2;
				num7 = (1.0 - num2) / 2.0;
				break;
			case 1:
				num5 = (1.0 + num2) / 2.0;
				num6 = 0.0 - (1.0 + num2);
				num7 = (1.0 + num2) / 2.0;
				break;
			default:
				num5 = num3;
				num6 = 0.0;
				num7 = 0.0 - num3;
				break;
			}
			_b0 = (float)(num5 / num4);
			_b1 = (float)(num6 / num4);
			_b2 = (float)(num7 / num4);
			_a1 = (float)(-2.0 * num2 / num4);
			_a2 = (float)((1.0 - num3) / num4);
		}

		public float Process(float x)
		{
			float num = _b0 * x + _z1;
			_z1 = _b1 * x - _a1 * num + _z2;
			_z2 = _b2 * x - _a2 * num;
			return num;
		}
	}

	public const int Rate = 44100;

	public static readonly ActivityPattern[] Patterns = new ActivityPattern[35]
	{
		new ActivityPattern("page", "page", null, 0.55f, 14f, 40f, 1, 2, 0.45f, 0.8f, 0f, 0f, 0f),
		new ActivityPattern("manga", "manga", null, 0.45f, 5f, 14f, 1, 1, 0f, 0f, 0f, 0f, 0f),
		new ActivityPattern("ereader", "ereader", null, 0.25f, 15f, 40f, 1, 1, 0f, 0f, 0f, 0f, 0f),
		new ActivityPattern("typing", "key", null, 0.32f, 1.5f, 7f, 6, 36, 0.07f, 0.17f, 0f, 0f, 0f),
		new ActivityPattern("typefast", "key", null, 0.32f, 0.8f, 4f, 14, 55, 0.045f, 0.1f, 0f, 0f, 0f),
		new ActivityPattern("browse", "trackpad", "typingBurst", 0.3f, 2f, 8f, 1, 3, 0.25f, 0.7f, 0.3f, 0.6f, 1.5f),
		new ActivityPattern("typewriter", "typewriterKey", "typewriterBell", 0.6f, 1.2f, 5f, 8, 30, 0.11f, 0.24f, 0.3f, 0.3f, 0.6f),
		new ActivityPattern("pencil", "pencil", null, 0.35f, 1.5f, 7f, 2, 7, 0.4f, 1.1f, 0f, 0f, 0f),
		new ActivityPattern("sketch", "sketch", null, 0.35f, 1f, 5f, 3, 9, 0.5f, 1.4f, 0f, 0f, 0f),
		new ActivityPattern("skim", "manga", "pencil", 0.4f, 3f, 9f, 1, 3, 0.3f, 0.6f, 0.5f, 0.4f, 1f),
		new ActivityPattern("brush", "brush", null, 0.3f, 1.5f, 6f, 2, 6, 0.7f, 1.5f, 0f, 0f, 0f),
		new ActivityPattern("watercolor", "brush", "waterDrop", 0.3f, 1.5f, 6f, 2, 5, 0.7f, 1.5f, 0.4f, 0.2f, 0.6f),
		new ActivityPattern("knit", "knit", null, 0.32f, 1f, 4f, 6, 16, 0.3f, 0.46f, 0f, 0f, 0f),
		new ActivityPattern("crochet", "crochet", null, 0.28f, 1f, 4f, 5, 12, 0.35f, 0.55f, 0f, 0f, 0f),
		new ActivityPattern("phone", "phoneTap", "swipe", 0.22f, 2f, 9f, 1, 5, 0.25f, 0.7f, 0.4f, 0.2f, 0.5f),
		new ActivityPattern("buttons", "button", null, 0.32f, 0.6f, 3f, 3, 12, 0.08f, 0.25f, 0f, 0f, 0f),
		new ActivityPattern("dnd", "pencil", "dice", 0.4f, 3f, 10f, 1, 3, 0.4f, 1f, 0.35f, 0.5f, 1.5f),
		new ActivityPattern("dm", "page", "dice", 0.5f, 8f, 22f, 1, 1, 0f, 0f, 0.45f, 0.8f, 2f),
		new ActivityPattern("ramen", "slurp", "bowl", 0.55f, 6f, 16f, 1, 1, 0f, 0f, 0.65f, 0.3f, 1.2f),
		new ActivityPattern("sip", "sip", "cup", 0.4f, 10f, 25f, 1, 1, 0f, 0f, 0.75f, 0.8f, 1.6f),
		new ActivityPattern("straw", "straw", null, 0.45f, 8f, 20f, 1, 1, 0f, 0f, 0f, 0f, 0f),
		new ActivityPattern("boba", "boba", null, 0.45f, 7f, 18f, 1, 1, 0f, 0f, 0f, 0f, 0f),
		new ActivityPattern("bento", "chopsticks", "chew", 0.4f, 4f, 10f, 1, 2, 0.3f, 0.6f, 0.8f, 0.3f, 0.6f),
		new ActivityPattern("watermelon", "crunch", "chew", 0.5f, 7f, 15f, 1, 1, 0f, 0f, 0.9f, 0.35f, 0.6f),
		new ActivityPattern("marshmallow", "squish", null, 0.3f, 9f, 18f, 1, 1, 0f, 0f, 0f, 0f, 0f),
		new ActivityPattern("iron", "ironGlide", "steam", 0.4f, 1.5f, 5f, 2, 4, 0.8f, 1.3f, 0.45f, 0.1f, 0.4f),
		ActivityPattern.Looping("vacuum", "vacuumLoop", 0.32f),
		new ActivityPattern("sweep", "broom", null, 0.4f, 2f, 6f, 4, 10, 0.55f, 0.85f, 0f, 0f, 0f),
		new ActivityPattern("dumbbell", "exhale", "clank", 0.45f, 5f, 12f, 6, 10, 1.6f, 2.3f, 0.8f, 0.5f, 1f),
		new ActivityPattern("jumprope", "rope", null, 0.45f, 3f, 8f, 10, 24, 0.42f, 0.5f, 0f, 0f, 0f),
		new ActivityPattern("situps", "exhale", null, 0.3f, 4f, 10f, 8, 15, 1.7f, 2.4f, 0f, 0f, 0f),
		new ActivityPattern("dance", "step", null, 0.38f, 1.5f, 4f, 8, 16, 0.3f, 0.5f, 0f, 0f, 0f),
		ActivityPattern.Looping("treadmill", "treadmillLoop", 0.38f),
		new ActivityPattern("meditate", "breathCalm", null, 0.16f, 0.8f, 2.5f, 1, 1, 0f, 0f, 0f, 0f, 0f),
		new ActivityPattern("sleep", "breathSleep", "snore", 0.18f, 0.3f, 1.2f, 1, 1, 0f, 0f, 0.1f, 0.5f, 1.5f)
	};

	public static ActivityPattern FindPattern(string id)
	{
		for (int i = 0; i < Patterns.Length; i++)
		{
			if (Patterns[i].Id == id)
			{
				return Patterns[i];
			}
		}
		return null;
	}

	public static List<float[]> Render(string set)
	{
		List<float[]> list = new List<float[]>();
		int num = ((set.EndsWith("Loop") || set.StartsWith("breath")) ? 1 : 8);
		int num2 = 7919;
		for (int i = 0; i < set.Length; i++)
		{
			num2 = num2 * 31 + set[i];
		}
		for (int j = 0; j < num; j++)
		{
			Rng r = new Rng(num2 + j * 101);
			float[] array = RenderOne(set, r, j);
			if (array != null)
			{
				list.Add(array);
			}
		}
		return list;
	}

	private static float[] RenderOne(string set, Rng r, int variant)
	{
		switch (set)
		{
		case "page":
			return Page(r, thin: false);
		case "manga":
			return Page(r, thin: true);
		case "ereader":
			return EReaderTap(r);
		case "key":
			return Keystroke(r, variant >= 6);
		case "typingBurst":
			return TypingBurst(r);
		case "trackpad":
			return Trackpad(r);
		case "typewriterKey":
			return TypewriterKey(r);
		case "typewriterBell":
			return TypewriterBell(r);
		case "pencil":
			return PencilStroke(r, charcoal: false);
		case "sketch":
			return PencilStroke(r, charcoal: true);
		case "brush":
			return BrushStroke(r);
		case "waterDrop":
			if (variant % 3 != 2)
			{
				return WaterDrop(r);
			}
			return JarTap(r);
		case "knit":
			return NeedleClicks(r, crochet: false);
		case "crochet":
			return NeedleClicks(r, crochet: true);
		case "phoneTap":
			return PhoneTap(r);
		case "swipe":
			return Swipe(r);
		case "button":
			return Button(r, variant % 3 == 2);
		case "dice":
			return Dice(r);
		case "slurp":
			return Slurp(r, 0.7f, 1.25f, 1f);
		case "sip":
			return Slurp(r, 0.28f, 0.5f, 0.55f);
		case "bowl":
			return Ceramic(r, 2750f, 0.12f);
		case "cup":
			return CupOnSaucer(r);
		case "straw":
			return Straw(r, boba: false);
		case "boba":
			return Straw(r, boba: true);
		case "chopsticks":
			return Chopsticks(r);
		case "chew":
			return Chew(r, sticky: false);
		case "squish":
			return Chew(r, sticky: true);
		case "crunch":
			return Crunch(r);
		case "ironGlide":
			return Swish(r, 0.5f, 0.8f, 1400f, 200f);
		case "steam":
			return Steam(r);
		case "vacuumLoop":
			return VacuumLoop(r);
		case "broom":
			return Broom(r);
		case "clank":
			return Clank(r);
		case "exhale":
			return Exhale(r);
		case "rope":
			return Rope(r);
		case "step":
			return Step(r, variant % 4 == 3);
		case "treadmillLoop":
			return TreadmillLoop(r);
		case "breathCalm":
			return Breath(r, 3f, 0.6f, 3.6f, 800f, 650f);
		case "breathSleep":
			return Breath(r, 1.8f, 0.3f, 2.6f, 560f, 480f);
		case "snore":
			return Snore(r);
		default:
			return null;
		}
	}

	private static float[] Page(Rng r, bool thin)
	{
		float num = (thin ? r.Range(0.24f, 0.38f) : r.Range(0.42f, 0.66f));
		float[] array = New(num + 0.08f);
		int num2 = Samples(num);
		Biquad biquad = Biquad.HighPass(thin ? 900f : 600f, 0.7f);
		Biquad biquad2 = new Biquad();
		float a = (thin ? r.Range(2600f, 3200f) : r.Range(1600f, 2100f));
		float b = (thin ? r.Range(5200f, 6400f) : r.Range(3800f, 4800f));
		float num3 = r.Range(0.62f, 0.8f);
		float num4 = 0f;
		float num5 = (thin ? 90f : 60f);
		for (int i = 0; i < num2; i++)
		{
			float num6 = (float)i / (float)num2;
			if ((i & 0x1F) == 0)
			{
				biquad2.SetBandPass(Lerp(a, b, num6 * num6), 0.85f);
			}
			num4 += (r.Noise() - num4) * 0.004f;
			float num7 = (float)Math.Pow(SmoothStep(0f, num3, num6), 1.3) * 0.7f;
			float num8 = ((num6 > num3) ? ((float)Math.Exp((0f - (num6 - num3)) * 9f)) : 1f);
			float num9 = (float)Math.Exp(0f - Sq((num6 - num3) / 0.07f));
			float num10 = num7 * num8 + num9 * (thin ? 0.55f : 0.9f);
			float num11 = Clamp(1f + num4 * 6f, 0.4f, 1.6f);
			array[i] += biquad2.Process(biquad.Process(r.Noise())) * num10 * num11;
			if (num6 > 0.1f && num6 < num3 + 0.05f && r.Next() < num5 / 44100f)
			{
				Tick(array, i, 3500f, 0.002f, r.Range(0.12f, 0.3f), r);
			}
		}
		if (!thin)
		{
			Thump(array, Samples(num * num3 + 0.04f), 300f, 0.035f, 0.22f, r);
		}
		return Finish(array, 0.9f);
	}

	private static float[] EReaderTap(Rng r)
	{
		float[] b = New(0.06f);
		Modal(b, 0, r.Range(1300f, 1600f), 0.008f, 0.5f);
		Modal(b, 0, r.Range(2400f, 2900f), 0.005f, 0.25f);
		Thump(b, 0, 600f, 0.006f, 0.3f, r);
		return Finish(b, 0.9f);
	}

	private static float[] Keystroke(Rng r, bool space)
	{
		float[] b = New(0.18f);
		float num = (space ? r.Range(650f, 950f) : r.Range(1500f, 2500f));
		Tick(b, 0, 2500f, 0.0015f, 0.6f, r);
		Modal(b, 0, num, space ? 0.016f : 0.009f, 0.55f);
		Modal(b, 0, num * r.Range(1.6f, 1.9f), 0.006f, 0.3f);
		Thump(b, Samples(0.002f), 320f, 0.008f, 0.35f, r);
		if (space)
		{
			Tick(b, Samples(0.004f), 1800f, 0.002f, 0.3f, r);
		}
		int at = Samples(r.Range(0.065f, 0.11f));
		Tick(b, at, 3000f, 0.001f, 0.25f, r);
		Modal(b, at, num * 1.15f, 0.005f, 0.2f);
		return Finish(b, 0.9f);
	}

	private static float[] TypingBurst(Rng r)
	{
		int num = r.Int(4, 10);
		float[] array = New((float)num * 0.15f + 0.2f);
		float num2 = 0f;
		for (int i = 0; i < num; i++)
		{
			Mix(array, Keystroke(r, i == num / 2 && r.Next() < 0.5f), Samples(num2), r.Range(0.7f, 1f));
			num2 += r.Range(0.08f, 0.15f);
		}
		return Finish(array, 0.9f);
	}

	private static float[] Trackpad(Rng r)
	{
		float[] b = New(0.05f);
		Tick(b, 0, 2200f, 0.0012f, 0.5f, r);
		Modal(b, 0, r.Range(2800f, 3600f), 0.003f, 0.5f);
		Thump(b, 0, 500f, 0.004f, 0.2f, r);
		return Finish(b, 0.9f);
	}

	private static float[] TypewriterKey(Rng r)
	{
		float[] b = New(0.3f);
		Tick(b, 0, 300f, 0.002f, 0.8f, r);
		Modal(b, 0, 1100f * r.Range(0.93f, 1.07f), 0.03f, 0.5f);
		Modal(b, 0, 2650f * r.Range(0.95f, 1.05f), 0.022f, 0.35f);
		Modal(b, 0, 4300f * r.Range(0.95f, 1.05f), 0.015f, 0.25f);
		Modal(b, 0, 6100f * r.Range(0.95f, 1.05f), 0.01f, 0.15f);
		Thump(b, Samples(0.003f), 180f, 0.018f, 0.6f, r);
		int at = Samples(r.Range(0.04f, 0.06f));
		Tick(b, at, 4500f, 0.001f, 0.25f, r);
		Modal(b, at, 5200f, 0.004f, 0.15f);
		return Finish(b, 0.9f);
	}

	private static float[] TypewriterBell(Rng r)
	{
		float[] b = New(1.5f);
		float num = r.Range(2550f, 2650f);
		Modal(b, 0, num, 0.8f, 0.5f);
		Modal(b, 0, num * 2.02f, 0.45f, 0.25f);
		Modal(b, 0, num * 3.04f, 0.25f, 0.12f);
		float num2 = 0.3f;
		float num3 = 0.034f;
		for (int i = 0; i < 12; i++)
		{
			int at = Samples(num2);
			Tick(b, at, 3500f, 0.0012f, 0.35f, r);
			Modal(b, at, 4200f, 0.003f, 0.15f);
			num2 += num3;
			num3 *= 0.93f;
		}
		int at2 = Samples(num2 + 0.01f);
		Thump(b, at2, 150f, 0.04f, 0.7f, r);
		Modal(b, at2, 900f, 0.03f, 0.3f);
		return Finish(b, 0.9f);
	}

	private static float[] PencilStroke(Rng r, bool charcoal)
	{
		float num = (charcoal ? r.Range(0.5f, 1.4f) : r.Range(0.3f, 0.95f));
		float[] array = New(num + 0.05f);
		Biquad biquad = Biquad.HighPass(charcoal ? 500f : 1200f, 0.7f);
		Biquad biquad2 = Biquad.LowPass(charcoal ? 9000f : 16000f, 0.7f);
		Biquad biquad3 = new Biquad();
		float num2 = 0f;
		float num4;
		for (float num3 = 0f; num3 < num; num3 += num4 + r.Range(0.02f, 0.08f))
		{
			num4 = (charcoal ? r.Range(0.15f, 0.45f) : r.Range(0.06f, 0.22f));
			float frequency = (charcoal ? r.Range(1800f, 2800f) : r.Range(3200f, 5200f));
			biquad3.SetBandPass(frequency, charcoal ? 0.7f : 1.3f);
			float num5 = r.Range(0.6f, 1f);
			int num6 = Samples(num3);
			int num7 = Samples(num4);
			for (int i = 0; i < num7 && num6 + i < array.Length; i++)
			{
				float num8 = (float)i / (float)num7;
				num2 += (r.Noise() - num2) * 0.08f;
				float num9 = Clamp(0.5f + Math.Abs(num2) * 3f, 0f, 1.6f);
				float num10 = (float)Math.Pow(Math.Sin(Math.PI * (double)num8), 0.7);
				array[num6 + i] += biquad2.Process(biquad3.Process(biquad.Process(r.Noise()))) * num10 * num9 * num5;
			}
		}
		return Finish(array, 0.9f);
	}

	private static float[] BrushStroke(Rng r)
	{
		float num = r.Range(0.45f, 1f);
		float[] array = New(num + 0.05f);
		Biquad biquad = Biquad.BandPass(r.Range(800f, 1400f), 0.6f);
		Biquad biquad2 = Biquad.LowPass(3200f, 0.7f);
		int num2 = Samples(num);
		float num3 = 0f;
		for (int i = 0; i < num2; i++)
		{
			float num4 = (float)i / (float)num2;
			num3 += (r.Noise() - num3) * 0.002f;
			float num5 = (float)Math.Pow(Math.Sin(Math.PI * (double)num4), 1.5) * Clamp(1f + num3 * 5f, 0.5f, 1.5f);
			array[i] += biquad2.Process(biquad.Process(r.Noise())) * num5;
		}
		Thump(array, 0, 400f, 0.01f, 0.12f, r);
		return Finish(array, 0.9f);
	}

	private static float[] WaterDrop(Rng r)
	{
		float[] array = New(0.12f);
		float num = r.Range(700f, 900f);
		float num2 = r.Range(1900f, 2400f);
		double num3 = 0.0;
		int num4 = Samples(0.04f);
		for (int i = 0; i < num4; i++)
		{
			float num5 = (float)i / (float)num4;
			float num6 = num * (float)Math.Pow(num2 / num, Math.Min(1f, num5 * 1.6f));
			num3 += Math.PI * 2.0 * (double)num6 / 44100.0;
			array[i] += (float)Math.Sin(num3) * (float)Math.Exp((0f - num5) * 5f) * 0.6f;
		}
		Tick(array, 0, 3000f, 0.001f, 0.2f, r);
		return Finish(array, 0.9f);
	}

	private static float[] JarTap(Rng r)
	{
		float[] b = New(0.3f);
		Tick(b, 0, 2500f, 0.0008f, 0.35f, r);
		Modal(b, 0, r.Range(2700f, 3100f), 0.05f, 0.5f);
		Modal(b, 0, r.Range(6400f, 7200f), 0.025f, 0.25f);
		return Finish(b, 0.9f);
	}

	private static float[] NeedleClicks(Rng r, bool crochet)
	{
		float[] b = New(0.22f);
		int num = Samples(r.Range(0.045f, 0.09f));
		if (crochet)
		{
			Modal(b, 0, r.Range(1900f, 2300f), 0.008f, 0.4f);
			Modal(b, 0, r.Range(3500f, 4100f), 0.005f, 0.2f);
			Swirl(b, Samples(0.01f), 0.06f, 2000f, 0.8f, 0.35f, r);
			Modal(b, num, r.Range(1900f, 2300f), 0.006f, 0.25f);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				int at = ((i != 0) ? num : 0);
				float num2 = ((i == 0) ? 1f : 0.7f);
				Tick(b, at, 4000f, 0.0008f, 0.4f * num2, r);
				Modal(b, at, r.Range(2800f, 3400f), 0.012f, 0.5f * num2);
				Modal(b, at, r.Range(4800f, 5600f), 0.008f, 0.3f * num2);
				Modal(b, at, r.Range(6900f, 7900f), 0.005f, 0.2f * num2);
			}
		}
		return Finish(b, 0.9f);
	}

	private static float[] PhoneTap(Rng r)
	{
		float[] b = New(0.04f);
		Thump(b, 0, 900f, 0.006f, 0.5f, r);
		Modal(b, 0, r.Range(2500f, 3100f), 0.003f, 0.2f);
		return Finish(b, 0.9f);
	}

	private static float[] Swipe(Rng r)
	{
		float[] b = New(0.13f);
		Swirl(b, 0, r.Range(0.07f, 0.11f), r.Range(2800f, 3600f), 0.7f, 0.5f, r);
		return Finish(b, 0.9f);
	}

	private static float[] Button(Rng r, bool dpad)
	{
		float[] b = New(0.06f);
		Tick(b, 0, 2000f, 0.0008f, 0.4f, r);
		Modal(b, 0, dpad ? r.Range(1100f, 1300f) : r.Range(1500f, 2100f), dpad ? 0.008f : 0.006f, 0.45f);
		Modal(b, 0, r.Range(2600f, 3200f), 0.004f, 0.25f);
		Thump(b, 0, 600f, 0.004f, 0.2f, r);
		return Finish(b, 0.9f);
	}

	private static float[] Dice(Rng r)
	{
		float[] b = New(0.95f);
		int num = r.Int(3, 7);
		float num2 = 0f;
		float num3 = r.Range(0.09f, 0.14f);
		float num4 = 1f;
		for (int i = 0; i < num; i++)
		{
			int at = Samples(num2);
			Modal(b, at, r.Range(1800f, 2600f), 0.009f, 0.5f * num4);
			Modal(b, at, r.Range(3400f, 4400f), 0.006f, 0.3f * num4);
			Thump(b, at, 350f, 0.012f, 0.35f * num4, r);
			Tick(b, at, 3000f, 0.0008f, 0.3f * num4, r);
			num2 += num3;
			num3 *= r.Range(0.62f, 0.8f);
			num4 *= 0.78f;
		}
		int num5 = r.Int(2, 4);
		for (int j = 0; j < num5; j++)
		{
			num2 += r.Range(0.012f, 0.025f);
			Modal(b, Samples(num2), r.Range(2400f, 3200f), 0.004f, 0.25f * num4);
		}
		return Finish(b, 0.9f);
	}

	private static float[] Slurp(Rng r, float minLength, float maxLength, float strength)
	{
		float num = r.Range(minLength, maxLength);
		float[] array = New(num + 0.08f);
		int num2 = Samples(num);
		Biquad biquad = new Biquad();
		Biquad biquad2 = new Biquad();
		float a = r.Range(450f, 600f);
		float b = r.Range(950f, 1250f);
		float a2 = r.Range(1700f, 1900f);
		float b2 = r.Range(2400f, 2700f);
		if (strength < 0.9f)
		{
			a = 600f;
			b = 1000f;
			a2 = 1600f;
			b2 = 2200f;
		}
		double num3 = 0.0;
		float num4 = r.Range(25f, 60f);
		float num5 = r.Range(0.5f, 1f);
		float num6 = 18f * strength;
		for (int i = 0; i < num2; i++)
		{
			float num7 = (float)i / (float)num2;
			if ((i & 0x1F) == 0)
			{
				biquad.SetBandPass(Lerp(a, b, num7), 2.2f);
				biquad2.SetBandPass(Lerp(a2, b2, num7), 3f);
			}
			num4 = Clamp(num4 + r.Noise() * 0.4f, 25f, 60f);
			double num8 = num3;
			num3 += Math.PI * 2.0 * (double)num4 / 44100.0;
			if (Math.Floor(num8 / (Math.PI * 2.0)) != Math.Floor(num3 / (Math.PI * 2.0)))
			{
				num5 = r.Range(0.4f, 1f);
			}
			float num9 = 0.35f + 0.65f * num5 * (float)Math.Pow(Math.Max(0.0, Math.Sin(num3)), 3.0);
			float num10 = SmoothStep(0f, 0.04f / num, num7) * Lerp(0.8f, 1f, num7) * ((num7 > 0.88f) ? (1f - SmoothStep(0.88f, 1f, num7)) : 1f);
			float x = r.Noise();
			array[i] += (0.7f * biquad.Process(x) + 0.45f * biquad2.Process(x)) * num9 * num10 * 2.2f;
			if (num7 > 0.05f && num7 < 0.9f && r.Next() < num6 / 44100f)
			{
				Blip(array, i, r.Range(1100f, 3200f), 0.012f, 0.25f);
			}
		}
		if (strength > 0.9f)
		{
			int at = Samples(num * 0.97f);
			Tick(array, at, 800f, 0.004f, 0.4f, r);
			Thump(array, at, 250f, 0.01f, 0.3f, r);
		}
		return Finish(array, 0.9f);
	}

	private static float[] Straw(Rng r, bool boba)
	{
		float num = r.Range(0.6f, 1f);
		float[] array = New(num + 0.08f);
		int num2 = Samples(num);
		Biquad biquad = Biquad.BandPass(r.Range(1450f, 1750f), 4f);
		Biquad biquad2 = Biquad.BandPass(r.Range(2900f, 3300f), 5f);
		Biquad biquad3 = Biquad.BandPass(r.Range(420f, 480f), 6f);
		double num3 = 0.0;
		float num4 = r.Range(35f, 55f);
		for (int i = 0; i < num2; i++)
		{
			float x = (float)i / (float)num2;
			num3 += Math.PI * 2.0 * (double)num4 / 44100.0;
			float num5 = 0.45f + 0.55f * (float)Math.Pow(Math.Max(0.0, Math.Sin(num3)), 2.0);
			float num6 = SmoothStep(0f, 0.06f, x) * (1f - SmoothStep(0.85f, 1f, x));
			float x2 = r.Noise();
			array[i] += (biquad.Process(x2) * 0.8f + biquad2.Process(x2) * 0.5f + biquad3.Process(x2) * 0.3f) * num5 * num6 * 2.5f;
		}
		if (boba)
		{
			int num7 = r.Int(2, 5);
			for (int j = 0; j < num7; j++)
			{
				int at = Samples(r.Range(0.15f, num * 0.9f));
				Glide(array, at, 220f, 120f, 0.03f, 0.6f);
				Thump(array, at, 300f, 0.02f, 0.3f, r);
			}
		}
		return Finish(array, 0.9f);
	}

	private static float[] Ceramic(Rng r, float pitch, float decay)
	{
		float[] b = New(decay * 5f);
		Tick(b, 0, 3000f, 0.0008f, 0.4f, r);
		Modal(b, 0, pitch * r.Range(0.95f, 1.05f), decay, 0.45f);
		Modal(b, 0, pitch * 1.67f * r.Range(0.97f, 1.03f), decay * 0.58f, 0.25f);
		Modal(b, 0, pitch * 2.58f * r.Range(0.97f, 1.03f), decay * 0.33f, 0.15f);
		return Finish(b, 0.9f);
	}

	private static float[] CupOnSaucer(Rng r)
	{
		float[] b = New(0.45f);
		float num = r.Range(3100f, 3500f);
		for (int i = 0; i < 2; i++)
		{
			int at = ((i != 0) ? Samples(r.Range(0.02f, 0.03f)) : 0);
			float num2 = ((i == 0) ? 1f : 0.4f);
			Tick(b, at, 3000f, 0.0008f, 0.35f * num2, r);
			Modal(b, at, num, 0.07f, 0.45f * num2);
			Modal(b, at, num * 1.63f, 0.045f, 0.25f * num2);
			Modal(b, at, num * 2.48f, 0.02f, 0.12f * num2);
		}
		return Finish(b, 0.9f);
	}

	private static float[] Chopsticks(Rng r)
	{
		float[] b = New(0.2f);
		for (int i = 0; i < 2; i++)
		{
			int at = ((i != 0) ? Samples(r.Range(0.05f, 0.09f)) : 0);
			float num = ((i == 0) ? 1f : 0.75f);
			Tick(b, at, 1800f, 0.0008f, 0.3f * num, r);
			Modal(b, at, r.Range(1100f, 1400f), 0.014f, 0.5f * num);
			Modal(b, at, r.Range(2500f, 2900f), 0.008f, 0.3f * num);
		}
		return Finish(b, 0.9f);
	}

	private static float[] Chew(Rng r, bool sticky)
	{
		int num = r.Int(3, 6);
		float num2 = (sticky ? r.Range(0.26f, 0.32f) : r.Range(0.2f, 0.25f));
		float[] array = New((float)num * num2 + 0.2f);
		Biquad biquad = Biquad.LowPass(sticky ? 450f : 650f, 0.7f);
		Biquad biquad2 = Biquad.BandPass(800f, 2f);
		for (int i = 0; i < num; i++)
		{
			int num3 = Samples((float)i * num2);
			int num4 = Samples(0.12f);
			for (int j = 0; j < num4 && num3 + j < array.Length; j++)
			{
				float num5 = (float)j / (float)num4;
				float num6 = (float)Math.Sin(Math.PI * (double)num5);
				float x = r.Noise();
				array[num3 + j] += (biquad.Process(x) * 1.6f + (sticky ? (biquad2.Process(x) * 0.5f) : 0f)) * num6;
			}
			Tick(array, num3 + num4, 1500f, 0.002f, 0.12f, r);
		}
		return Finish(array, 0.9f);
	}

	private static float[] Crunch(Rng r)
	{
		float[] array = New(0.45f);
		int num = Samples(0.14f);
		for (int i = 0; i < num; i++)
		{
			if (r.Next() < 1f / 49f)
			{
				Tick(array, i, 1500f, 0.0006f, r.Range(0.2f, 0.6f) * (float)Math.Exp((float)(-i) / (float)Samples(0.06f)), r);
			}
		}
		Biquad biquad = Biquad.BandPass(1000f, 0.8f);
		int num2 = Samples(0.25f);
		for (int j = 0; j < num2; j++)
		{
			array[j] += biquad.Process(r.Noise()) * (float)Math.Exp((float)(-j) / (float)Samples(0.08f)) * 0.35f;
		}
		Thump(array, 0, 300f, 0.02f, 0.3f, r);
		return Finish(array, 0.9f);
	}

	private static float[] Swish(Rng r, float minLength, float maxLength, float lowPass, float highPass)
	{
		float num = r.Range(minLength, maxLength);
		float[] array = New(num + 0.05f);
		Biquad biquad = Biquad.LowPass(lowPass, 0.7f);
		Biquad biquad2 = Biquad.HighPass(highPass, 0.7f);
		int num2 = Samples(num);
		for (int i = 0; i < num2; i++)
		{
			float num3 = (float)i / (float)num2;
			array[i] += biquad.Process(biquad2.Process(r.Noise())) * (float)Math.Sin(Math.PI * (double)num3);
		}
		return Finish(array, 0.9f);
	}

	private static float[] Steam(Rng r)
	{
		float num = r.Range(0.6f, 1f);
		float[] array = New(num + 0.05f);
		Biquad biquad = Biquad.HighPass(2500f, 0.7f);
		Biquad biquad2 = Biquad.LowPass(9000f, 0.7f);
		int num2 = Samples(num);
		double num3 = 0.0;
		for (int i = 0; i < num2; i++)
		{
			float num4 = (float)i / 44100f;
			num3 += 0.0017097102876679146;
			float num5 = SmoothStep(0f, 0.03f, num4) * ((num4 > num - 0.35f) ? ((num - num4) / 0.35f) : 1f);
			float num6 = 1f + 0.15f * (float)Math.Sin(num3);
			array[i] += biquad2.Process(biquad.Process(r.Noise())) * num5 * num6;
		}
		return Finish(array, 0.9f);
	}

	private static float[] VacuumLoop(Rng r)
	{
		float[] array = New(4.5f);
		Biquad biquad = Biquad.BandPass(1300f, 0.5f);
		Biquad biquad2 = Biquad.LowPass(4500f, 0.7f);
		for (int i = 0; i < array.Length; i++)
		{
			double num = (double)i / 44100.0;
			double num2 = 1.0 + 0.003 * Math.Sin(Math.PI / 2.0 * num);
			double num3 = 0.0;
			for (int j = 1; j <= 8; j++)
			{
				num3 += Math.Sin(Math.PI * 380.0 * (double)j * num * num2) / (double)j;
			}
			float num4 = biquad2.Process(biquad.Process(r.Noise()));
			array[i] = (float)(num3 * 0.35 + Math.Sin(Math.PI * 3040.0 * num) * 0.06) + num4 * 1.6f;
		}
		return Finish(CrossfadeLoop(array, 4f, 0.5f), 0.9f);
	}

	private static float[] Broom(Rng r)
	{
		float num = r.Range(0.3f, 0.5f);
		float[] array = New(num + 0.05f);
		Biquad biquad = Biquad.BandPass(r.Range(2800f, 3600f), 0.55f);
		Biquad biquad2 = Biquad.HighPass(900f, 0.7f);
		int num2 = Samples(num);
		for (int i = 0; i < num2; i++)
		{
			float num3 = (float)i / 44100f;
			float num4 = SmoothStep(0f, 0.06f, num3) * (float)Math.Exp((0f - Math.Max(0f, num3 - 0.06f)) * 5f);
			array[i] += biquad2.Process(biquad.Process(r.Noise())) * num4;
			if (r.Next() < 1f / 126f)
			{
				Tick(array, i, 3000f, 0.0005f, 0.3f * num4, r);
			}
		}
		return Finish(array, 0.9f);
	}

	private static float[] Clank(Rng r)
	{
		float[] b = New(0.9f);
		Tick(b, 0, 200f, 0.002f, 0.7f, r);
		float[] array = new float[5] { 440f, 1180f, 2260f, 3510f, 5020f };
		float[] array2 = new float[5] { 0.35f, 0.25f, 0.18f, 0.12f, 0.08f };
		float[] array3 = new float[5] { 0.45f, 0.35f, 0.25f, 0.18f, 0.1f };
		for (int i = 0; i < array.Length; i++)
		{
			Modal(b, 0, array[i] * r.Range(0.94f, 1.06f), array2[i], array3[i]);
		}
		Thump(b, 0, 200f, 0.02f, 0.4f, r);
		return Finish(b, 0.9f);
	}

	private static float[] Exhale(Rng r)
	{
		float num = r.Range(0.35f, 0.6f);
		float[] array = New(num + 0.05f);
		Biquad biquad = Biquad.BandPass(r.Range(700f, 1000f), 0.7f);
		Biquad biquad2 = Biquad.LowPass(2600f, 0.7f);
		int num2 = Samples(num);
		for (int i = 0; i < num2; i++)
		{
			float num3 = (float)i / 44100f;
			float num4 = SmoothStep(0f, 0.05f, num3) * (float)Math.Exp((0f - Math.Max(0f, num3 - 0.05f)) * 4f);
			array[i] += biquad2.Process(biquad.Process(r.Noise())) * num4;
		}
		return Finish(array, 0.9f);
	}

	private static float[] Rope(Rng r)
	{
		float[] array = New(0.3f);
		Biquad biquad = new Biquad();
		int num = Samples(0.09f);
		for (int i = 0; i < num; i++)
		{
			float num2 = (float)i / (float)num;
			if ((i & 0x1F) == 0)
			{
				biquad.SetBandPass(Lerp(700f, 2600f, num2), 1.2f);
			}
			array[i] += biquad.Process(r.Noise()) * (float)Math.Sin(Math.PI * (double)num2);
		}
		int at = Samples(r.Range(0.1f, 0.13f));
		Thump(array, at, 170f, 0.025f, 0.6f, r);
		Tick(array, at, 1500f, 0.001f, 0.15f, r);
		return Finish(array, 0.9f);
	}

	private static float[] Step(Rng r, bool squeak)
	{
		float[] b = New(0.1f);
		Thump(b, 0, 260f, 0.018f, 0.6f, r);
		Tick(b, 0, 1200f, 0.001f, 0.2f, r);
		if (squeak)
		{
			Glide(b, Samples(0.005f), r.Range(2200f, 2400f), r.Range(2600f, 2800f), 0.04f, 0.12f);
		}
		return Finish(b, 0.9f);
	}

	private static float[] TreadmillLoop(Rng r)
	{
		float[] array = New(3.4f);
		Biquad biquad = Biquad.LowPass(700f, 0.7f);
		Biquad biquad2 = Biquad.BandPass(1800f, 0.6f);
		for (int i = 0; i < array.Length; i++)
		{
			double num = (double)i / 44100.0;
			double num2 = Math.Sin(Math.PI * 190.0 * num) + 0.4 * Math.Sin(Math.PI * 380.0 * num) + 0.2 * Math.Sin(Math.PI * 570.0 * num);
			float x = r.Noise();
			float num3 = biquad.Process(x) * (0.5f + 0.5f * (float)Math.Sin(Math.PI * 24.0 * num));
			array[i] = (float)num2 * 0.06f + num3 * 0.5f + biquad2.Process(x) * 0.45f;
		}
		for (int j = 0; j < 10; j++)
		{
			int num4 = Samples((float)j * 0.375f);
			if (num4 >= array.Length)
			{
				break;
			}
			Thump(array, num4, 180f, 0.035f, 0.9f, r);
			Tick(array, num4, 1500f, 0.003f, 0.3f, r);
		}
		return Finish(CrossfadeLoop(array, 3f, 0.4f), 0.9f);
	}

	private static float[] Breath(Rng r, float inhale, float hold, float exhale, float inColour, float outColour)
	{
		float[] array = New(inhale + hold + exhale + 0.1f);
		Biquad biquad = Biquad.LowPass(inColour, 0.7f);
		Biquad biquad2 = Biquad.LowPass(outColour, 0.7f);
		Biquad biquad3 = Biquad.BandPass(1200f, 0.4f);
		int num = Samples(inhale);
		for (int i = 0; i < num; i++)
		{
			float num2 = (float)i / (float)num;
			array[i] += biquad3.Process(biquad.Process(r.Noise())) * Sq((float)Math.Sin(Math.PI * (double)num2)) * 0.5f;
		}
		int num3 = Samples(inhale + hold);
		int num4 = Samples(exhale);
		for (int j = 0; j < num4; j++)
		{
			float num5 = (float)j / (float)num4;
			array[num3 + j] += biquad2.Process(r.Noise()) * Sq((float)Math.Sin(Math.PI * (double)num5)) * 0.7f;
		}
		return Finish(array, 0.9f);
	}

	private static float[] Snore(Rng r)
	{
		float num = r.Range(0.8f, 1.1f);
		float[] array = New(num + 0.05f);
		Biquad biquad = Biquad.LowPass(450f, 0.7f);
		Biquad biquad2 = Biquad.BandPass(700f, 2f);
		Biquad biquad3 = Biquad.LowPass(600f, 0.7f);
		float num2 = r.Range(60f, 80f);
		double num3 = 0.0;
		float num4 = 0f;
		int num5 = Samples(num);
		for (int i = 0; i < num5; i++)
		{
			float num6 = (float)i / (float)num5;
			double d = num3;
			num3 += (double)(num2 / 44100f);
			if (Math.Floor(d) != Math.Floor(num3))
			{
				num4 = 1f;
			}
			num4 *= 0.93f;
			float num7 = (float)Math.Sin(Math.PI * (double)num6);
			float num8 = biquad.Process(num4 + r.Noise() * 0.1f);
			array[i] += (biquad2.Process(num8) * 2f + num8 * 0.6f + biquad3.Process(r.Noise()) * 0.3f) * num7;
		}
		return Finish(array, 0.9f);
	}

	private static float[] New(float seconds)
	{
		return new float[Math.Max(1, Samples(seconds))];
	}

	private static int Samples(float seconds)
	{
		return (int)(seconds * 44100f);
	}

	private static void Modal(float[] b, int at, float frequency, float decay, float amp)
	{
		int num = Math.Min(b.Length - at, Samples(decay * 6f));
		double num2 = Math.PI * 2.0 * (double)frequency / 44100.0;
		for (int i = 0; i < num; i++)
		{
			b[at + i] += amp * (float)(Math.Exp((float)(-i) / (decay * 44100f)) * Math.Sin(num2 * (double)i));
		}
	}

	private static void Tick(float[] b, int at, float highPass, float length, float amp, Rng r)
	{
		Biquad biquad = Biquad.HighPass(highPass, 0.7f);
		int num = Math.Min(b.Length - at, Samples(length * 5f));
		for (int i = 0; i < num; i++)
		{
			b[at + i] += biquad.Process(r.Noise()) * amp * (float)Math.Exp((float)(-i) / (length * 44100f));
		}
	}

	private static void Thump(float[] b, int at, float lowPass, float length, float amp, Rng r)
	{
		Biquad biquad = Biquad.LowPass(lowPass, 0.7f);
		int num = Math.Min(b.Length - at, Samples(length * 5f));
		for (int i = 0; i < num; i++)
		{
			b[at + i] += biquad.Process(r.Noise()) * amp * 3f * (float)Math.Exp((float)(-i) / (length * 44100f));
		}
	}

	private static void Blip(float[] b, int at, float frequency, float length, float amp)
	{
		int num = Math.Min(b.Length - at, Samples(length));
		double num2 = 0.0;
		for (int i = 0; i < num; i++)
		{
			float num3 = (float)i / (float)num;
			num2 += Math.PI * 2.0 * (double)frequency * (double)(1f + num3 * 0.6f) / 44100.0;
			b[at + i] += amp * (float)Math.Sin(num2) * (1f - num3) * (1f - num3);
		}
	}

	private static void Glide(float[] b, int at, float from, float to, float length, float amp)
	{
		int num = Math.Min(b.Length - at, Samples(length));
		double num2 = 0.0;
		for (int i = 0; i < num; i++)
		{
			float num3 = (float)i / (float)num;
			num2 += Math.PI * 2.0 * (double)Lerp(from, to, num3) / 44100.0;
			b[at + i] += amp * (float)Math.Sin(num2) * (float)Math.Sin(Math.PI * (double)Math.Min(1f, num3 * 4f) * 0.5) * (1f - num3);
		}
	}

	private static void Swirl(float[] b, int at, float length, float centre, float q, float amp, Rng r)
	{
		Biquad biquad = Biquad.BandPass(centre, q);
		int num = Math.Min(b.Length - at, Samples(length));
		for (int i = 0; i < num; i++)
		{
			float num2 = (float)i / (float)num;
			b[at + i] += biquad.Process(r.Noise()) * amp * 2f * Sq((float)Math.Sin(Math.PI * (double)num2));
		}
	}

	private static void Mix(float[] into, float[] clip, int at, float gain)
	{
		int num = Math.Min(clip.Length, into.Length - at);
		for (int i = 0; i < num; i++)
		{
			into[at + i] += clip[i] * gain;
		}
	}

	private static float[] CrossfadeLoop(float[] raw, float length, float fade)
	{
		int num = Samples(length);
		int num2 = Samples(fade);
		float[] array = new float[num];
		Array.Copy(raw, array, num);
		for (int i = 0; i < num2 && num + i < raw.Length; i++)
		{
			float num3 = (float)i / (float)num2;
			float num4 = (float)Math.Sin((double)num3 * Math.PI * 0.5);
			float num5 = (float)Math.Cos((double)num3 * Math.PI * 0.5);
			array[i] = raw[i] * num4 + raw[num + i] * num5;
		}
		return array;
	}

	private static float[] Finish(float[] b, float peak)
	{
		Biquad biquad = Biquad.HighPass(25f, 0.7f);
		for (int i = 0; i < b.Length; i++)
		{
			b[i] = biquad.Process(b[i]);
		}
		int num = Math.Min(b.Length / 4, Samples(0.001f));
		for (int j = 0; j < num; j++)
		{
			b[j] *= (float)j / (float)num;
		}
		int num2 = Math.Min(b.Length / 4, Samples(0.006f));
		for (int k = 0; k < num2; k++)
		{
			b[b.Length - 1 - k] *= (float)k / (float)num2;
		}
		float num3 = 0f;
		for (int l = 0; l < b.Length; l++)
		{
			num3 = Math.Max(num3, Math.Abs(b[l]));
		}
		if (num3 > 1E-06f)
		{
			float num4 = peak / num3;
			for (int m = 0; m < b.Length; m++)
			{
				b[m] *= num4;
			}
		}
		return b;
	}

	private static float Lerp(float a, float b, float t)
	{
		return a + (b - a) * t;
	}

	private static float Sq(float x)
	{
		return x * x;
	}

	private static float Clamp(float x, float lo, float hi)
	{
		if (!(x < lo))
		{
			if (!(x > hi))
			{
				return x;
			}
			return hi;
		}
		return lo;
	}

	private static float SmoothStep(float edge0, float edge1, float x)
	{
		if (edge1 <= edge0)
		{
			if (!(x >= edge1))
			{
				return 0f;
			}
			return 1f;
		}
		float num = Clamp((x - edge0) / (edge1 - edge0), 0f, 1f);
		return num * num * (3f - 2f * num);
	}
}
[BepInPlugin("cn.ontogether.dayandnight", "On-Together: Day and Night", "1.0.3")]
public sealed class DayAndNightPlugin : BaseUnityPlugin
{
	private sealed class CameraSkyboxState
	{
		public Skybox Skybox;

		public Material OriginalMaterial;
	}

	private sealed class ShadowRendererState
	{
		public Renderer Renderer;

		public ShadowCastingMode OriginalMode;

		public bool OriginalReceiveShadows;
	}

	private sealed class SpecialLocalLight
	{
		public float DayIntensity;

		public float NightIntensity;

		public bool ReserveBudget;
	}

	private sealed class CampfireEmissionState
	{
		public GameObject Overlay;

		public Material[] Materials;

		public bool[] Visible;
	}

	private sealed class SchoolRingGlowState
	{
		public GameObject Overlay;

		public Material Glow;

		public Material Hidden;

		public GameObject Wash;

		public Mesh WashMesh;

		public Material WashMaterial;

		public float WashStrength;
	}

	private sealed class IndoorBushState
	{
		public Matrix4x4[] Matrices;

		public int Index;

		public Matrix4x4 Original;

		public MeshRenderer Renderer;

		public bool WasEnabled;
	}

	private sealed class DeviceScreenState
	{
		public Renderer Source;

		public Renderer OverlayRenderer;

		public GameObject Overlay;

		public Material[] Materials;

		public Light Light;

		public bool HasScreenAnchor;

		public Vector3 ScreenLocalCenter;

		public Vector3 ScreenLocalNormal;

		public bool IsGameConsole;

		public Color DisplayColor;

		public Color TargetDisplayColor;

		public float NextDisplayChangeAt;
	}

	private sealed class SeasonRecolor
	{
		public readonly string Material;

		public readonly string[] Properties;

		public readonly float Hue;

		public readonly float SaturationScale;

		public readonly float ValueScale;

		public readonly bool Ground;

		public readonly bool Absolute;

		public readonly Color Target;

		public SeasonRecolor(string material, string properties, float hue, float saturationScale, float valueScale, bool ground)
		{
			//IL_004d: 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)
			Material = material;
			Properties = properties.Split(new char[1] { ',' });
			Hue = hue;
			SaturationScale = saturationScale;
			ValueScale = valueScale;
			Ground = ground;
			Absolute = false;
			Target = Color.white;
		}

		public SeasonRecolor(string material, string properties, Color target, bool ground)
		{
			//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)
			Material = material;
			Properties = properties.Split(new char[1] { ',' });
			Hue = 0f;
			SaturationScale = 1f;
			ValueScale = 1f;
			Ground = ground;
			Absolute = true;
			Target = target;
		}
	}

	private sealed class CanopyCluster
	{
		public Vector3 Centre;

		public float Radius;

		public float BottomY;

		public float TopY;

		public int Palette;

		public int Members;
	}

	private sealed class SeasonMaterialState
	{
		public Material Material;

		public int[] PropertyIds;

		public string[] PropertyNames;

		public Color[] Originals;
	}

	private sealed class SeasonCanopyState
	{
		public BushInstancing Batch;

		public Vector4[] OriginalColor1;

		public Vector4[] OriginalColor2;

		public float[] OriginalThreshold1;

		public int[] Cluster;
	}

	private sealed class LeafEmitterState
	{
		public ParticleSystem System;

		public ParticleSystemRenderer Renderer;

		public Material OriginalMaterial;

		public float OriginalRate;

		public bool OriginalSheetEnabled;

		public ParticleSystemAnimationMode OriginalSheetMode;

		public int OriginalTilesX;

		public int OriginalTilesY;

		public ParticleSystemAnimationType OriginalAnimation;

		public MinMaxCurve OriginalFrameOverTime;

		public MinMaxCurve OriginalStartFrame;

		public int OriginalCycleCount;

		public float OriginalShapeRadius;

		public bool ShapeAdjusted;

		public bool OriginalExternalForces;

		public bool OriginalVelocityEnabled;

		public ParticleSystemSimulationSpace OriginalVelocitySpace;

		public MinMaxCurve OriginalVelocityX;

		public MinMaxCurve OriginalVelocityY;

		public MinMaxCurve OriginalVelocityZ;

		public bool NoiseCaptured;

		public bool NoiseBoosted;

		public bool OriginalNoiseEnabled;

		public float OriginalNoiseStrength;

		public float OriginalNoiseFrequency;

		public bool Cloned;

		public Vector3 WindVelocity;

		public float WindSampleAt;
	}

	private sealed class CanopyShadowState
	{
		public BushInstancing Batch;

		public ShadowCastingMode OriginalMode;

		public bool Captured;
	}

	private sealed class WindMaterial
	{
		public Material Material;

		public float Original;

		public string SpeedProperty;

		public float OriginalSpeed;
	}

	private struct LeafLampSample
	{
		public Vector3 Position;

		public Vector3 Forward;

		public Color Radiance;

		public float Range;

		public float SpotEdge;
	}

	private sealed class GroundLeaf
	{
		public Vector3 Position;

		public Vector3 Right;

		public Vector3 Forward;

		public Vector3 Normal;

		public int Frame;

		public float BornAt;

		public Color Illumination;

		public float LiftedAt = -1f;

		public Vector3 Velocity;

		public Vector3 Drift;

		public float Spin;

		public float DriftFactor;

		public bool OnWater;

		public float BobPhase;

		public Vector3 WaterTarget;

		public float NextWaterStep;

		public float FlowSpeed = 0.6f;

		public float StepSpeed = 0.6f;

		public float Lane;

		public float WanderAngle;

		public float WanderTurn;

		public int WaterBody = -1;

		public bool InCurrent;

		public float StillExpiry = -1f;

		public Vector3 StuckAt;

		public float StuckSince;

		public bool InWaterfall;

		public int WaterfallSegment = -1;

		public float WaterfallAlong;

		public float WaterfallOffset;

		public Transform WaterfallTransform;
	}

	private sealed class WaterMaterial
	{
		public Material Material;

		public int[] PropertyIds;

		public string[] PropertyNames;

		public Color[] Originals;

		public Color[] DrivenColors;

		public bool HasReflectionStrength;

		public float OriginalReflectionStrength;

		public bool IsWaterfall;

		public bool IsOpenWater;

		public float[] SkyMirrorWeights;
	}

	private sealed class WaterParticleState
	{
		public ParticleSystem System;

		public MinMaxGradient OriginalStartColor;
	}

	private sealed class FaceInstanceInfo
	{
		public Material Instance;

		public Color BaseColor;

		public int TintProperty;

		public bool HasSourceTint;

		public int SourceTintProperty;

		public Color LastSourceTint;

		public bool HasSourceTexture;

		public int SourceTextureProperty;

		public int InstanceTextureProperty;

		public Texture LastSourceTexture;
	}

	private sealed class NativeFeatureMaterial
	{
		public int Slot;

		public Material Original;

		public Material Instance;

		public Color BaseColor;

		public int TintProperty;

		public FaceInstanceInfo Info;

		public bool InPlace;

		public bool HasWritten;

		public Color LastWritten;

		public string TextureProperty;

		public Texture SourceTexture;

		public Texture2D DimTexture;

		public Color32[] SourcePixels;

		public Color32[] Scratch;

		public int Bucket;
	}

	private sealed class NativeFeatureRenderer
	{
		public Renderer Renderer;

		public Material[] Assigned;

		public readonly List<NativeFeatureMaterial> Materials = new List<NativeFeatureMaterial>();

		public readonly Dictionary<int, FaceInstanceInfo> Instances = new Dictionary<int, FaceInstanceInfo>();

		public readonly Dictionary<int, FaceInstanceInfo> ByInstance = new Dictionary<int, FaceInstanceInfo>();

		public readonly Dictionary<int, NativeFeatureMaterial> InPlaceEntries = new Dictionary<int, NativeFeatureMaterial>();

		public readonly List<Material> Owned = new List<Material>();

		public float Brightness = -1f;

		public float SmoothedBrightness = -1f;

		public int ConsecutiveReassigns;

		public bool Abandoned;
	}

	private sealed class HiddenCloudRendererState
	{
		public Renderer Renderer;

		public bool OriginalForceRenderingOff;

		public bool OriginalEnabled;
	}

	private sealed class HiddenWorldCloudRootState
	{
		public GameObject Root;

		public bool OriginalActive;
	}

	private sealed class CloudInstancingState
	{
		public CloudInstancing Instancing;

		public bool OriginalEnabled;
	}

	private sealed class ToonMaterial
	{
		public Material Material;

		public bool HadSystemShadows;

		public float OrigSystemShadows;

		public bool HadSystemShadowLevel;

		public float OrigSystemShadowLevel;

		public bool HadBaseColorStep;

		public float OrigBaseColorStep;

		public bool HadUseBaseAs1st;

		public float OrigUseBaseAs1st;

		public bool HadUse1stAs2nd;

		public float OrigUse1stAs2nd;

		public bool PlayerShadowAdjusted;

		public bool SurfaceShadowAdjusted;

		public bool Has1st;

		public Color Orig1st;

		public bool Has2nd;

		public Color Orig2nd;
	}

	private sealed class ActivityVoice
	{
		public PlayerAnimationController Player;

		public Animator Animator;

		public PlayerFocusController Focus;

		public GameObject Holder;

		public AudioSource Source;

		public ActivityPattern Pattern;

		public float NextEventAt;

		public int BurstLeft;

		public float NextNoteAt;

		public float PendingAccentAt = -1f;

		public float Distance;
	}

	public const string PluginVersion = "1.0.3";

	private const int SchoolGlassInsideQueue = 3250;

	private const int SchoolGlowFallbackQueue = 2600;

	private const int GreenhouseRoofSamples = 25;

	private const float CanopyLowerScaleDark = 0.5f;

	private const float CanopyLowerScaleLight = 0.98f;

	private const float CanopyShadeLowDark = 0.58f;

	private const float CanopyShadeLowLight = 0.98f;

	private const float CanopyShadeHigh = 1.08f;

	private const float CanopyShadeJitter = 0.07f;

	private const float CanopyClusterRadius = 9f;

	private const float AutumnMaxSaturation = 0.86f;

	private const int CanopyShadowGrid = 18;

	private const float CanopyShadowVertexJitter = 0.78f;

	private const int CanopyDapplePatterns = 8;

	private const float GroundLeafViewerRange = 70f;

	private const float GroundLeafFadeSeconds = 3f;

	private const float RiverLeafReach = 4.5f;

	private const float PondLeafHalfWidth = 4f;

	private const float PondLeafBackEdge = 4f;

	private const float PondLeafLipZ = -5.78f;

	private const float PondLeafLipHalfWidth = 0.42f;

	private const int FaceBrightnessSteps = 24;

	private const int FaceDecalMaxSize = 256;

	private const string FaceInstanceSuffix = " (DayNight Facial Light)";

	private const float CloudFieldRadius = 210f;

	private const float IndoorGreenScanInterval = 3f;

	private const float IndoorGreenScanRange = 60f;

	private const int LeafTileSize = 128;

	private const float ClonedLeafBaseRate = 0.4f;

	private const float LeafTileDarken = 0.92f;

	private const int ActivityVoiceLimit = 8;

	private const float ActivityHearingRange = 14f;

	private const int GlitterRings = 26;

	private const int GlitterColumns = 5;

	private const float IndoorRainFadeDepth = 0.5f;

	private const float IndoorRainLevel = 0.8f;

	private ConfigEntry<bool> _gradingEnabled;

	private ConfigEntry<float> _temperature;

	private ConfigEntry<float> _tint;

	private ConfigEntry<float> _postExposure;

	private ConfigEntry<float> _contrast;

	private ConfigEntry<float> _saturation;

	private ConfigEntry<Color> _dayColorFilter;

	private ConfigEntry<float> _shadowCooling;

	private ConfigEntry<string> _tonemapping;

	private ConfigEntry<bool> _disableFilmGrain;

	private ConfigEntry<bool> _disableDepthOfField;

	private ConfigEntry<bool> _disableMotionBlur;

	private ConfigEntry<bool> _disableBloom;

	private ConfigEntry<bool> _disableVignette;

	private ConfigEntry<bool> _neutralizeSplitToning;

	private ConfigEntry<bool> _adjustSun;

	private ConfigEntry<float> _sunElevation;

	private ConfigEntry<float> _sunAzimuth;

	private ConfigEntry<float> _sunIntensity;

	private ConfigEntry<float> _sunShadowStrength;

	private ConfigEntry<float> _sunNeutralize;

	private ConfigEntry<bool> _forceShadowCasting;

	private ConfigEntry<bool> _restoreTreeShadows;

	private ConfigEntry<bool> _hardShadows;

	private ConfigEntry<int> _shadowMapResolution;

	private ConfigEntry<int> _shadowCascadeCount;

	private ConfigEntry<bool> _stabilizeShadowEdges;

	private ConfigEntry<bool> _dappledCanopyShadows;

	private ConfigEntry<float> _canopyShadowGaps;

	private ConfigEntry<string> _seasonTheme;

	private ConfigEntry<float> _autumnStrength;

	private ConfigEntry<bool> _autumnGroundRecolor;

	private ConfigEntry<float> _canopyShading;

	private ConfigEntry<float> _canopyShadeBrightness;

	private ConfigEntry<float> _autumnWarmFilter;

	private ConfigEntry<float> _leafFallRate;

	private ConfigEntry<int> _leafFallTrees;

	private ConfigEntry<int> _groundLeafLimit;

	private ConfigEntry<float> _groundLeafLifetime;

	private ConfigEntry<float> _autumnWaterTint;

	private ConfigEntry<float> _autumnSunElevation;

	private ConfigEntry<bool> _harvestMoon;

	private ConfigEntry<bool> _leavesOnWater;

	private ConfigEntry<bool> _halloweenStringLights;

	private ConfigEntry<bool> _dayCycleEnabled;

	private ConfigEntry<float> _cycleMinutes;

	private ConfigEntry<float> _noonMinute;

	private ConfigEntry<float> _maxElevation;

	private ConfigEntry<float> _nightBrightness;

	private ConfigEntry<float> _minimumNightLight;

	private ConfigEntry<float> _nightExposureDip;

	private ConfigEntry<float> _shadowDistance;

	private ConfigEntry<bool> _lampsEnabled;

	private ConfigEntry<string> _lampStyle;

	private ConfigEntry<string> _lampKeywords;

	private ConfigEntry<int> _maxLitLamps;

	private ConfigEntry<float> _lampRange;

	private ConfigEntry<float> _lampIntensity;

	private ConfigEntry<float> _haloSize;

	private ConfigEntry<bool> _deckStringLightsEnabled;

	private ConfigEntry<float> _deckStringLightRange;

	private ConfigEntry<float> _deckStringLightIntensity;

	private ConfigEntry<float> _deckStringColorCycleSeconds;

	private ConfigEntry<float> _deskLampRange;

	private ConfigEntry<float> _deskLampIntensity;

	private ConfigEntry<bool> _campfireLightsEnabled;

	private ConfigEntry<bool> _treeLanternLightsEnabled;

	private ConfigEntry<bool> _playTowerSunLightEnabled;

	private ConfigEntry<bool> _schoolRingLights;

	private ConfigEntry<float> _schoolRingBrightness;

	private ConfigEntry<bool> _deviceScreensGlow;

	private ConfigEntry<bool> _waterDaylight;

	private ConfigEntry<float> _nightWaterBrightness;

	private ConfigEntry<Color> _dayWaterPatternColor;

	private ConfigEntry<Color> _nightWaterPatternColor;

	private ConfigEntry<float> _waterWaveBrightness;

	private ConfigEntry<float> _nightWaterfallFoamBrightness;

	private ConfigEntry<float> _seaSkyReflection;

	private ConfigEntry<float> _twilightSeaBrightness;

	private ConfigEntry<bool> _sunGlitterEnabled;

	private ConfigEntry<float> _sunGlitterStrength;

	private ConfigEntry<float> _sunGlitterCoverage;

	private ConfigEntry<float> _sunGlitterSpread;

	private ConfigEntry<bool> _waterShadowOverlayEnabled;

	private ConfigEntry<float> _waterShadowOverlayStrength;

	private ConfigEntry<bool> _toonShading;

	private ConfigEntry<float> _shadeDarkness;

	private ConfigEntry<float> _surfaceShadeStep;

	private ConfigEntry<float> _surfaceNoonShadeStep;

	private ConfigEntry<float> _surfaceSystemShadowLevel;

	private ConfigEntry<float> _playerShadeDarkness;

	private ConfigEntry<float> _playerSystemShadowLevel;

	private ConfigEntry<float> _playerShadeStep;

	private ConfigEntry<bool> _replaceSkybox;

	private ConfigEntry<float> _atmosphereThickness;

	private ConfigEntry<float> _skyExposure;

	private ConfigEntry<float> _sunSize;

	private ConfigEntry<Color> _skyTint;

	private ConfigEntry<Color> _groundColor;

	private ConfigEntry<bool> _moonEnabled;

	private ConfigEntry<float> _lunarCycleDays;

	private ConfigEntry<float> _newMoonBrightness;

	private ConfigEntry<float> _moonSize;

	private ConfigEntry<Color> _moonColor;

	private ConfigEntry<bool> _sunsetGlowEnabled;

	private ConfigEntry<float> _sunsetGlowStrength;

	private ConfigEntry<bool> _freezeTime;

	private ConfigEntry<float> _frozenHour;

	private ConfigEntry<int> _twilightVariantOverride;

	private float _lastCyclePhase;

	private int _lastVariantOverride = -1;

	private ConfigEntry<float> _pinkDuskChance;

	private ConfigEntry<float> _redDuskChance;

	private ConfigEntry<float> _twilightWorldTint;

	private ConfigEntry<float> _twilightWidth;

	private ConfigEntry<float> _twilightFalloff;

	private ConfigEntry<bool> _starsEnabled;

	private ConfigEntry<int> _starCount;

	private ConfigEntry<float> _meteorChance;

	private ConfigEntry<bool> _cloudsEnabled;

	private ConfigEntry<int> _cloudCount;

	private ConfigEntry<bool> _cloudShadows;

	private ConfigEntry<float> _cloudSpeed;

	private ConfigEntry<float> _cloudDirection;

	private ConfigEntry<float> _cloudAltitude;

	private ConfigEntry<float> _cloudScale;

	private ConfigEntry<bool> _hideVanillaClouds;

	private ConfigEntry<bool> _weatherEnabled;

	private ConfigEntry<bool> _randomRain;

	private ConfigEntry<bool> _alwaysRain;

	private ConfigEntry<float> _rainChance;

	private ConfigEntry<string> _rainToggleKey;

	private ConfigEntry<float> _rainMinutesMin;

	private ConfigEntry<float> _rainMinutesMax;

	private ConfigEntry<float> _weatherTransitionSeconds;

	private ConfigEntry<float> _rainLightMultiplier;

	private ConfigEntry<float> _rainExposureDip;

	private ConfigEntry<float> _rainAudioVolume;

	private ConfigEntry<float> _thunderChancePerMinute;

	private ConfigEntry<float> _rainDropSize;

	private ConfigEntry<float> _rainDensity;

	private ConfigEntry<bool> _gustsEnabled;

	private ConfigEntry<float> _gustInterval;

	private ConfigEntry<float> _gustStrengthScale;

	private ConfigEntry<bool> _decorDimming;

	private ConfigEntry<float> _nightDecorBrightness;

	private ConfigEntry<string> _decorExcludeKeywords;

	private ConfigEntry<float> _ambientCoolShift;

	private ConfigEntry<float> _ambientIntensity;

	private ConfigEntry<bool> _natureAmbienceEnabled;

	private ConfigEntry<float> _noonCicadaVolume;

	private ConfigEntry<float> _nightNatureVolume;

	private ConfigEntry<float> _natureFadeSeconds;

	private ConfigEntry<float> _rainNatureMultiplier;

	private ConfigEntry<float> _leafStepVolume;

	private ConfigEntry<float> _windVolume;

	private ConfigEntry<float> _crowVolume;

	private ConfigEntry<float> _crowCallsPerMinute;

	private ConfigEntry<bool> _activitySoundsEnabled;

	private ConfigEntry<float> _activitySoundVolume;

	private ConfigEntry<bool> _leafStepPuffs;

	private ConfigEntry<bool> _configMenuEnabled;

	private ConfigEntry<string> _configMenuKey;

	private ConfigEntry<string> _configMenuLanguage;

	private ConfigEntry<int> _configRevision;

	private GameObject _volumeObject;

	private Volume _volume;

	private VolumeProfile _profile;

	private Material _skyMaterial;

	private Material _originalSkybox;

	private bool _skyApplied;

	private bool _skyRuntimeEnabled;

	private GameObject _moonObject;

	private Material _moonMaterial;

	private Texture2D _moonTexture;

	private Mesh _moonMesh;

	private float _moonPhase;

	private float _moonIllumination = 1f;

	private float _lastMoonTexturePhase = -10f;

	private float _nextMoonPhaseUpdate;

	private bool _ambientCaptured;

	private AmbientMode _origAmbientMode;

	private Color _origAmbientLight;

	private Color _origAmbientSky;

	private Color _origAmbientEquator;

	private Color _origAmbientGround;

	private float _origAmbientIntensity;

	private Coroutine _applyRoutine;

	private Light _sunLight;

	private bool _sunCaptured;

	private Quaternion _origSunRotation;

	private Color _origSunColor;

	private float _origSunIntensity;

	private float _origSunShadowStrength;

	private int _postForcedCount;

	private int _skyboxForcedCount;

	private int _cameraSkyboxForcedCount;

	private float _nextPostCheck;

	private float _nextDayCycleUpdate;

	private Camera _worldCamera;

	private static readonly FieldInfo ProfilePhotoCameraField = typeof(PhotoController).GetField("_photoCamera", BindingFlags.Instance | BindingFlags.NonPublic);

	private Camera _profilePhotoCamera;

	private bool _profilePhotoLookupAttempted;

	private Camera _neutralPhotoRenderCamera;

	private bool _neutralPhotoVolumeEnabled;

	private Quaternion _neutralPhotoSunRotation;

	private Color _neutralPhotoSunColor;

	private float _neutralPhotoSunIntensity;

	private float _neutralPhotoSunShadowStrength;

	private Color _neutralPhotoAmbientLight;

	private Color _neutralPhotoAmbientSky;

	private Color _neutralPhotoAmbientEquator;

	private Color _neutralPhotoAmbientGround;

	private float _neutralPhotoAmbientIntensity;

	private float _neutralPhotoReflectionIntensity;

	private readonly Dictionary<int, CameraSkyboxState> _cameraSkyboxStates = new Dictionary<int, CameraSkyboxState>();

	private readonly Dictionary<int, ShadowRendererState> _shadowRendererStates = new Dictionary<int, ShadowRendererState>();

	private LightShadows _origSunShadows;

	private float _nextGiUpdate;

	private float _nextShadowRescan;

	private float _nextPlayerShadowRefresh;

	private float _nextSceneFeatureLampRescan;

	private bool _playerDiagnosticsWritten;

	private ColorAdjustments _colorAdjustments;

	private bool _colorGradingModeCaptured;

	private ColorGradingMode _originalColorGradingMode;

	private readonly List<Light> _lampLights = new List<Light>();

	private readonly List<GameObject> _lampHolders = new List<GameObject>();

	private readonly List<Transform> _lampHalos = new List<Transform>();

	private readonly Dictionary<Light, float> _deckStringLightHues = new Dictionary<Light, float>();

	private readonly Dictionary<Renderer, float> _deckStringHaloHues = new Dictionary<Renderer, float>();

	private readonly Dictionary<Light, SpecialLocalLight> _specialLocalLights = new Dictionary<Light, SpecialLocalLight>();

	private readonly List<CampfireEmissionState> _campfireEmissionStates = new List<CampfireEmissionState>();

	private readonly List<SchoolRingGlowState> _schoolRingGlows = new List<SchoolRingGlowState>();

	private readonly List<Renderer> _schoolGlassRenderers = new List<Renderer>();

	private readonly Dictionary<Material, int> _schoolGlassOriginalQueues = new Dictionary<Material, int>();

	private Renderer _schoolRingRenderer;

	private float _nextSchoolScan;

	private float _nextSchoolGlassAssert;

	private bool _schoolCameraInside;

	private float _schoolGlassRadius;

	private int _schoolGlowQueue = 2600;

	private bool _schoolRoomKnown;

	private Vector3 _schoolRoomCentre;

	private float _schoolRoomRadius;

	private float _schoolRoomFloor;

	private float _schoolRoomCeiling;

	private Bounds _schoolRoomBounds;

	private Particle[] _schoolCullParticles = (Particle[])(object)new Particle[256];

	private int _schoolCulledRain;

	private int _schoolCulledLeaves;

	private float _nextSchoolCullLog;

	private bool _greenhouseKnown;

	private Transform _greenhouseFrame;

	private Bounds _greenhouseLocal;

	private Bounds _greenhouseWorldBounds;

	private Matrix4x4 _greenhouseWorldToLocal;

	private float[] _greenhouseRoof;

	private bool[] _greenhouseCovered;

	private float[] _greenhouseDepth;

	private float _nextGreenhouseScan;

	private GameObject _indoorWeatherAudioObject;

	private AudioSource _indoorRainAudioSource;

	private AudioSource _indoorRainDetailAudioSource;

	private AudioSource _indoorThunderAudioSource;

	private AudioLowPassFilter _rainIndoorLowPass;

	private AudioReverbFilter _rainIndoorReverb;

	private int _indoorRainRoom = -1;

	private float _indoorRainWeight;

	private readonly Dictionary<Material, Material> _indoorGreenCopies = new Dictionary<Material, Material>();

	private readonly Dictionary<Renderer, Material[]> _indoorGreenRenderers = new Dictionary<Renderer, Material[]>();

	private readonly List<IndoorBushState> _indoorGreenBushes = new List<IndoorBushState>();

	private bool _seasonRoomsPending;

	private readonly Dictionary<Material, SeasonMaterialState> _indoorGreenStates = new Dictionary<Material, SeasonMaterialState>();

	private float _nextIndoorGreenScan;

	private readonly HashSet<Renderer> _indoorGreenRejected = new HashSet<Renderer>();

	private readonly List<DeviceScreenState> _deviceScreenStates = new List<DeviceScreenState>();

	private static readonly Color[] DeckStringPastelColors = (Color[])(object)new Color[6]
	{
		new Color(1f, 0.68f, 0.66f, 1f),
		new Color(0.98f, 0.82f, 0.56f, 1f),
		new Color(0.71f, 0.88f, 0.64f, 1f),
		new Color(0.57f, 0.82f, 0.88f, 1f),
		new Color(0.65f, 0.7f, 0.96f, 1f),
		new Color(0.88f, 0.66f, 0.92f, 1f)
	};

	private static readonly Color[] DeckStringHalloweenColors = (Color[])(object)new Color[2]
	{
		new Color(1f, 0.42f, 0.05f, 1f),
		new Color(0.56f, 0.17f, 0.88f, 1f)
	};

	private Material _haloMaterial;

	private Mesh _haloMesh;

	private float _nextLampUpdate;

	private float _lastDayWeight = 1f;

	private float _lampWeight;

	private static readonly SeasonRecolor[] AutumnRecolors = new SeasonRecolor[14]
	{
		new SeasonRecolor("ToonWaveInstance", "_Color_3", new Color(0.361f, 0.18f, 0.078f, 1f), ground: false),
		new SeasonRecolor("Green 10", "_BaseColor,_Color", new Color(0.851f, 0.561f, 0.235f, 1f), ground: false),
		new SeasonRecolor("Green 10 2", "_BaseColor,_Color", new Color(0.851f, 0.561f, 0.235f, 1f), ground: false),
		new SeasonRecolor("M_Grass_01", "_BaseColor,_Color", new Color(0.788f, 0.541f, 0.22f, 1f), ground: false),
		new SeasonRecolor("Flower 3 Green Circle", "_BaseColor,_Color", new Color(0.784f, 0.486f, 0.2f, 1f), ground: false),
		new SeasonRecolor("Flower 2", "_BaseColor,_Color", 0.095f, 1.4f, 1f, ground: false),
		new SeasonRecolor("Flower 3 White Circle 1", "_BaseColor,_Color", 0.095f, 1.4f, 1f, ground: false),
		new SeasonRecolor("Flower 4", "_BaseColor,_Color", 0.085f, 1.4f, 1f, ground: false),
		new SeasonRecolor("M_GroundGrass 30", "_BaseColor,_Color", 0.098f, 1.4f, 0.96f, ground: true),
		new SeasonRecolor("M_GroundGrass 10", "_BaseColor,_Color", 0.098f, 1.4f, 0.96f, ground: true),
		new SeasonRecolor("M_PathNature 1", "_BaseColor,_Color", 0.085f, 1.3f, 1f, ground: true),
		new SeasonRecolor("M_PathNature Mid", "_BaseColor,_Color", 0.088f, 1.25f, 1f, ground: true),
		new SeasonRecolor("M_PathNature Long", "_BaseColor,_Color", 0.088f, 1.25f, 1f, ground: true),
		new SeasonRecolor("M_PathNature Short", "_BaseColor,_Color", 0.088f, 1.25f, 1f, ground: true)
	};

	private static readonly Color[] AutumnCanopyPalette = (Color[])(object)new Color[4]
	{
		new Color(0.949f, 0.776f, 0.235f, 1f),
		new Color(0.929f, 0.655f, 0.2f, 1f),
		new Color(0.91f, 0.486f, 0.18f, 1f),
		new Color(0.847f, 0.286f, 0.173f, 1f)
	};

	private static readonly int[] AutumnCanopyWeights = new int[8] { 0, 0, 0, 1, 1, 2, 2, 3 };

	private static readonly Color CanopyBandDark = new Color(0.3f, 0.14f, 0.06f, 1f);

	private static readonly Color CanopyBandLight = new Color(0.8f, 0.52f, 0.24f, 1f);

	private static readonly Color AutumnWarmFilter = new Color(1.02f, 0.9f, 0.62f, 1f);

	private static readonly Color HarvestMoonColor = new Color(1f, 0.78f, 0.42f, 1f);

	private readonly List<SeasonMaterialState> _seasonMaterials = new List<SeasonMaterialState>();

	private readonly HashSet<Material> _seasonSeen = new HashSet<Material>();

	private readonly List<SeasonCanopyState> _seasonCanopies = new List<SeasonCanopyState>();

	private readonly List<CanopyCluster> _canopyClusters = new List<CanopyCluster>();

	private readonly List<CanopyShadowState> _canopyShadows = new List<CanopyShadowState>();

	private readonly List<GameObject> _canopyShadowObjects = new List<GameObject>();

	private readonly List<Mesh> _canopyShadowMeshes = new List<Mesh>();

	private Material _canopyShadowMaterial;

	private bool[][] _canopyDappleMasks;

	private float _canopyDappleMaskGaps = -1f;

	private readonly List<LeafEmitterState> _leafEmitters = new List<LeafEmitterState>();

	private Material _autumnLeafMaterial;

	private Texture2D _autumnLeafAtlas;

	private readonly Material[] _treeLeafMaterials = (Material[])(object)new Material[4];

	private readonly Dictionary<GameObject, bool> _lighthouseOriginalActive = new Dictionary<GameObject, bool>();

	private float _nextLighthouseScan;

	private float _nextLeafEmitterLight;

	private GameObject _leafKickObject;

	private ParticleSystem _leafKick;

	private ParticleSystemRenderer _leafKickRenderer;

	private Vector3 _lastWalkerPosition;

	private Transform _walkerTransform;

	private float _nextWalkerLookup;

	private bool _walkerTracked;

	private float _nextLeafStepAt;

	private AudioSource _leafStepSource;

	private AudioSource _windAudioSource;

	private AudioSource _crowAudioSource;

	private AudioClip _leafStepClip;

	private AudioClip _windAudioClip;

	private readonly List<AudioClip> _crowClips = new List<AudioClip>();

	private float _crowStopAt;

	private float _leafStepStopAt;

	private float _nextCrowAt;

	private bool _windGenerated;

	private float[] _windSamples;

	private int _windReadPosition;

	private readonly List<WindMaterial> _windMaterials = new List<WindMaterial>();

	private bool _windCaptured;

	private float _gustStrength;

	private float _appliedGustWind = -1f;

	private float _nextGustAt;

	private float _scheduledGustInterval = -1f;

	private float _gustQuietSince;

	private int _leafEmitterLightCursor;

	private float _nextLeafLampSnapshot;

	private readonly List<LeafLampSample> _leafLampSamples = new List<LeafLampSample>();

	private float _gustEndAt;

	private Vector3 _gustDirection = Vector3.forward;

	private GameObject _gustFieldObject;

	private ParticleSystemForceField _gustField;

	private bool _leafForcesActive;

	private readonly List<GroundLeaf> _groundLeaves = new List<GroundLeaf>();

	private readonly List<Vector3> _groundLeafVertices = new List<Vector3>();

	private readonly List<Vector2> _groundLeafUvs = new List<Vector2>();

	private readonly List<int> _groundLeafTriangles = new List<int>();

	private readonly List<Color> _groundLeafColors = new List<Color>();

	private readonly List<int> _groundLeafDrawn = new List<int>();

	private float _nextGroundLeafLight;

	private int _groundLeafLightCursor;

	private GameObject _groundLeafObject;

	private Mesh _groundLeafMesh;

	private MeshRenderer _groundLeafRenderer;

	private Material _groundLeafMaterial;

	private float _nextGroundLeafSpawn;

	private bool _groundLeafDirty;

	private int _groundLeafRayMask;

	private bool _groundLeafRayMaskReady;

	private static readonly Func<ParticleSystem, Particle[], int, int, int> ReadLeafParticles = (Func<ParticleSystem, Particle[], int, int, int>)Delegate.CreateDelegate(typeof(Func<ParticleSystem, Particle[], int, int, int>), typeof(ParticleSystem).GetMethod("GetParticles", new Type[3]
	{
		typeof(Particle[]),
		typeof(int),
		typeof(int)
	}));

	private static readonly Action<ParticleSystem, Particle[], int, int> WriteLeafParticles = (Action<ParticleSystem, Particle[], int, int>)Delegate.CreateDelegate(typeof(Action<ParticleSystem, Particle[], int, int>), typeof(ParticleSystem).GetMethod("SetParticles", new Type[3]
	{
		typeof(Particle[]),
		typeof(int),
		typeof(int)
	}));

	private Particle[] _leafLightParticles = (Particle[])(object)new Particle[128];

	private readonly List<MeshCollider> _leafWaterProbes = new List<MeshCollider>();

	private float _nextLeafWaterScan;

	private float _nextLeafStatus;

	private Vector3 _airborneLeafWind;

	private readonly List<Vector3> _riverLeafRoute = new List<Vector3>();

	private readonly List<Transform> _pondLeafTransforms = new List<Transform>();

	private static readonly Vector3[] PondLeafRoute = (Vector3[])(object)new Vector3[7]
	{
		new Vector3(0f, 15.62f, 2f),
		new Vector3(0f, 15.62f, 0f),
		new Vector3(0f, 15.62f, -2.85f),
		new Vector3(0f, 15.562f, -5.783f),
		new Vector3(0f, 15.414f, -6.051f),
		new Vector3(0f, 15.315f, -6.105f),
		new Vector3(0f, -1.199f, -8.151f)
	};

	private int _waterLeafAttempts;

	private int _waterLeafHits;

	private int _waterLeafBlocked;

	private int _waterLeafSpawned;

	private readonly List<int> _stillLeafPerBody = new List<int>();

	private int _stillLeafCount;

	private int _appliedSeason = -1;

	private float _nextSeasonRescan;

	private int _seasonRescanAttempts;

	private readonly List<WaterMaterial> _waterMaterials = new List<WaterMaterial>();

	private readonly HashSet<Material> _waterSeen = new HashSet<Material>();

	private readonly List<WaterParticleState> _waterParticles = new List<WaterParticleState>();

	private readonly HashSet<int> _waterParticleIds = new HashSet<int>();

	private Color _seaSkyMirrorColor = Color.white;

	private Color _seaDrivenBodyColor = new Color(0.2f, 0.4f, 0.5f, 1f);

	private float _lastTwilightGlow;

	private float _lastSunVisibility;

	private float _seaSurfaceY;

	private Bounds _seaBounds;

	private bool _seaSurfaceValid;

	private float _nextWaterEffectScan;

	private float _origReflectionIntensity = 1f;

	private Material _waterShadowOverlayMaterial;

	private readonly List<GameObject> _waterShadowOverlayObjects = new List<GameObject>();

	private readonly HashSet<int> _waterShadowOverlaySourceIds = new HashSet<int>();

	private readonly List<WaterMaterial> _decorMaterials = new List<WaterMaterial>();

	private readonly HashSet<Material> _decorSeen = new HashSet<Material>();

	private float _nextDecorRescan;

	private readonly Dictionary<int, NativeFeatureRenderer> _nativeFeatureRenderers = new Dictionary<int, NativeFeatureRenderer>();

	private readonly List<Renderer> _faceRenderers = new List<Renderer>();

	private readonly List<Light> _faceLightSources = new List<Light>();

	private readonly List<int> _nativeFeatureCleanupIds = new List<int>();

	private Shader _faceTintShader;

	private float _nextFaceRendererScan;

	private float _nextFaceBrightnessUpdate;

	private float _nextFaceAssignCheck;

	private float _nextFaceStatusLog;

	private int _nativeFeatureLogged;

	private static readonly int BaseColorPropertyId = Shader.PropertyToID("_BaseColor");

	private static readonly int CanopyColor1PropertyId = Shader.PropertyToID("_Color_1");

	private static readonly int CanopyColor2PropertyId = Shader.PropertyToID("_Color_2");

	private static readonly int CanopyThresholdPropertyId = Shader.PropertyToID("_Threshold_1");

	private static readonly int BaseMapPropertyId = Shader.PropertyToID("_BaseMap");

	private static readonly string[] FaceTintPropertyNames = new string[4] { "_BaseColor", "_Color", "_Tint", "_TintColor" };

	private static readonly string[] FaceTexturePropertyNames = new string[3] { "_MainTex", "_Texture2D", "_BaseMap" };

	private int _lastTwilightId = int.MinValue;

	private string _twilightVariantName = "golden dusk";

	private Color _twilightGlowColor = new Color(1f, 0.42f, 0.1f, 1f);

	private Color _twilightSkyTint = new Color(0.82f, 0.44f, 0.18f, 1f);

	private Color _twilightSunColor = new Color(1f, 0.7f, 0.38f, 1f);

	private GameObject _sunsetGlowObject;

	private Material _sunsetGlowMaterial;

	private Texture2D _sunsetGlowTexture;

	private GameObject _duskShadeObject;

	private Material _duskShadeMaterial;

	private GameObject _sunGlitterObject;

	private Material _sunGlitterMaterial;

	private Mesh _sunGlitterMesh;

	private Vector3[] _glitterVertices;

	private Color[] _glitterColors;

	private GameObject _sunObject;

	private Material _sunMaterial;

	private Texture2D _sunTexture;

	private int _sunDiskState = -1;

	private bool _celestialValid;

	private float _lastSignedElevation;

	private float _lastSunAzimuth;

	private Camera _shadowAaCamera;

	private AntialiasingMode _originalAntialiasing;

	private AntialiasingQuality _originalAntialiasingQuality;

	private bool _shadowAaCaptured;

	private GameObject _starObject;

	private Material _starMaterial;

	private Mesh _starMesh;

	private Texture2D _starTexture;

	private readonly List<Color> _starBaseColors = new List<Color>();

	private readonly List<float> _starTwinklePhases = new List<float>();

	private readonly List<float> _starTwinkleSpeeds = new List<float>();

	private readonly List<float> _starTwinkleAmounts = new List<float>();

	private readonly List<Color> _starAnimatedColors = new List<Color>();

	private float _nextStarTwinkleUpdate;

	private GameObject _meteorObject;

	private Material _meteorMaterial;

	private bool _meteorActive;

	private Vector3 _meteorDir;

	private Vector3 _meteorVelocity;

	private float _meteorStartTime;

	private float _nextMeteorRoll;

	private readonly Random _visualRandom = new Random();

	private readonly Dictionary<int, HiddenCloudRendererState> _hiddenVanillaClouds = new Dictionary<int, HiddenCloudRendererState>();

	private readonly Dictionary<int, HiddenWorldCloudRootState> _hiddenWorldCloudRoots = new Dictionary<int, HiddenWorldCloudRootState>();

	private readonly Dictionary<int, CloudInstancingState> _hiddenCloudInstancers = new Dictionary<int, CloudInstancingState>();

	private float _nextVanillaCloudScan;

	private readonly HashSet<int> _cloudSuspectsLogged = new HashSet<int>();

	private readonly HashSet<int> _skyRenderersLogged = new HashSet<int>();

	private GameObject _cloudRoot;

	private Material _cloudMaterial;

	private readonly List<Transform> _cloudTransforms = new List<Transform>();

	private readonly List<Vector3> _cloudBaseScales = new List<Vector3>();

	private readonly List<Mesh> _cloudMeshList = new List<Mesh>();

	private bool _rainTarget;

	private float _rainBlend;

	private float _nextWeatherChange;

	private float _nextWorldProbe;

	private bool _worldSceneReady;

	private KeyCode _weatherToggleKey = (KeyCode)291;

	private readonly Random _weatherRandom = new Random();

	private GameObject _stormCloudRoot;

	private Material _stormCloudMaterial;

	private readonly List<Transform> _stormCloudTransforms = new List<Transform>();

	private readonly List<Vector3> _stormCloudBaseScales = new List<Vector3>();

	private readonly List<Mesh> _stormCloudMeshes = new List<Mesh>();

	private GameObject _rainObject;

	private ParticleSystem _rainParticles;

	private Material _rainMaterial;

	private Texture2D _rainTexture;

	private bool _rainUsesNativeMaterial;

	private GameObject _splashObject;

	private ParticleSystem _splashParticles;

	private Material _splashMaterial;

	private Texture2D _splashTexture;

	private float _splashAccumulator;

	private bool _splashDiagnosticWritten;

	private GameObject _weatherAudioObject;

	private AudioSource _rainAudioSource;

	private AudioSource _rainDetailAudioSource;

	private AudioSource _thunderAudioSource;

	private AudioClip _rainAudioClip;

	private AudioClip _rainDetailAudioClip;

	private AudioClip _thunderAudioClip;

	private string _weatherAudioPairSignature = "";

	private float _nextWeatherAudioProbe;

	private bool _weatherAudioWarningWritten;

	private float _nextThunderRoll;

	private float _lightningFlash;

	private bool _weatherFogCaptured;

	private bool _originalFogEnabled;

	private FogMode _originalFogMode;

	private Color _originalFogColor;

	private float _originalFogDensity;

	private float _originalFogStart;

	private float _originalFogEnd;

	private GameObject _natureAudioObject;

	private AudioSource _cicadaAudioSource;

	private AudioSource _nightNatureAudioSource;

	private AudioClip _cicadaAudioClip;

	private AudioClip _nightNatureAudioClip;

	private Coroutine _natureAudioLoadRoutine;

	private bool _natureAudioLoadAttempted;

	private int _lastNatureAudioPhase = -1;

	private KeyCode _configMenuKeyCode = (KeyCode)292;

	private bool _configMenuVisible;

	private bool _hotConfigDirty;

	private float _hotConfigApplyAt;

	private Rect _configMenuRect = new Rect(36f, 36f, 680f, 700f);

	private Vector2 _configMenuScroll;

	private int _configMenuTab;

	private CursorLockMode _cursorLockBeforeMenu;

	private bool _cursorVisibleBeforeMenu;

	private GUIStyle _menuTitleStyle;

	private GUIStyle _menuSectionStyle;

	private GUIStyle _menuNoteStyle;

	private GUIStyle _menuValueStyle;

	private Font _configMenuFont;

	private bool _ownsConfigMenuFont;

	private readonly HashSet<int> _lampRootIds = new HashSet<int>();

	private readonly HashSet<int> _sceneFeatureLightSourceIds = new HashSet<int>();

	private readonly List<ToonMaterial> _toonMaterials = new List<ToonMaterial>();

	private readonly List<ToonMaterial> _surfaceToonEntries = new List<ToonMaterial>();

	private readonly HashSet<Material> _toonSeen = new HashSet<Material>();

	private readonly HashSet<Material> _surfaceToonMaterials = new HashSet<Material>();

	private readonly HashSet<Material> _basketCourtToonMaterials = new HashSet<Material>();

	private static readonly float[] MapleLobeAngles = new float[5] { 0f, 0.95f, -0.95f, 2.3f, -2.3f };

	private static readonly float[] MapleLobeLengths = new float[5] { 0.95f, 0.86f, 0.86f, 0.68f, 0.68f };

	private static readonly Color[] LeafTileColors = (Color[])(object)new Color[4]
	{
		new Color(0.87308f, 0.71392006f, 0.21620001f, 1f),
		new Color(0.85468006f, 0.6026f, 0.184f, 1f),
		new Color(0.83720005f, 0.44712f, 0.16560002f, 1f),
		new Color(0.77924f, 0.26312003f, 0.15916f, 1f)
	};

	private readonly Dictionary<PlayerAnimationController, ActivityVoice> _activityVoices = new Dictionary<PlayerAnimationController, ActivityVoice>();

	private readonly Dictionary<string, AudioClip[]> _activityClips = new Dictionary<string, AudioClip[]>();

	private Dictionary<int, string> _activityStateMap;

	private readonly List<AnimatorClipInfo> _activityClipInfo = new List<AnimatorClipInfo>();

	private readonly List<ActivityVoice> _activityCandidates = new List<ActivityVoice>();

	private readonly HashSet<string> _activityLogged = new HashSet<string>();

	private readonly Random _activityRandom = new Random();

	private float _nextActivityScan;

	private static FieldInfo _playerAnimatorField;

	private static AnimationCurve _activityRolloff;

	private static readonly bool ActivitySoundsReady = false;

	private static readonly int AnimStateParameter = Animator.StringToHash("AnimState");

	private static Func<AudioClip, float[], int, bool> _setClipSamples;

	private static bool _setClipSamplesTried;

	private static readonly string[][] ActivityClipTokens = new string[45][]
	{
		new string[2] { "Listen", "" },
		new string[2] { "DM_Book", "dm" },
		new string[2] { "Play_Player0", "dnd" },
		new string[2] { "READ_Kindle", "ereader" },
		new string[2] { "Manga", "manga" },
		new string[2] { "Reading", "page" },
		new string[2] { "READ_", "page" },
		new string[2] { "Dactilo", "typewriter" },
		new string[2] { "TypeFast", "typefast" },
		new string[2] { "Browsing", "browse" },
		new string[2] { "WRITE_Typing", "typing" },
		new string[2] { "Laptop", "typing" },
		new string[2] { "Skimming", "skim" },
		new string[2] { "WRITE_Notebook", "pencil" },
		new string[2] { "Watercolor", "watercolor" },
		new string[2] { "Painting", "brush" },
		new string[2] { "LifeDrawing", "sketch" },
		new string[2] { "Draw", "sketch" },
		new string[2] { "Knitting", "knit" },
		new string[2] { "Croch", "crochet" },
		new string[2] { "Scrolling", "phone" },
		new string[2] { "Phone", "phone" },
		new string[2] { "Console", "buttons" },
		new string[2] { "Gameboy", "buttons" },
		new string[2] { "GameDeck", "buttons" },
		new string[2] { "Ramen", "ramen" },
		new string[2] { "Latte", "sip" },
		new string[2] { "Boba", "boba" },
		new string[2] { "Coconut", "straw" },
		new string[2] { "Bento", "bento" },
		new string[2] { "Watermelon", "watermelon" },
		new string[2] { "Marshmallow", "marshmallow" },
		new string[2] { "Ironing", "iron" },
		new string[2] { "Vacuum", "vacuum" },
		new string[2] { "Sweep", "sweep" },
		new string[2] { "Dumbbell", "dumbbell" },
		new string[2] { "JumpingRope", "jumprope" },
		new string[2] { "EXERCISE_Jump", "jumprope" },
		new string[2] { "SitUps", "situps" },
		new string[2] { "CircleCrunch", "situps" },
		new string[2] { "Exercise_Dance", "dance" },
		new string[2] { "SleepOnTable", "sleep" },
		new string[2] { "SleepMed", "meditate" },
		new string[2] { "MEDITATE", "meditate" },
		new string[2] { "Sleep", "sleep" }
	};

	private static readonly float[] GlitterColumnOffset = new float[5] { -1f, -0.5f, 0f, 0.5f, 1f };

	private static readonly float[] GlitterColumnAlpha = new float[5] { 0f, 0.55f, 1f, 0.55f, 0f };

	private void Awake()
	{
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_03da: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f10: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f49: Unknown result type (might be due to invalid IL or missing references)
		//IL_17a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_17bf: Unknown result type (might be due to invalid IL or missing references)
		_gradingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Grading", "Enabled", true, "Master switch for the Day and Night colour grade (white balance, exposure, contrast, shadow tone). F6 toggles it live for A/B comparison.");
		_temperature = ((BaseUnityPlugin)this).Config.Bind<float>("Grading", "Temperature", 20f, "White balance temperature, -100 (cold) to 100 (warm). Negative values counteract the game's warm cast.");
		_tint = ((BaseUnityPlugin)this).Config.Bind<float>("Grading", "Tint", 20f, "White balance green-magenta tint, -100 to 100. Positive counteracts the green cast of the grass-dominated daylight scenes.");
		_postExposure = ((BaseUnityPlugin)this).Config.Bind<float>("Grading", "Post exposure", 0f, "Exposure adjustment in EV. Zero preserves the clear authored highlights and sun disc.");
		_contrast = ((BaseUnityPlugin)this).Config.Bind<float>("Grading", "Contrast", 10f, "Contrast, -100 to 100. Positive values give shadows more presence.");
		_saturation = ((BaseUnityPlugin)this).Config.Bind<float>("Grading", "Saturation", 4f, "Saturation, -100 to 100.");
		_dayColorFilter = ((BaseUnityPlugin)this).Config.Bind<Color>("Grading", "Day color filter", new Color(1f, 0.98f, 1f, 1f), "Final daylight RGB multiplier. Kept very close to white so the grade removes only the green bias without laying a gray/magenta veil over the whole image.");
		_shadowCooling = ((BaseUnityPlugin)this).Config.Bind<float>("Grading", "Shadow cooling", 0.08f, "0-1. Shifts shadow regions toward a cooler, slightly deeper tone so they read as natural shade instead of warm haze.");
		_tonemapping = ((BaseUnityPlugin)this).Config.Bind<string>("Grading", "Tonemapping", "None", "None, Neutral or ACES. None preserves crisp pastel highlights and keeps the sun from being compressed into a gray disc; Neutral/ACES intentionally roll highlights off.");
		_disableFilmGrain = ((BaseUnityPlugin)this).Config.Bind<bool>("Grading", "Disable film grain", true, "Removes the game's film grain overlay, which contributes to the washed-out look.");
		_disableDepthOfField = ((BaseUnityPlugin)this).Config.Bind<bool>("Grading", "Disable depth of field", true, "Removes the game's depth-of-field blur. Sharper distance view and slightly cheaper on the GPU.");
		_disableMotionBlur = ((BaseUnityPlugin)this).Config.Bind<bool>("Grading", "Disable motion blur", true, "Removes the game's motion blur, which smears the image at sub-60 frame rates.");
		_disableBloom = ((BaseUnityPlugin)this).Config.Bind<bool>("Grading", "Disable bloom", true, "The game's own bloom (never visible before, since it shipped with post-processing off) washes the bright pastel scene into haze, especially at noon.");
		_disableVignette = ((BaseUnityPlugin)this).Config.Bind<bool>("Grading", "Disable vignette", true, "Removes the game's corner darkening.");
		_neutralizeSplitToning = ((BaseUnityPlugin)this).Config.Bind<bool>("Grading", "Neutralize split toning", true, "Overrides the game's own shadow/highlight color toning with neutral gray. Try this if the image still feels tinted after the white balance change.");
		_replaceSkybox = ((BaseUnityPlugin)this).Config.Bind<bool>("Sky", "Replace skybox", true, "Replaces the flat sky with a procedural atmosphere: deep blue zenith fading to a pale horizon, plus a visible sun disc that follows the scene's directional light. F5 toggles it live.");
		_atmosphereThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Atmosphere thickness", 0.9f, "0.5-2. Higher values deepen the blue but also whiten the horizon haze.");
		_skyExposure = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Exposure", 0.81f, "Skybox brightness.");
		_sunSize = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Sun size", 0.028f, "Apparent size of the daytime sun. The default keeps it compact and consistent through dawn and dusk.");
		_skyTint = ((BaseUnityPlugin)this).Config.Bind<Color>("Sky", "Sky tint", new Color(0.5f, 0.5f, 0.5f, 1f), "Tint applied to the atmosphere. Neutral gray gives a natural blue sky.");
		_groundColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Sky", "Ground color", new Color(0.6f, 0.8f, 0.85f, 1f), "Color of the skybox below the horizon. Keep it close to the sea color so the strip between the ocean edge and the sky blends in instead of showing a pale band.");
		_moonEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sky", "Enable moon phases", true, "Replaces the night-time miniature sun disc with a dedicated procedural moon whose lit face changes through a lunar cycle.");
		_lunarCycleDays = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Lunar cycle game days", 8f, "Number of in-game day/night cycles per complete lunar cycle. Eight gives the familiar eight recognizable moon phases; with a 30-minute day this is a four-hour lunar cycle.");
		_newMoonBrightness = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "New moon light multiplier", 0.6f, "0-1. Night directional-light brightness at new moon relative to full moon. Full moon always uses the existing Night brightness value as its baseline.");
		_moonSize = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Moon angular size", 0.05f, "Apparent size of the moon in the night sky.");
		_moonColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Sky", "Moon color", new Color(0.82f, 0.9f, 1f, 1f), "Tint of the illuminated lunar surface and its subtle halo.");
		_sunsetGlowEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sky", "Sunset glow", true, "Directional dawn/dusk color: a soft glow band hugs the horizon around the sun, so the sky blushes on the sun side while the opposite side stays dim, like a real sunset.");
		_sunsetGlowStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Sunset glow strength", 1f, "0-2. Opacity multiplier for the horizon glow band.");
		_freezeTime = ((BaseUnityPlugin)this).Config.Bind<bool>("Sky", "Hold time of day", false, "Keeps it at one time of day forever, instead of the clock moving on. Everything else still works normally. Turn it off and the day starts moving again.");
		_frozenHour = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Time to hold", 18f, "Which time to stay at. 12 is midday, 0 and 24 are midnight, 18 is about sunset and 6 is about sunrise.");
		_twilightVariantOverride = ((BaseUnityPlugin)this).Config.Bind<int>("Sky", "Always use this sunset colour", 0, "Normally the colour of each sunset is picked at random. Set this to always get the one you want. 0 random, 1 golden, 2 yellow morning, 3 pink, 4 deep red.");
		_pinkDuskChance = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Pink twilight chance", 0.05f, "0-1. Probability that a twilight rolls a pink sky instead of its usual color. Rolled once per twilight, deterministically from the real clock, and colors the glow band, sky tint and low-sun light together. A dusk normally comes up golden orange and a dawn plain yellow; dawns take this roll at 45% of the configured chance, because the haze that makes a sky burn builds up over the day.");
		_redDuskChance = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Crimson twilight chance", 0.03f, "0-1. Probability of a deep crimson twilight. Checked before the pink roll. Dawns take this roll at 30% of the configured chance.");
		_twilightWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Twilight width", 15f, "2-90 degrees of sun elevation. How far above and below the horizon a dawn or dusk reaches at all. Larger makes twilight last longer.");
		_twilightFalloff = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Twilight falloff", 1.6f, "0.2-8. Shape of the twilight inside that width. 1 is a straight ramp, so the sky starts colouring while the sun is still high. Higher pushes the colour into the last few degrees before the horizon and keeps the rest of the day clean.");
		_twilightWorldTint = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Twilight world tint", 0.77f, "0-1. How strongly the whole frame (ground, buildings, characters, sea) is pulled toward the twilight color while the sun crosses the horizon. 0 = only the sky and the low sun change color, like before.");
		_starsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sky", "Stars", true, "Starfield that fades in at dusk and out at dawn, slowly wheeling across the night sky.");
		_starCount = ((BaseUnityPlugin)this).Config.Bind<int>("Sky", "Star count", 180, "40-800. Number of stylized stars. A restrained count fits the game's clean cartoon sky better.");
		_meteorChance = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "Shooting star chance", 0.035f, "0-1. Probability per second (at deep night) that a shooting star streaks across the sky. 0.035 is roughly one every half minute.");
		_cloudsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Clouds", "Enabled", true, "Stylized puffy clouds that drift across the sky. They tint with dawn/dusk, darken under the night moon and can throw drifting shadows onto the island.");
		_cloudCount = ((BaseUnityPlugin)this).Config.Bind<int>("Clouds", "Cloud count", 24, "1-40. Number of clouds around the camera.");
		_cloudShadows = ((BaseUnityPlugin)this).Config.Bind<bool>("Clouds", "Cast cloud shadows", false, "Clouds write the shadow map, so soft shadow patches sweep across the ground as they drift. Costs some shadow-pass GPU; turn off first if the frame rate dips.");
		_cloudSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Clouds", "Wind speed", 0.8f, "Cloud drift speed in meters per second (0-30). Asset excavation proved every cloud in the sky is generated by this mod (the baked PR_CloudBase set is deactivated), so a clearly visible drift doubles as proof: a cloud that visibly moves is ours, and they all move.");
		_cloudDirection = ((BaseUnityPlugin)this).Config.Bind<float>("Clouds", "Wind direction", 25f, "Compass direction the clouds drift toward, in degrees.");
		_cloudAltitude = ((BaseUnityPlugin)this).Config.Bind<float>("Clouds", "Altitude", 50f, "Cloud base height in world units (25-150).");
		_cloudScale = ((BaseUnityPlugin)this).Config.Bind<float>("Clouds", "Cloud scale", 1f, "0.3-3. Overall cloud size multiplier.");
		_hideVanillaClouds = ((BaseUnityPlugin)this).Config.Bind<bool>("Clouds", "Hide vanilla clouds", true, "Hides the original clouds in the main world so they do not overlap the mod's clouds. Menu clouds and nearby player weather effects are preserved.");
		_weatherEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "Enabled", true, "Enables Day and Night rain events, visuals and the game's own rain ambience audio.");
		_randomRain = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "Random rain", true, "Starts and stops rain automatically. How often is set by 'Rain chance' below.");
		_alwaysRain = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "Always raining", false, "Holds the rain on and stops the random schedule. Stopping the rain by hand - the button in the menu, or the toggle key - clears this as well.");
		_rainChance = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain chance", 0.25f, "0.02-0.9. Roughly the share of the time it rains. A shower's own length is set by the two entries below; the clear stretch between showers is worked out from this and them, so 0.25 means about one hour in four is wet. Replaces the pair of 'Clear minutes' entries, which said the same thing in a way nobody could read the answer off.");
		_rainToggleKey = ((BaseUnityPlugin)this).Config.Bind<string>("Weather", "Toggle rain key", "F10", "Keyboard key that immediately starts or stops rain. F10 avoids FrameCare's F7-F9 keys.");
		_rainMinutesMin = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain minutes minimum", 2.5f, "Minimum duration of a random rain event.");
		_rainMinutesMax = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain minutes maximum", 5.5f, "Maximum duration of a random rain event.");
		_weatherTransitionSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Transition seconds", 14f, "Seconds used to build or clear the storm instead of popping instantly.");
		_rainLightMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain light multiplier", 0.58f, "0.2-1. Directional and ambient light multiplier under full rain cover.");
		_rainExposureDip = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain exposure dip", -0.18f, "Additional post exposure in EV during full rain.");
		_rainAudioVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain audio volume", 0.62f, "0-1. Combined volume of the game's long StormRain and Rain ambience layers.");
		_thunderChancePerMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Thunder chance per minute", 0.06f, "Average per-minute chance of a brief lightning flash and the game's built-in Thunder clip.");
		_rainDropSize = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain drop size multiplier", 0.4f, "Visible size of raindrops (0.4-1.4). This does not change their fall speed.");
		_rainDensity = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Rain density multiplier", 1.66f, "Amount of visible rain (0.5-2.0). Higher values may have a small performance cost.");
		_gustsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "Gusts of wind", true, "Every so often a gust crosses the island: the tree canopies lean and sway together, falling leaves are blown sideways, and leaves lying on the ground skitter along and are carried off. Works in both seasons - the canopies sway either way, there are simply no leaves to move in summer.");
		_gustInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Gust interval seconds", 480f, "Average quiet time between gusts. Each one lasts four to nine seconds and comes from a new direction.");
		_gustStrengthScale = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Gust strength", 0.4f, "0-2. How hard a gust blows: how far the canopies lean, how hard the airborne leaves are pushed, and how quickly leaves on the ground are carried away.");
		_adjustSun = ((BaseUnityPlugin)this).Config.Bind<bool>("Sun", "Adjust sun", true, "The game parks its directional light at a permanent overhead noon (90 degrees, straight down) with shadow strength 0.22, which makes the world look flat. This tilts the sun to a pleasant afternoon angle and restores shadow definition. Purely visual, does not affect gameplay.");
		_sunElevation = ((BaseUnityPlugin)this).Config.Bind<float>("Sun", "Elevation", 45f, "Sun height above the horizon in degrees. 90 restores the game's original overhead angle.");
		_sunAzimuth = ((BaseUnityPlugin)this).Config.Bind<float>("Sun", "Azimuth", 330f, "Compass direction the sunlight comes from, 0-360 degrees.");
		_sunIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Sun", "Intensity multiplier", 1f, "Multiplier on the sun light intensity.");
		_sunShadowStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Sun", "Shadow strength", 0.75f, "0-1. How dark sun shadows are. The game's original value is 0.22 (nearly invisible).");
		_shadowDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Sun", "Shadow distance", 220f, "Distance in world units within which shadows render, measured from the CAMERA. Zoomed-out views put the whole frame beyond a short distance and every shadow in view vanishes at once (the giant Circle_Hill cylinders made this obvious). Lower this first if shadow cost is too high.");
		_hardShadows = ((BaseUnityPlugin)this).Config.Bind<bool>("Sun", "Hard shadows", false, "Uses crisp shadow edges instead of the smoother default. Smooth shadows usually look better on moving characters.");
		_shadowMapResolution = ((BaseUnityPlugin)this).Config.Bind<int>("Sun", "Shadow map resolution", 4096, "Main directional-light shadow atlas resolution. 4096 keeps character and tree shadows clear across the long 220-unit shadow distance; lower values trade sharpness for performance.");
		_shadowCascadeCount = ((BaseUnityPlugin)this).Config.Bind<int>("Sun", "Shadow cascade count", 4, "Directional shadow cascades (1-4). Four preserves nearby shadow detail while the camera also covers distant scenery.");
		_stabilizeShadowEdges = ((BaseUnityPlugin)this).Config.Bind<bool>("Sun", "Stabilize moving shadow edges", true, "Uses high-quality spatial edge smoothing without frame-history blending. This avoids making transparent character outlines fade while the character moves.");
		_sunNeutralize = ((BaseUnityPlugin)this).Config.Bind<float>("Sun", "Neutralize warm tint", 0.25f, "0-1. Blends the sun color from the game's warm cream toward neutral white.");
		_forceShadowCasting = ((BaseUnityPlugin)this).Config.Bind<bool>("Sun", "Force shadow casting", true, "The game disables shadow casting on most environment objects (built for its shadowless overhead sun). This re-enables it so the tilted sun casts consistent shadows everywhere. Turn off if the shadow pass costs too much on your GPU.");
		_restoreTreeShadows = ((BaseUnityPlugin)this).Config.Bind<bool>("Sun", "Restore tree shadows", true, "Forces confirmed tree crowns and trunks to cast and receive directional shadows. This restores crown self-shadowing/back-side depth and lets trunks/crowns project onto the ground. Disable only if the additional moving foliage shadow casters are too expensive.");
		_dayCycleEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Day cycle", "Enabled", true, "Real-clock day/night cycle: 'Noon at minute' of every hour is high noon and one full day lasts 'Cycle minutes'. With the current defaults (0/60), a full day matches one real hour. Overrides the static sun elevation/azimuth while active.");
		_cycleMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("Day cycle", "Cycle minutes", 60f, "Length of one full day-night cycle in real minutes (5-1440). 1440 follows a full real day.");
		_noonMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Day cycle", "Noon at minute", 0f, "Minute of the hour that counts as high noon.");
		_maxElevation = ((BaseUnityPlugin)this).Config.Bind<float>("Day cycle", "Max sun elevation", 80f, "Sun height above the horizon at noon, in degrees (20-80). Higher noon sun keeps shadows short.");
		_nightBrightness = ((BaseUnityPlugin)this).Config.Bind<float>("Day cycle", "Night brightness", 0.58f, "0-1. Moonlight intensity relative to daylight, so nights stay cozy instead of pitch black.");
		_minimumNightLight = ((BaseUnityPlugin)this).Config.Bind<float>("Day cycle", "Minimum visible night light", 0.34f, "0-1. Main-light floor after moon phase and rain multipliers. Keeps characters, trees and paths readable during rainy new-moon nights without removing night color or lamp contrast.");
		_nightExposureDip = ((BaseUnityPlugin)this).Config.Bind<float>("Day cycle", "Night exposure dip", -0.12f, "Extra post exposure in EV applied at deep night. This darkens EVERYTHING on screen - including water, chalkboards and other glowing unlit materials that ignore the sun.");
		_lampsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Lamps", "Enabled", true, "EXPERIMENTAL: attaches warm point lights to lamp/lantern objects, lit automatically at dusk and night (needs the day cycle). Only works if the game's shaders support additional lights - check the ADDITIONAL LIGHTS log line.");
		_lampKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("Lamps", "Name keywords", "lamp,lantern,streetlight,street_light,lamppost", "Comma-separated name fragments used to recognize lamp objects. The last run only found 5 lamps, so if some street lights stay dark, add a fragment of their object name here and press F4. 'lighthouse' is always excluded.");
		_lampStyle = ((BaseUnityPlugin)this).Config.Bind<string>("Lamps", "Style", "Both", "Light = real point lights that illuminate surroundings; Halo = a cartoon glow sprite on the lamp itself, matching the vanilla art style; Both = the two combined.");
		_maxLitLamps = ((BaseUnityPlugin)this).Config.Bind<int>("Lamps", "Max lit lamps", 48, "Only the N nearest local lights (lamps and hanging string bulbs) are active at once. Range: 1-256. Halos remain visible on every recognized light.");
		_haloSize = ((BaseUnityPlugin)this).Config.Bind<float>("Lamps", "Halo size", 1.3f, "Diameter of the glow sprite in world units.");
		_lampRange = ((BaseUnityPlugin)this).Config.Bind<float>("Lamps", "Range", 9f, "Point light range in world units.");
		_lampIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Lamps", "Intensity", 3.5f, "Point light intensity at deep night.");
		_deckStringLightsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Lamps", "Colorful hanging string lights", true, "Adds point lights and visible halos to the original Tool Shop deck-light bulbs. Their colors travel smoothly through a rainbow at night.");
		_deckStringLightRange = ((BaseUnityPlugin)this).Config.Bind<float>("Lamps", "Hanging string light range", 2.4f, "2-12. Point-light range for each hanging bulb.");
		_deckStringLightIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Lamps", "Hanging string light intensity", 0.25f, "0-5. Brightness for each hanging bulb before the shared local-light budget is applied.");
		_deckStringColorCycleSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Lamps", "Hanging string color cycle seconds", 18f, "4-90. Seconds for the hanging bulbs to complete one smooth rainbow cycle.");
		_deskLampRange = ((BaseUnityPlugin)this).Config.Bind<float>("Lamps", "Desk lamp range", 3f, "1-8. Range of the dedicated player-desk and library-table lamp lights.");
		_deskLampIntensity = ((BaseUnityPlugin)t