Decompiled source of AirlockDoorColor v0.0.1

AirlockDoorColor.dll

Decompiled 2 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;

[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.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("AirlockDoorColor")]
[assembly: AssemblyTitle("AirlockDoorColor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 FieldInfo diodeMaterial = AccessTools.Field(typeof(Diode), "_materialData");

		private static 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 ? BepinPlugin.Bindings.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 ? BepinPlugin.Bindings.CurrentColor : (flag2 ? closedColor : unsafeColor), val5);
				}
			}
		}
	}
	[BepInPlugin("AirlockDoorColor", "AirlockDoorColor", "0.0.1")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static class Bindings
		{
			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;
			}
		}

		private void Awake()
		{
			//IL_00be: 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)
			Harmony.CreateAndPatchAll(typeof(AirlockButtonPanelPatch), "AirlockDoorColor");
			Bindings.OpenDoorColorR = ((BaseUnityPlugin)this).Config.Bind<float>("DoorColor", "DoorColorR", 5.2f, (ConfigDescription)null);
			Bindings.OpenDoorColorG = ((BaseUnityPlugin)this).Config.Bind<float>("DoorColor", "DoorColorG", 5.2f, (ConfigDescription)null);
			Bindings.OpenDoorColorB = ((BaseUnityPlugin)this).Config.Bind<float>("DoorColor", "DoorColorB", 6f, (ConfigDescription)null);
			Bindings.OpenDoorColorA = ((BaseUnityPlugin)this).Config.Bind<float>("DoorColor", "DoorColorA", 1f, (ConfigDescription)null);
			Bindings.CurrentColor = new Color(Bindings.OpenDoorColorR.Value, Bindings.OpenDoorColorG.Value, Bindings.OpenDoorColorB.Value, Bindings.OpenDoorColorA.Value);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin AirlockDoorColor is loaded!");
		}
	}
	internal class ConfigGUI : ModSettingsMenu
	{
		public static void ColorPicker(Rect rect, string Name, ref Color Color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginArea(rect, "", GUIStyle.op_Implicit("Box"));
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(Name ?? "", Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(GUIStyle.op_Implicit("Box"), Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("R", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(10f) });
			Color.r = GUILayout.HorizontalSlider(Color.r, 0f, 20f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("G", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(10f) });
			Color.g = GUILayout.HorizontalSlider(Color.g, 0f, 20f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("B", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(10f) });
			Color.b = GUILayout.HorizontalSlider(Color.b, 0f, 20f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("A", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(10f) });
			Color.a = GUILayout.HorizontalSlider(Color.a, 0f, 1f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			GUILayout.BeginVertical(GUIStyle.op_Implicit("Box"), (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(44f),
				GUILayout.Height(44f)
			});
			GUI.color = Color;
			GUILayout.Label((Texture)new Texture2D(60, 40), Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
			GUILayout.Label($"{Color.r},{Color.g},{Color.b},{Color.a}", Array.Empty<GUILayoutOption>());
			GUILayout.EndArea();
		}

		public override void Draw()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			ColorPicker(new Rect(8f, 58f, 480f, 160f), "Open Door Color", ref BepinPlugin.Bindings.CurrentColor);
			if (GUILayout.Button("Reset Color", Array.Empty<GUILayoutOption>()))
			{
				BepinPlugin.Bindings.CurrentColor = BepinPlugin.Bindings.DefaultColor;
			}
			BepinPlugin.Bindings.UpdateColorConfig();
		}

		public override string Name()
		{
			return "AirlockDoorColor";
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)3;

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

		public override string Description => "Sets airlock button color for open doors to white. Configurable";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AirlockDoorColor";

		public const string PLUGIN_NAME = "AirlockDoorColor";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}