Decompiled source of CompanyMoonConfig v0.1.0

Tomatobird.CompanyMoonConfig.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.CompanyMoonConfig")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+a01aeef09091dee73a8cd58d93eddd3df76c0c71")]
[assembly: AssemblyProduct("CompanyMoonConfig")]
[assembly: AssemblyTitle("Tomatobird.CompanyMoonConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CompanyMoonConfig
{
	[BepInPlugin("Tomatobird.CompanyMoonConfig", "CompanyMoonConfig", "0.1.0")]
	public class CompanyMoonConfig : BaseUnityPlugin
	{
		public static bool mapEnabled;

		public static bool localVolumetricFogEnabled;

		public static float localVolumetricFogThinness;

		public static bool sunWithShadowsEnabled;

		public static float sunBrightness;

		public static bool indirectEnabled;

		public static float indirectBrightness;

		public static bool skyAndFogGlobalVolumeEnabled;

		public static float fogGlobalVolumeWeight;

		public static CompanyMoonConfig Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			mapEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CompanyMapEnabled", true, "Should the comany moon map object and related props be enabled?").Value;
			localVolumetricFogEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Lighting", "LocalVolumetricFog", false, "Should local volumetric fog be enabled?").Value;
			localVolumetricFogThinness = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting", "LocalVolumetricFogThinness", 45f, "How thin should the fog be? Lower values make fog thicker.").Value;
			sunWithShadowsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Lighting", "SunWithShadows", true, "Should the sun object be enabled?").Value;
			sunBrightness = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting", "SunBrightness", 1.972f, "How bright should the sunlight be?").Value;
			indirectEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Lighting", "Indirect", true, "Should indirect lighting be enabled?").Value;
			indirectBrightness = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting", "IndirectBrightness", 2f, "How bright should the indirect light be?").Value;
			skyAndFogGlobalVolumeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Lighting", "SkyAndFogGlobalVolume", true, "Should sky and global fog be enabled?").Value;
			fogGlobalVolumeWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Ligthing", "GlobalFogVolumeWeight", 1f, new ConfigDescription("How strong should the fog be? 0 disables the object.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())).Value;
			SceneManager.sceneLoaded += OnSceneLoaded;
			Logger.LogInfo((object)"Tomatobird.CompanyMoonConfig v0.1.0 has loaded!");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name != "CompanyBuilding")
			{
				return;
			}
			Transform val = null;
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			foreach (GameObject val2 in rootGameObjects)
			{
				if (((Object)val2).name == "Environment")
				{
					val = val2.transform;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Environment not found");
				return;
			}
			Transform val3 = val.Find("Map");
			if (val3 != null)
			{
				((Component)val3).gameObject.SetActive(mapEnabled);
			}
			Transform obj = val.Find("LightsContainer");
			if (obj != null)
			{
				((Component)obj).gameObject.SetActive(mapEnabled);
			}
			Transform obj2 = val.Find("Interactables");
			if (obj2 != null)
			{
				((Component)obj2).gameObject.SetActive(mapEnabled);
			}
			Transform obj3 = val.Find("Lighting");
			object obj4;
			if (obj3 == null)
			{
				obj4 = null;
			}
			else
			{
				Transform obj5 = obj3.Find("BrightDay");
				obj4 = ((obj5 != null) ? obj5.Find("Local Volumetric Fog") : null);
			}
			Transform val4 = (Transform)obj4;
			if ((Object)(object)val4 != (Object)null)
			{
				((Component)val4).GetComponent<LocalVolumetricFog>().parameters.meanFreePath = localVolumetricFogThinness;
			}
			Transform obj6 = val.Find("Lighting");
			object obj7;
			if (obj6 == null)
			{
				obj7 = null;
			}
			else
			{
				Transform obj8 = obj6.Find("BrightDay");
				obj7 = ((obj8 != null) ? obj8.Find("Sun").GetChild(0) : null);
			}
			Transform val5 = (Transform)obj7;
			Transform val6 = ((val5 != null) ? val5.Find("SunWithShadows") : null);
			Transform val7 = ((val5 != null) ? val5.Find("Indirect") : null);
			Transform val8 = ((val5 != null) ? val5.Find("Sky and Fog Global Volume") : null);
			if ((Object)(object)val6 != (Object)null)
			{
				((Component)val6).gameObject.SetActive(sunWithShadowsEnabled);
				((Component)val6).GetComponent<Light>().intensity = sunBrightness;
			}
			if ((Object)(object)val7 != (Object)null)
			{
				((Component)val7).gameObject.SetActive(indirectEnabled);
				((Component)val7).GetComponent<Light>().intensity = indirectBrightness;
			}
			if (val8 != null)
			{
				((Component)val8).gameObject.SetActive(skyAndFogGlobalVolumeEnabled);
			}
			Volume val9 = ((val5 != null) ? ((Component)val5.Find("Sky and Fog Global Volume")).GetComponent<Volume>() : null);
			if ((Object)(object)val9 != (Object)null)
			{
				val9.weight = fogGlobalVolumeWeight;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.CompanyMoonConfig";

		public const string PLUGIN_NAME = "CompanyMoonConfig";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}