using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LightController_V2.Client;
using LightController_V2.Properties;
using LightController_V2.Server;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
[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("LightController_V2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LightController_V2")]
[assembly: AssemblyTitle("LightController_V2")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
static <Module>()
{
}
}
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;
}
}
}
namespace LightController_V2
{
[BepInPlugin("cobster.Lights", "LightController", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(MenuManager))]
internal class MenuManagerPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void displayWarning(MenuManager __instance)
{
if (!ConfigServer)
{
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void spawnNetManager(StartOfRound __instance)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
for (int i = 0; i < array.Length; i++)
{
if (((NetworkBehaviour)array[i]).IsOwner)
{
instance.sessionPlayer = array[i];
}
}
instance.LightControlObject = new GameObject("Cobster.Lights.Controller");
Functionality functionality = instance.LightControlObject.AddComponent<Functionality>();
LightController lightController = instance.LightControlObject.AddComponent<LightController>();
try
{
lightController.Execute();
}
catch
{
}
Control control = lightController.FindControlByName("Light Colour");
Control control2 = lightController.FindControlByName("Light Brightness %");
Control control3 = lightController.FindControlByName("Chroma Speed %");
if (((NetworkBehaviour)__instance).IsHost && ConfigServer)
{
GameObject val = Object.Instantiate<GameObject>(instance.NetworkerPrefab);
val.GetComponent<NetworkObject>().Spawn(false);
MultiplayerController.instance.ColourValue.Value = control.GetIndexFromList(ConfigColours);
MultiplayerController.instance.BrightnessValue.Value = ConfigBrightness;
MultiplayerController.instance.ChromaSpeedValue.Value = ConfigChromaSpeed;
}
functionality.useServer = false;
control.SetValue(control.GetIndexFromList(ConfigColours));
control2.SetValue(ConfigBrightness);
control3.SetValue(ConfigChromaSpeed);
if (ConfigServer)
{
functionality.useServer = true;
}
if (ConfigServer && !((NetworkBehaviour)__instance).IsHost)
{
control.SetValue(MultiplayerController.instance.ColourValue.Value);
control2.SetValue(MultiplayerController.instance.BrightnessValue.Value);
control3.SetValue(MultiplayerController.instance.ChromaSpeedValue.Value);
}
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void AddToPrefabs(ref GameNetworkManager __instance)
{
if (ConfigServer)
{
((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(instance.NetworkerPrefab);
}
}
}
private const string modGUID = "cobster.Lights";
private const string modName = "LightController";
private const string modVersion = "2.0.0";
internal ManualLogSource mls;
private readonly Harmony harmony = new Harmony("cobster.Lights");
public static Plugin instance;
public static string ConfigColours;
public static int ConfigBrightness;
public static int ConfigChromaSpeed;
public static bool ConfigServer = true;
public static float ConfigPanelX;
public static float ConfigPanelY;
public static float ConfigPanelZ;
public GameObject NetworkerPrefab;
public GameObject LightControlObject;
public PlayerControllerB sessionPlayer;
private void Awake()
{
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
instance = this;
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
AssetBundle val = AssetBundle.LoadFromMemory(Resources.lc_assets);
string[] allAssetNames = val.GetAllAssetNames();
NetworkerPrefab = val.LoadAsset<GameObject>("Assets/AssetPrefab/Cobster.Lights.Networker.prefab");
NetworkerPrefab.AddComponent<MultiplayerController>();
mls = Logger.CreateLogSource("cobster.Lights");
mls.LogInfo((object)"cobster.Lights running on ver 2.0.0");
ConfigColours = ((BaseUnityPlugin)this).Config.Bind<string>("Preset Settings", "Light Colour", "DEFAULT", "Colour of the lights that will show when loading in (DEFAULT, CHROMA, WHITE, RED, GREEN, BLUE, AQUA, ORANGE, GOLD, PURPLE).").Value;
ConfigBrightness = ((BaseUnityPlugin)this).Config.Bind<int>("Preset Settings", "Light Brightness", 12, "Brightness of the lights that will show when loading in (0 - 100). 0 = dim. 100 = bright.").Value;
ConfigChromaSpeed = ((BaseUnityPlugin)this).Config.Bind<int>("Preset Settings", "Chroma Speed", 20, "Brightness of the lights that will show when loading in (0 - 100). 0 = slow transition. 100 = fast transition.").Value;
ConfigServer = ((BaseUnityPlugin)this).Config.Bind<bool>("Preset Settings", "Multiplayer Compatibility", true, "If the mod works in mulitplayer. false = becomes fully client-sided and does not require others to install. true = becomes server-sided (with client-sided ingame options) and requires everyone to install").Value;
ConfigPanelX = ((BaseUnityPlugin)this).Config.Bind<float>("Panel Position", "X", 1.07f, "X Position").Value;
ConfigPanelY = ((BaseUnityPlugin)this).Config.Bind<float>("Panel Position", "Y", 2.5f, "Y Position").Value;
ConfigPanelZ = ((BaseUnityPlugin)this).Config.Bind<float>("Panel Position", "Z", -11.75f, "Z Position").Value;
ConfigColours = ConfigColours.ToLower().FirstCharToUpper();
mls.LogInfo((object)ConfigColours);
ConfigBrightness = Mathf.Clamp(ConfigBrightness, 0, 100);
ConfigChromaSpeed = Mathf.Clamp(ConfigChromaSpeed, 0, 100);
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
BepInPlugin metadata = pluginInfo.Value.Metadata;
if (metadata.GUID.Equals("mborsh.WiderShipMod"))
{
if (new Vector3(ConfigPanelX, ConfigPanelY, ConfigPanelZ) == new Vector3(1.065f, 2.4963f, -11.7502f))
{
ConfigPanelZ = -6.75f;
ConfigPanelY = 2.7f;
}
break;
}
}
harmony.PatchAll();
}
}
public static class StringExtensions
{
public static string FirstCharToUpper(this string input)
{
if (1 == 0)
{
}
if (input != null)
{
if (input == "")
{
throw new ArgumentException("input cannot be empty", "input");
}
string result = input[0].ToString().ToUpper() + input.Substring(1);
if (1 == 0)
{
}
return result;
}
throw new ArgumentNullException("input");
}
}
}
namespace LightController_V2.Server
{
internal class MultiplayerController : NetworkBehaviour
{
public static MultiplayerController instance;
public NetworkVariable<int> BrightnessValue = new NetworkVariable<int>(12345678, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);
public NetworkVariable<int> ColourValue = new NetworkVariable<int>(12345678, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);
public NetworkVariable<int> ChromaSpeedValue = new NetworkVariable<int>(12345678, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);
public float Cooldown = 1f;
private void Awake()
{
instance = this;
Debug.Log((object)"please just work instancing");
NetworkVariable<int> brightnessValue = BrightnessValue;
brightnessValue.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)brightnessValue.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnBrightnessChanged));
NetworkVariable<int> colourValue = ColourValue;
colourValue.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)colourValue.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnColourChanged));
NetworkVariable<int> chromaSpeedValue = ChromaSpeedValue;
chromaSpeedValue.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)chromaSpeedValue.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnChromaSpeedChanged));
}
private void Update()
{
if (((NetworkBehaviour)instance).IsOwner)
{
instance.Cooldown -= Time.deltaTime;
if (instance.Cooldown < 0f)
{
GetChromaStateClientRpc(Plugin.instance.LightControlObject.GetComponent<Functionality>().ChromaStatus);
Cooldown = 1f;
}
}
}
public void OnBrightnessChanged(int previous, int current)
{
LightController component = Plugin.instance.LightControlObject.GetComponent<LightController>();
Control control = component.FindControlByName("Light Brightness %");
Functionality component2 = Plugin.instance.LightControlObject.GetComponent<Functionality>();
((Component)component2).GetComponent<Functionality>().UpdateIntensity(current, server: true);
control.SetValue(current, invoke: false);
control.UpdateInformation(component.VariableScreen);
}
public void OnColourChanged(int previous, int current)
{
LightController component = Plugin.instance.LightControlObject.GetComponent<LightController>();
Control control = component.FindControlByName("Light Colour");
Plugin.instance.LightControlObject.GetComponent<Functionality>().UpdateColour(current, server: true);
control.SetValue(current, invoke: false);
control.UpdateInformation(component.VariableScreen);
}
public void OnChromaSpeedChanged(int previous, int current)
{
LightController component = Plugin.instance.LightControlObject.GetComponent<LightController>();
Control control = component.FindControlByName("Chroma Speed %");
Plugin.instance.LightControlObject.GetComponent<Functionality>().UpdateChromaSpeed(current, server: true);
control.SetValue(current, invoke: false);
control.UpdateInformation(component.VariableScreen);
}
public void SendControlNetworking(string id, int value)
{
switch (id)
{
case "brightness":
if (((NetworkBehaviour)instance).IsOwner)
{
UpdateBrightnessValueClientRpc(value);
}
else
{
UpdateBrightnessValueServerRpc(value);
}
break;
case "colour":
if (((NetworkBehaviour)instance).IsOwner)
{
UpdateColourValueClientRpc(value);
}
else
{
UpdateColourValueServerRpc(value);
}
break;
case "chromaspeed":
if (((NetworkBehaviour)instance).IsOwner)
{
UpdateChromaSpeedValueClientRpc(value);
}
else
{
UpdateChromaSpeedValueServerRpc(value);
}
break;
}
}
[ServerRpc(RequireOwnership = false)]
public void UpdateBrightnessValueServerRpc(int value)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3962382667u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, value);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3962382667u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
Debug.Log((object)"server");
UpdateBrightnessValueClientRpc(value);
}
}
}
[ClientRpc]
public void UpdateBrightnessValueClientRpc(int value)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3938824259u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, value);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3938824259u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Debug.Log((object)"client");
if (((NetworkBehaviour)instance).IsOwner)
{
value = Mathf.Clamp(value, 0, 100);
value = Mathf.RoundToInt((float)(value / 2)) * 2;
BrightnessValue.Value = value;
}
}
}
[ServerRpc(RequireOwnership = false)]
public void UpdateColourValueServerRpc(int value)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(834857335u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, value);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 834857335u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
UpdateColourValueClientRpc(value);
}
}
}
[ClientRpc]
public void UpdateColourValueClientRpc(int value)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4092170537u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, value);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4092170537u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviour)instance).IsOwner)
{
value = Mathf.Clamp(value, 0, 9);
ColourValue.Value = value;
}
}
}
[ServerRpc(RequireOwnership = false)]
public void UpdateChromaSpeedValueServerRpc(int value)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3552544853u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, value);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3552544853u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
UpdateChromaSpeedValueClientRpc(value);
}
}
}
[ClientRpc]
public void UpdateChromaSpeedValueClientRpc(int value)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4288948843u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, value);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4288948843u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Debug.Log((object)"eriojgferiogijoijo");
if (((NetworkBehaviour)instance).IsOwner)
{
value = Mathf.Clamp(value, 0, 100);
value = Mathf.RoundToInt((float)value / 5f) * 5;
ChromaSpeedValue.Value = value;
}
}
}
[ClientRpc]
public void GetChromaStateClientRpc(float value)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//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_007d: 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)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1038293797u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1038293797u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Plugin.instance.LightControlObject.GetComponent<Functionality>().ChromaStatus = value;
Debug.Log((object)value);
}
}
}
protected override void __initializeVariables()
{
if (BrightnessValue == null)
{
throw new Exception("MultiplayerController.BrightnessValue cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)BrightnessValue).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)BrightnessValue, "BrightnessValue");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)BrightnessValue);
if (ColourValue == null)
{
throw new Exception("MultiplayerController.ColourValue cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)ColourValue).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)ColourValue, "ColourValue");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)ColourValue);
if (ChromaSpeedValue == null)
{
throw new Exception("MultiplayerController.ChromaSpeedValue cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)ChromaSpeedValue).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)ChromaSpeedValue, "ChromaSpeedValue");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)ChromaSpeedValue);
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_MultiplayerController()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3962382667u, new RpcReceiveHandler(__rpc_handler_3962382667));
NetworkManager.__rpc_func_table.Add(3938824259u, new RpcReceiveHandler(__rpc_handler_3938824259));
NetworkManager.__rpc_func_table.Add(834857335u, new RpcReceiveHandler(__rpc_handler_834857335));
NetworkManager.__rpc_func_table.Add(4092170537u, new RpcReceiveHandler(__rpc_handler_4092170537));
NetworkManager.__rpc_func_table.Add(3552544853u, new RpcReceiveHandler(__rpc_handler_3552544853));
NetworkManager.__rpc_func_table.Add(4288948843u, new RpcReceiveHandler(__rpc_handler_4288948843));
NetworkManager.__rpc_func_table.Add(1038293797u, new RpcReceiveHandler(__rpc_handler_1038293797));
}
private static void __rpc_handler_3962382667(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int value = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref value);
target.__rpc_exec_stage = (__RpcExecStage)1;
((MultiplayerController)(object)target).UpdateBrightnessValueServerRpc(value);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3938824259(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int value = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref value);
target.__rpc_exec_stage = (__RpcExecStage)2;
((MultiplayerController)(object)target).UpdateBrightnessValueClientRpc(value);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_834857335(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int value = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref value);
target.__rpc_exec_stage = (__RpcExecStage)1;
((MultiplayerController)(object)target).UpdateColourValueServerRpc(value);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4092170537(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int value = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref value);
target.__rpc_exec_stage = (__RpcExecStage)2;
((MultiplayerController)(object)target).UpdateColourValueClientRpc(value);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3552544853(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int value = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref value);
target.__rpc_exec_stage = (__RpcExecStage)1;
((MultiplayerController)(object)target).UpdateChromaSpeedValueServerRpc(value);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4288948843(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int value = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref value);
target.__rpc_exec_stage = (__RpcExecStage)2;
((MultiplayerController)(object)target).UpdateChromaSpeedValueClientRpc(value);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1038293797(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
float value = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref value, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((MultiplayerController)(object)target).GetChromaStateClientRpc(value);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "MultiplayerController";
}
}
}
namespace LightController_V2.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("LightController_V2.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] lc_assets
{
get
{
object @object = ResourceManager.GetObject("lc_assets", resourceCulture);
return (byte[])@object;
}
}
internal Resources()
{
}
}
}
namespace LightController_V2.Client
{
public class Functionality : MonoBehaviour
{
public string Colour;
public float Brightness;
public Vector2 BrightnessRange = new Vector2(50f, 700f);
public float ChromaStatus = 0f;
public float ChromaSpeed = 15f;
public bool useServer = true;
public string ServerColour;
public float ServerBrightness;
public float ServerChromaSpeed;
public Vector2 ChromaSpeedRange = new Vector2(30f, 1f);
public List<LightObj> ChromaObjects = new List<LightObj>();
public List<LightObj> LightObjects = new List<LightObj>();
public Dictionary<string, ColourConstruct> ColourDictionary = new Dictionary<string, ColourConstruct>
{
{
"Default",
new ColourConstruct(new Vector4(1f, 1f, 1f, 1f), 6901f, 0f)
},
{
"White",
new ColourConstruct(new Vector4(1f, 1f, 1f, 1f), 12000f, 0f)
},
{
"Chroma",
new ColourConstruct(Vector4.zero, 6901f, 0f)
},
{
"Red",
new ColourConstruct(new Vector4(1f, 0.3f, 0.3f, 1f), 6901f, 0f)
},
{
"Green",
new ColourConstruct(new Vector4(0.3f, 0.7f, 0.3f, 1f), 6901f, 0f)
},
{
"Blue",
new ColourConstruct(new Vector4(0.3f, 0.3f, 1f, 1f), 6901f, 0f)
},
{
"Aqua",
new ColourConstruct(new Vector4(0.3f, 0.7f, 1f, 1f), 6901f, 0f)
},
{
"Orange",
new ColourConstruct(new Vector4(1f, 0.54f, 0f, 1f), 6901f, 0f)
},
{
"Gold",
new ColourConstruct(new Vector4(0.59f, 0.54f, 0.13f, 1f), 6901f, 0f)
},
{
"Purple",
new ColourConstruct(new Vector4(0.51f, 0.13f, 0.83f, 1f), 6901f, 0f)
}
};
private Gradient ChromaGradient = new Gradient();
private GradientColorKey[] ChromaGradientColourKey = (GradientColorKey[])(object)new GradientColorKey[7];
public static Color NewLerpColour(int r, int g, int b)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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 Color((float)(r / 200), (float)(g / 200), (float)(b / 200));
}
public void LightSyncButton(bool ButtonType)
{
Debug.Log((object)"Sync");
}
private GradientColorKey[] ConstructGradientColourKey(Vector3[] lc)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
float num = 1f / ((float)lc.Length + 1f);
GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[lc.Length];
Color val = default(Color);
for (int i = 0; i < lc.Length; i++)
{
((Color)(ref val))..ctor(lc[i].x, lc[i].y, lc[i].z);
array[i] = new GradientColorKey(val, num * (float)i);
}
return array;
}
private GradientAlphaKey[] ConstructGradientAlphaKey()
{
//IL_0013: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
return (GradientAlphaKey[])(object)new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(1f, 1f)
};
}
private void Start()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
Vector3[] lc = (Vector3[])(object)new Vector3[8]
{
new Vector3(0.74f, 0f, 1.055f),
new Vector3(0.375f, 0f, 0.65f),
new Vector3(0f, 0f, 1.275f),
new Vector3(0f, 1.275f, 0f),
new Vector3(1.275f, 1.275f, 0f),
new Vector3(1.275f, 0.635f, 0f),
new Vector3(1.275f, 0f, 0f),
new Vector3(0.74f, 0f, 1.055f)
};
ChromaGradient.SetKeys(ConstructGradientColourKey(lc), ConstructGradientAlphaKey());
}
public void ChromaSpeedButton(bool ButtonType)
{
DefineLights();
DefineServerValues();
Control control = ((Component)this).GetComponent<LightController>().FindControlByName("Chroma Speed %");
MultiplayerController instance = MultiplayerController.instance;
if (useServer && (Object)(object)instance != (Object)null)
{
instance.SendControlNetworking("chromaspeed", control.controlValue);
return;
}
UpdateChromaSpeed(control.controlValue, server: false);
control.Save();
}
public void UpdateChromaSpeed(int value, bool server)
{
float num = ChromaSpeedRange.y - ChromaSpeedRange.x;
if (server)
{
ServerChromaSpeed = (float)value * 1f / 100f * num + ChromaSpeedRange.x;
}
else
{
ChromaSpeed = (float)value * 1f / 100f * num + ChromaSpeedRange.x;
}
}
public void LightColourButton(bool ButtonType)
{
DefineLights();
DefineServerValues();
Control control = ((Component)this).GetComponent<LightController>().FindControlByName("Light Colour");
MultiplayerController instance = MultiplayerController.instance;
if (useServer && (Object)(object)instance != (Object)null)
{
instance.SendControlNetworking("colour", control.controlIndexValue.GetValueOrDefault());
return;
}
UpdateColour(control.controlIndexValue.GetValueOrDefault(), server: false);
control.Save();
}
public void UpdateColour(int index, bool server)
{
ChromaObjects = new List<LightObj>();
Control control = ((Component)this).GetComponent<LightController>().FindControlByName("Light Colour");
if (server)
{
ServerColour = control.controlIndexs[index];
}
else
{
Colour = control.controlIndexs[index];
}
string key = (useServer ? ServerColour : Colour);
float num = (useServer ? ServerBrightness : Brightness);
ColourConstruct colourConstruct = ColourDictionary[key];
if (colourConstruct.Chroma)
{
ChromaObjects = new List<LightObj>(LightObjects);
for (int i = 0; i < LightObjects.Count; i++)
{
LightObjects[i].ChangeLightTemperature(colourConstruct.Temperature);
LightObjects[i].ChangeLightBrightness(num + colourConstruct.AddedBrightness);
}
}
else
{
for (int j = 0; j < LightObjects.Count; j++)
{
LightObjects[j].ChangeLightColour(colourConstruct);
LightObjects[j].ChangeLightTemperature(colourConstruct.Temperature);
LightObjects[j].ChangeLightBrightness(num + colourConstruct.AddedBrightness);
}
}
}
public void LightIntenseButton(bool ButtonType)
{
DefineLights();
DefineServerValues();
Control control = ((Component)this).GetComponent<LightController>().FindControlByName("Light Brightness %");
MultiplayerController instance = MultiplayerController.instance;
if (useServer && (Object)(object)instance != (Object)null)
{
instance.SendControlNetworking("brightness", control.controlValue);
return;
}
UpdateIntensity(control.controlValue, server: false);
control.Save();
}
public void UpdateIntensity(int value, bool server)
{
float num = BrightnessRange.y - BrightnessRange.x;
if (server)
{
ServerBrightness = (float)value * 1f / 100f * num + BrightnessRange.x;
}
else
{
Brightness = (float)value * 1f / 100f * num + BrightnessRange.x;
}
float num2 = (useServer ? ServerBrightness : Brightness);
string key = (useServer ? ServerColour : Colour);
ColourConstruct colourConstruct = ColourDictionary[key];
for (int i = 0; i < LightObjects.Count; i++)
{
LightObjects[i].ChangeLightBrightness(num2 + colourConstruct.AddedBrightness);
}
}
public void LightHostButton(bool ButtonType)
{
Control control = ((Component)this).GetComponent<LightController>().FindControlByName("Light Syncing");
useServer = control.controlIndexValue == 0;
if (useServer)
{
SwitchToServer();
return;
}
((Component)this).GetComponent<LightController>().FindControlByName("Chroma Speed %").LoadSave();
((Component)this).GetComponent<LightController>().FindControlByName("Light Colour").LoadSave();
((Component)this).GetComponent<LightController>().FindControlByName("Light Brightness %").LoadSave();
}
private void Update()
{
float num = (useServer ? ServerChromaSpeed : ChromaSpeed);
ChromaStatus += 1f / num * Time.deltaTime;
if ((double)ChromaStatus > 0.5)
{
ChromaStatus = 0f;
}
}
private void FixedUpdate()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
Color val = ChromaGradient.Evaluate(ChromaStatus);
float num = (useServer ? ServerChromaSpeed : ChromaSpeed);
for (int i = 0; i < ChromaObjects.Count; i++)
{
ChromaObjects[i].ObjectLight.color = Color.Lerp(ChromaObjects[i].ObjectLight.color, val, Time.deltaTime * (15f / num));
}
}
private void DefineLights()
{
if (LightObjects.Count != 0)
{
return;
}
Transform transform = GameObject.Find("ShipElectricLights").transform;
for (int i = 0; i < transform.childCount; i++)
{
Transform child = transform.GetChild(i);
if ((Object)(object)((Component)child).GetComponent<Light>() != (Object)null)
{
LightObjects.Add(new LightObj(((Component)child).gameObject, ((Component)child).GetComponent<Light>()));
}
}
}
private void DefineServerValues()
{
if (!((Object)(object)MultiplayerController.instance == (Object)null) && (CheckIfNull(ServerChromaSpeed) || CheckIfNull(ServerBrightness) || ServerColour == null))
{
MultiplayerController instance = MultiplayerController.instance;
UpdateChromaSpeed(instance.ChromaSpeedValue.Value, server: true);
UpdateColour(instance.ColourValue.Value, server: true);
UpdateIntensity(instance.BrightnessValue.Value, server: true);
if (useServer)
{
SwitchToServer();
}
}
}
private void SwitchToServer()
{
useServer = true;
LightController component = ((Component)this).GetComponent<LightController>();
MultiplayerController instance = MultiplayerController.instance;
component.FindControlByName("Chroma Speed %").SetValue(instance.ChromaSpeedValue.Value);
component.FindControlByName("Light Colour").SetValue(instance.ColourValue.Value);
component.FindControlByName("Light Brightness %").SetValue(instance.BrightnessValue.Value);
UpdateChromaSpeed(instance.ChromaSpeedValue.Value, server: true);
UpdateColour(instance.ColourValue.Value, server: true);
UpdateIntensity(instance.BrightnessValue.Value, server: true);
}
private bool CheckIfNull(float val)
{
return string.IsNullOrEmpty(val.ToString());
}
}
public class ColourConstruct
{
public bool Chroma;
public Vector4 ColourRGBA;
public float Temperature;
public float AddedBrightness;
public ColourConstruct(Vector4 colour, float temp, float _brightness)
{
//IL_000f: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
Chroma = false;
if (colour == Vector4.zero)
{
Chroma = true;
}
ColourRGBA = colour;
Temperature = temp;
AddedBrightness = _brightness;
}
}
public class LightObj
{
public GameObject LightObject;
public Light ObjectLight;
public LightObj(GameObject _lObject, Light _lComponent)
{
LightObject = _lObject;
ObjectLight = _lComponent;
}
public bool ChangeLightColour(ColourConstruct Colour)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if (Colour.Chroma)
{
return false;
}
ObjectLight.color = Color.op_Implicit(Colour.ColourRGBA);
return true;
}
public void ChangeLightTemperature(float temp)
{
ObjectLight.colorTemperature = temp;
}
public void ChangeLightBrightness(float brightness)
{
ObjectLight.intensity = brightness;
}
}
public class LightController : MonoBehaviour
{
public List<ButtonEvent> TriggerQueue = new List<ButtonEvent>();
public LightController instance;
public Control CurrentControl;
public List<Control> ControlList;
public Screen VariableScreen;
public Functionality localSave;
private ButtonEvent AdditionWeighing1;
private ButtonEvent SubtractingWeighing1;
private ButtonEvent AdditionWeighing2;
private ButtonEvent SubtractingWeighing2;
public void Execute()
{
instance = this;
localSave = ((Component)this).GetComponent<Functionality>();
ControlList = new List<Control>();
ControlList.Add(new Control("Light Colour", localSave.LightColourButton, _buttonHold: false, 1f, _useValue: false, 1, new List<string>(localSave.ColourDictionary.Keys), "Previous Colour", "Next Colour", 0, -1, _ignoreSave: false));
ControlList.Add(new Control("Light Brightness %", localSave.LightIntenseButton, _buttonHold: true, 0.1f, _useValue: true, 2, null, "Decrease Intensity", "Increase Intensity", 0, 100, _ignoreSave: false));
ControlList.Add(new Control("Chroma Speed %", localSave.ChromaSpeedButton, _buttonHold: true, 0.1f, _useValue: true, 5, null, "Decrease Speed", "Increase Speed", 0, 100, _ignoreSave: false));
if (Plugin.ConfigServer)
{
ControlList.Add(new Control("Light Syncing", localSave.LightHostButton, _buttonHold: true, 0.1f, _useValue: false, 5, new List<string> { "Server", "Local" }, "Switch", "Switch", 0, 100, _ignoreSave: false));
}
CurrentControl = ControlList[0];
ConstructPanel();
UpdateControlList();
if (Plugin.ConfigServer)
{
MultiplayerController.instance.SendControlNetworking("getchromastate", 0);
}
}
public Control FindControlByName(string name)
{
for (int i = 0; i < ControlList.Count; i++)
{
if (ControlList[i].name == name)
{
return ControlList[i];
}
}
return null;
}
private void FixedUpdate()
{
for (int i = 0; i < TriggerQueue.Count; i++)
{
TriggerQueue[i].ButtonPressed(this);
}
}
private void UpdateControlList()
{
for (int i = 0; i < ControlList.Count; i++)
{
ControlList[i].action.Invoke(false);
}
}
private void ConstructPanel()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
UnityAction<bool> uAction = OnControlSwitch;
UnityAction<bool> uAction2 = OnControlButton;
AdditionWeighing1 = NewButton(ButtonType: true, "Next", 1.2f, new Vector3(Plugin.ConfigPanelX + 0.23f, Plugin.ConfigPanelY - 0.2f, Plugin.ConfigPanelZ), uAction, new Vector3(90f, 0f, 0f));
SubtractingWeighing1 = NewButton(ButtonType: false, "Previous", 1.2f, new Vector3(Plugin.ConfigPanelX - 0.07f, Plugin.ConfigPanelY - 0.2f, Plugin.ConfigPanelZ), uAction, new Vector3(90f, 0f, 0f));
AdditionWeighing2 = NewButton(ButtonType: true, "Add", 1f, new Vector3(Plugin.ConfigPanelX + 0.23f, Plugin.ConfigPanelY - 0.5f, Plugin.ConfigPanelZ), uAction2, new Vector3(90f, 0f, 0f));
SubtractingWeighing2 = NewButton(ButtonType: false, "Subtract", 1f, new Vector3(Plugin.ConfigPanelX - 0.07f, Plugin.ConfigPanelY - 0.5f, Plugin.ConfigPanelZ), uAction2, new Vector3(90f, 0f, 0f));
VariableScreen = NewScreen(10f, 10f, new Vector3(Plugin.ConfigPanelX, Plugin.ConfigPanelY, Plugin.ConfigPanelZ), new Vector3(0f, 180f, 180f));
CurrentControl.UseControl(SubtractingWeighing2, AdditionWeighing2, VariableScreen);
}
public void OnControlButton(bool _ButtonType)
{
CurrentControl.ControlAction(_ButtonType, VariableScreen);
}
public void OnControlSwitch(bool ButtonType)
{
int num = ControlList.Count - 1;
int num2 = ControlList.IndexOf(CurrentControl) + (ButtonType ? 1 : (-1));
if (num2 > num)
{
num2 = 0;
}
if (num2 < 0)
{
num2 = num;
}
CurrentControl = ControlList[num2];
CurrentControl.UseControl(SubtractingWeighing2, AdditionWeighing2, VariableScreen);
}
private ButtonEvent NewButton(bool ButtonType, string buttonName, float size, Vector3 Position, UnityAction<bool> UAction, Vector3 Rotation)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_004d: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("HangarDoorButtonPanel");
if ((Object)(object)val == (Object)null)
{
Debug.Log((object)"Panel wasnt found");
return new ButtonEvent(new GameObject("null"), new GameObject("null"), "", _buttonType: false, instance, UAction, 0);
}
GameObject val2 = Object.Instantiate<GameObject>(val);
GameObject val3 = (ButtonType ? ((Component)val2.transform.Find("StartButton")).gameObject : ((Component)val2.transform.Find("StopButton")).gameObject);
val2.transform.parent = GameObject.Find("HangarDoorButtonPanel").transform;
((Object)val2).name = buttonName + " (Cobster.Lights.Button)";
Object.Destroy((Object)(object)val2.GetComponent<MeshFilter>());
Object.Destroy((Object)(object)val2.GetComponent<MeshRenderer>());
foreach (Transform item in val2.transform)
{
Transform val4 = item;
if (((Object)val4).name != "Audio" && ((Object)val4).name != ((Object)val3).name)
{
Object.Destroy((Object)(object)((Component)val4).gameObject);
}
}
float num = -1.1921f * size;
float num2 = 1f - size + 1f;
Vector3 localScale = val3.transform.GetChild(0).localScale;
val3.transform.localScale = new Vector3(num, -1.1921f, num);
val3.transform.GetChild(0).rotation = Quaternion.Euler(Vector3.zero);
val3.transform.GetChild(0).localPosition = Vector3.zero;
val3.transform.GetChild(0).localScale = new Vector3(localScale.x * num2, localScale.y * num2, localScale.z * num2);
val2.transform.Find("Audio").localPosition = Vector3.zero;
val2.transform.position = Position;
val2.transform.rotation = Quaternion.Euler(Rotation);
val2.transform.position = (ButtonType ? (val2.transform.position + val2.transform.forward * 0.1f) : (val2.transform.position - val2.transform.forward * 0.1f));
return new ButtonEvent(val3, val2, buttonName, ButtonType, instance, UAction, 1);
}
private Screen NewScreen(float width, float height, Vector3 position, Vector3 rotation)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("HangarDoorButtonPanel");
if ((Object)(object)val == (Object)null)
{
Debug.Log((object)"Panel wasnt found");
return null;
}
GameObject gameObject = ((Component)val.transform.Find("ElevatorPanelScreen")).gameObject;
GameObject val2 = Object.Instantiate<GameObject>(gameObject);
val2.transform.parent = val.transform;
val2.transform.position = position;
val2.transform.eulerAngles = rotation;
val2.SetActive(true);
((Object)val2).name = "Cobster.Lights.Screen";
GameObject gameObject2 = ((Component)val2.transform.GetChild(0).GetChild(0)).gameObject;
GameObject gameObject3 = ((Component)val2.transform.GetChild(0).GetChild(1)).gameObject;
val2.transform.localScale = new Vector3(0.0009f, 0.0003f, 0.0005f);
gameObject2.transform.localScale = new Vector3(-1.9f, 5.9661f, 1f);
gameObject3.transform.localScale = new Vector3(-1.9f, 5.9661f, 1f);
((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).autoSizeTextContainer = true;
((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).autoSizeTextContainer = true;
return new Screen(val2);
}
}
public class ButtonEvent
{
public GameObject button;
public GameObject buttonPanel;
public InteractTrigger buttonTrigger;
public bool buttonType;
public int buttonSpeed;
public UnityAction<bool> onPress;
public UnityAction<bool> onPressSecondary;
private bool hasPressed = false;
public string hoverTip;
public ButtonEvent(GameObject _button, GameObject _buttonContainer, string _name, bool _buttonType, LightController _lc, UnityAction<bool> _onPress, int _buttonSpeed)
{
button = _button;
buttonPanel = _buttonContainer;
buttonTrigger = ((Component)button.transform.GetChild(0)).gameObject.GetComponent<InteractTrigger>();
buttonType = _buttonType;
buttonSpeed = _buttonSpeed;
onPress = _onPress;
onPressSecondary = null;
hoverTip = _name;
UpdateTip(hoverTip);
buttonTrigger.cooldownTime = 0.05f;
_lc.TriggerQueue.Add(this);
}
public void UpdateTip(string tip)
{
buttonTrigger.hoverTip = tip + " : [E]";
}
public void ButtonPressed(LightController lightcontroller)
{
if (buttonTrigger.currentCooldownValue > 0f)
{
if (!hasPressed)
{
hasPressed = true;
onPress.Invoke(buttonType);
if (onPressSecondary != null)
{
onPressSecondary.Invoke(buttonType);
}
}
}
else
{
hasPressed = false;
}
}
}
public class Screen
{
public GameObject screenObject;
private string title;
private string subtitle;
public Screen(GameObject _screen)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
screenObject = _screen;
title = "";
subtitle = "";
ChangeTitle(title);
ChangeInformation(subtitle);
ChangeTitleFormatting(new Vector4(0f, -10f, -5f, 0f), (TextAlignmentOptions)258, 20f);
ChangeInformationFormatting(new Vector4(0f, -10f, -5f, 0f), (TextAlignmentOptions)514, 25);
}
public void ChangeTitleFormatting(Vector4 margin, TextAlignmentOptions alignment, float fontSize = -1f)
{
//IL_0036: 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)
TextMeshProUGUI component = ((Component)screenObject.transform.GetChild(0).GetChild(0)).GetComponent<TextMeshProUGUI>();
if (fontSize != -1f)
{
((TMP_Text)component).fontSize = fontSize;
}
((TMP_Text)component).margin = margin;
((TMP_Text)component).alignment = alignment;
}
public void ChangeInformationFormatting(Vector4 margin, TextAlignmentOptions alignment, int fontSize = -1)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI component = ((Component)screenObject.transform.GetChild(0).GetChild(1)).GetComponent<TextMeshProUGUI>();
if (fontSize != -1)
{
((TMP_Text)component).fontSize = fontSize;
}
((TMP_Text)component).margin = margin;
((TMP_Text)component).alignment = alignment;
}
public void ChangeTitle(string _title)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)screenObject.transform.GetChild(0).GetChild(0)).gameObject;
TextMeshProUGUI component = gameObject.GetComponent<TextMeshProUGUI>();
Vector2 preferredValues = ((TMP_Text)component).GetPreferredValues(_title);
((TMP_Text)component).text = _title;
gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(1000f, 10f);
}
public void ChangeInformation(string _info)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)screenObject.transform.GetChild(0).GetChild(1)).gameObject;
TextMeshProUGUI component = gameObject.GetComponent<TextMeshProUGUI>();
Vector2 preferredValues = ((TMP_Text)component).GetPreferredValues(_info);
((TMP_Text)component).text = _info;
gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(1000f, 10f);
}
}
public class Control
{
public string name;
private string negativeButtonTip;
private string positiveButtonTip;
public UnityAction<bool> action;
private bool buttonHold;
private float buttonSpeed;
public int ControlValueJump;
public int controlValue;
private int save_controlValue;
private int min;
private bool useMin;
private int max;
private bool useMax;
public int? controlIndexValue;
private int? save_controlIndexValue;
public List<string>? controlIndexs;
private bool ValueOrList;
private bool ignoreSave;
public Control(string _name, UnityAction<bool> onClick, bool _buttonHold, float _buttonSpeed, bool _useValue, int _controlJump, List<string>? _controlList, string _negtip, string _postip, int _min, int _max, bool _ignoreSave)
{
name = _name;
action = onClick;
buttonHold = _buttonHold;
buttonSpeed = _buttonSpeed;
controlValue = 0;
save_controlValue = 0;
controlIndexs = _controlList;
ValueOrList = _useValue;
if (!controlIndexValue.HasValue)
{
controlIndexValue = 0;
save_controlIndexValue = 0;
}
useMin = _min >= 0;
useMax = _max >= 0;
min = _min;
max = _max;
negativeButtonTip = _negtip;
positiveButtonTip = _postip;
ignoreSave = _ignoreSave;
ControlValueJump = _controlJump;
}
public void ControlAction(bool buttonType, Screen screen)
{
if (ValueOrList)
{
controlValue = GetValue(ControlValueJump * (buttonType ? 1 : (-1)));
}
else
{
controlIndexValue = GetListValue(buttonType ? 1 : (-1));
}
UpdateInformation(screen);
}
public Control UseControl(ButtonEvent negativeButton, ButtonEvent positiveButton, Screen screen)
{
negativeButton.onPressSecondary = action;
positiveButton.onPressSecondary = action;
negativeButton.UpdateTip(negativeButtonTip);
positiveButton.UpdateTip(positiveButtonTip);
negativeButton.buttonTrigger.holdInteraction = buttonHold;
positiveButton.buttonTrigger.holdInteraction = buttonHold;
negativeButton.buttonTrigger.timeToHold = buttonSpeed;
positiveButton.buttonTrigger.timeToHold = buttonSpeed;
screen.ChangeTitle(name);
UpdateInformation(screen);
return this;
}
public void UpdateInformation(Screen screen)
{
if (ValueOrList)
{
screen.ChangeInformation("-" + ControlValueJump + " < " + controlValue + " > " + ControlValueJump + "+");
}
else
{
screen.ChangeInformation(controlIndexs[controlIndexValue.GetValueOrDefault()]);
}
}
public void Save()
{
save_controlIndexValue = controlIndexValue;
save_controlValue = controlValue;
}
public void LoadSave()
{
if (!ignoreSave)
{
controlIndexValue = save_controlIndexValue;
controlValue = save_controlValue;
action.Invoke(false);
}
}
public void SetValue(int val, bool invoke = true)
{
controlIndexValue = val;
controlValue = val;
if (invoke)
{
action.Invoke(false);
}
}
public int GetValue(int change)
{
int num = controlValue + change;
if (useMin)
{
num = Mathf.Max(num, min);
}
if (useMax)
{
num = Mathf.Min(num, max);
}
return num;
}
public int GetIndexFromList(string str)
{
return controlIndexs.IndexOf(str);
}
public int GetListValue(int change)
{
int? num = controlIndexValue + change;
if (num < 0)
{
num = controlIndexs.Count + num;
}
if (num > controlIndexs.Count - 1)
{
num -= controlIndexs.Count;
}
return num.GetValueOrDefault();
}
}
}