Decompiled source of Airlock Door Color v0.0.3

AirlockDoorColor.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
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 CG.Client.Ship;
using CG.Client.Ship.Views;
using CG.Ship.Hull;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using VFX;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AirlockDoorColor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Template")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3+94507b305e56cadd7863735effac5dd365931402")]
[assembly: AssemblyProduct("AirlockDoorColor")]
[assembly: AssemblyTitle("Changes the open airlock door button color from green to white. Client Side.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.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 AirlockDoorColor
{
	[HarmonyPatch(typeof(AirlockButtonPanel), "UpdateDiodes")]
	internal class AirlockButtonPanelPatch
	{
		private static readonly FieldInfo diodeMaterial = AccessTools.Field(typeof(Diode), "_materialData");

		private static readonly FieldInfo diodeproperty = AccessTools.Field(typeof(Diode), "_propertyBlock");

		private static Color closedColor = new Color(0f, 6f, 0f, 1f);

		private static Color unsafeColor = new Color(0f, 0f, 0f, 1f);

		private static void Postfix(Airlock ____airlock, Diode ___diodeInnerDoor, Diode ___diodeOuterDoor)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < ____airlock.airlockDoors.Count; i++)
			{
				AirlockDoor val = ____airlock.airlockDoors[i];
				if ((int)val.airlockDoorType == 0)
				{
					bool flag = !((AbstractDoor)val).IsLocked && (val.IsSafe || !____airlock.IsSafetyEnabled);
					List<RendererSourceData> list = (List<RendererSourceData>)diodeMaterial.GetValue(___diodeInnerDoor);
					? val2 = (MaterialPropertyBlock)diodeproperty.GetValue(___diodeInnerDoor);
					if ((int)val2 == 0)
					{
						val2 = new MaterialPropertyBlock();
					}
					MaterialPropertyBlock val3 = (MaterialPropertyBlock)val2;
					MaterialUtils.UpdateRendererMaterials(list, "_EmissiveColor", ((AbstractDoor)val).IsOpen ? Configs.CurrentColor : (flag ? closedColor : unsafeColor), val3);
				}
				else
				{
					bool flag2 = !((AbstractDoor)val).IsLocked && (val.IsSafe || !____airlock.IsSafetyEnabled);
					List<RendererSourceData> list2 = (List<RendererSourceData>)diodeMaterial.GetValue(___diodeOuterDoor);
					? val4 = (MaterialPropertyBlock)diodeproperty.GetValue(___diodeOuterDoor);
					if ((int)val4 == 0)
					{
						val4 = new MaterialPropertyBlock();
					}
					MaterialPropertyBlock val5 = (MaterialPropertyBlock)val4;
					MaterialUtils.UpdateRendererMaterials(list2, "_EmissiveColor", ((AbstractDoor)val).IsOpen ? Configs.CurrentColor : (flag2 ? closedColor : unsafeColor), val5);
				}
			}
		}
	}
	[BepInPlugin("18107.AirlockDoorColor", "Airlock Door Color", "0.0.3")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			Harmony.CreateAndPatchAll(typeof(AirlockButtonPanelPatch), "18107.AirlockDoorColor");
			Configs.Load(this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.AirlockDoorColor is loaded!");
		}
	}
	internal class Configs
	{
		internal static Color DefaultColor = new Color(5.2f, 5.2f, 6f, 1f);

		internal static Color CurrentColor;

		internal static ConfigEntry<float> OpenDoorColorR;

		internal static ConfigEntry<float> OpenDoorColorG;

		internal static ConfigEntry<float> OpenDoorColorB;

		internal static ConfigEntry<float> OpenDoorColorA;

		internal static void UpdateColorConfig()
		{
			OpenDoorColorR.Value = CurrentColor.r;
			OpenDoorColorG.Value = CurrentColor.g;
			OpenDoorColorB.Value = CurrentColor.b;
			OpenDoorColorA.Value = CurrentColor.a;
		}

		internal static void Load(BepinPlugin plugin)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			OpenDoorColorR = ((BaseUnityPlugin)plugin).Config.Bind<float>("DoorColor", "DoorColorR", 5.2f, (ConfigDescription)null);
			OpenDoorColorG = ((BaseUnityPlugin)plugin).Config.Bind<float>("DoorColor", "DoorColorG", 5.2f, (ConfigDescription)null);
			OpenDoorColorB = ((BaseUnityPlugin)plugin).Config.Bind<float>("DoorColor", "DoorColorB", 6f, (ConfigDescription)null);
			OpenDoorColorA = ((BaseUnityPlugin)plugin).Config.Bind<float>("DoorColor", "DoorColorA", 1f, (ConfigDescription)null);
			CurrentColor = new Color(OpenDoorColorR.Value, OpenDoorColorG.Value, OpenDoorColorB.Value, OpenDoorColorA.Value);
		}
	}
	internal class ConfigGUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Airlock Door Color";
		}

		public override void Draw()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (GUITools.DrawColorPicker(new Rect(8f, 58f, 480f, 160f), "Open Door Color", ref Configs.CurrentColor, Configs.DefaultColor, false, 0f, 20f))
			{
				Configs.UpdateColorConfig();
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.AirlockDoorColor";

		public const string PLUGIN_NAME = "AirlockDoorColor";

		public const string USERS_PLUGIN_NAME = "Airlock Door Color";

		public const string PLUGIN_VERSION = "0.0.3";

		public const string PLUGIN_DESCRIPTION = "Changes the open airlock door button color from green to white. Client Side.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107, Dragon";

		public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Airlock_Door_Color";
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "18107, Dragon";

		public override string Description => "Sets airlock button color for open doors to white";
	}
}