using System;
using System.CodeDom.Compiler;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using GTFO.API.Utilities;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PlayerColorCustomizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayerColorCustomizer")]
[assembly: AssemblyTitle("PlayerColorCustomizer")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PlayerColorCustomizer
{
internal static class Logger
{
private static readonly ManualLogSource _Logger;
static Logger()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_Logger = new ManualLogSource("PlayerColorCustomizer");
Logger.Sources.Add((ILogSource)(object)_Logger);
}
private static string Format(object msg)
{
return msg.ToString();
}
public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
{
_Logger.LogInfo(handler);
}
public static void Info(string str)
{
_Logger.LogMessage((object)str);
}
public static void Info(object data)
{
_Logger.LogMessage((object)Format(data));
}
public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
{
_Logger.LogDebug(handler);
}
public static void Debug(string str)
{
_Logger.LogDebug((object)str);
}
public static void Debug(object data)
{
_Logger.LogDebug((object)Format(data));
}
public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
{
_Logger.LogError(handler);
}
public static void Error(string str)
{
_Logger.LogError((object)str);
}
public static void Error(object data)
{
_Logger.LogError((object)Format(data));
}
public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
{
_Logger.LogFatal(handler);
}
public static void Fatal(string str)
{
_Logger.LogFatal((object)str);
}
public static void Fatal(object data)
{
_Logger.LogFatal((object)Format(data));
}
public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
{
_Logger.LogWarning(handler);
}
public static void Warn(string str)
{
_Logger.LogWarning((object)str);
}
public static void Warn(object data)
{
_Logger.LogWarning((object)Format(data));
}
[Conditional("DEBUG")]
public static void DebugOnly(object data)
{
_Logger.LogDebug((object)Format(data));
}
}
[BepInPlugin("JarheadHME.PlayerColorCustomizer", "PlayerColorCustomizer", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class Plugin : BasePlugin
{
private Harmony _Harmony = null;
public override void Load()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
_Harmony = new Harmony("PlayerColorCustomizer.Harmony");
_Harmony.PatchAll();
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin has loaded with ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_Harmony.GetPatchedMethods().Count());
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches!");
}
Logger.Info(val);
}
public override bool Unload()
{
_Harmony.UnpatchSelf();
return ((BasePlugin)this).Unload();
}
}
public static class ConfigManager
{
public static ConfigFile configFile;
private static ConfigEntry<string> _Slot1Color;
private static ConfigEntry<string> _Slot2Color;
private static ConfigEntry<string> _Slot3Color;
private static ConfigEntry<string> _Slot4Color;
private static ConfigEntry<string> _LocalSlotColor;
public static string Slot1Color
{
get
{
return _Slot1Color.Value;
}
set
{
_Slot1Color.Value = value;
}
}
public static string Slot2Color
{
get
{
return _Slot2Color.Value;
}
set
{
_Slot2Color.Value = value;
}
}
public static string Slot3Color
{
get
{
return _Slot3Color.Value;
}
set
{
_Slot3Color.Value = value;
}
}
public static string Slot4Color
{
get
{
return _Slot4Color.Value;
}
set
{
_Slot4Color.Value = value;
}
}
public static string LocalSlotColor
{
get
{
return _LocalSlotColor.Value;
}
set
{
_LocalSlotColor.Value = value;
}
}
static ConfigManager()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Expected O, but got Unknown
string text = Path.Combine(Paths.ConfigPath, "PlayerColorCustomizer.cfg");
configFile = new ConfigFile(text, true);
string format = "Color for the {0} Character slot ({1})\nValid options:\nAny valid RGB/RGBA hex codes prefixed with #, for ex:\n#F84, #FF8844, #F84A, #DA8224FF\nOr any of the followed named colors without a # prefix:\nred, cyan, blue, darkblue, lightblue, purple, yellow, lime, fuchsia, white, silver, grey, black, orange, brown, maroon, green, olive, navy, teal, aqua, magenta";
_Slot1Color = configFile.Bind<string>("Colors", "Slot 1 Color", "#C21F4E", string.Format(format, "first", "Pink/Woods"));
_Slot2Color = configFile.Bind<string>("Colors", "Slot 2 Color", "#18935E", string.Format(format, "second", "Green/Dauda"));
_Slot3Color = configFile.Bind<string>("Colors", "Slot 3 Color", "#20558C", string.Format(format, "third", "Blue/Hackett"));
_Slot4Color = configFile.Bind<string>("Colors", "Slot 4 Color", "#7A1A8E", string.Format(format, "fourth", "Purple/Bishop"));
_LocalSlotColor = configFile.Bind<string>("Colors", "Local Player Color", string.Empty, string.Format(format, "local player's", "Whatever slot you join"));
LiveEditListener val = LiveEdit.CreateListener(Paths.ConfigPath, "PlayerColorCustomizer.cfg", false);
val.FileChangedEventCooldown = 0.75f;
val.FileChanged += new LiveEditEventHandler(OnLiveEditUpdate);
}
public static void OnLiveEditUpdate(LiveEditEventArgs e)
{
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
Logger.Info("Config file changed");
try
{
configFile.Reload();
}
catch (IOException)
{
Logger.Error("Config File Failed to load (retrying 1/3)");
try
{
configFile.Reload();
Logger.Info("Successfully loaded");
}
catch (IOException)
{
Logger.Error("Config File Failed to load (retrying 2/3)");
try
{
configFile.Reload();
Logger.Info("Successfully loaded");
goto end_IL_0042;
}
catch (IOException)
{
Logger.Error("Config File Failed to load 3 times. Try saving again.");
return;
}
end_IL_0042:;
}
}
Patches.Postfix_PlayerManager_Setup(PlayerManager.Current);
Il2CppReferenceArray<SNet_Slot> characterSlots = SNet.Slots.CharacterSlots;
Color playerColor = default(Color);
bool flag = default(bool);
Color playerColor2 = default(Color);
for (int i = 0; i < ((Il2CppArrayBase<SNet_Slot>)(object)characterSlots).Length; i++)
{
SNet_Slot val = ((Il2CppArrayBase<SNet_Slot>)(object)characterSlots)[i];
if ((Object)(object)((val != null) ? val.player : null) == (Object)null)
{
continue;
}
SNet_Player player = val.player;
if (player.IsLocal && !player.IsBot)
{
if (ColorUtility.TryParseHtmlString(LocalSlotColor, ref playerColor))
{
player.PlayerColor = playerColor;
player.PlayerAgent.OnPlayerNameChanged();
continue;
}
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Local player color '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(LocalSlotColor);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' invalid, using normal slot color");
}
Logger.Warn(val2);
}
string[] array = new string[4] { Slot1Color, Slot2Color, Slot3Color, Slot4Color };
if (ColorUtility.TryParseHtmlString(array[i], ref playerColor2))
{
player.PlayerColor = playerColor2;
player.PlayerAgent.OnPlayerNameChanged();
}
}
CM_PageMap current = CM_PageMap.Current;
if ((Object)(object)current != (Object)null)
{
current.UpdatePlayerData();
}
}
}
[HarmonyPatch]
internal sealed class Patches
{
[HarmonyPatch(typeof(PlayerManager), "Setup")]
[HarmonyPostfix]
public static void Postfix_PlayerManager_Setup(PlayerManager __instance)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
string[] array = new string[4]
{
ConfigManager.Slot1Color,
ConfigManager.Slot2Color,
ConfigManager.Slot3Color,
ConfigManager.Slot4Color
};
Color val = default(Color);
bool flag = default(bool);
for (int i = 0; i < array.Length; i++)
{
if (ColorUtility.TryParseHtmlString(array[i], ref val))
{
((Il2CppArrayBase<Color>)(object)__instance.m_playerColors)[i] = val;
continue;
}
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(22, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Slot Color ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(i + 1);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(array[i]);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' invalid");
}
Logger.Warn(val2);
}
}
[HarmonyPatch(typeof(LocalPlayerAgent), "Setup")]
[HarmonyPostfix]
public static void Postfix_LocalPlayerAgent_Setup(LocalPlayerAgent __instance)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
Color playerColor = default(Color);
if (ColorUtility.TryParseHtmlString(ConfigManager.LocalSlotColor, ref playerColor))
{
SNet_Player owner = ((PlayerAgent)__instance).Owner;
if (owner.IsLocal && !owner.IsBot)
{
owner.PlayerColor = playerColor;
}
((PlayerAgent)__instance).OnPlayerNameChanged();
}
}
}
[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
[CompilerGenerated]
internal static class VersionInfo
{
public const string RootNamespace = "PlayerColorCustomizer";
public const string Version = "1.0.0";
public const string VersionPrerelease = null;
public const string VersionMetadata = null;
public const string SemVer = "1.0.0";
public const string GitRevShort = null;
public const string GitRevLong = null;
public const string GitBranch = null;
public const string GitTag = null;
public const int GitCommitsSinceTag = 0;
public const bool GitIsDirty = false;
}
}