using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CG.Client.Ship;
using CG.Client.Ship.Views;
using CG.Ship.Hull;
using HarmonyLib;
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: AssemblyTitle("AirlockDoorColor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AirlockDoorColor")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b947e497-cb0f-405d-b3b9-3cdbfa9fed5c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.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("id107.airlockdoorcolor", "AirlockDoorColor", "0.0.3")]
[BepInProcess("Void Crew.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BepinPlugin : BaseUnityPlugin
{
private void Awake()
{
Harmony.CreateAndPatchAll(typeof(AirlockButtonPanelPatch), "id107.airlockdoorcolor");
Configs.Load(this);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.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 static class MyPluginInfo
{
public const string PLUGIN_GUID = "id107.airlockdoorcolor";
public const string PLUGIN_NAME = "AirlockDoorColor";
public const string PLUGIN_VERSION = "0.0.3";
}
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";
}