Decompiled source of SpaceSunShine v1.3.0

Plugin/SpaceSunShine.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SpaceSunShine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1d96edad74f8a8c81b88b97ce63a467aaa6a8899")]
[assembly: AssemblyProduct("SpaceSunShine")]
[assembly: AssemblyTitle("SpaceSunShine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SpaceSunShine
{
	public class Configs
	{
		public static ConfigEntry<bool> UOS;

		public static ConfigEntry<bool> EFL;

		public static ConfigEntry<bool> DSL;

		public static ConfigEntry<bool> SL;

		public Configs(ConfigFile config)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			ConfigDefinition val = new ConfigDefinition("Lighting", "Use old sun lighting method");
			ConfigDefinition val2 = new ConfigDefinition("Lighting", "Enable flood light");
			ConfigDefinition val3 = new ConfigDefinition("Lighting", "Disable Sun Light");
			ConfigDefinition val4 = new ConfigDefinition("Space stuff", "Enable ladder in space");
			ConfigDescription val5 = new ConfigDescription("Choose if you want to use the old method for generating the light of the sun or the newer one thats like LE", (AcceptableValueBase)null, Array.Empty<object>());
			ConfigDescription val6 = new ConfigDescription("Choose if you want to enable the flood light for a lil more light on the dark side of the ship", (AcceptableValueBase)null, Array.Empty<object>());
			ConfigDescription val7 = new ConfigDescription("Disables the sun light added by this mod (will not disable other mods that add the same feature e.g LethalExpansion)", (AcceptableValueBase)null, Array.Empty<object>());
			ConfigDescription val8 = new ConfigDescription("Choose if you want to enable the ladder while in space\nMay conflict with mods untested i am only enabling it when needed to mitigate it effecting other mods if it does", (AcceptableValueBase)null, Array.Empty<object>());
			UOS = config.Bind<bool>(val, false, val5);
			EFL = config.Bind<bool>(val2, true, val6);
			DSL = config.Bind<bool>(val3, false, val7);
			SL = config.Bind<bool>(val4, true, val8);
		}
	}
	internal class OnEvents
	{
		public class OnFloodlight : MonoBehaviour
		{
			public void OnEnable()
			{
				GameObject shipLightsPostClone = SpaceSunShine.ShipLightsPostClone;
				if (shipLightsPostClone != null)
				{
					shipLightsPostClone.SetActive(false);
				}
			}

			public void OnDisable()
			{
				GameObject shipLightsPostClone = SpaceSunShine.ShipLightsPostClone;
				if (shipLightsPostClone != null)
				{
					shipLightsPostClone.SetActive(true);
				}
			}

			public void OnDestroy()
			{
				SpaceSunShine.ShipLightsPostClone = null;
			}
		}

		public class OnLadder : MonoBehaviour
		{
			public void OnEnable()
			{
				GameObject outsideShipRoomClone = SpaceSunShine.OutsideShipRoomClone;
				if (outsideShipRoomClone != null)
				{
					outsideShipRoomClone.SetActive(false);
				}
			}

			public void OnDisable()
			{
				GameObject outsideShipRoomClone = SpaceSunShine.OutsideShipRoomClone;
				if (outsideShipRoomClone != null)
				{
					outsideShipRoomClone.SetActive(true);
				}
			}

			public void OnDestroy()
			{
				SpaceSunShine.OutsideShipRoomClone = null;
			}
		}
	}
	[BepInPlugin("SpaceSunShine", "SpaceSunShine", "1.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log = new ManualLogSource("SpaceSunShine");

		public static Configs Configs { get; internal set; }

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SpaceSunShine is loaded!");
			Configs = new Configs(((BaseUnityPlugin)this).Config);
			SceneManager.sceneLoaded += SpaceSunShine.OnSceneLoaded;
		}
	}
	public static class PluginMetadata
	{
		public const string PLUGIN_GUID = "SpaceSunShine";

		public const string PLUGIN_NAME = "SpaceSunShine";

		public const string PLUGIN_VERSION = "1.3.0";
	}
	internal static class SpaceSunShine
	{
		private static GameObject ZeekerSun = null;

		private static GameObject ShipModels2b = null;

		private static GameObject OutsideShipRoom = null;

		private static GameObject ShipLightsPost = null;

		private static GameObject HangarShip = null;

		public static GameObject Sun = null;

		public static GameObject OutsideShipRoomClone = null;

		public static GameObject ShipLightsPostClone = null;

		public static AssetBundle mainAssetBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("SpaceSunShine.dll", "spacesunshine.lcm"));

		private const string DLL = "SpaceSunShine.dll";

		private const string LethalCatsarmyModule = "spacesunshine.lcm";

		private const string SpaceShipScene = "SampleSceneRelay";

		private const string SunPrefab = "Assets/Mods/SpaceSunShine/Prefabs/Sun.prefab";

		private const string Floodlight2 = "Floodlight2";

		public static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name != "SampleSceneRelay")
			{
				return;
			}
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			GameObject val = ((IEnumerable<GameObject>)rootGameObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject name) => ((Object)name).name == "Environment"));
			GameObject gameObject = ((Component)val.transform.Find("Lighting")).gameObject;
			HangarShip = ((Component)val.transform.Find("HangarShip")).gameObject;
			ZeekerSun = ((Component)gameObject.transform.Find("Sun")).gameObject;
			ShipModels2b = ((Component)HangarShip.transform.Find("ShipModels2b")).gameObject;
			InitFloodLights();
			InitLadder();
			if (!Configs.DSL.Value)
			{
				if (Configs.UOS.Value)
				{
					Light component = ZeekerSun.GetComponent<Light>();
					((Behaviour)component).enabled = true;
				}
				else
				{
					InitSun();
				}
			}
		}

		private static void InitSun()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			AssetBundle obj = mainAssetBundle;
			GameObject val = ((obj != null) ? obj.LoadAsset<GameObject>("Assets/Mods/SpaceSunShine/Prefabs/Sun.prefab") : null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogError((object)"Failed to load new sun(Asset bundle failure)");
				return;
			}
			Sun = Object.Instantiate<GameObject>(val);
			Animator component = ZeekerSun.GetComponent<Animator>();
			((Behaviour)component).enabled = false;
			Quaternion val2 = default(Quaternion);
			((Quaternion)(ref val2))..ctor(0f, 0f, 0f, 0f);
			Vector3 zero = Vector3.zero;
			ZeekerSun.transform.localScale = Vector3.one;
			ZeekerSun.transform.position = zero;
			ZeekerSun.transform.localPosition = zero;
			ZeekerSun.transform.rotation = val2;
			ZeekerSun.transform.localRotation = val2;
			Sun.transform.SetParent(ZeekerSun.transform, true);
		}

		private static void InitFloodLights()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (Configs.EFL.Value)
			{
				ShipLightsPost = ((Component)ShipModels2b.transform.Find("ShipLightsPost")).gameObject;
				ShipLightsPostClone = Object.Instantiate<GameObject>(ShipLightsPost, ShipModels2b.transform);
				ShipLightsPostClone.transform.position = ShipLightsPost.transform.position;
				GameObject gameObject = ((Component)ShipLightsPostClone.transform.Find("Floodlight2")).gameObject;
				gameObject.transform.rotation = new Quaternion(0.5461f, 0.6892f, -0.4661f, -0.0976f);
				gameObject.transform.localEulerAngles = new Vector3(32.3982f, 229.6713f, 92.1077f);
				ShipLightsPostClone.SetActive(true);
				ShipLightsPost.AddComponent<OnEvents.OnFloodlight>();
				ShipLightsPost.SetActive(!Object.op_Implicit((Object)(object)ShipLightsPost));
				ShipLightsPost.SetActive(!Object.op_Implicit((Object)(object)ShipLightsPost));
			}
		}

		private static void InitLadder()
		{
			if (Configs.SL.Value)
			{
				OutsideShipRoom = ((Component)HangarShip.transform.Find("OutsideShipRoom")).gameObject;
				OutsideShipRoomClone = Object.Instantiate<GameObject>(OutsideShipRoom, HangarShip.transform);
				OutsideShipRoomClone.SetActive(true);
				OutsideShipRoom.AddComponent<OnEvents.OnLadder>();
				OutsideShipRoom.SetActive(!Object.op_Implicit((Object)(object)OutsideShipRoom));
				OutsideShipRoom.SetActive(!Object.op_Implicit((Object)(object)OutsideShipRoom));
			}
		}

		public static Quaternion Copy(this Quaternion quat, float xOffset = 0f, float yOffset = 0f, float zOffset = 0f, float wOffset = 0f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			return new Quaternion(quat.x + xOffset, quat.y + yOffset, quat.z + zOffset, quat.w + wOffset);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SpaceSunShine";

		public const string PLUGIN_NAME = "SpaceSunShine";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}