Decompiled source of SandboxCustomizer v1.0.2

plugins/SandboxCustomizer.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using SandboxCustomizer.Info;
using SandboxCustomizer.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SandboxCustomizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SandboxCustomizer")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f4c914f1-16e3-4ece-a0b1-651235f769d5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SandboxCustomizer
{
	public class BetterUnblocker : MonoBehaviour
	{
		private TimeOfDayChanger main_changer = null;

		private UltrakillEvent events = null;

		public UnityEvent sanbox_switch_event = new UnityEvent();

		public void Start()
		{
			((MonoBehaviour)this).Invoke("OnEnable", 0.1f);
		}

		public void OnEnable()
		{
			ObjectActivator val = null;
			if (((Component)this).gameObject.TryGetComponent<ObjectActivator>(ref val))
			{
				((MonoBehaviour)val).CancelInvoke();
			}
			if (events == null)
			{
				events = val.events;
			}
		}

		public void Update()
		{
			if ((Object)(object)main_changer != (Object)null)
			{
				if (main_changer.allDone)
				{
					main_changer = null;
					if (events != null)
					{
						events.Invoke();
					}
				}
				return;
			}
			bool flag = false;
			Transform transform = GameObject.Find("Activators").transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				if (!((Component)transform.GetChild(i)).gameObject.activeSelf)
				{
					continue;
				}
				GameObject gameObject = ((Component)transform.GetChild(i)).gameObject;
				TimeOfDayChanger val = null;
				for (int j = 0; j < gameObject.transform.childCount; j++)
				{
					if (!((Component)gameObject.transform.GetChild(j)).TryGetComponent<TimeOfDayChanger>(ref val))
					{
						continue;
					}
					if (val.allDone)
					{
						val = null;
						continue;
					}
					main_changer = val;
					bool flag2 = false;
					flag = true;
					foreach (CustomSandbox sandbox in SandboxManager.sandboxs)
					{
						if ((Object)(object)sandbox.tod_changer == (Object)(object)val)
						{
							SandboxManager.sandbox_current = sandbox;
							if (sandbox.info.path != null)
							{
								((ConfigEntryBase)Plugin.load_on_start).SetSerializedValue(sandbox.info.path.Replace(Plugin.sandbox_folder_path + "\\", ""));
							}
							else
							{
								((ConfigEntryBase)Plugin.load_on_start).SetSerializedValue("Day");
							}
							flag2 = true;
							break;
						}
					}
					if (!flag2)
					{
						SandboxManager.sandbox_current = null;
						SandboxManager.activators_vanilla.TryGetValue(gameObject, out var value);
						if (value == null)
						{
							Debug.Log((object)"GUYS WE'RE LITERALLY GONNA #SAVETF2 THIS TIME GUYS!! #FIXTF2 GUYS!!!");
							SandboxManager.main_sandbox = null;
						}
						else
						{
							SandboxManager.main_sandbox = value;
							if (value != null)
							{
								((ConfigEntryBase)Plugin.load_on_start).SetSerializedValue(value);
							}
							else
							{
								((ConfigEntryBase)Plugin.load_on_start).SetSerializedValue("Day");
							}
						}
					}
					sanbox_switch_event.Invoke();
				}
			}
			if (!flag)
			{
				events.Invoke();
			}
		}
	}
	public static class CSBUtils
	{
		public static string version = "1.0.0";

		public static void CreateContainer(string name, string path)
		{
			if (!string.Equals(".csb", Path.GetExtension(path), StringComparison.OrdinalIgnoreCase))
			{
				Debug.Log((object)("Can't create field because \"" + path + "\" is not a csb"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			if (text.Contains("[" + name + "]"))
			{
				Debug.Log((object)("Field \"" + name + "\" with same name already exists"));
				return;
			}
			string text2 = "\n[" + name + "]\n{\n}";
			text += text2;
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static string CreateCSB(string name, string directory)
		{
			string text = Path.Combine(directory, name + ".csb");
			if (File.Exists(text))
			{
				Debug.Log((object)("File \"" + text + "\" already made"));
				return text;
			}
			StreamWriter streamWriter = new StreamWriter(text);
			streamWriter.Write("|" + version + "|");
			streamWriter.Close();
			return text;
		}

		public static List<string> GetFieldsInContainer(string file, int container_start)
		{
			List<string> list = new List<string>();
			string text = "";
			string text2 = "";
			bool flag = false;
			int num = container_start;
			int num2 = 0;
			int num3 = 1;
			int num4 = 0;
			while (num < file.Count())
			{
				if (file[num] == '{')
				{
					num3++;
				}
				if (file[num] == '}')
				{
					num3--;
				}
				if (num3 == 0)
				{
					break;
				}
				if (file[num] == '(')
				{
					num2++;
				}
				if (file[num] == ')')
				{
					num2--;
				}
				if (file[num] == '[')
				{
					num4++;
					if (num2 == 1)
					{
						flag = true;
						num++;
						continue;
					}
				}
				if (file[num] == ']')
				{
					num4--;
					if (num2 == 1)
					{
						flag = false;
						int result = 0;
						if (int.TryParse(text2, out result))
						{
							num2--;
							num3++;
							num += 3 + result;
							text2 = "";
							continue;
						}
					}
				}
				if (flag)
				{
					text2 += file[num];
				}
				num++;
			}
			text = file.Substring(container_start, num - container_start);
			list = text.Split(new char[1] { '\n' }).ToList();
			list.RemoveAt(0);
			list.RemoveAt(list.Count - 1);
			return list;
		}

		public static string RemoveFieldsInContainter(string file, int container_start)
		{
			List<string> list = new List<string>();
			string text = "";
			string text2 = "";
			bool flag = false;
			int num = container_start;
			int num2 = 0;
			int num3 = 1;
			int num4 = 0;
			while (num < file.Count())
			{
				if (file[num] == '{')
				{
					num3++;
				}
				if (file[num] == '}')
				{
					num3--;
				}
				if (num3 == 0)
				{
					break;
				}
				if (file[num] == '(')
				{
					num2++;
				}
				if (file[num] == ')')
				{
					num2--;
				}
				if (file[num] == '[')
				{
					num4++;
					if (num2 == 1)
					{
						flag = true;
						num++;
						continue;
					}
				}
				if (file[num] == ']')
				{
					num4--;
					if (num2 == 1)
					{
						flag = false;
						int result = 0;
						if (int.TryParse(text2, out result))
						{
							num2--;
							num3++;
							num += 3 + result;
							text2 = "";
							continue;
						}
					}
				}
				if (flag)
				{
					text2 += file[num];
				}
				num++;
			}
			return file.Remove(container_start, num - container_start);
		}

		public static void CreateColorField(string container_name, Color color, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			string item = "(color){" + color.r + "," + color.g + "," + color.b + "," + color.a + "}";
			fieldsInContainer.Add(item);
			string text3 = "";
			text3 += "\n";
			foreach (string item2 in fieldsInContainer)
			{
				text3 = text3 + item2 + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static Color GetColorField(string container_name, int index, string path)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			Color clear = Color.clear;
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return Color.clear;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return Color.clear;
			}
			int container_start = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, container_start);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return Color.clear;
			}
			if (!fieldsInContainer[index].Contains("(color"))
			{
				Debug.Log((object)("Color could not be found at field index: " + index));
				return Color.clear;
			}
			int num = fieldsInContainer[index].IndexOf("){") + "){".Length;
			string text3 = fieldsInContainer[index].Substring(num, fieldsInContainer[index].Length - 1 - num);
			List<string> list = new List<string>();
			list = text3.Split(new char[1] { ',' }).ToList();
			if (list.Count() > 2)
			{
				float[] array = new float[list.Count];
				for (int i = 0; i < list.Count; i++)
				{
					if (!float.TryParse(list[i], out array[i]))
					{
						Debug.Log((object)(container_name + ": " + index + " | Could not determine color value " + i));
						array[i] = 0f;
					}
				}
				clear.r = array[0];
				clear.g = array[1];
				clear.b = array[2];
				if (list.Count() > 3)
				{
					clear.a = array[3];
				}
				else
				{
					clear.a = 1f;
				}
				return clear;
			}
			Debug.Log((object)("Not enough values in color field " + container_name + ": " + index + " to determine color"));
			return Color.clear;
		}

		public static void SetColorField(string container_name, Color color, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return;
			}
			string value = "(color){" + color.r + "," + color.g + "," + color.b + "," + color.a + "}";
			fieldsInContainer[index] = value;
			string text3 = "";
			text3 += "\n";
			foreach (string item in fieldsInContainer)
			{
				text3 = text3 + item + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static void CreateFloatField(string container_name, float num, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num2 = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num2);
			text = RemoveFieldsInContainter(text, num2);
			string item = "(float){" + num + "}";
			fieldsInContainer.Add(item);
			string text3 = "";
			text3 += "\n";
			foreach (string item2 in fieldsInContainer)
			{
				text3 = text3 + item2 + "\n";
			}
			text = text.Insert(num2, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static float GetFloatField(string container_name, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return 0f;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return 0f;
			}
			int container_start = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, container_start);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return 0f;
			}
			if (!fieldsInContainer[index].Contains("(float)"))
			{
				Debug.Log((object)("Float could not be found at field index: " + index));
				return 0f;
			}
			int num = fieldsInContainer[index].IndexOf("){") + "){".Length;
			string s = fieldsInContainer[index].Substring(num, fieldsInContainer[index].Length - 1 - num);
			if (!float.TryParse(s, out var result))
			{
				Debug.Log((object)(container_name + ": " + index + " | Could not determine float value"));
				return 0f;
			}
			return result;
		}

		public static void SetFloatField(string container_name, float num, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num2 = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num2);
			text = RemoveFieldsInContainter(text, num2);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return;
			}
			string value = "(float){" + num + "}";
			fieldsInContainer[index] = value;
			string text3 = "";
			text3 += "\n";
			foreach (string item in fieldsInContainer)
			{
				text3 = text3 + item + "\n";
			}
			text = text.Insert(num2, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static void CreateBoolField(string container_name, bool value, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			string item = "(bool){" + value + "}";
			fieldsInContainer.Add(item);
			string text3 = "";
			text3 += "\n";
			foreach (string item2 in fieldsInContainer)
			{
				text3 = text3 + item2 + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static bool GetBoolField(string container_name, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return false;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return false;
			}
			int container_start = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, container_start);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return false;
			}
			if (!fieldsInContainer[index].Contains("(bool"))
			{
				Debug.Log((object)("Bool could not be found at field index: " + index));
				return false;
			}
			int num = fieldsInContainer[index].IndexOf("){") + "){".Length;
			string value = fieldsInContainer[index].Substring(num, fieldsInContainer[index].Length - 1 - num);
			if (!bool.TryParse(value, out var result))
			{
				Debug.Log((object)(container_name + ": " + index + " | Could not determine boolean value"));
				return false;
			}
			return result;
		}

		public static void SetBoolField(string container_name, bool value, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return;
			}
			string value2 = "(bool){" + value + "}";
			fieldsInContainer[index] = value2;
			string text3 = "";
			text3 += "\n";
			foreach (string item in fieldsInContainer)
			{
				text3 = text3 + item + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static void CreateBase64Field(string container_name, string data, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			string item = "(base64[" + data.Length + "]){" + data + "}";
			fieldsInContainer.Add(item);
			string text3 = "";
			text3 += "\n";
			foreach (string item2 in fieldsInContainer)
			{
				text3 = text3 + item2 + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static string GetBase64Field(string container_name, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return "";
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return "";
			}
			int container_start = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, container_start);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return "";
			}
			if (!fieldsInContainer[index].Contains("(base64"))
			{
				Debug.Log((object)("Base64 could not be found at field index: " + index));
				return "";
			}
			int num = fieldsInContainer[index].IndexOf("){") + "){".Length;
			return fieldsInContainer[index].Substring(num, fieldsInContainer[index].Length - 1 - num);
		}

		public static void SetBase64Field(string container_name, string data, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return;
			}
			string value = "(base64[" + data.Length + "]){" + data + "}";
			fieldsInContainer[index] = value;
			string text3 = "";
			text3 += "\n";
			foreach (string item in fieldsInContainer)
			{
				text3 = text3 + item + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static void CreateStringField(string container_name, string str, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			string item = "(string){" + str + "}";
			fieldsInContainer.Add(item);
			string text3 = "";
			text3 += "\n";
			foreach (string item2 in fieldsInContainer)
			{
				text3 = text3 + item2 + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}

		public static string GetStringField(string container_name, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return "";
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return "";
			}
			int container_start = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, container_start);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return "";
			}
			if (!fieldsInContainer[index].Contains("(string"))
			{
				Debug.Log((object)("String could not be found at field index: " + index));
				return "";
			}
			int num = fieldsInContainer[index].IndexOf("){") + "){".Length;
			return fieldsInContainer[index].Substring(num, fieldsInContainer[index].Length - 1 - num);
		}

		public static void SetStringField(string container_name, string str, int index, string path)
		{
			if (!File.Exists(path))
			{
				Debug.Log((object)("File \"" + path + "\" is not found"));
				return;
			}
			StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			streamReader.Close();
			string text2 = "[" + container_name + "]\n{";
			if (!text.Contains(text2))
			{
				Debug.Log((object)("Container " + container_name + " is not found"));
				return;
			}
			int num = text.IndexOf(text2) + text2.Length;
			List<string> fieldsInContainer = GetFieldsInContainer(text, num);
			text = RemoveFieldsInContainter(text, num);
			if (index >= fieldsInContainer.Count || index < 0)
			{
				Debug.Log((object)"Field index out of range");
				return;
			}
			string value = "(string){" + str + "}";
			fieldsInContainer[index] = value;
			string text3 = "";
			text3 += "\n";
			foreach (string item in fieldsInContainer)
			{
				text3 = text3 + item + "\n";
			}
			text = text.Insert(num, text3);
			StreamWriter streamWriter = new StreamWriter(path);
			streamWriter.Write(text);
			streamWriter.Close();
		}
	}
	public class CustomSandbox
	{
		public static GameObject base_indoors;

		public static GameObject base_outdoors;

		public static GameObject base_activator;

		public Material skybox_mat;

		public GameObject custom_indoors;

		public GameObject custom_outdoors;

		public GameObject custom_activator;

		public TimeOfDayChanger tod_changer;

		public ObjectActivator obj_activator;

		public UltrakillEvent uk_event;

		public List<Light> new_lights = new List<Light>();

		public List<Light> indoor_lights = new List<Light>();

		public List<Light> outdoor_lights = new List<Light>();

		public List<MeshRenderer> godrays = new List<MeshRenderer>();

		public SandboxInfo info = new SandboxInfo();

		public bool in_scene = false;

		public static void MakeBaseSandbox()
		{
			GameObject gameObject = ((Component)GameObject.Find("IndoorsLighting").transform.Find("Day")).gameObject;
			GameObject gameObject2 = ((Component)GameObject.Find("OutdoorsLighting").transform.Find("Day")).gameObject;
			GameObject gameObject3 = ((Component)GameObject.Find("Activators").transform.Find("Day Activator")).gameObject;
			base_indoors = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
			((Object)base_indoors).name = "Base (Indoors)";
			base_indoors.SetActive(false);
			base_outdoors = Object.Instantiate<GameObject>(gameObject2, gameObject2.transform.parent);
			((Object)base_outdoors).name = "Base (Outdoors)";
			base_outdoors.SetActive(false);
			base_activator = Object.Instantiate<GameObject>(gameObject3, gameObject3.transform.parent);
			((Object)base_activator).name = "Base Activator";
			base_activator.SetActive(false);
		}

		public void AddToScene()
		{
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			if (in_scene)
			{
				return;
			}
			GameObject gameObject = ((Component)GameObject.Find("IndoorsLighting").transform.Find("Day")).gameObject;
			GameObject gameObject2 = ((Component)GameObject.Find("OutdoorsLighting").transform.Find("Day")).gameObject;
			GameObject gameObject3 = ((Component)GameObject.Find("Activators").transform.Find("Day Activator")).gameObject;
			custom_indoors = Object.Instantiate<GameObject>(base_indoors, base_indoors.transform.parent);
			((Object)custom_indoors).name = "Custom (Indoors)";
			custom_outdoors = Object.Instantiate<GameObject>(base_outdoors, base_outdoors.transform.parent);
			((Object)custom_outdoors).name = "Custom (Outdoors)";
			custom_activator = Object.Instantiate<GameObject>(base_activator, base_activator.transform.parent);
			((Object)custom_activator).name = "Custom Activator";
			tod_changer = custom_activator.GetComponentInChildren<TimeOfDayChanger>();
			skybox_mat = new Material(tod_changer.newSkybox);
			if (info.skybox == null)
			{
				info.skybox = new SkyboxInfo();
				info.skybox.texture = (Texture2D)base_activator.GetComponentInChildren<TimeOfDayChanger>().newSkybox.mainTexture;
				info.skybox.name = null;
				skybox_mat.mainTexture = (Texture)(object)info.skybox.texture;
			}
			else
			{
				skybox_mat.mainTexture = (Texture)(object)info.skybox.texture;
			}
			tod_changer.newSkybox = skybox_mat;
			obj_activator = custom_activator.GetComponent<ObjectActivator>();
			uk_event = obj_activator.events;
			uk_event.toActivateObjects = (GameObject[])(object)new GameObject[2] { custom_indoors, custom_outdoors };
			Light[] componentsInChildren = custom_indoors.GetComponentsInChildren<Light>();
			if (info.indoor_lights != null)
			{
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					indoor_lights.Add(componentsInChildren[i]);
					componentsInChildren[i].color = info.indoor_lights[i].color;
				}
			}
			else
			{
				info.indoor_lights = new List<LightInfo>();
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					indoor_lights.Add(componentsInChildren[j]);
					LightInfo lightInfo = new LightInfo();
					lightInfo.color = componentsInChildren[j].color;
					info.indoor_lights.Add(lightInfo);
				}
			}
			Light[] componentsInChildren2 = custom_outdoors.GetComponentsInChildren<Light>();
			if (info.outdoor_lights != null)
			{
				for (int k = 0; k < componentsInChildren2.Length; k++)
				{
					outdoor_lights.Add(componentsInChildren2[k]);
					componentsInChildren2[k].color = info.outdoor_lights[k].color;
				}
			}
			else
			{
				info.outdoor_lights = new List<LightInfo>();
				for (int l = 0; l < componentsInChildren2.Length; l++)
				{
					outdoor_lights.Add(componentsInChildren2[l]);
					LightInfo lightInfo2 = new LightInfo();
					lightInfo2.color = componentsInChildren2[l].color;
					info.outdoor_lights.Add(lightInfo2);
				}
			}
			MeshRenderer[] componentsInChildren3 = custom_indoors.GetComponentsInChildren<MeshRenderer>();
			if (info.godrays != null)
			{
				for (int m = 0; m < componentsInChildren3.Length; m++)
				{
					godrays.Add(componentsInChildren3[m]);
					((Renderer)componentsInChildren3[m]).material.color = info.godrays[m].color;
				}
			}
			else
			{
				info.godrays = new List<GodrayInfo>();
				for (int n = 0; n < componentsInChildren3.Length; n++)
				{
					godrays.Add(componentsInChildren3[n]);
					GodrayInfo godrayInfo = new GodrayInfo();
					godrayInfo.color = ((Renderer)componentsInChildren3[n]).material.color;
					info.godrays.Add(godrayInfo);
				}
			}
			if (info.fog != null)
			{
				tod_changer.fogColor = info.fog.color;
				if (info.fog.enabled)
				{
					tod_changer.fogStart = info.fog.start;
					tod_changer.fogEnd = info.fog.end;
				}
				else
				{
					tod_changer.fogStart = 1E+21f;
					tod_changer.fogEnd = 1E+20f;
				}
			}
			else
			{
				info.fog = new FogInfo();
				info.fog.color = tod_changer.fogColor;
				info.fog.start = tod_changer.fogStart;
				info.fog.end = tod_changer.fogEnd;
				info.fog.enabled = true;
			}
			Light[] componentsInChildren4 = custom_outdoors.GetComponentsInChildren<Light>();
			foreach (Light item in componentsInChildren4)
			{
				new_lights.Add(item);
			}
			tod_changer.newLights = new_lights.ToArray();
			UpdateEffects();
			in_scene = true;
		}

		public void RemoveFromScene()
		{
			if (in_scene)
			{
				Object.Destroy((Object)(object)custom_indoors);
				Object.Destroy((Object)(object)custom_outdoors);
				Object.Destroy((Object)(object)custom_activator);
				tod_changer = null;
				obj_activator = null;
				uk_event = null;
				in_scene = false;
				indoor_lights.Clear();
				outdoor_lights.Clear();
				godrays.Clear();
			}
		}

		public void Clear()
		{
			RemoveFromScene();
			tod_changer = null;
			obj_activator = null;
			uk_event = null;
			in_scene = false;
		}

		public void LoadSkyboxFromPath(string path)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			if (!File.Exists(path))
			{
				Debug.Log((object)("Error when trying to load skybox from path: " + path));
				return;
			}
			byte[] array = File.ReadAllBytes(path);
			if (info.skybox == null)
			{
				info.skybox = new SkyboxInfo();
			}
			info.skybox.texture = new Texture2D(0, 0, (TextureFormat)4, false);
			((Texture)info.skybox.texture).filterMode = (FilterMode)0;
			ImageConversion.LoadImage(info.skybox.texture, array);
			if ((Object)(object)skybox_mat != (Object)null)
			{
				skybox_mat.mainTexture = (Texture)(object)info.skybox.texture;
			}
		}

		public void LoadSkyboxFromData(byte[] data)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			Texture2D val = new Texture2D(0, 0, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, data))
			{
				Debug.Log((object)"Error when trying to load sandbox from data");
				return;
			}
			if (info.skybox == null)
			{
				info.skybox = new SkyboxInfo();
			}
			info.skybox.texture = val;
			((Texture)info.skybox.texture).filterMode = (FilterMode)0;
			if ((Object)(object)skybox_mat != (Object)null)
			{
				skybox_mat.mainTexture = (Texture)(object)info.skybox.texture;
			}
		}

		public void LoadSkyboxFromURL(string url)
		{
			UnityWebRequest request = UnityWebRequestTexture.GetTexture(url);
			((AsyncOperation)request.SendWebRequest()).completed += delegate
			{
				try
				{
					if (!request.isNetworkError && !request.isHttpError)
					{
						if (info.skybox == null)
						{
							info.skybox = new SkyboxInfo();
						}
						info.skybox.texture = DownloadHandlerTexture.GetContent(request);
						if ((Object)(object)skybox_mat != (Object)null)
						{
							skybox_mat.mainTexture = (Texture)(object)info.skybox.texture;
						}
					}
					else
					{
						Debug.Log((object)("Error when trying to load skybox from path/url: " + url));
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
				finally
				{
					request.Dispose();
				}
			};
		}

		public void UpdateEffects()
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)custom_indoors != (Object)null)
			{
				for (int i = 0; i < indoor_lights.Count; i++)
				{
					indoor_lights[i].color = info.indoor_lights[i].color;
				}
			}
			if ((Object)(object)custom_outdoors != (Object)null)
			{
				for (int j = 0; j < outdoor_lights.Count; j++)
				{
					outdoor_lights[j].color = info.outdoor_lights[j].color;
				}
			}
			if ((Object)(object)custom_indoors != (Object)null)
			{
				for (int k = 0; k < godrays.Count; k++)
				{
					((Renderer)godrays[k]).material.color = info.godrays[k].color;
				}
			}
			tod_changer.fogColor = info.fog.color;
			if (info.fog.enabled)
			{
				tod_changer.fogStart = info.fog.start;
				tod_changer.fogEnd = info.fog.end;
			}
			else
			{
				tod_changer.fogStart = 1E+25f;
				tod_changer.fogEnd = 1E+26f;
			}
			new_lights.Clear();
			Light[] componentsInChildren = custom_outdoors.GetComponentsInChildren<Light>();
			foreach (Light item in componentsInChildren)
			{
				new_lights.Add(item);
			}
			tod_changer.newLights = new_lights.ToArray();
		}
	}
	[BepInPlugin("ironfarm.uk.sandboxcustom", "SandboxCustomizer", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private bool sandbox_loaded = false;

		private GameObject indoor_light_object = null;

		private GameObject outdoor_light_object = null;

		private Transform day_indoors = null;

		private Transform day_outdoors = null;

		public static List<CustomSandbox> sbs = new List<CustomSandbox>();

		private List<string> tex_path = new List<string>();

		public static string united_kingdom_path = Path.GetFullPath(Path.Combine(Application.dataPath, "..\\"));

		public static List<string> cg_skybox_paths = new List<string> { "Cybergrind\\Textures\\Skyboxes", "Cybergrind\\Textures\\Starbuster\\Skyboxes", "Cybergrind\\Textures\\Vvizard\\Skyboxes" };

		public static string data_folder_path = Path.Combine(Utils.ModDir(), "Data");

		public static string sandbox_folder_path = Path.Combine(Utils.ModDir(), "Sandboxes");

		public static string skybox_folder_path = Path.Combine(Utils.ModDir(), "Skyboxes");

		public static ConfigEntry<string> load_on_start;

		public static ConfigEntry<bool> remeber_last_sandbox;

		public static ConfigEntry<bool> auto_save_sandbox;

		public static ConfigEntry<float> tod_speed;

		public void Start()
		{
			AssetHandler.LoadBundle();
			AssetHandler.MakePrefabs();
			WhyDoesGettingAddressableNamesAtRuntimeHaveToBeSoHard.GetAddressKeys();
			Debug.Log((object)Application.dataPath);
			Debug.Log((object)Application.persistentDataPath);
			Debug.Log((object)"Lololo");
			load_on_start = ((BaseUnityPlugin)this).Config.Bind<string>("Sandbox", "Load_Sandbox_On_Start", "Day", (ConfigDescription)null);
			remeber_last_sandbox = ((BaseUnityPlugin)this).Config.Bind<bool>("Sandbox", "Remember_Last_Sandbox", true, (ConfigDescription)null);
			auto_save_sandbox = ((BaseUnityPlugin)this).Config.Bind<bool>("Sandbox", "Auto_Save_Sandbox", false, (ConfigDescription)null);
			tod_speed = ((BaseUnityPlugin)this).Config.Bind<float>("Sandbox", "Sandbox_Transition_Speed", 1f, (ConfigDescription)null);
			foreach (string item in Directory.EnumerateFiles(skybox_folder_path))
			{
				for (int i = 0; i < Utils.image_types.Count; i++)
				{
					if (string.Equals(Utils.image_types[i], Path.GetExtension(item), StringComparison.OrdinalIgnoreCase))
					{
						tex_path.Add(item);
						SandboxManager.tex_path.Add(item);
					}
				}
			}
			Debug.Log((object)"We did it reddit");
			SceneManager.sceneLoaded += SandboxLoadCheck;
			SceneManager.sceneUnloaded += SandboxUnloadCheck;
		}

		public void SandboxLoadCheck(Scene scene, LoadSceneMode sceneMode)
		{
			if (!(SceneHelper.CurrentScene == "uk_construct"))
			{
				return;
			}
			Debug.Log((object)"Custom Sandbox has Loaded");
			sandbox_loaded = true;
			CustomSandbox.MakeBaseSandbox();
			SandboxManager.Clear();
			SandboxManager.Setup();
			foreach (string item in Directory.EnumerateFiles(sandbox_folder_path))
			{
				if (string.Equals(".csb", Path.GetExtension(item), StringComparison.OrdinalIgnoreCase))
				{
					CustomSandbox customSandbox = new CustomSandbox();
					customSandbox.info = SandboxInfo.LoadInfo(item);
					if (customSandbox.info != null)
					{
						SandboxManager.AddSandbox(customSandbox);
					}
				}
			}
			SandboxManager.global_tod_speed = tod_speed.Value;
			SandboxManager.UpdateTODs();
			if (remeber_last_sandbox.Value)
			{
				GameObject value = null;
				if (!SandboxManager.vanilla_activators.TryGetValue(load_on_start.Value, out value))
				{
					foreach (CustomSandbox sandbox in SandboxManager.sandboxs)
					{
						if (sandbox.info.path == Path.Combine(sandbox_folder_path, load_on_start.Value))
						{
							SandboxManager.HardForceSandbox(sandbox);
							break;
						}
					}
					return;
				}
				SandboxManager.HardForceBaseSandbox(load_on_start.Value);
				SandboxManager.main_sandbox = load_on_start.Value;
			}
			else
			{
				((ConfigEntryBase)load_on_start).SetSerializedValue("Day");
			}
		}

		public void SandboxUnloadCheck(Scene scene)
		{
			if (SceneHelper.CurrentScene != "uk_construct" && sandbox_loaded)
			{
				Debug.Log((object)"Sandbox has Unloaded.");
				SandboxManager.Clear();
				sandbox_loaded = false;
			}
		}

		public void Update()
		{
			if (!sandbox_loaded)
			{
			}
		}
	}
	internal class PluginInfo
	{
		public const string Name = "SandboxCustomizer";

		public const string GUID = "ironfarm.uk.sandboxcustom";

		public const string Version = "1.0.2";
	}
	public class PointerAdder : MonoBehaviour
	{
		private ControllerPointer pointer;

		public List<UnityAction> on_pressed_actions = new List<UnityAction>();

		private void Awake()
		{
			if (!((Component)this).TryGetComponent<ControllerPointer>(ref pointer))
			{
				pointer = ((Component)this).gameObject.AddComponent<ControllerPointer>();
			}
			foreach (UnityAction on_pressed_action in on_pressed_actions)
			{
				pointer.OnPressed.AddListener(on_pressed_action);
			}
		}
	}
	public static class SandboxManager
	{
		private enum TODB
		{
			Left,
			Right,
			Add,
			Delete,
			Edit,
			Settings
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__27_0;

			public static UnityAction <>9__27_1;

			public static UnityAction <>9__27_2;

			public static UnityAction <>9__27_3;

			public static UnityAction <>9__27_4;

			public static UnityAction <>9__27_5;

			public static UnityAction <>9__39_0;

			internal void <Setup>b__27_0()
			{
				if (tod_grid_index > 0)
				{
					tod_grid_index--;
				}
				UpdateGrid();
				Debug.Log((object)tod_grid_index);
			}

			internal void <Setup>b__27_1()
			{
				if (tod_grid_index < tod_grid_list.Count - 1)
				{
					tod_grid_index++;
				}
				UpdateGrid();
				Debug.Log((object)tod_grid_index);
			}

			internal void <Setup>b__27_2()
			{
				CustomSandbox customSandbox = new CustomSandbox();
				AddSandbox(customSandbox);
				if (tex_path.Count > 0)
				{
					string text = tex_path[Random.Range(0, tex_path.Count)];
					customSandbox.LoadSkyboxFromPath(text);
					customSandbox.info.skybox.name = text.Replace(Plugin.skybox_folder_path + "\\", "");
					customSandbox.info.skybox.name = customSandbox.info.skybox.name.Replace("PutSkyboxHere\\", "");
					CSBUtils.SetStringField("Skybox", customSandbox.info.skybox.name, 0, customSandbox.info.path);
				}
				UpdateGrid();
				Debug.Log((object)"Added sandbox");
			}

			internal void <Setup>b__27_3()
			{
				DeleteSandbox(sandbox_current);
				UpdateGrid();
				Debug.Log((object)"Removed sandbox");
			}

			internal void <Setup>b__27_4()
			{
				edit_panel.UpdateName();
				edit_panel.gameObject.SetActive(true);
				tod_panel.SetActive(false);
			}

			internal void <Setup>b__27_5()
			{
				settings_panel.remember_enabled = Plugin.remeber_last_sandbox.Value;
				settings_panel.auto_save_enabled = Plugin.auto_save_sandbox.Value;
				settings_panel.tod_slider.value = global_tod_speed;
				settings_panel.tod_speed_value.text = settings_panel.tod_slider.value.ToString("0.00");
				settings_panel.button_auto_save_img.SetActive(settings_panel.auto_save_enabled);
				settings_panel.button_remember_img.SetActive(settings_panel.remember_enabled);
				settings_panel.gameObject.SetActive(true);
				tod_panel.SetActive(false);
			}

			internal void <HardForceBaseSandbox>b__39_0()
			{
				RevertToDSpeedOnUnblock(target_base_tod);
			}
		}

		private static GameObject tod_grid;

		private static GameObject tod_changer;

		public static GameObject tod_panel;

		public static GameObject blocker;

		public static GameObject unblocker;

		public static float global_tod_speed = 1f;

		public static List<GameObject> tod_grid_list = new List<GameObject>();

		public static int tod_grid_index = 0;

		private static List<GameObject> tod_buttons = new List<GameObject>();

		private static int tod_button_total = 8;

		public static List<CustomSandbox> sandboxs = new List<CustomSandbox>();

		public static List<string> tex_path = new List<string>();

		public static GameObject base_tod_button;

		public static EditPanel edit_panel = new EditPanel();

		public static SettingsPanel settings_panel = new SettingsPanel();

		public static CustomSandbox sandbox_current = null;

		public static string main_sandbox = null;

		public static LightColorSlider cob = new LightColorSlider();

		private static bool is_setup = false;

		private static int todb_count = 6;

		public static GameObject[] shop_button_mover = (GameObject[])(object)new GameObject[todb_count];

		public static UnityEvent on_blocked_event = new UnityEvent();

		public static UnityEvent on_unblock_event = new UnityEvent();

		public static CustomSandbox dead_sandbox = new CustomSandbox();

		public static Dictionary<string, GameObject> vanilla_activators = new Dictionary<string, GameObject>();

		public static Dictionary<GameObject, string> activators_vanilla = new Dictionary<GameObject, string>();

		public static CustomSandbox backup_sandbox = null;

		public static GameObject target_activator;

		public static TimeOfDayChanger target_base_tod;

		private static bool load_sandboxes = false;

		public static void Setup()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected O, but got Unknown
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Expected O, but got Unknown
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Expected O, but got Unknown
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Expected O, but got Unknown
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Expected O, but got Unknown
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Expected O, but got Unknown
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Expected O, but got Unknown
			if (is_setup)
			{
				return;
			}
			Utils.InitUIObjets();
			is_setup = true;
			tod_buttons = new List<GameObject>();
			sandboxs = new List<CustomSandbox>();
			on_blocked_event = new UnityEvent();
			on_unblock_event = new UnityEvent();
			dead_sandbox = new CustomSandbox();
			tod_changer = GameObject.Find("Sandbox Shop/Canvas/Border/TOD Changer");
			tod_panel = GameObject.Find("Sandbox Shop/Canvas/Border/TOD Changer/Panel");
			tod_grid = GameObject.Find("Sandbox Shop/Canvas/Border/TOD Changer/Panel/TOD Grid");
			blocker = GameObject.Find("Sandbox Shop/Canvas/Border/TOD Changer/Panel/Blocker");
			unblocker = blocker.GetComponent<ObjectActivator>().events.toActivateObjects[0];
			unblocker.AddComponent<BetterUnblocker>();
			vanilla_activators.Add("Dawn", ((Component)GameObject.Find("Activators").transform.Find("Dawn Activator")).gameObject);
			vanilla_activators.Add("Day", ((Component)GameObject.Find("Activators").transform.Find("Day Activator")).gameObject);
			vanilla_activators.Add("Dusk", ((Component)GameObject.Find("Activators").transform.Find("Dusk Activator")).gameObject);
			vanilla_activators.Add("Night", ((Component)GameObject.Find("Activators").transform.Find("Night Activator")).gameObject);
			vanilla_activators.Add("Night Darker", ((Component)GameObject.Find("Activators").transform.Find("Night Darker Activator")).gameObject);
			vanilla_activators.Add("Lust", ((Component)GameObject.Find("Activators").transform.Find("Lust Activator")).gameObject);
			vanilla_activators.Add("Greed", ((Component)GameObject.Find("Activators").transform.Find("Greed Activator")).gameObject);
			vanilla_activators.Add("Foggy", ((Component)GameObject.Find("Activators").transform.Find("Foggy Activator")).gameObject);
			foreach (KeyValuePair<string, GameObject> vanilla_activator in vanilla_activators)
			{
				activators_vanilla.Add(vanilla_activator.Value, vanilla_activator.Key);
			}
			base_tod_button = ((Component)Object.Instantiate<Transform>(tod_grid.transform.Find("Day"), tod_grid.transform)).gameObject;
			((Object)base_tod_button).name = "Base (Button)";
			base_tod_button.SetActive(false);
			blocker.GetComponent<ObjectActivator>().events.onActivate.AddListener(new UnityAction(onBlocked));
			unblocker.GetComponent<ObjectActivator>().events.onActivate.AddListener(new UnityAction(onUnblock));
			shop_button_mover[0] = Utils.CloneButtonForShop(AssetHandler.LoadAsset<GameObject>("button left"), tod_panel.transform);
			shop_button_mover[1] = Utils.CloneButtonForShop(AssetHandler.LoadAsset<GameObject>("button right"), tod_panel.transform);
			shop_button_mover[2] = Utils.CloneButtonForShop(AssetHandler.LoadAsset<GameObject>("button add"), tod_panel.transform);
			shop_button_mover[3] = Utils.CloneButtonForShop(AssetHandler.LoadAsset<GameObject>("button delete"), tod_panel.transform);
			shop_button_mover[4] = Utils.CloneButtonForShop(AssetHandler.LoadAsset<GameObject>("button edit"), tod_panel.transform);
			shop_button_mover[5] = Utils.CloneButtonForShop(AssetHandler.LoadAsset<GameObject>("button settings"), tod_panel.transform);
			edit_panel.Create(tod_changer.transform);
			edit_panel.gameObject.SetActive(false);
			settings_panel.Create(tod_changer.transform);
			settings_panel.gameObject.SetActive(false);
			tod_grid_list.Add(tod_grid);
			UpdateGrid();
			UpdateTODs();
			List<UnityAction> on_pressed_actions = shop_button_mover[0].GetComponent<PointerAdder>().on_pressed_actions;
			object obj = <>c.<>9__27_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					if (tod_grid_index > 0)
					{
						tod_grid_index--;
					}
					UpdateGrid();
					Debug.Log((object)tod_grid_index);
				};
				<>c.<>9__27_0 = val;
				obj = (object)val;
			}
			on_pressed_actions.Add((UnityAction)obj);
			List<UnityAction> on_pressed_actions2 = shop_button_mover[1].GetComponent<PointerAdder>().on_pressed_actions;
			object obj2 = <>c.<>9__27_1;
			if (obj2 == null)
			{
				UnityAction val2 = delegate
				{
					if (tod_grid_index < tod_grid_list.Count - 1)
					{
						tod_grid_index++;
					}
					UpdateGrid();
					Debug.Log((object)tod_grid_index);
				};
				<>c.<>9__27_1 = val2;
				obj2 = (object)val2;
			}
			on_pressed_actions2.Add((UnityAction)obj2);
			List<UnityAction> on_pressed_actions3 = shop_button_mover[2].GetComponent<PointerAdder>().on_pressed_actions;
			object obj3 = <>c.<>9__27_2;
			if (obj3 == null)
			{
				UnityAction val3 = delegate
				{
					CustomSandbox customSandbox = new CustomSandbox();
					AddSandbox(customSandbox);
					if (tex_path.Count > 0)
					{
						string text = tex_path[Random.Range(0, tex_path.Count)];
						customSandbox.LoadSkyboxFromPath(text);
						customSandbox.info.skybox.name = text.Replace(Plugin.skybox_folder_path + "\\", "");
						customSandbox.info.skybox.name = customSandbox.info.skybox.name.Replace("PutSkyboxHere\\", "");
						CSBUtils.SetStringField("Skybox", customSandbox.info.skybox.name, 0, customSandbox.info.path);
					}
					UpdateGrid();
					Debug.Log((object)"Added sandbox");
				};
				<>c.<>9__27_2 = val3;
				obj3 = (object)val3;
			}
			on_pressed_actions3.Add((UnityAction)obj3);
			List<UnityAction> on_pressed_actions4 = shop_button_mover[3].GetComponent<PointerAdder>().on_pressed_actions;
			object obj4 = <>c.<>9__27_3;
			if (obj4 == null)
			{
				UnityAction val4 = delegate
				{
					DeleteSandbox(sandbox_current);
					UpdateGrid();
					Debug.Log((object)"Removed sandbox");
				};
				<>c.<>9__27_3 = val4;
				obj4 = (object)val4;
			}
			on_pressed_actions4.Add((UnityAction)obj4);
			List<UnityAction> on_pressed_actions5 = shop_button_mover[4].GetComponent<PointerAdder>().on_pressed_actions;
			object obj5 = <>c.<>9__27_4;
			if (obj5 == null)
			{
				UnityAction val5 = delegate
				{
					edit_panel.UpdateName();
					edit_panel.gameObject.SetActive(true);
					tod_panel.SetActive(false);
				};
				<>c.<>9__27_4 = val5;
				obj5 = (object)val5;
			}
			on_pressed_actions5.Add((UnityAction)obj5);
			List<UnityAction> on_pressed_actions6 = shop_button_mover[5].GetComponent<PointerAdder>().on_pressed_actions;
			object obj6 = <>c.<>9__27_5;
			if (obj6 == null)
			{
				UnityAction val6 = delegate
				{
					settings_panel.remember_enabled = Plugin.remeber_last_sandbox.Value;
					settings_panel.auto_save_enabled = Plugin.auto_save_sandbox.Value;
					settings_panel.tod_slider.value = global_tod_speed;
					settings_panel.tod_speed_value.text = settings_panel.tod_slider.value.ToString("0.00");
					settings_panel.button_auto_save_img.SetActive(settings_panel.auto_save_enabled);
					settings_panel.button_remember_img.SetActive(settings_panel.remember_enabled);
					settings_panel.gameObject.SetActive(true);
					tod_panel.SetActive(false);
				};
				<>c.<>9__27_5 = val6;
				obj6 = (object)val6;
			}
			on_pressed_actions6.Add((UnityAction)obj6);
		}

		public static void AddSandbox(CustomSandbox sandbox)
		{
			tod_button_total++;
			if (8 * tod_grid_list.Count() < tod_button_total)
			{
				GameObject val = Object.Instantiate<GameObject>(tod_grid, tod_grid.transform.parent);
				int childCount = val.transform.childCount;
				for (int i = 0; i < childCount; i++)
				{
					Object.Destroy((Object)(object)((Component)val.transform.GetChild(i)).gameObject);
				}
				tod_grid_list.Add(val);
				UpdateGrid();
			}
			sandbox.AddToScene();
			sandbox.tod_changer.speedMultiplier = global_tod_speed;
			sandboxs.Add(sandbox);
			GameObject gameObject = Object.Instantiate<GameObject>(base_tod_button, tod_grid_list[tod_grid_list.Count() - 1].transform).gameObject;
			gameObject.SetActive(true);
			((Object)gameObject).name = "Custom (Button)";
			gameObject.GetComponent<ShopButton>().toActivate[0] = sandbox.custom_activator;
			tod_buttons.Add(gameObject);
			UpdateDisableList();
			SandboxInfo.SaveInfo(sandbox.info);
			if (!Plugin.sbs.Contains(sandbox))
			{
				Plugin.sbs.Add(sandbox);
			}
		}

		public static void MakeDeadSandbox()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			dead_sandbox.AddToScene();
			for (int i = 0; i < dead_sandbox.info.outdoor_lights.Count; i++)
			{
				dead_sandbox.info.outdoor_lights[i].color = Color.black;
			}
			for (int j = 0; j < dead_sandbox.info.indoor_lights.Count; j++)
			{
				dead_sandbox.info.indoor_lights[j].color = Color.black;
			}
			dead_sandbox.skybox_mat.SetColor("_Tint", Color.black);
			dead_sandbox.UpdateEffects();
			UpdateDisableList();
		}

		public static void DeleteSandbox(CustomSandbox sandbox, bool delete_save = true)
		{
			if (!sandboxs.Contains(sandbox))
			{
				Debug.Log((object)"Sandbox being deleted is not in list");
				return;
			}
			if (File.Exists(sandbox.info.path) && delete_save)
			{
				File.Delete(sandbox.info.path);
			}
			int num = sandboxs.IndexOf(sandbox);
			bool flag = false;
			if (sandbox == sandbox_current)
			{
				flag = true;
			}
			if (flag)
			{
				if (num < sandboxs.Count - 1)
				{
					ForceSandbox(sandboxs[num + 1]);
				}
				else if (num > 0)
				{
					ForceSandbox(sandboxs[num - 1]);
				}
				else
				{
					((Component)GameObject.Find("Activators").transform.Find("Day Activator")).gameObject.SetActive(true);
					blocker.SetActive(true);
					sandbox_current = null;
				}
			}
			int num2 = num / 8 + 1;
			tod_button_total--;
			Object.Destroy((Object)(object)tod_buttons[num]);
			tod_buttons.RemoveAt(num);
			if (num2 < tod_grid_list.Count - 1)
			{
				for (int i = num2; i < tod_grid_list.Count - 1; i++)
				{
					GameObject gameObject = ((Component)tod_grid_list[i + 1].transform.GetChild(0)).gameObject;
					gameObject.transform.SetParent(tod_grid_list[i].transform);
				}
				if (tod_grid_list[tod_grid_list.Count - 1].transform.childCount == 0)
				{
					Object.Destroy((Object)(object)tod_grid_list[tod_grid_list.Count - 1]);
					tod_grid_list.RemoveAt(tod_grid_list.Count - 1);
				}
			}
			else if (tod_button_total % 8 == 0)
			{
				Object.Destroy((Object)(object)tod_grid_list[num2]);
				tod_grid_list.RemoveAt(num2);
				if (num2 == tod_grid_index)
				{
					tod_grid_index--;
				}
			}
			UpdateGrid();
			UpdateDisableList();
			if (Plugin.sbs.Contains(sandbox))
			{
				Plugin.sbs.Remove(sandbox);
			}
			if (flag)
			{
				sandbox.RemoveFromScene();
				sandboxs.RemoveAt(num);
			}
			else
			{
				sandbox.RemoveFromScene();
				sandboxs.RemoveAt(num);
			}
		}

		public static void RefreshSkybox()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if (backup_sandbox != null)
			{
				ForceSandbox(backup_sandbox);
				sandbox_current = backup_sandbox;
			}
			on_unblock_event.RemoveListener(new UnityAction(RefreshSkybox));
		}

		public static void smile()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Debug.Log((object)"I LIED >:(");
			on_unblock_event.RemoveListener(new UnityAction(smile));
		}

		public static void ForceSandbox(CustomSandbox sandbox)
		{
			if (sandboxs.Contains(sandbox))
			{
				int num = sandboxs.IndexOf(sandbox);
				sandbox.custom_activator.SetActive(true);
				blocker.SetActive(true);
			}
		}

		public static void HardForceSandbox(CustomSandbox sandbox)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			if (sandboxs.Contains(sandbox))
			{
				int num = sandboxs.IndexOf(sandbox);
				sandbox.tod_changer.speedMultiplier = 10000000f;
				sandbox.custom_activator.SetActive(true);
				sandbox_current = sandbox;
				on_unblock_event.AddListener((UnityAction)delegate
				{
					RevertToDSpeedOnUnblock(sandbox.tod_changer);
				});
				blocker.SetActive(true);
			}
		}

		public static void ForceBaseSandbox(string name)
		{
			target_activator = null;
			vanilla_activators.TryGetValue(name, out target_activator);
			if ((Object)(object)target_activator != (Object)null)
			{
				target_activator.SetActive(true);
				blocker.SetActive(true);
			}
			else
			{
				Debug.Log((object)"You dumb and reactive frendo");
			}
		}

		public static void HardForceBaseSandbox(string name)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			target_activator = null;
			vanilla_activators.TryGetValue(name, out target_activator);
			if ((Object)(object)target_activator != (Object)null)
			{
				target_base_tod = ((Component)target_activator.transform.GetChild(0)).GetComponent<TimeOfDayChanger>();
				target_base_tod.speedMultiplier = 10000000f;
				target_activator.SetActive(true);
				UnityEvent obj = on_unblock_event;
				object obj2 = <>c.<>9__39_0;
				if (obj2 == null)
				{
					UnityAction val = delegate
					{
						RevertToDSpeedOnUnblock(target_base_tod);
					};
					<>c.<>9__39_0 = val;
					obj2 = (object)val;
				}
				obj.AddListener((UnityAction)obj2);
				blocker.SetActive(true);
			}
			else
			{
				Debug.Log((object)"You dumb and reactive frendo");
			}
		}

		public static void RevertToDSpeedOnUnblock(TimeOfDayChanger tod)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			if ((Object)(object)tod != (Object)null)
			{
				tod.speedMultiplier = global_tod_speed;
			}
			on_unblock_event.RemoveListener((UnityAction)delegate
			{
				RevertToDSpeedOnUnblock(tod);
			});
		}

		public static void UpdateGrid()
		{
			foreach (GameObject item in tod_grid_list)
			{
				item.SetActive(false);
			}
			tod_grid_list[tod_grid_index].SetActive(true);
			if (tod_grid_index == 0)
			{
				shop_button_mover[0].SetActive(false);
			}
			else
			{
				shop_button_mover[0].SetActive(true);
			}
			if (tod_grid_index == tod_grid_list.Count - 1)
			{
				shop_button_mover[1].SetActive(false);
			}
			else
			{
				shop_button_mover[1].SetActive(true);
			}
			if (tod_buttons.Count == 0 || sandbox_current == null)
			{
				shop_button_mover[3].SetActive(false);
				shop_button_mover[4].SetActive(false);
			}
			else
			{
				shop_button_mover[3].SetActive(true);
				shop_button_mover[4].SetActive(true);
			}
			shop_button_mover[5].SetActive(true);
		}

		public static void UpdateDisableList()
		{
			Transform transform = GameObject.Find("Activators").transform;
			Transform transform2 = GameObject.Find("IndoorsLighting").transform;
			Transform transform3 = GameObject.Find("OutdoorsLighting").transform;
			List<GameObject> list = new List<GameObject>();
			List<GameObject> list2 = new List<GameObject>();
			for (int i = 0; i < transform2.childCount; i++)
			{
				list.Add(((Component)transform2.GetChild(i)).gameObject);
			}
			for (int j = 0; j < transform.childCount; j++)
			{
				list.Add(((Component)transform.GetChild(j)).gameObject);
			}
			list.Add(((Component)transform.Find("Dawn Activator")).GetComponent<ObjectActivator>().events.toActivateObjects[2]);
			list.Add(((Component)transform.Find("Night Activator")).GetComponent<ObjectActivator>().events.toActivateObjects[2]);
			list.Add(((Component)transform.Find("Foggy Activator")).GetComponent<ObjectActivator>().events.toActivateObjects[2]);
			for (int k = 0; k < transform3.childCount; k++)
			{
				list2.Add(((Component)transform3.GetChild(k)).gameObject);
			}
			for (int l = 0; l < transform.childCount; l++)
			{
				List<GameObject> list3 = list.ToList();
				List<GameObject> list4 = new List<GameObject>();
				List<GameObject> list5 = ((Component)transform.GetChild(l)).GetComponent<ObjectActivator>().events.toActivateObjects.ToList();
				list5.Add(((Component)transform.GetChild(l)).gameObject);
				foreach (GameObject item in list3)
				{
					if (((Object)item).name == "IndoorsGarage" || ((Object)item).name == "IndoorsBuilding")
					{
						list4.Add(item);
					}
					foreach (GameObject item2 in list5)
					{
						if ((Object)(object)item == (Object)(object)item2)
						{
							list4.Add(item);
						}
					}
				}
				foreach (GameObject item3 in list4)
				{
					list3.Remove(item3);
				}
				((Component)transform.GetChild(l)).GetComponent<ObjectActivator>().events.toDisActivateObjects = list3.ToArray();
				List<GameObject> list6 = list2.ToList();
				List<GameObject> list7 = new List<GameObject>();
				List<GameObject> list8 = new List<GameObject>();
				foreach (GameObject item4 in list6)
				{
					foreach (GameObject item5 in list5)
					{
						if ((Object)(object)item4 == (Object)(object)item5)
						{
							list7.Add(item4);
						}
					}
				}
				foreach (GameObject item6 in list7)
				{
					list6.Remove(item6);
				}
				List<Light> list9 = new List<Light>();
				foreach (GameObject item7 in list6)
				{
					for (int m = 0; m < item7.transform.childCount; m++)
					{
						if (((Object)item7.transform.GetChild(m)).name.Contains("Directional Light"))
						{
							list9.Add(((Component)item7.transform.GetChild(m)).GetComponent<Light>());
						}
					}
				}
				((Component)transform.GetChild(l).Find("TOD Changer")).gameObject.GetComponent<TimeOfDayChanger>().oldLights = list9.ToArray();
			}
			UpdateTODs();
		}

		public static void UpdateTODs()
		{
			Transform transform = GameObject.Find("Activators").transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				((Component)transform.GetChild(i).Find("TOD Changer")).gameObject.GetComponent<TimeOfDayChanger>().speedMultiplier = global_tod_speed;
			}
		}

		public static void SaveSandboxes()
		{
			foreach (CustomSandbox sandbox in sandboxs)
			{
				SandboxInfo.SaveInfo(sandbox.info);
			}
		}

		public static void DeleteSandboxes()
		{
			if (sandbox_current != null)
			{
				((Component)GameObject.Find("Activators").transform.Find("Day Activator")).gameObject.SetActive(true);
				blocker.SetActive(true);
				sandbox_current = null;
			}
			while (sandboxs.Count != 0)
			{
				DeleteSandbox(sandboxs[0]);
			}
		}

		public static void ReloadSandboxes()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			if (sandbox_current != null)
			{
				ForceBaseSandbox("Day");
				((ConfigEntryBase)Plugin.load_on_start).SetSerializedValue("Day");
				sandbox_current = null;
			}
			while (sandboxs.Count != 0)
			{
				DeleteSandbox(sandboxs[0], delete_save: false);
			}
			if (!load_sandboxes)
			{
				on_unblock_event.AddListener(new UnityAction(LoadSandboxes));
				blocker.SetActive(true);
				load_sandboxes = true;
			}
		}

		public static void LoadSandboxes()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			foreach (string item in Directory.EnumerateFiles(Plugin.sandbox_folder_path))
			{
				if (string.Equals(".csb", Path.GetExtension(item), StringComparison.OrdinalIgnoreCase))
				{
					CustomSandbox customSandbox = new CustomSandbox();
					customSandbox.info = SandboxInfo.LoadInfo(item);
					if (customSandbox.info != null)
					{
						AddSandbox(customSandbox);
					}
				}
			}
			on_unblock_event.RemoveListener(new UnityAction(LoadSandboxes));
			load_sandboxes = false;
		}

		public static void doAThing()
		{
			if (is_setup && sandboxs == null)
			{
			}
		}

		public static void onBlocked()
		{
			foreach (GameObject item in tod_grid_list)
			{
				item.SetActive(false);
			}
			for (int i = 0; i < todb_count; i++)
			{
				shop_button_mover[i].SetActive(false);
			}
			on_blocked_event.Invoke();
		}

		public static void onUnblock()
		{
			for (int i = 0; i < todb_count; i++)
			{
				shop_button_mover[i].SetActive(true);
			}
			UpdateGrid();
			on_unblock_event.Invoke();
		}

		public static void Clear()
		{
			tod_button_total = 8;
			tod_grid = null;
			tod_grid_list = new List<GameObject>();
			tod_grid_index = 0;
			tod_changer = null;
			tod_buttons = new List<GameObject>();
			foreach (CustomSandbox sandbox in sandboxs)
			{
				sandbox.Clear();
			}
			sandboxs = new List<CustomSandbox>();
			sandbox_current = null;
			backup_sandbox = null;
			tod_panel = null;
			shop_button_mover = (GameObject[])(object)new GameObject[todb_count];
			((UnityEventBase)on_unblock_event).RemoveAllListeners();
			((UnityEventBase)on_blocked_event).RemoveAllListeners();
			vanilla_activators.Clear();
			activators_vanilla.Clear();
			load_sandboxes = false;
			is_setup = false;
		}
	}
	public static class Utils
	{
		public static List<string> image_types = new List<string> { ".jpeg", ".jpg", ".png", ".bmp" };

		private static GameObject shop_slider_base = null;

		private static GameObject shop_button_base = null;

		public static string ModDir()
		{
			return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}

		public static T CopyComponent<T>(T original, GameObject destination) where T : Component
		{
			Type type = ((object)original).GetType();
			Component val = destination.AddComponent(type);
			FieldInfo[] fields = type.GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(val, fieldInfo.GetValue(original));
			}
			return (T)(object)((val is T) ? val : null);
		}

		public static List<string> LayerMaskNames(LayerMask lmask)
		{
			List<string> list = new List<string>();
			int num = 1;
			for (int i = 0; i < 32; i++)
			{
				if ((((LayerMask)(ref lmask)).value & num) > 0)
				{
					list.Add(LayerMask.LayerToName(i));
					Debug.Log((object)(LayerMask.LayerToName(i) + " " + i));
				}
				num *= 2;
			}
			return list;
		}

		public static void InitUIObjets()
		{
			shop_slider_base = GameObject.Find("Shop/Canvas/Weapons/RevolverWindow/Color Screen/Standard/Custom/Unlocked/Color 1/Red/Slider");
			shop_button_base = GameObject.Find("Sandbox Shop/Canvas/Border/TOD Changer/Panel/Close Button");
		}

		public static GameObject CloneButtonForShop(GameObject button_base, Transform transform)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)shop_button_base == (Object)null)
			{
				Debug.Log((object)"Couldn;t clode the buteon");
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(shop_button_base, transform);
			Object.Destroy((Object)(object)((Component)val.transform.Find("Text")).gameObject);
			val.transform.localPosition = button_base.transform.localPosition;
			for (int i = 0; i < button_base.transform.childCount; i++)
			{
				if (!(((Object)button_base.transform.GetChild(i)).name == "Panel"))
				{
					Object.Instantiate<Transform>(button_base.transform.GetChild(i), val.transform);
				}
			}
			((Object)val).name = ((Object)button_base).name;
			val.GetComponent<RectTransform>().anchoredPosition = button_base.GetComponent<RectTransform>().anchoredPosition;
			val.GetComponent<RectTransform>().anchoredPosition3D = button_base.GetComponent<RectTransform>().anchoredPosition3D;
			val.GetComponent<RectTransform>().anchorMax = button_base.GetComponent<RectTransform>().anchorMax;
			val.GetComponent<RectTransform>().anchorMin = button_base.GetComponent<RectTransform>().anchorMin;
			val.GetComponent<RectTransform>().offsetMin = button_base.GetComponent<RectTransform>().offsetMin;
			val.GetComponent<RectTransform>().offsetMax = button_base.GetComponent<RectTransform>().offsetMax;
			val.GetComponent<ShopButton>().toActivate = (GameObject[])(object)new GameObject[0];
			val.GetComponent<ShopButton>().toDeactivate = (GameObject[])(object)new GameObject[0];
			val.AddComponent<PointerAdder>();
			return val;
		}

		public static GameObject ReplaceButtonForShop(GameObject button_base, Transform transform)
		{
			GameObject result = CloneButtonForShop(button_base, transform);
			Object.Destroy((Object)(object)button_base);
			return result;
		}

		public static GameObject CloneSliderForShop(GameObject slider_base, Transform transform)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)shop_slider_base == (Object)null)
			{
				Debug.Log((object)"codit colne ths ikdler");
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(shop_slider_base, transform);
			val.SetActive(true);
			val.transform.localPosition = slider_base.transform.localPosition;
			((Object)val).name = ((Object)slider_base).name;
			val.GetComponent<RectTransform>().anchoredPosition = slider_base.GetComponent<RectTransform>().anchoredPosition;
			val.GetComponent<RectTransform>().anchoredPosition3D = slider_base.GetComponent<RectTransform>().anchoredPosition3D;
			val.GetComponent<RectTransform>().anchorMax = slider_base.GetComponent<RectTransform>().anchorMax;
			val.GetComponent<RectTransform>().anchorMin = slider_base.GetComponent<RectTransform>().anchorMin;
			val.GetComponent<RectTransform>().offsetMin = slider_base.GetComponent<RectTransform>().offsetMin;
			val.GetComponent<RectTransform>().offsetMax = slider_base.GetComponent<RectTransform>().offsetMax;
			((Graphic)((Component)val.transform.Find("Background")).GetComponent<Image>()).color = ((Graphic)((Component)slider_base.transform.Find("Background")).GetComponent<Image>()).color;
			((Graphic)((Component)val.transform.Find("Fill Area/Fill")).GetComponent<Image>()).color = ((Graphic)((Component)slider_base.transform.Find("Fill Area/Fill")).GetComponent<Image>()).color;
			((Graphic)((Component)val.transform.Find("Handle Slide Area/Handle")).GetComponent<Image>()).color = ((Graphic)((Component)slider_base.transform.Find("Handle Slide Area/Handle")).GetComponent<Image>()).color;
			Object.Destroy((Object)(object)((Component)val.transform.Find("Value")).gameObject);
			val.GetComponent<Slider>().onValueChanged = slider_base.GetComponent<Slider>().onValueChanged;
			slider_base.SetActive(false);
			return val;
		}

		public static GameObject ReplaceSliderForShop(GameObject slider_base, Transform transform)
		{
			GameObject result = CloneSliderForShop(slider_base, transform);
			Object.Destroy((Object)(object)slider_base);
			return result;
		}

		public static int[] BitCountFinder(int num)
		{
			if (num < 1)
			{
				Debug.Log((object)"bruh");
				return null;
			}
			int num2 = (int)Math.Ceiling(Math.Log(num + 1, 2.0));
			int num3 = num2;
			int[] array = new int[num3];
			for (int i = 0; i < num2; i++)
			{
				array[i] = 0;
			}
			int num4 = 0;
			for (int j = 0; j < num + 1; j++)
			{
				num4 = 0;
				for (int k = 0; k < num2; k++)
				{
					if (((int)Math.Pow(2.0, k) & j) > 0)
					{
						num4++;
					}
				}
				if (num4 > 0)
				{
					array[num4 - 1]++;
				}
			}
			for (int l = 0; l < num2; l++)
			{
				Debug.Log((object)(l + 1 + ": " + array[l]));
			}
			return array;
		}
	}
	public static class AssetHandler
	{
		public static AssetBundle bundle;

		public static bool bundleLoaded;

		public static GameObject edit_panel;

		public static GameObject light_panel;

		public static GameObject light_color_slider;

		public static GameObject skybox_panel;

		public static GameObject fog_panel;

		public static GameObject misc_panel;

		public static GameObject settings_panel;

		public static void LoadBundle()
		{
			if (bundleLoaded)
			{
				Debug.Log((object)"Bundle already loaded");
				return;
			}
			bundle = AssetBundle.LoadFromFile(Path.Combine(Path.Combine(Utils.ModDir(), "Data"), "custom_sandbox_assets"));
			if ((Object)(object)bundle != (Object)null)
			{
				Debug.Log((object)"Bundle successfully loaded");
				bundleLoaded = true;
			}
			else
			{
				Debug.Log((object)"Bundle failed to loaded");
				bundleLoaded = false;
			}
		}

		public static T LoadAsset<T>(string name) where T : Object
		{
			if (!bundleLoaded)
			{
				Debug.Log((object)"Bundle is not loaded");
				return default(T);
			}
			T val = bundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Debug.Log((object)(name + " didn't load"));
			}
			return val;
		}

		public static void UnloadBundle()
		{
			if (!bundleLoaded)
			{
				Debug.Log((object)"Bundle already unloaded");
				return;
			}
			Debug.Log((object)"Bundle succesfully unloaded");
			bundle.Unload(true);
			bundle = null;
		}

		public static void MakePrefabs()
		{
			edit_panel = AssetHandler.LoadAsset<GameObject>("EditPanel");
			edit_panel.AddComponent<HudOpenEffect>();
			light_panel = AssetHandler.LoadAsset<GameObject>("LightColorPanel");
			light_panel.AddComponent<HudOpenEffect>();
			light_color_slider = AssetHandler.LoadAsset<GameObject>("LightColorSlider");
			skybox_panel = AssetHandler.LoadAsset<GameObject>("SkyboxPanel");
			skybox_panel.AddComponent<HudOpenEffect>();
			fog_panel = AssetHandler.LoadAsset<GameObject>("FogPanel");
			fog_panel.AddComponent<HudOpenEffect>();
			misc_panel = AssetHandler.LoadAsset<GameObject>("MiscPanel");
			misc_panel.AddComponent<HudOpenEffect>();
			settings_panel = AssetHandler.LoadAsset<GameObject>("SettingsPanel");
			settings_panel.AddComponent<HudOpenEffect>();
		}
	}
	public static class WhyDoesGettingAddressableNamesAtRuntimeHaveToBeSoHard
	{
		public static async void GetAddressKeys()
		{
			AsyncOperationHandle<IResourceLocator> thingy = Addressables.LoadContentCatalogAsync("Where the catalog json is", (string)null);
			await thingy.Task;
			List<string> addressKeys = new List<string>();
			IResourceLocator resLocator = thingy.Result;
			if (resLocator == null)
			{
				return;
			}
			if (resLocator != null)
			{
				Debug.Log((object)"YEAAAAAAH");
				foreach (object key in resLocator.Keys)
				{
					addressKeys.Add(key.ToString());
					Debug.Log((object)key.ToString());
				}
				File.WriteAllLines(Path.Combine("Path you want to save the cataloge"), addressKeys);
			}
			else
			{
				Debug.Log((object)"Aw fiddlesticks");
			}
		}
	}
}
namespace SandboxCustomizer.UI
{
	public class EditPanel
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__13_2;

			internal void <Create>b__13_2()
			{
				if (SandboxManager.sandbox_current.info.path != null)
				{
					SandboxManager.sandbox_current.info = SandboxInfo.LoadInfo(SandboxManager.sandbox_current.info.path);
					string path = "bruh";
					if (File.Exists(Path.Combine(Plugin.skybox_folder_path, SandboxManager.sandbox_current.info.skybox.name)))
					{
						path = Path.Combine(Plugin.skybox_folder_path, SandboxManager.sandbox_current.info.skybox.name);
					}
					else if (File.Exists(Path.Combine(Plugin.skybox_folder_path, "PutSkyboxHere", SandboxManager.sandbox_current.info.skybox.name)))
					{
						path = Path.Combine(Plugin.skybox_folder_path, "PutSkyboxHere", SandboxManager.sandbox_current.info.skybox.name);
					}
					SandboxManager.sandbox_current.LoadSkyboxFromPath(path);
					SandboxManager.sandbox_current.UpdateEffects();
					RenderSettings.skybox = SandboxManager.sandbox_current.skybox_mat;
				}
			}
		}

		public GameObject gameObject;

		public GameObject button_lights;

		public GameObject button_skybox;

		public GameObject button_fog;

		public GameObject button_misc;

		public Text sandbox_name;

		public GameObject button_save;

		public GameObject button_refresh;

		public GameObject button_back;

		public LightColorPanel light_panel;

		public SkyboxPanel skybox_panel;

		public FogPanel fog_panel;

		public MiscPanel misc_panel;

		public void Create(Transform transform)
		{
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Expected O, but got Unknown
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Expected O, but got Unknown
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			gameObject = Object.Instantiate<GameObject>(AssetHandler.edit_panel, transform);
			button_lights = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button lights")).gameObject, gameObject.transform);
			button_skybox = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button skybox")).gameObject, gameObject.transform);
			button_fog = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button fog")).gameObject, gameObject.transform);
			button_misc = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button misc")).gameObject, gameObject.transform);
			sandbox_name = ((Component)gameObject.transform.Find("SandboxName")).gameObject.GetComponent<Text>();
			button_save = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button save")).gameObject, gameObject.transform);
			button_refresh = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button refresh")).gameObject, gameObject.transform);
			button_back = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button back")).gameObject, gameObject.transform);
			light_panel = new LightColorPanel();
			light_panel.Create(gameObject.transform);
			light_panel.gameObject.SetActive(false);
			skybox_panel = new SkyboxPanel();
			skybox_panel.Create(gameObject.transform);
			skybox_panel.gameObject.SetActive(false);
			fog_panel = new FogPanel();
			fog_panel.Create(gameObject.transform);
			fog_panel.gameObject.SetActive(false);
			misc_panel = new MiscPanel();
			misc_panel.Create(gameObject.transform);
			misc_panel.gameObject.SetActive(false);
			button_back.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				SandboxManager.tod_panel.SetActive(true);
				gameObject.SetActive(false);
			});
			button_save.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				if (SandboxManager.sandbox_current != null)
				{
					SandboxInfo.SaveInfo(SandboxManager.sandbox_current.info);
					((ConfigEntryBase)Plugin.load_on_start).SetSerializedValue(SandboxManager.sandbox_current.info.path.Replace(Plugin.sandbox_folder_path + "\\", ""));
				}
				UpdateName();
			});
			List<UnityAction> on_pressed_actions = button_refresh.GetComponent<PointerAdder>().on_pressed_actions;
			object obj = <>c.<>9__13_2;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					if (SandboxManager.sandbox_current.info.path != null)
					{
						SandboxManager.sandbox_current.info = SandboxInfo.LoadInfo(SandboxManager.sandbox_current.info.path);
						string path = "bruh";
						if (File.Exists(Path.Combine(Plugin.skybox_folder_path, SandboxManager.sandbox_current.info.skybox.name)))
						{
							path = Path.Combine(Plugin.skybox_folder_path, SandboxManager.sandbox_current.info.skybox.name);
						}
						else if (File.Exists(Path.Combine(Plugin.skybox_folder_path, "PutSkyboxHere", SandboxManager.sandbox_current.info.skybox.name)))
						{
							path = Path.Combine(Plugin.skybox_folder_path, "PutSkyboxHere", SandboxManager.sandbox_current.info.skybox.name);
						}
						SandboxManager.sandbox_current.LoadSkyboxFromPath(path);
						SandboxManager.sandbox_current.UpdateEffects();
						RenderSettings.skybox = SandboxManager.sandbox_current.skybox_mat;
					}
				};
				<>c.<>9__13_2 = val;
				obj = (object)val;
			}
			on_pressed_actions.Add((UnityAction)obj);
			button_lights.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Expected O, but got Unknown
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0179: Expected O, but got Unknown
				light_panel.gameObject.SetActive(true);
				if (SandboxManager.sandbox_current != null)
				{
					light_panel.ClearAllSliders();
					foreach (LightInfo light_info2 in SandboxManager.sandbox_current.info.outdoor_lights)
					{
						LightColorSlider slider2 = new LightColorSlider();
						light_panel.AddColorSlider(slider2);
						slider2.SetColor(light_info2.color);
						slider2.on_value_change_event.AddListener((UnityAction)delegate
						{
							//IL_0013: Unknown result type (might be due to invalid IL or missing references)
							//IL_0018: Unknown result type (might be due to invalid IL or missing references)
							//IL_009c: Unknown result type (might be due to invalid IL or missing references)
							light_info2.color = slider2.color;
							SandboxManager.sandbox_current.UpdateEffects();
							Color color2 = default(Color);
							((Color)(ref color2))..ctor(slider2.slider_r.value, slider2.slider_g.value, slider2.slider_b.value, slider2.slider_mag.value);
							if (Plugin.auto_save_sandbox.Value && File.Exists(SandboxManager.sandbox_current.info.path))
							{
								CSBUtils.SetColorField("Outdoor Lights", color2, SandboxManager.sandbox_current.info.outdoor_lights.IndexOf(light_info2), SandboxManager.sandbox_current.info.path);
							}
						});
					}
					foreach (LightInfo light_info in SandboxManager.sandbox_current.info.indoor_lights)
					{
						LightColorSlider slider = new LightColorSlider();
						light_panel.AddColorSlider(slider);
						slider.SetColor(light_info.color);
						slider.on_value_change_event.AddListener((UnityAction)delegate
						{
							//IL_0013: Unknown result type (might be due to invalid IL or missing references)
							//IL_0018: Unknown result type (might be due to invalid IL or missing references)
							//IL_009c: Unknown result type (might be due to invalid IL or missing references)
							light_info.color = slider.color;
							SandboxManager.sandbox_current.UpdateEffects();
							Color color = default(Color);
							((Color)(ref color))..ctor(slider.slider_r.value, slider.slider_g.value, slider.slider_b.value, slider.slider_mag.value);
							if (Plugin.auto_save_sandbox.Value && File.Exists(SandboxManager.sandbox_current.info.path))
							{
								CSBUtils.SetColorField("Indoor Lights", color, SandboxManager.sandbox_current.info.indoor_lights.IndexOf(light_info), SandboxManager.sandbox_current.info.path);
							}
						});
					}
				}
			});
			button_skybox.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				skybox_panel.gameObject.SetActive(true);
				((Graphic)skybox_panel.skybox_image).material.mainTexture = (Texture)(object)SandboxManager.sandbox_current.info.skybox.texture;
			});
			button_fog.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Expected O, but got Unknown
				fog_panel.gameObject.SetActive(true);
				((UnityEventBase)fog_panel.on_value_change_event).RemoveAllListeners();
				fog_panel.fog_enable = SandboxManager.sandbox_current.info.fog.enabled;
				fog_panel.SetColor(SandboxManager.sandbox_current.info.fog.color);
				fog_panel.fog_start.value = SandboxManager.sandbox_current.info.fog.start;
				fog_panel.fog_end.value = SandboxManager.sandbox_current.info.fog.end;
				if (fog_panel.fog_enable)
				{
					fog_panel.fog_enable_img.SetActive(true);
				}
				else
				{
					fog_panel.fog_enable_img.SetActive(false);
				}
				fog_panel.on_value_change_event.AddListener((UnityAction)delegate
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_008d: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
					SandboxManager.sandbox_current.info.fog.color = fog_panel.fog_color;
					SandboxManager.sandbox_current.info.fog.enabled = fog_panel.fog_enable;
					SandboxManager.sandbox_current.info.fog.start = fog_panel.fog_start.value;
					SandboxManager.sandbox_current.info.fog.end = fog_panel.fog_end.value;
					RenderSettings.fogColor = fog_panel.fog_color;
					if (Plugin.auto_save_sandbox.Value && File.Exists(SandboxManager.sandbox_current.info.path))
					{
						CSBUtils.SetColorField("Fog", fog_panel.fog_color, 0, SandboxManager.sandbox_current.info.path);
						CSBUtils.SetFloatField("Fog", fog_panel.fog_start.value, 1, SandboxManager.sandbox_current.info.path);
						CSBUtils.SetFloatField("Fog", fog_panel.fog_end.value, 2, SandboxManager.sandbox_current.info.path);
						CSBUtils.SetBoolField("Fog", fog_panel.fog_enable, 3, SandboxManager.sandbox_current.info.path);
					}
					if (fog_panel.fog_enable)
					{
						RenderSettings.fogStartDistance = fog_panel.fog_start.value;
						RenderSettings.fogEndDistance = fog_panel.fog_end.value;
						fog_panel.fog_enable_img.SetActive(true);
					}
					else
					{
						RenderSettings.fogStartDistance = 1E+25f;
						RenderSettings.fogEndDistance = 1E+26f;
						fog_panel.fog_enable_img.SetActive(false);
					}
					SandboxManager.sandbox_current.UpdateEffects();
				});
			});
			button_misc.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Expected O, but got Unknown
				misc_panel.gameObject.SetActive(true);
				misc_panel.godray_alpha.value = SandboxManager.sandbox_current.info.godrays[0].color.a;
				((UnityEventBase)misc_panel.on_value_change_event).RemoveAllListeners();
				misc_panel.on_value_change_event.AddListener((UnityAction)delegate
				{
					//IL_006e: Unknown result type (might be due to invalid IL or missing references)
					foreach (GodrayInfo godray in SandboxManager.sandbox_current.info.godrays)
					{
						godray.color.a = misc_panel.godray_alpha.value;
						if (Plugin.auto_save_sandbox.Value && File.Exists(SandboxManager.sandbox_current.info.path))
						{
							CSBUtils.SetColorField("Godrays", godray.color, SandboxManager.sandbox_current.info.godrays.IndexOf(godray), SandboxManager.sandbox_current.info.path);
						}
					}
					SandboxManager.sandbox_current.UpdateEffects();
				});
			});
		}

		public void UpdateName()
		{
			string text = "";
			if (SandboxManager.sandbox_current != null && SandboxManager.sandbox_current.info.path != null)
			{
				text = SandboxManager.sandbox_current.info.path.Replace(Plugin.sandbox_folder_path + "\\", "");
				text = text.Replace(".csb", "");
			}
			sandbox_name.text = text;
		}
	}
	public class FogPanel
	{
		public GameObject gameObject;

		public GameObject button_back;

		public GameObject button_fog_enable;

		public GameObject fog_enable_img;

		public bool fog_enable;

		public Image fog_img;

		public Color fog_color;

		public Slider fog_r;

		public Slider fog_g;

		public Slider fog_b;

		public Slider fog_start;

		public Slider fog_end;

		public Text fog_start_value;

		public Text fog_end_value;

		public UnityEvent on_value_change_event;

		public void Create(Transform transform)
		{
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Expected O, but got Unknown
			gameObject = Object.Instantiate<GameObject>(AssetHandler.fog_panel, transform);
			button_back = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("button back")).gameObject, gameObject.transform);
			button_fog_enable = Utils.ReplaceButtonForShop(((Component)gameObject.transform.Find("fog enable button")).gameObject, gameObject.transform);
			fog_enable_img = ((Component)gameObject.transform.Find("fog enable button/Image(Clone)")).gameObject;
			fog_enable = true;
			fog_img = ((Component)gameObject.transform.Find("ColorSlider/Color")).GetComponent<Image>();
			fog_r = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("ColorSlider/Red")).gameObject, gameObject.transform.Find("ColorSlider")).GetComponent<Slider>();
			fog_g = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("ColorSlider/Green")).gameObject, gameObject.transform.Find("ColorSlider")).GetComponent<Slider>();
			fog_b = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("ColorSlider/Blue")).gameObject, gameObject.transform.Find("ColorSlider")).GetComponent<Slider>();
			fog_start = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("fog start/FogSlider")).gameObject, gameObject.transform.Find("fog start")).GetComponent<Slider>();
			fog_end = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("fog end/FogSlider")).gameObject, gameObject.transform.Find("fog end")).GetComponent<Slider>();
			fog_start_value = ((Component)gameObject.transform.Find("fog start/fog value")).GetComponent<Text>();
			fog_end_value = ((Component)gameObject.transform.Find("fog end/fog value")).GetComponent<Text>();
			fog_start.maxValue = 1000f;
			fog_start.minValue = -1000f;
			fog_start.wholeNumbers = true;
			fog_end.maxValue = 1000f;
			fog_end.minValue = -1000f;
			fog_end.wholeNumbers = true;
			fog_color = Color.black;
			on_value_change_event = new UnityEvent();
			UpdateColor();
			button_back.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				gameObject.SetActive(false);
			});
			button_fog_enable.GetComponent<PointerAdder>().on_pressed_actions.Add((UnityAction)delegate
			{
				fog_enable = !fog_enable;
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)fog_r.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				UpdateColor();
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)fog_g.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				UpdateColor();
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)fog_b.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				UpdateColor();
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)fog_start.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				fog_start_value.text = fog_start.value.ToString();
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)fog_end.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				fog_end_value.text = fog_end.value.ToString();
				on_value_change_event.Invoke();
			});
		}

		public void UpdateColor()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			fog_color.r = fog_r.value;
			fog_color.g = fog_g.value;
			fog_color.b = fog_b.value;
			fog_color.a = 1f;
			((Graphic)fog_img).color = fog_color;
		}

		public void SetColor(Color col)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			fog_r.value = col.r;
			fog_g.value = col.g;
			fog_b.value = col.b;
			UpdateColor();
		}
	}
	public class LightColorSlider
	{
		public GameObject gameObject;

		public Slider slider_r;

		public Slider slider_g;

		public Slider slider_b;

		public Slider slider_mag;

		public Image color_img;

		public Image color_glow_img;

		public Color color;

		public Color slider_value;

		public UnityEvent on_value_change_event;

		public void Create(Transform transform)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			color = Color.white;
			slider_value = Color.white;
			gameObject = Object.Instantiate<GameObject>(AssetHandler.light_color_slider, transform);
			slider_r = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("Red")).gameObject, gameObject.transform).GetComponent<Slider>();
			slider_g = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("Green")).gameObject, gameObject.transform).GetComponent<Slider>();
			slider_b = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("Blue")).gameObject, gameObject.transform).GetComponent<Slider>();
			slider_mag = Utils.ReplaceSliderForShop(((Component)gameObject.transform.Find("Magnitude")).gameObject, gameObject.transform).GetComponent<Slider>();
			color_img = ((Component)gameObject.transform.Find("Color")).GetComponent<Image>();
			color_glow_img = ((Component)gameObject.transform.Find("ColorGlow")).GetComponent<Image>();
			UpdateColor();
			on_value_change_event = new UnityEvent();
			((UnityEvent<float>)(object)slider_r.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				UpdateColor();
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)slider_g.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				UpdateColor();
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)slider_b.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				UpdateColor();
				on_value_change_event.Invoke();
			});
			((UnityEvent<float>)(object)slider_mag.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				UpdateColor();
				on_value_change_event.Invoke();
			});
		}

		public void Destroy()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			slider_r = null;
			slider_g = null;
			slider_b = null;
			slider_mag = null;
			color_img = null;
			color_glow_img = null;
			color = Color.