using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ColourfulFlashlights;
using ColourfulFlashlights.NetcodePatcher;
using ColourfulFlashlights.Properties;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TerminalApi;
using TerminalApi.Events;
using Unity.Netcode;
using UnityEngine;
[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("ColourfulFlashlights")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("3.1.1.0")]
[assembly: AssemblyInformationalVersion("3.1.1")]
[assembly: AssemblyProduct("ColourfulFlashlights")]
[assembly: AssemblyTitle("ColourfulFlashlights")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 ColourfulFlashlights
{
public static class Assets
{
public static AssetBundle MainAssetBundle;
public static void PopulateAssets()
{
if ((Object)(object)MainAssetBundle == (Object)null)
{
Debug.Log((object)$"{Resources.cfasset}");
MainAssetBundle = AssetBundle.LoadFromMemory(Resources.cfasset);
}
}
}
public static class Helpers
{
private static string persistentDataPath = Application.persistentDataPath + "\\ColourfulFlashlights.txt";
public static Dictionary<string, string> colourDict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "White", "#FFFFFF" },
{ "Blue", "#0000FF" },
{ "Red", "#FF0000" },
{ "Green", "#2FDE2F" },
{ "Yellow", "#FFFF00" },
{ "Pink", "#FC96FF" },
{ "Orange", "#FF7B00" },
{ "Purple", "#7E00F5" }
};
public static Color? HexStringToColor(string hex)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (!hex.StartsWith("#") || hex.Length > 7)
{
return null;
}
Color value = default(Color);
if (ColorUtility.TryParseHtmlString(hex, ref value))
{
return value;
}
return null;
}
public static string ColorToHexString(Color colour)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
string text = ColorUtility.ToHtmlStringRGB(colour);
return "#" + text;
}
public static Color? NameToColor(string name)
{
if (colourDict.TryGetValue(name, out var value))
{
return HexStringToColor(value);
}
return null;
}
public static void WriteCFValue()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//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_003b: Unknown result type (might be due to invalid IL or missing references)
try
{
string text = ColorToHexString(Plugin.activeColour) ?? "";
Color? previousColour = Plugin.previousColour;
if (previousColour.HasValue)
{
Color valueOrDefault = previousColour.GetValueOrDefault();
if (true)
{
text = text + "\n" + ColorToHexString(valueOrDefault);
}
}
File.WriteAllText(persistentDataPath, text);
Plugin.mls.LogDebug((object)"Successfully wrote ColourfulFlashlights.txt");
}
catch (IOException ex)
{
Plugin.mls.LogError((object)"Failed to write ColourfulFlashlights.txt");
Plugin.mls.LogError((object)ex.ToString());
}
}
public static void ReadCFValue()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
try
{
if (File.Exists(persistentDataPath))
{
string[] array = File.ReadAllLines(persistentDataPath);
if (array.Length == 0)
{
return;
}
Color? val = HexStringToColor(array[0]);
if (val.HasValue)
{
Color valueOrDefault = val.GetValueOrDefault();
if (true)
{
Plugin.activeColour = valueOrDefault;
}
}
if (array.Length > 1)
{
Color? val2 = HexStringToColor(array[1]);
if (val2.HasValue)
{
Color valueOrDefault2 = val2.GetValueOrDefault();
if (true)
{
Plugin.previousColour = valueOrDefault2;
}
}
}
Plugin.mls.LogDebug((object)"Successfully read ColourfulFlashlights.txt");
}
else
{
Plugin.mls.LogDebug((object)"ColourfulFlashlights.txt does not exist");
}
}
catch (IOException ex)
{
Plugin.mls.LogError((object)"Failed to read ColourfulFlashlights.txt");
Plugin.mls.LogError((object)ex.ToString());
}
}
}
public struct PlayerColour : INetworkSerializable, IEquatable<PlayerColour>
{
public ulong ClientId;
public Color Color;
public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
((BufferSerializer<ulong>*)(&serializer))->SerializeValue<ulong>(ref ClientId, default(ForPrimitives));
serializer.SerializeValue(ref Color);
}
public bool Equals(PlayerColour other)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
return ClientId == other.ClientId && ((Color)(ref Color)).Equals(other.Color);
}
public override bool Equals(object obj)
{
return obj is PlayerColour other && Equals(other);
}
public override int GetHashCode()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return HashCode.Combine<ulong, Color>(ClientId, Color);
}
}
public class CFNetwork : NetworkBehaviour
{
public NetworkList<PlayerColour> PlayerColours;
public static CFNetwork Instance { get; private set; }
private void Awake()
{
Instance = this;
PlayerColours = new NetworkList<PlayerColour>();
}
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
PlayerColours.OnListChanged += OnListChanged;
Plugin.mls.LogInfo((object)"CFNetwork Ready");
}
public override void OnNetworkDespawn()
{
((NetworkBehaviour)this).OnNetworkDespawn();
PlayerColours.OnListChanged -= OnListChanged;
Plugin.mls.LogInfo((object)"CFNetwork Closed");
}
private void OnListChanged(NetworkListEvent<PlayerColour> e)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
ApplyFlashlightColour(e.Value.ClientId, e.Value.Color);
}
public bool TryGetColour(ulong clientId, out Color colour)
{
//IL_0052: 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_0031: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < PlayerColours.Count; i++)
{
if (PlayerColours[i].ClientId == clientId)
{
colour = PlayerColours[i].Color;
return true;
}
}
colour = default(Color);
return false;
}
private void ApplyFlashlightColour(ulong clientId, Color color)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = ((IEnumerable<PlayerControllerB>)RoundManager.Instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => p.playerClientId == clientId));
if (!((Object)(object)val != (Object)null))
{
return;
}
IEnumerable<FlashlightItem> enumerable = val.ItemSlots.OfType<FlashlightItem>();
foreach (FlashlightItem item in enumerable)
{
item.flashlightBulb.color = color;
item.flashlightBulbGlow.color = color;
val.helmetLight.color = color;
}
Plugin.mls.LogDebug((object)$"Changed flashlight color of player {clientId} to {color}");
}
[ServerRpc(RequireOwnership = false)]
public void SetPlayerColourServerRpc(ulong clientId, Color color)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_0096: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2167799236u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, clientId);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref color);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2167799236u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
base.__rpc_exec_stage = (__RpcExecStage)0;
Plugin.mls.LogDebug((object)"SetPlayerColourServerRpc Sent");
if (!((NetworkBehaviour)this).IsServer)
{
return;
}
PlayerColour playerColour = default(PlayerColour);
playerColour.ClientId = clientId;
playerColour.Color = color;
PlayerColour playerColour2 = playerColour;
int num = -1;
for (int i = 0; i < PlayerColours.Count; i++)
{
if (PlayerColours[i].ClientId == clientId)
{
num = i;
break;
}
}
if (num >= 0)
{
PlayerColours[num] = playerColour2;
}
else
{
PlayerColours.Add(playerColour2);
}
}
protected override void __initializeVariables()
{
if (PlayerColours == null)
{
throw new Exception("CFNetwork.PlayerColours cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)PlayerColours).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)PlayerColours, "PlayerColours");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)PlayerColours);
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(2167799236u, new RpcReceiveHandler(__rpc_handler_2167799236), "SetPlayerColourServerRpc");
((NetworkBehaviour)this).__initializeRpcs();
}
private static void __rpc_handler_2167799236(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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)
//IL_0052: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong clientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
Color color = default(Color);
((FastBufferReader)(ref reader)).ReadValueSafe(ref color);
target.__rpc_exec_stage = (__RpcExecStage)1;
((CFNetwork)(object)target).SetPlayerColourServerRpc(clientId, color);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "CFNetwork";
}
}
[HarmonyPatch]
public class NetworkObjectManager
{
private static GameObject networkPrefab;
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
public static void Init()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
if (!((Object)(object)networkPrefab != (Object)null))
{
networkPrefab = (GameObject)Assets.MainAssetBundle.LoadAsset("CFNetworkHandler");
networkPrefab.AddComponent<CFNetwork>();
NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
private static void SpawnNetworkHandler()
{
//IL_0024: 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)
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
}
public static class Patches
{
[HarmonyPatch(typeof(FlashlightItem))]
public class CFFlashlightItemPatch
{
[HarmonyPatch("SwitchFlashlight")]
[HarmonyPostfix]
public static void SwitchFlashlightPatch(FlashlightItem __instance)
{
//IL_0049: 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_005c: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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_0073: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null)
{
Plugin.mls.LogWarning((object)"SwitchFlashlightPatch: instance was null");
return;
}
ulong playerClientId = ((GrabbableObject)__instance).playerHeldBy.playerClientId;
Plugin.mls.LogDebug((object)$"SwitchFlash pId: {playerClientId}");
Color colour = Color.white;
if (playerClientId == Plugin.currentPlayerId)
{
colour = Plugin.activeColour;
if (Plugin.firstFlashlight)
{
if (Plugin.activeColour == Color.white)
{
HUDManager.Instance.DisplayTip("Change flashlight colour!", "Type 'cf' into the ship terminal for guidance!", false, false, "LC_Tip1");
}
Plugin.firstFlashlight = false;
}
}
else
{
CFNetwork.Instance.TryGetColour(playerClientId, out colour);
}
__instance.flashlightBulb.color = colour;
__instance.flashlightBulbGlow.color = colour;
((GrabbableObject)__instance).playerHeldBy.helmetLight.color = colour;
Plugin.mls.LogDebug((object)$"SwitchFlash - ClientId: {playerClientId} - Colour: {Helpers.ColorToHexString(colour)}");
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
public class CFPlayerControllerBPatch
{
[HarmonyPatch("SpawnPlayerAnimation")]
[HarmonyPostfix]
public static void SpawnPlayerPatch(PlayerControllerB __instance)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
ulong num = (Plugin.currentPlayerId = __instance.playerClientId);
string arg = Helpers.ColorToHexString(Plugin.activeColour);
Plugin.mls.LogInfo((object)$"Player spawned with client id: {num}, flashlight colour: {arg}");
CFNetwork.Instance.SetPlayerColourServerRpc(__instance.playerClientId, Plugin.activeColour);
}
}
}
[BepInPlugin("Cubly.ColourfulFlashlights", "ColourfulFlashlights", "3.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string MOD_NAME = "ColourfulFlashlights";
private const string MOD_GUID = "Cubly.ColourfulFlashlights";
public const string MOD_VERSION = "3.1.1";
private readonly Harmony harmony = new Harmony("Cubly.ColourfulFlashlights");
public static Plugin Instance;
public static ManualLogSource mls;
public static ConfigEntry<string>[] ConfigHex = new ConfigEntry<string>[3];
public static ConfigEntry<bool> ConfigSyncOthers;
public static ConfigEntry<bool> ConfigPersist;
public static Dictionary<ulong, Color> PlayerColours = new Dictionary<ulong, Color>();
public static ulong currentPlayerId;
public static bool firstFlashlight = true;
public static Color activeColour = Color.white;
public static Color? previousColour = null;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Cubly.ColourfulFlashlights");
ConfigHex[0] = ((BaseUnityPlugin)this).Config.Bind<string>("Custom Presets", "Custom 1", "#7BF286", "A hex colour code. Enter 'cf 1' into the ship terminal to use.");
ConfigHex[1] = ((BaseUnityPlugin)this).Config.Bind<string>("Custom Presets", "Custom 2", "#EFB8EC", "A hex colour code. Enter 'cf 2' into the ship terminal to use.");
ConfigHex[2] = ((BaseUnityPlugin)this).Config.Bind<string>("Custom Presets", "Custom 3", "#6456D0", "A hex colour code. Enter 'cf 3' into the ship terminal to use.");
ConfigPersist = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Persist colour", true, "If true, the last used flashlight colour will be loaded on game startup.");
if (ConfigPersist.Value)
{
Helpers.ReadCFValue();
}
harmony.PatchAll();
Assets.PopulateAssets();
Terminal.Init();
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);
}
}
}
mls.LogInfo((object)"ColourfulFlashlights 3.1.1 loaded!");
}
}
public static class Terminal
{
[CompilerGenerated]
private static class <>O
{
public static TerminalParseSentenceEventHandler <0>__TextSubmitted;
}
private static string cfHelp = "[Colourful Flashlights] Help\n\ncf <name> [colour name, e.g. cf red]\ncf <hex> [a hex code, e.g. cf #E9B7F7]\ncf <1,2,3> [a preset from config]\ncf undo [reverts to last used colour]\n\nValid colour names:\nwhite, blue, red, green, yellow, pink, orange, purple\n\n";
private static string cfText = "[Colourful Flashlights] Version 3.1.1\nBy cubly\n\nChange your flashlight to shine whatever colour you like!\n\nEnter 'cf' and then any valid colour name, hexadecimal colour code or config option number!\nExamples:\ncf purple\ncf #FF00CC\ncf 2\n\nEnter 'cf help' for a list of commands and colours!\n\n";
public static void Init()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
object obj = <>O.<0>__TextSubmitted;
if (obj == null)
{
TerminalParseSentenceEventHandler val = TextSubmitted;
<>O.<0>__TextSubmitted = val;
obj = (object)val;
}
Events.TerminalParsedSentence += (TerminalParseSentenceEventHandler)obj;
TerminalApi.AddCommand("cf", "Colourful Flashlights", (string)null, true);
}
public static void TextSubmitted(object sender, TerminalParseSentenceEventArgs e)
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
if (e.SubmittedText == "cf")
{
e.ReturnedNode.displayText = cfText;
}
else
{
if (!e.SubmittedText.StartsWith("cf "))
{
return;
}
string[] array = e.SubmittedText.Split(' ');
if (array[1] == "help")
{
e.ReturnedNode.displayText = cfHelp;
return;
}
if (array[1] == "undo")
{
if (Plugin.previousColour.HasValue)
{
UpdateActiveColour(Plugin.previousColour.Value);
e.ReturnedNode.displayText = "[Colourful Flashlights]\nSUCCESS!\n\nFlashlight colour reverted!\n\n";
}
else
{
e.ReturnedNode.displayText = "[Colourful Flashlights]\nERROR!\n\nYou must change colours at least once before undo can function.\n\n";
}
return;
}
bool flag;
switch (array[1])
{
case "1":
case "2":
case "3":
flag = true;
break;
default:
flag = false;
break;
}
if (flag)
{
int num = int.Parse(array[1]);
Color? val = Helpers.HexStringToColor(Plugin.ConfigHex[num - 1].Value);
if (val.HasValue)
{
Color valueOrDefault = val.GetValueOrDefault();
if (true)
{
UpdateActiveColour(valueOrDefault);
e.ReturnedNode.displayText = "[Colourful Flashlights]\nSUCCESS!" + $"\n\nConfiguration colour {num} ({Plugin.ConfigHex[num - 1].Value}) applied!\n\n";
return;
}
}
e.ReturnedNode.displayText = "[Colourful Flashlights]\nERROR!" + $"\n\nConfiguration colour {num} is not a valid hex code!\nUpdate your configuration with a valid hexadecimal colour code.\n\n";
}
else if (array[1] != null)
{
Color? val2 = Helpers.NameToColor(array[1]);
if (val2.HasValue)
{
Color valueOrDefault2 = val2.GetValueOrDefault();
if (true)
{
UpdateActiveColour(valueOrDefault2);
e.ReturnedNode.displayText = "[Colourful Flashlights]\nSUCCESS!\n\nColour " + array[1] + " applied!\n\n";
return;
}
}
val2 = Helpers.HexStringToColor(array[1]);
if (val2.HasValue)
{
Color valueOrDefault3 = val2.GetValueOrDefault();
if (true)
{
UpdateActiveColour(valueOrDefault3);
e.ReturnedNode.displayText = "[Colourful Flashlights]\nSUCCESS!\n\nColour " + array[1] + " applied!\n\n";
return;
}
}
e.ReturnedNode.displayText = "[Colourful Flashlights]\nERROR!\n\nPlease provide a valid colour name, hexadecimal colour code or config option number!\n\nExamples:\ncf purple\ncf #FF00CC\ncf 2\n\nUse 'cf help' for a list of options.\n\n";
}
else
{
e.ReturnedNode.displayText = cfText;
}
}
}
private static void UpdateActiveColour(Color color)
{
//IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
Plugin.previousColour = Plugin.activeColour;
Plugin.activeColour = color;
Helpers.WriteCFValue();
CFNetwork.Instance.SetPlayerColourServerRpc(Plugin.currentPlayerId, color);
PlayerControllerB val = ((IEnumerable<PlayerControllerB>)RoundManager.Instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => p.playerClientId == Plugin.currentPlayerId));
if ((Object)(object)val != (Object)null)
{
FlashlightItem[] array = val.ItemSlots.Where((GrabbableObject item) => (Object)(object)item != (Object)null && item is FlashlightItem).Cast<FlashlightItem>().ToArray();
FlashlightItem[] array2 = array;
foreach (FlashlightItem val2 in array2)
{
val2.flashlightBulb.color = color;
val2.flashlightBulbGlow.color = color;
val.helmetLight.color = color;
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ColourfulFlashlights";
public const string PLUGIN_NAME = "ColourfulFlashlights";
public const string PLUGIN_VERSION = "3.1.1";
}
}
namespace ColourfulFlashlights.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("ColourfulFlashlights.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[] cfasset
{
get
{
object @object = ResourceManager.GetObject("cfasset", resourceCulture);
return (byte[])@object;
}
}
internal Resources()
{
}
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<PlayerColour>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<PlayerColour>();
}
}
}
namespace ColourfulFlashlights.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}