Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Modpack for my friends v1.0.1
plugins/2018-LC_API/LC_API.dll.old
Decompiled 2 years agousing System; using System.Collections.Concurrent; using System.Collections.Generic; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LC_API.BundleAPI; using LC_API.Comp; using LC_API.Data; using LC_API.Extensions; using LC_API.GameInterfaceAPI; using LC_API.ManualPatches; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("LC_API")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Utilities for plugin devs")] [assembly: AssemblyFileVersion("2.1.1.0")] [assembly: AssemblyInformationalVersion("2.1.1")] [assembly: AssemblyProduct("LC_API")] [assembly: AssemblyTitle("LC_API")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LC_API { internal static class CheatDatabase { private const string DAT_CD_BROADCAST = "LC_API_CD_Broadcast"; private const string SIG_REQ_GUID = "LC_API_ReqGUID"; private const string SIG_SEND_MODS = "LC_APISendMods"; private static Dictionary<string, PluginInfo> PluginsLoaded = new Dictionary<string, PluginInfo>(); public static void RunLocalCheatDetector() { PluginsLoaded = Chainloader.PluginInfos; using Dictionary<string, PluginInfo>.ValueCollection.Enumerator enumerator = PluginsLoaded.Values.GetEnumerator(); while (enumerator.MoveNext()) { switch (enumerator.Current.Metadata.GUID) { case "mikes.lethalcompany.mikestweaks": case "mom.llama.enhancer": case "Posiedon.GameMaster": case "LethalCompanyScalingMaster": case "verity.amberalert": ModdedServer.SetServerModdedOnly(); break; } } } public static void OtherPlayerCheatDetector() { Plugin.Log.LogWarning((object)"Asking all other players for their mod list.."); GameTips.ShowTip("Mod List:", "Asking all other players for installed mods.."); GameTips.ShowTip("Mod List:", "Check the logs for more detailed results.\n<size=13>(Note that if someone doesnt show up on the list, they may not have LC_API installed)</size>"); Networking.Broadcast("LC_API_CD_Broadcast", "LC_API_ReqGUID"); } internal static void CDNetGetString(string data, string signature) { if (data == "LC_API_CD_Broadcast" && signature == "LC_API_ReqGUID") { string text = ""; foreach (PluginInfo value in PluginsLoaded.Values) { text = text + "\n" + value.Metadata.GUID; } Networking.Broadcast(GameNetworkManager.Instance.localPlayerController.playerUsername + " responded with these mods:" + text, "LC_APISendMods"); } if (signature == "LC_APISendMods") { GameTips.ShowTip("Mod List:", data); Plugin.Log.LogWarning((object)data); } } } [BepInPlugin("LC_API", "LC_API", "2.1.1")] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private ConfigEntry<bool> configOverrideModServer; private ConfigEntry<bool> configLegacyAssetLoading; private ConfigEntry<bool> configDisableBundleLoader; public static bool Initialized { get; private set; } private void Awake() { //IL_00a5: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown configOverrideModServer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Force modded server browser", false, "Should the API force you into the modded server browser?"); configLegacyAssetLoading = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Legacy asset bundle loading", false, "Should the BundleLoader use legacy asset loading? Turning this on may help with loading assets from older plugins."); configDisableBundleLoader = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable BundleLoader", false, "Should the BundleLoader be turned off? Enable this if you are having problems with mods that load assets using a different method from LC_API's BundleLoader."); Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogWarning((object)"\n.____ _________ _____ __________ .___ \r\n| | \\_ ___ \\ / _ \\ \\______ \\| | \r\n| | / \\ \\/ / /_\\ \\ | ___/| | \r\n| |___\\ \\____ / | \\| | | | \r\n|_______ \\\\______ /______\\____|__ /|____| |___| \r\n \\/ \\//_____/ \\/ \r\n "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Starting up.."); if (configOverrideModServer.Value) { ModdedServer.SetServerModdedOnly(); } Harmony val = new Harmony("ModAPI"); MethodInfo methodInfo = AccessTools.Method(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated", (Type[])null, (Type[])null); AccessTools.Method(typeof(GameNetworkManager), "LobbyDataIsJoinable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ServerPatch), "OnLobbyCreate", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuManager), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(ServerPatch), "CacheMenuManager", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(ServerPatch), "ChatInterpreter", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, new Action<string, string>(CheatDatabase.CDNetGetString)); Networking.GetListString = (Action<List<string>, string>)Delegate.Combine(Networking.GetListString, new Action<List<string>, string>(Networking.LCAPI_NET_SYNCVAR_SET)); } internal void Start() { Initialize(); } internal void OnDestroy() { Initialize(); } internal void Initialize() { //IL_002f: 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_003a: Expected O, but got Unknown if (!Initialized) { Initialized = true; if (!configDisableBundleLoader.Value) { BundleLoader.Load(configLegacyAssetLoading.Value); } GameObject val = new GameObject("API"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<LC_APIManager>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Started!"); CheatDatabase.RunLocalCheatDetector(); } } internal static void PatchMethodManual(MethodInfo method, MethodInfo patch, Harmony harmony) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony.Patch((MethodBase)method, new HarmonyMethod(patch), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LC_API"; public const string PLUGIN_NAME = "LC_API"; public const string PLUGIN_VERSION = "2.1.1"; } } namespace LC_API.ServerAPI { public static class ModdedServer { private static bool moddedOnly; [Obsolete("Use SetServerModdedOnly() instead. This will be removed/private in a future update.")] public static bool setModdedOnly; public static bool ModdedOnly => moddedOnly; public static void SetServerModdedOnly() { moddedOnly = true; Plugin.Log.LogMessage((object)"A plugin has set your game to only allow you to play with other people who have mods!"); } public static void OnSceneLoaded() { if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance) && ModdedOnly) { GameNetworkManager instance = GameNetworkManager.Instance; instance.gameVersionNum += 16440; setModdedOnly = true; } } } public static class Networking { public static Action<string, string> GetString = delegate { }; public static Action<List<string>, string> GetListString = delegate { }; public static Action<int, string> GetInt = delegate { }; public static Action<float, string> GetFloat = delegate { }; public static Action<Vector3, string> GetVector3 = delegate { }; private static Dictionary<string, string> syncStringVars = new Dictionary<string, string>(); public static void Broadcast(string data, string signature) { if (data.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); return; } HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDstring.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(List<string> data, string signature) { string text = ""; foreach (string datum in data) { if (datum.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); return; } if (datum.Contains("\n")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( NewLine )"); return; } text = text + datum + "\n"; } HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data?.ToString() + "/" + signature + "/" + NetworkBroadcastDataType.BDlistString.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(int data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDint.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(float data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDfloat.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(Vector3 data, string signature) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; string[] obj = new string[9] { "<size=0>NWE/", null, null, null, null, null, null, null, null }; Vector3 val = data; obj[1] = ((object)(Vector3)(ref val)).ToString(); obj[2] = "/"; obj[3] = signature; obj[4] = "/"; obj[5] = NetworkBroadcastDataType.BDvector3.ToString(); obj[6] = "/"; obj[7] = GameNetworkManager.Instance.localPlayerController.playerClientId.ToString(); obj[8] = "/</size>"; instance.AddTextToChatOnServer(string.Concat(obj), -1); } public static void RegisterSyncVariable(string name) { if (!syncStringVars.ContainsKey(name)) { syncStringVars.Add(name, ""); } else { Plugin.Log.LogError((object)("Cannot register Sync Variable! A Sync Variable has already been registered with name " + name)); } } public static void SetSyncVariable(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; Broadcast(new List<string> { name, value }, "LCAPI_NET_SYNCVAR_SET"); } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } private static void SetSyncVariableB(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } internal static void LCAPI_NET_SYNCVAR_SET(List<string> list, string arg2) { if (arg2 == "LCAPI_NET_SYNCVAR_SET") { SetSyncVariableB(list[0], list[1]); } } public static string GetSyncVariable(string name) { if (syncStringVars.ContainsKey(name)) { return syncStringVars[name]; } Plugin.Log.LogError((object)("Cannot get the value of Sync Variable " + name + " as it is not registered!")); return ""; } private static void GotString(string data, string signature) { } private static void GotInt(int data, string signature) { } private static void GotFloat(float data, string signature) { } private static void GotVector3(Vector3 data, string signature) { } } } namespace LC_API.ManualPatches { internal static class ServerPatch { internal static bool OnLobbyCreate(GameNetworkManager __instance, Result result, Lobby lobby) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)result != 1) { Debug.LogError((object)$"Lobby could not be created! {result}", (Object)(object)__instance); } __instance.lobbyHostSettings.lobbyName = "[MODDED]" + __instance.lobbyHostSettings.lobbyName.ToString(); Plugin.Log.LogMessage((object)"server pre-setup success"); return true; } internal static bool CacheMenuManager(MenuManager __instance) { LC_APIManager.MenuManager = __instance; return true; } internal static bool ChatInterpreter(HUDManager __instance, string chatMessage) { //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (!chatMessage.Contains("NWE") || !chatMessage.Contains("<size=0>")) { return true; } string[] array = chatMessage.Split(new char[1] { '/' }); if (array.Length < 5) { if (array.Length >= 3) { if (!int.TryParse(array[4], out var result)) { Plugin.Log.LogWarning((object)"Failed to parse player ID!!"); return false; } if ((result == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester) { return false; } Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result2); switch (result2) { case NetworkBroadcastDataType.BDstring: Networking.GetString(array[1], array[2]); break; case NetworkBroadcastDataType.BDint: Networking.GetInt(int.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDfloat: Networking.GetFloat(float.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDvector3: { string[] array2 = array[1].Replace("(", "").Replace(")", "").Split(new char[1] { ',' }); Vector3 arg = default(Vector3); if (array2.Length == 3) { if (float.TryParse(array2[0], out var result3) && float.TryParse(array2[1], out var result4) && float.TryParse(array2[2], out var result5)) { arg.x = result3; arg.y = result4; arg.z = result5; } else { Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug."); } } else { Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug."); } Networking.GetVector3(arg, array[2]); break; } case NetworkBroadcastDataType.BDlistString: { string[] source = array[1].Split(new char[1] { '\n' }); Networking.GetListString(source.ToList(), array[2]); break; } } _ = LC_APIManager.netTester; return false; } Plugin.Log.LogError((object)"Generic Network receive fail. This is a failure of the API, and it should be reported as a bug."); Plugin.Log.LogError((object)$"Generic Network receive fail (expected 5+ data fragments, got {array.Length}). This is a failure of the API, and it should be reported as a bug."); return true; } if (!int.TryParse(array[4], out var result6)) { Plugin.Log.LogWarning((object)("Failed to parse player ID '" + array[4] + "'!!")); return false; } if ((result6 == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester) { return false; } if (!Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result7)) { Plugin.Log.LogError((object)("Unknown datatype - unable to parse '" + array[3] + "' into a known data type!")); return false; } switch (result7) { case NetworkBroadcastDataType.BDstring: Networking.GetString.InvokeActionSafe(array[1], array[2]); break; case NetworkBroadcastDataType.BDint: Networking.GetInt.InvokeActionSafe(int.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDfloat: Networking.GetFloat.InvokeActionSafe(float.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDvector3: { string text = array[1].Trim('(', ')'); string[] array3 = text.Split(new char[1] { ',' }); Vector3 param = default(Vector3); float result8; float result9; float result10; if (array3.Length != 3) { Plugin.Log.LogError((object)$"Vector3 Network receive fail (expected 3 numbers, got {array3.Length} number(?)(s) instead). This is a failure of the API, and it should be reported as a bug. (passing an empty Vector3 in its place)"); } else if (float.TryParse(array3[0], out result8) && float.TryParse(array3[1], out result9) && float.TryParse(array3[2], out result10)) { param.x = result8; param.y = result9; param.z = result10; } else { Plugin.Log.LogError((object)("Vector3 Network receive fail (failed to parse '" + text + "' as numbers). This is a failure of the API, and it should be reported as a bug.")); } Networking.GetVector3.InvokeActionSafe(param, array[2]); break; } } _ = LC_APIManager.netTester; return false; } internal static bool ChatCommands(HUDManager __instance, CallbackContext context) { if (__instance.chatTextField.text.ToLower().Contains("/modcheck")) { CheatDatabase.OtherPlayerCheatDetector(); return false; } return true; } } } namespace LC_API.GameInterfaceAPI { public static class GameState { private static readonly Action NothingAction = delegate { }; public static int AlivePlayerCount { get; private set; } public static ShipState ShipState { get; private set; } public static event Action PlayerDied; public static event Action LandOnMoon; public static event Action WentIntoOrbit; public static event Action ShipStartedLeaving; internal static void GSUpdate() { if (!((Object)(object)StartOfRound.Instance == (Object)null)) { if (StartOfRound.Instance.shipHasLanded && ShipState != ShipState.OnMoon) { ShipState = ShipState.OnMoon; GameState.LandOnMoon.InvokeActionSafe(); } if (StartOfRound.Instance.inShipPhase && ShipState != 0) { ShipState = ShipState.InOrbit; GameState.WentIntoOrbit.InvokeActionSafe(); } if (StartOfRound.Instance.shipIsLeaving && ShipState != ShipState.LeavingMoon) { ShipState = ShipState.LeavingMoon; GameState.ShipStartedLeaving.InvokeActionSafe(); } if (AlivePlayerCount < StartOfRound.Instance.livingPlayers) { GameState.PlayerDied.InvokeActionSafe(); } AlivePlayerCount = StartOfRound.Instance.livingPlayers; } } static GameState() { GameState.PlayerDied = NothingAction; GameState.LandOnMoon = NothingAction; GameState.WentIntoOrbit = NothingAction; GameState.ShipStartedLeaving = NothingAction; } } public class GameTips { private static List<string> tipHeaders = new List<string>(); private static List<string> tipBodys = new List<string>(); private static float lastMessageTime; public static void ShowTip(string header, string body) { tipHeaders.Add(header); tipBodys.Add(body); } public static void UpdateInternal() { lastMessageTime -= Time.deltaTime; if ((tipHeaders.Count > 0) & (lastMessageTime < 0f)) { lastMessageTime = 5f; if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip(tipHeaders[0], tipBodys[0], false, false, "LC_Tip1"); } tipHeaders.RemoveAt(0); tipBodys.RemoveAt(0); } } } } namespace LC_API.Extensions { public static class DelegateExtensions { private static readonly PropertyInfo PluginGetLogger = AccessTools.Property(typeof(BaseUnityPlugin), "Logger"); public static void InvokeActionSafe(this Action action) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action)@delegate)(); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } public static void InvokeActionSafe<T>(this Action<T> action, T param) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action<T>)@delegate)(param); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } public static void InvokeActionSafe<T1, T2>(this Action<T1, T2> action, T1 param1, T2 param2) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action<T1, T2>)@delegate)(param1, param2); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } internal static void InvokeParameterlessDelegate<T>(this T paramlessDelegate) where T : Delegate { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if ((Delegate?)paramlessDelegate == (Delegate?)null) { return; } Delegate[] invocationList = paramlessDelegate.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((T)@delegate).DynamicInvoke(); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } } } namespace LC_API.Data { internal enum NetworkBroadcastDataType { Unknown, BDint, BDfloat, BDvector3, BDstring, BDlistString } public enum ShipState { InOrbit, OnMoon, LeavingMoon } } namespace LC_API.Comp { internal class LC_APIManager : MonoBehaviour { public static MenuManager MenuManager; public static bool netTester; private static int playerCount; private static bool wanttoCheckMods; private static float lobbychecktimer; public void Update() { GameState.GSUpdate(); GameTips.UpdateInternal(); if ((((Object)(object)HUDManager.Instance != (Object)null) & netTester) && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { Networking.Broadcast("testerData", "testerSignature"); } if (!ModdedServer.setModdedOnly) { ModdedServer.OnSceneLoaded(); } else if (ModdedServer.ModdedOnly && (Object)(object)MenuManager != (Object)null && Object.op_Implicit((Object)(object)MenuManager.versionNumberText)) { ((TMP_Text)MenuManager.versionNumberText).text = $"v{GameNetworkManager.Instance.gameVersionNum - 16440}\nMOD"; } if ((Object)(object)GameNetworkManager.Instance != (Object)null) { if (playerCount < GameNetworkManager.Instance.connectedPlayers) { lobbychecktimer = -4.5f; wanttoCheckMods = true; } playerCount = GameNetworkManager.Instance.connectedPlayers; } if (lobbychecktimer < 0f) { lobbychecktimer += Time.deltaTime; } else if (wanttoCheckMods && (Object)(object)HUDManager.Instance != (Object)null) { wanttoCheckMods = false; CD(); } } private void CD() { CheatDatabase.OtherPlayerCheatDetector(); } } } namespace LC_API.BundleAPI { public static class BundleLoader { [Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")] public delegate void OnLoadedAssetsDelegate(); [Obsolete("Use GetLoadedAsset instead. This will be removed/private in a future update.")] public static ConcurrentDictionary<string, Object> assets = new ConcurrentDictionary<string, Object>(); [Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")] public static OnLoadedAssetsDelegate OnLoadedAssets = LoadAssetsCompleted; public static bool AssetsInLegacyDirectory { get; private set; } public static bool LegacyLoadingEnabled { get; private set; } public static event Action OnLoadedBundles; internal static void Load(bool legacyLoading) { LegacyLoadingEnabled = legacyLoading; Plugin.Log.LogMessage((object)"BundleAPI will now load all asset bundles..."); string path = Path.Combine(Paths.BepInExRootPath, "Bundles"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); Plugin.Log.LogMessage((object)"BundleAPI Created legacy bundle directory in BepInEx/Bundles"); } string[] array = (from x in Directory.GetFiles(path, "*", SearchOption.AllDirectories) where !x.EndsWith(".manifest", StringComparison.CurrentCultureIgnoreCase) select x).ToArray(); AssetsInLegacyDirectory = array.Length != 0; if (!AssetsInLegacyDirectory) { Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from legacy directory"); } if (AssetsInLegacyDirectory) { Plugin.Log.LogWarning((object)"The path BepInEx > Bundles is outdated and should not be used anymore! Bundles will be loaded from BepInEx > plugins from now on"); LoadAllAssetsFromDirectory(array, legacyLoading); } string[] invalidEndings = new string[7] { ".dll", ".json", ".png", ".md", ".old", ".txt", ".exe" }; path = Path.Combine(Paths.BepInExRootPath, "plugins"); array = (from file in Directory.GetFiles(path, "*", SearchOption.AllDirectories) where !invalidEndings.Any((string ending) => file.EndsWith(ending, StringComparison.CurrentCultureIgnoreCase)) select file).ToArray(); if (array.Length == 0) { Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from plugins folder"); } else { LoadAllAssetsFromDirectory(array, legacyLoading); } OnLoadedAssets.InvokeParameterlessDelegate(); BundleLoader.OnLoadedBundles.InvokeActionSafe(); } private static void LoadAllAssetsFromDirectory(string[] array, bool legacyLoading) { if (legacyLoading) { Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!")); for (int i = 0; i < array.Length; i++) { try { SaveAsset(array[i], legacyLoading); } catch (Exception) { Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[i])); } } return; } Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!")); for (int j = 0; j < array.Length; j++) { try { SaveAsset(array[j], legacyLoading); } catch (Exception) { Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[j])); } } } public static void SaveAsset(string path, bool legacyLoad) { AssetBundle val = AssetBundle.LoadFromFile(path); try { string[] allAssetNames = val.GetAllAssetNames(); foreach (string text in allAssetNames) { Plugin.Log.LogMessage((object)("Got asset for load: " + text)); Object val2 = val.LoadAsset(text); if (val2 == (Object)null) { Plugin.Log.LogWarning((object)$"Skipped/failed loading an asset (from bundle '{((Object)val).name}') - Asset path: {val2}"); continue; } string key = (legacyLoad ? text.ToUpper() : text.ToLower()); if (assets.ContainsKey(key)) { Plugin.Log.LogError((object)"BundleAPI got duplicate asset!"); break; } assets.TryAdd(key, val2); Plugin.Log.LogMessage((object)("Loaded asset: " + val2.name)); } } finally { if (val != null) { val.Unload(false); } } } public static TAsset GetLoadedAsset<TAsset>(string itemPath) where TAsset : Object { Object value = null; if (LegacyLoadingEnabled) { assets.TryGetValue(itemPath.ToUpper(), out value); } if (value == (Object)null) { assets.TryGetValue(itemPath.ToLower(), out value); } return (TAsset)(object)value; } private static void LoadAssetsCompleted() { Plugin.Log.LogMessage((object)"BundleAPI finished loading all assets."); } static BundleLoader() { BundleLoader.OnLoadedBundles = LoadAssetsCompleted; } } }
plugins/BepInEx_Unofficial-BepInEx_ConfigurationManager/ConfigurationManager/ConfigurationManager.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ConfigurationManager.Utilities; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyProduct("BepInEx.ConfigurationManager")] [assembly: AssemblyTitle("BepInEx.ConfigurationManager")] [assembly: AssemblyDescription("Universal in-game configuration manager for BepInEx plugins")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("https://github.com/BepInEx/BepInEx.ConfigurationManager")] [assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: AssemblyVersion("18.1.0.0")] namespace ConfigurationManager { internal static class SettingSearcher { private static readonly ICollection<string> _updateMethodNames = new string[4] { "Update", "FixedUpdate", "LateUpdate", "OnGUI" }; public static BaseUnityPlugin[] FindPlugins() { return Chainloader.PluginInfos.Values.Select((PluginInfo x) => x.Instance).Union(Object.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast<BaseUnityPlugin>()).ToArray(); } public static void CollectSettings(out IEnumerable<SettingEntryBase> results, out List<string> modsWithoutSettings, bool showDebug) { modsWithoutSettings = new List<string>(); try { results = GetBepInExCoreConfig(); } catch (Exception ex) { results = Enumerable.Empty<SettingEntryBase>(); ConfigurationManager.Logger.LogError((object)ex); } BaseUnityPlugin[] array = FindPlugins(); foreach (BaseUnityPlugin val in array) { Type type = ((object)val).GetType(); BepInPlugin metadata = val.Info.Metadata; if (type.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().Any((BrowsableAttribute x) => !x.Browsable)) { modsWithoutSettings.Add(metadata.Name); continue; } List<SettingEntryBase> list = new List<SettingEntryBase>(); list.AddRange(GetPluginConfig(val).Cast<SettingEntryBase>()); list.RemoveAll((SettingEntryBase x) => x.Browsable == false); if (list.Count == 0) { modsWithoutSettings.Add(metadata.Name); } if (showDebug && type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Any((MethodInfo x) => _updateMethodNames.Contains(x.Name))) { PropertySettingEntry propertySettingEntry = new PropertySettingEntry(val, type.GetProperty("enabled"), val); propertySettingEntry.DispName = "!Allow plugin to run on every frame"; propertySettingEntry.Description = "Disabling this will disable some or all of the plugin's functionality.\nHooks and event-based functionality will not be disabled.\nThis setting will be lost after game restart."; propertySettingEntry.IsAdvanced = true; list.Add(propertySettingEntry); } if (list.Count > 0) { results = results.Concat(list); } } } private static IEnumerable<SettingEntryBase> GetBepInExCoreConfig() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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 PropertyInfo property = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.NonPublic); if ((object)property == null) { throw new ArgumentNullException("coreConfigProp"); } ConfigFile source = (ConfigFile)property.GetValue(null, null); BepInPlugin bepinMeta = new BepInPlugin("BepInEx", "BepInEx", typeof(Chainloader).Assembly.GetName().Version.ToString()); return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)source).Select((Func<KeyValuePair<ConfigDefinition, ConfigEntryBase>, SettingEntryBase>)((KeyValuePair<ConfigDefinition, ConfigEntryBase> kvp) => new ConfigSettingEntry(kvp.Value, null) { IsAdvanced = true, PluginInfo = bepinMeta })); } private static IEnumerable<ConfigSettingEntry> GetPluginConfig(BaseUnityPlugin plugin) { return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)plugin.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> kvp) => new ConfigSettingEntry(kvp.Value, plugin)); } } internal sealed class ConfigSettingEntry : SettingEntryBase { public ConfigEntryBase Entry { get; } public override Type SettingType => Entry.SettingType; public ConfigSettingEntry(ConfigEntryBase entry, BaseUnityPlugin owner) { Entry = entry; DispName = entry.Definition.Key; base.Category = entry.Definition.Section; ConfigDescription description = entry.Description; base.Description = ((description != null) ? description.Description : null); TypeConverter converter = TomlTypeConverter.GetConverter(entry.SettingType); if (converter != null) { base.ObjToStr = (object o) => converter.ConvertToString(o, entry.SettingType); base.StrToObj = (string s) => converter.ConvertToObject(s, entry.SettingType); } ConfigDescription description2 = entry.Description; AcceptableValueBase val = ((description2 != null) ? description2.AcceptableValues : null); if (val != null) { GetAcceptableValues(val); } base.DefaultValue = entry.DefaultValue; ConfigDescription description3 = entry.Description; SetFromAttributes((description3 != null) ? description3.Tags : null, owner); } private void GetAcceptableValues(AcceptableValueBase values) { Type type = ((object)values).GetType(); PropertyInfo property = type.GetProperty("AcceptableValues", BindingFlags.Instance | BindingFlags.Public); if ((object)property != null) { base.AcceptableValues = ((IEnumerable)property.GetValue(values, null)).Cast<object>().ToArray(); return; } PropertyInfo property2 = type.GetProperty("MinValue", BindingFlags.Instance | BindingFlags.Public); if ((object)property2 != null) { PropertyInfo property3 = type.GetProperty("MaxValue", BindingFlags.Instance | BindingFlags.Public); if ((object)property3 == null) { throw new ArgumentNullException("maxProp"); } base.AcceptableValueRange = new KeyValuePair<object, object>(property2.GetValue(values, null), property3.GetValue(values, null)); base.ShowRangeAsPercent = ((base.AcceptableValueRange.Key.Equals(0) || base.AcceptableValueRange.Key.Equals(1)) && base.AcceptableValueRange.Value.Equals(100)) || (base.AcceptableValueRange.Key.Equals(0f) && base.AcceptableValueRange.Value.Equals(1f)); } } public override object Get() { return Entry.BoxedValue; } protected override void SetValue(object newVal) { Entry.BoxedValue = newVal; } } [BepInPlugin("com.bepis.bepinex.configurationmanager", "Configuration Manager", "18.1")] [Browsable(false)] public class ConfigurationManager : BaseUnityPlugin { private sealed class PluginSettingsData { public sealed class PluginSettingsGroupData { public string Name; public List<SettingEntryBase> Settings; } public BepInPlugin Info; public List<PluginSettingsGroupData> Categories; public int Height; public string Website; private bool _collapsed; public bool Collapsed { get { return _collapsed; } set { _collapsed = value; Height = 0; } } } public const string GUID = "com.bepis.bepinex.configurationmanager"; public const string Version = "18.1"; internal static ManualLogSource Logger; private static SettingFieldDrawer _fieldDrawer; private static readonly Color _advancedSettingColor = new Color(1f, 0.95f, 0.67f, 1f); private const int WindowId = -68; private const string SearchBoxName = "searchBox"; private bool _focusSearchBox; private string _searchString = string.Empty; public bool OverrideHotkey; private bool _displayingWindow; private bool _obsoleteCursor; private string _modsWithoutSettings; private List<SettingEntryBase> _allSettings; private List<PluginSettingsData> _filteredSetings = new List<PluginSettingsData>(); private bool _windowWasMoved; private bool _tipsPluginHeaderWasClicked; private bool _tipsWindowWasMoved; private Rect _screenRect; private Vector2 _settingWindowScrollPos; private int _tipsHeight; private PropertyInfo _curLockState; private PropertyInfo _curVisible; private int _previousCursorLockState; private bool _previousCursorVisible; private readonly ConfigEntry<bool> _showAdvanced; private readonly ConfigEntry<bool> _showKeybinds; private readonly ConfigEntry<bool> _showSettings; private readonly ConfigEntry<KeyboardShortcut> _keybind; private readonly ConfigEntry<bool> _hideSingleSection; private readonly ConfigEntry<bool> _pluginConfigCollapsedDefault; private bool _showDebug; internal Rect SettingWindowRect { get; private set; } internal int LeftColumnWidth { get; private set; } internal int RightColumnWidth { get; private set; } public bool DisplayingWindow { get { return _displayingWindow; } set { if (_displayingWindow == value) { return; } _displayingWindow = value; SettingFieldDrawer.ClearCache(); if (_displayingWindow) { CalculateWindowRect(); BuildSettingList(); _focusSearchBox = true; if ((object)_curLockState != null) { _previousCursorLockState = (_obsoleteCursor ? Convert.ToInt32((bool)_curLockState.GetValue(null, null)) : ((int)_curLockState.GetValue(null, null))); _previousCursorVisible = (bool)_curVisible.GetValue(null, null); } } else if (!_previousCursorVisible || _previousCursorLockState != 0) { SetUnlockCursor(_previousCursorLockState, _previousCursorVisible); } this.DisplayingWindowChanged?.Invoke(this, new ValueChangedEventArgs<bool>(value)); } } public string SearchString { get { return _searchString; } private set { if (value == null) { value = string.Empty; } if (!(_searchString == value)) { _searchString = value; BuildFilteredSettingList(); } } } public event EventHandler<ValueChangedEventArgs<bool>> DisplayingWindowChanged; public ConfigurationManager() { //IL_00a5: 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) //IL_00c0: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; _fieldDrawer = new SettingFieldDrawer(this); _showAdvanced = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "Show advanced", false, (ConfigDescription)null); _showKeybinds = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "Show keybinds", true, (ConfigDescription)null); _showSettings = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "Show settings", true, (ConfigDescription)null); _keybind = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Show config manager", new KeyboardShortcut((KeyCode)282, (KeyCode[])(object)new KeyCode[0]), new ConfigDescription("The shortcut used to toggle the config manager window on and off.\nThe key can be overridden by a game-specific plugin if necessary, in that case this setting is ignored.", (AcceptableValueBase)null, new object[0])); _hideSingleSection = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide single sections", false, new ConfigDescription("Show section title for plugins with only one section", (AcceptableValueBase)null, new object[0])); _pluginConfigCollapsedDefault = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Plugin collapsed default", true, new ConfigDescription("If set to true plugins will be collapsed when opening the configuration manager window", (AcceptableValueBase)null, new object[0])); } public static void RegisterCustomSettingDrawer(Type settingType, Action<SettingEntryBase> onGuiDrawer) { if ((object)settingType == null) { throw new ArgumentNullException("settingType"); } if (onGuiDrawer == null) { throw new ArgumentNullException("onGuiDrawer"); } if (SettingFieldDrawer.SettingDrawHandlers.ContainsKey(settingType)) { Logger.LogWarning((object)("Tried to add a setting drawer for type " + settingType.FullName + " while one already exists.")); } else { SettingFieldDrawer.SettingDrawHandlers[settingType] = onGuiDrawer; } } public void BuildSettingList() { SettingSearcher.CollectSettings(out var results, out var modsWithoutSettings, _showDebug); _modsWithoutSettings = string.Join(", ", (from x in modsWithoutSettings select x.TrimStart(new char[1] { '!' }) into x orderby x select x).ToArray()); _allSettings = results.ToList(); BuildFilteredSettingList(); } private void BuildFilteredSettingList() { IEnumerable<SettingEntryBase> source = _allSettings; string[] searchStrings = SearchString.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (searchStrings.Length != 0) { source = source.Where((SettingEntryBase x) => ContainsSearchString(x, searchStrings)); } else { if (!_showAdvanced.Value) { source = source.Where((SettingEntryBase x) => x.IsAdvanced != true); } if (!_showKeybinds.Value) { source = source.Where((SettingEntryBase x) => !IsKeyboardShortcut(x)); } if (!_showSettings.Value) { source = source.Where((SettingEntryBase x) => x.IsAdvanced == true || IsKeyboardShortcut(x)); } } bool settingsAreCollapsed = _pluginConfigCollapsedDefault.Value; HashSet<string> nonDefaultCollpasingStateByPluginName = new HashSet<string>(); foreach (PluginSettingsData filteredSeting in _filteredSetings) { if (filteredSeting.Collapsed != settingsAreCollapsed) { nonDefaultCollpasingStateByPluginName.Add(filteredSeting.Info.Name); } } _filteredSetings = (from x in (from x in source group x by x.PluginInfo).Select(delegate(IGrouping<BepInPlugin, SettingEntryBase> pluginSettings) { IEnumerable<PluginSettingsData.PluginSettingsGroupData> source2 = from eb in pluginSettings group eb by eb.Category into x orderby string.Equals(x.Key, "Keyboard shortcuts", StringComparison.Ordinal), x.Key select new PluginSettingsData.PluginSettingsGroupData { Name = x.Key, Settings = (from set in x orderby set.Order descending, set.DispName select set).ToList() }; string website = Utils.GetWebsite(pluginSettings.First().PluginInstance); return new PluginSettingsData { Info = pluginSettings.Key, Categories = source2.ToList(), Collapsed = (nonDefaultCollpasingStateByPluginName.Contains(pluginSettings.Key.Name) ? (!settingsAreCollapsed) : settingsAreCollapsed), Website = website }; }) orderby x.Info.Name select x).ToList(); } private static bool IsKeyboardShortcut(SettingEntryBase x) { if ((object)x.SettingType != typeof(KeyboardShortcut)) { return (object)x.SettingType == typeof(KeyCode); } return true; } private static bool ContainsSearchString(SettingEntryBase setting, string[] searchStrings) { string combinedSearchTarget = setting.PluginInfo.Name + "\n" + setting.PluginInfo.GUID + "\n" + setting.DispName + "\n" + setting.Category + "\n" + setting.Description + "\n" + setting.DefaultValue?.ToString() + "\n" + setting.Get(); return searchStrings.All((string s) => combinedSearchTarget.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) >= 0); } private void CalculateWindowRect() { //IL_005d: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Min(Screen.width, 650); int num2 = ((Screen.height < 560) ? Screen.height : (Screen.height - 100)); int num3 = Mathf.RoundToInt((float)(Screen.width - num) / 2f); int num4 = Mathf.RoundToInt((float)(Screen.height - num2) / 2f); SettingWindowRect = new Rect((float)num3, (float)num4, (float)num, (float)num2); _screenRect = new Rect(0f, 0f, (float)Screen.width, (float)Screen.height); Rect settingWindowRect = SettingWindowRect; LeftColumnWidth = Mathf.RoundToInt(((Rect)(ref settingWindowRect)).width / 2.5f); settingWindowRect = SettingWindowRect; RightColumnWidth = (int)((Rect)(ref settingWindowRect)).width - LeftColumnWidth - 115; _windowWasMoved = false; } private void OnGUI() { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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) //IL_00b9: 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_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00de: Unknown result type (might be due to invalid IL or missing references) if (!DisplayingWindow) { return; } SetUnlockCursor(0, cursorVisible: true); Vector2 val = Vector2.op_Implicit(UnityInput.Current.mousePosition); val.y = (float)Screen.height - val.y; Rect settingWindowRect; if (!_windowWasMoved) { if (GUI.Button(_screenRect, string.Empty, GUI.skin.box)) { settingWindowRect = SettingWindowRect; if (!((Rect)(ref settingWindowRect)).Contains(val)) { DisplayingWindow = false; } } ImguiUtils.DrawWindowBackground(SettingWindowRect); } Rect val2 = GUILayout.Window(-68, SettingWindowRect, new WindowFunction(SettingsWindow), "Plugin / mod settings", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (val2 != SettingWindowRect) { _windowWasMoved = true; SettingWindowRect = val2; _tipsWindowWasMoved = true; } if (SettingFieldDrawer.SettingKeyboardShortcut) { return; } if (_windowWasMoved) { settingWindowRect = SettingWindowRect; if (!((Rect)(ref settingWindowRect)).Contains(val)) { return; } } Input.ResetInputAxes(); } private static void DrawTooltip(Rect area) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00c8: 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) string tooltip = GUI.tooltip; if (!string.IsNullOrEmpty(tooltip)) { GUIStyle val = new GUIStyle(GUI.skin.box); val.wordWrap = true; val.alignment = (TextAnchor)4; GUIContent val2 = new GUIContent(tooltip); float num = val.CalcHeight(val2, 400f) + 10f; Vector2 mousePosition = Event.current.mousePosition; float num2 = ((mousePosition.x + 400f > ((Rect)(ref area)).width) ? (((Rect)(ref area)).width - 400f) : mousePosition.x); float num3 = ((mousePosition.y + 25f + num > ((Rect)(ref area)).height) ? (mousePosition.y - num) : (mousePosition.y + 25f)); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(num2, num3, 400f, num); ImguiUtils.DrawContolBackground(val3, Color.black); val.Draw(val3, val2, -1); } } private void SettingsWindow(int id) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Invalid comparison between Unknown and I4 //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) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) DrawWindowHeader(); _settingWindowScrollPos = GUILayout.BeginScrollView(_settingWindowScrollPos, false, true, (GUILayoutOption[])(object)new GUILayoutOption[0]); float y = _settingWindowScrollPos.y; Rect val = SettingWindowRect; float height = ((Rect)(ref val)).height; GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]); if (string.IsNullOrEmpty(SearchString)) { DrawTips(); if (_tipsHeight == 0 && (int)Event.current.type == 7) { val = GUILayoutUtility.GetLastRect(); _tipsHeight = (int)((Rect)(ref val)).height; } } int num = _tipsHeight; foreach (PluginSettingsData filteredSeting in _filteredSetings) { if (filteredSeting.Height == 0 || ((float)(num + filteredSeting.Height) >= y && (float)num <= y + height)) { try { DrawSinglePlugin(filteredSeting); } catch (ArgumentException) { } if (filteredSeting.Height == 0 && (int)Event.current.type == 7) { val = GUILayoutUtility.GetLastRect(); filteredSeting.Height = (int)((Rect)(ref val)).height; } } else { try { GUILayout.Space((float)filteredSeting.Height); } catch (ArgumentException) { } } num += filteredSeting.Height; } if (_showDebug) { GUILayout.Space(10f); GUILayout.Label("Plugins with no options available: " + _modsWithoutSettings, (GUILayoutOption[])(object)new GUILayoutOption[0]); } else { GUILayout.Space(70f); } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (!SettingFieldDrawer.DrawCurrentDropdown()) { DrawTooltip(SettingWindowRect); } GUI.DragWindow(); } private void DrawTips() { string text = ((!_tipsPluginHeaderWasClicked) ? "Tip: Click plugin names to expand. Click setting and group names to see their descriptions." : ((!_tipsWindowWasMoved) ? "Tip: You can drag this window to move it. It will stay open while you interact with the game." : null)); if (text != null) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label(text, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.EndHorizontal(); } } private void DrawWindowHeader() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUI.enabled = SearchString == string.Empty; bool flag = GUILayout.Toggle(_showSettings.Value, "Normal settings", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (_showSettings.Value != flag) { _showSettings.Value = flag; BuildFilteredSettingList(); } flag = GUILayout.Toggle(_showKeybinds.Value, "Keyboard shortcuts", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (_showKeybinds.Value != flag) { _showKeybinds.Value = flag; BuildFilteredSettingList(); } Color color = GUI.color; GUI.color = _advancedSettingColor; flag = GUILayout.Toggle(_showAdvanced.Value, "Advanced settings", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (_showAdvanced.Value != flag) { _showAdvanced.Value = flag; BuildFilteredSettingList(); } GUI.color = color; GUI.enabled = true; GUILayout.Space(8f); flag = GUILayout.Toggle(_showDebug, "Debug info", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (_showDebug != flag) { _showDebug = flag; BuildSettingList(); } if (GUILayout.Button("Open Log", (GUILayoutOption[])(object)new GUILayoutOption[0])) { try { Utils.OpenLog(); } catch (SystemException ex) { Logger.Log((LogLevel)10, (object)ex.Message); } } GUILayout.Space(8f); if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[0])) { DisplayingWindow = false; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Search: ", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUI.SetNextControlName("searchBox"); SearchString = GUILayout.TextField(SearchString, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (_focusSearchBox) { GUI.FocusWindow(-68); GUI.FocusControl("searchBox"); _focusSearchBox = false; } if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { SearchString = string.Empty; } GUILayout.Space(8f); if (GUILayout.Button(_pluginConfigCollapsedDefault.Value ? "Expand All" : "Collapse All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { bool flag2 = !_pluginConfigCollapsedDefault.Value; _pluginConfigCollapsedDefault.Value = flag2; foreach (PluginSettingsData filteredSeting in _filteredSetings) { filteredSeting.Collapsed = flag2; } _tipsPluginHeaderWasClicked = true; } GUILayout.EndHorizontal(); } private void DrawSinglePlugin(PluginSettingsData plugin) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUIContent content = (_showDebug ? new GUIContent($"{plugin.Info.Name.TrimStart(new char[1] { '!' })} {plugin.Info.Version}", (Texture)null, "GUID: " + plugin.Info.GUID) : new GUIContent($"{plugin.Info.Name.TrimStart(new char[1] { '!' })} {plugin.Info.Version}")); bool flag = !string.IsNullOrEmpty(SearchString); bool flag2 = plugin.Website != null; if (flag2) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Space(29f); } if (SettingFieldDrawer.DrawPluginHeader(content, plugin.Collapsed && !flag) && !flag) { _tipsPluginHeaderWasClicked = true; plugin.Collapsed = !plugin.Collapsed; } if (flag2) { Color color = GUI.color; GUI.color = Color.gray; if (GUILayout.Button(new GUIContent("URL", (Texture)null, plugin.Website), GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { Utils.OpenWebsite(plugin.Website); } GUI.color = color; GUILayout.EndHorizontal(); } if (flag || !plugin.Collapsed) { foreach (PluginSettingsData.PluginSettingsGroupData category in plugin.Categories) { if (!string.IsNullOrEmpty(category.Name) && (plugin.Categories.Count > 1 || !_hideSingleSection.Value)) { SettingFieldDrawer.DrawCategoryHeader(category.Name); } foreach (SettingEntryBase setting in category.Settings) { DrawSingleSetting(setting); GUILayout.Space(2f); } } } GUILayout.EndVertical(); } private void DrawSingleSetting(SettingEntryBase setting) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); try { DrawSettingName(setting); _fieldDrawer.DrawSettingValue(setting); DrawDefaultButton(setting); } catch (Exception arg) { Logger.Log((LogLevel)2, (object)$"Failed to draw setting {setting.DispName} - {arg}"); GUILayout.Label("Failed to draw this field, check log for details.", (GUILayoutOption[])(object)new GUILayoutOption[0]); } GUILayout.EndHorizontal(); } private void DrawSettingName(SettingEntryBase setting) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0081: Expected O, but got Unknown //IL_0081: 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) if (!setting.HideSettingName) { Color color = GUI.color; if (setting.IsAdvanced == true) { GUI.color = _advancedSettingColor; } GUILayout.Label(new GUIContent(setting.DispName.TrimStart(new char[1] { '!' }), (Texture)null, setting.Description), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width((float)LeftColumnWidth), GUILayout.MaxWidth((float)LeftColumnWidth) }); GUI.color = color; } } private static void DrawDefaultButton(SettingEntryBase setting) { if (setting.HideDefaultButton) { return; } object defaultValue = setting.DefaultValue; if (defaultValue != null || setting.SettingType.IsClass) { GUILayout.Space(5f); if (GUILayout.Button("Reset", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { setting.Set(defaultValue); } } } private void Start() { Type typeFromHandle = typeof(Cursor); _curLockState = typeFromHandle.GetProperty("lockState", BindingFlags.Static | BindingFlags.Public); _curVisible = typeFromHandle.GetProperty("visible", BindingFlags.Static | BindingFlags.Public); if ((object)_curLockState == null && (object)_curVisible == null) { _obsoleteCursor = true; _curLockState = typeof(Screen).GetProperty("lockCursor", BindingFlags.Static | BindingFlags.Public); _curVisible = typeof(Screen).GetProperty("showCursor", BindingFlags.Static | BindingFlags.Public); } try { ((BaseUnityPlugin)this).Config.Save(); } catch (IOException ex) { Logger.Log((LogLevel)12, (object)("WARNING: Failed to write to config directory, expect issues!\nError message:" + ex.Message)); } catch (UnauthorizedAccessException ex2) { Logger.Log((LogLevel)12, (object)("WARNING: Permission denied to write to config directory, expect issues!\nError message:" + ex2.Message)); } } private void Update() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (DisplayingWindow) { SetUnlockCursor(0, cursorVisible: true); } if (!OverrideHotkey) { KeyboardShortcut value = _keybind.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { DisplayingWindow = !DisplayingWindow; } } } private void LateUpdate() { if (DisplayingWindow) { SetUnlockCursor(0, cursorVisible: true); } } private void SetUnlockCursor(int lockState, bool cursorVisible) { if ((object)_curLockState != null) { if (_obsoleteCursor) { _curLockState.SetValue(null, Convert.ToBoolean(lockState), null); } else { _curLockState.SetValue(null, lockState, null); } _curVisible.SetValue(null, cursorVisible, null); } } } internal class PropertySettingEntry : SettingEntryBase { private Type _settingType; public object Instance { get; internal set; } public PropertyInfo Property { get; internal set; } public override string DispName { get { if (!string.IsNullOrEmpty(base.DispName)) { return base.DispName; } return Property.Name; } protected internal set { base.DispName = value; } } public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType); public PropertySettingEntry(object instance, PropertyInfo settingProp, BaseUnityPlugin pluginInstance) { SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance); if (!base.Browsable.HasValue) { base.Browsable = settingProp.CanRead && settingProp.CanWrite; } base.ReadOnly = settingProp.CanWrite; Property = settingProp; Instance = instance; } public override object Get() { return Property.GetValue(Instance, null); } protected override void SetValue(object newVal) { Property.SetValue(Instance, newVal, null); } } public abstract class SettingEntryBase { public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput); private static readonly PropertyInfo[] _myProperties = typeof(SettingEntryBase).GetProperties(BindingFlags.Instance | BindingFlags.Public); public object[] AcceptableValues { get; protected set; } public KeyValuePair<object, object> AcceptableValueRange { get; protected set; } public bool? ShowRangeAsPercent { get; protected set; } public Action<ConfigEntryBase> CustomDrawer { get; private set; } public CustomHotkeyDrawerFunc CustomHotkeyDrawer { get; private set; } public bool? Browsable { get; protected set; } public string Category { get; protected set; } public object DefaultValue { get; protected set; } public bool HideDefaultButton { get; protected set; } public bool HideSettingName { get; protected set; } public string Description { get; protected internal set; } public virtual string DispName { get; protected internal set; } public BepInPlugin PluginInfo { get; protected internal set; } public bool? ReadOnly { get; protected set; } public abstract Type SettingType { get; } public BaseUnityPlugin PluginInstance { get; private set; } public bool? IsAdvanced { get; internal set; } public int Order { get; protected set; } public Func<object, string> ObjToStr { get; internal set; } public Func<string, object> StrToObj { get; internal set; } public abstract object Get(); public void Set(object newVal) { if (ReadOnly != true) { SetValue(newVal); } } protected abstract void SetValue(object newVal); internal void SetFromAttributes(object[] attribs, BaseUnityPlugin pluginInstance) { PluginInstance = pluginInstance; PluginInfo = ((pluginInstance != null) ? pluginInstance.Info.Metadata : null); if (attribs == null || attribs.Length == 0) { return; } foreach (object obj in attribs) { if (obj == null) { continue; } if (!(obj is DisplayNameAttribute displayNameAttribute)) { if (!(obj is CategoryAttribute categoryAttribute)) { if (!(obj is DescriptionAttribute descriptionAttribute)) { if (!(obj is DefaultValueAttribute defaultValueAttribute)) { if (!(obj is ReadOnlyAttribute readOnlyAttribute)) { if (!(obj is BrowsableAttribute browsableAttribute)) { Action<SettingEntryBase> action = obj as Action<SettingEntryBase>; if (action == null) { if (obj is string text) { switch (text) { case "ReadOnly": ReadOnly = true; break; case "Browsable": Browsable = true; break; case "Unbrowsable": case "Hidden": Browsable = false; break; case "Advanced": IsAdvanced = true; break; } continue; } Type type = obj.GetType(); if (!(type.Name == "ConfigurationManagerAttributes")) { break; } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (var item in from my in _myProperties join other in fields on my.Name equals other.Name select new { my, other }) { try { object obj2 = item.other.GetValue(obj); if (obj2 != null) { if ((object)item.my.PropertyType != item.other.FieldType && typeof(Delegate).IsAssignableFrom(item.my.PropertyType)) { obj2 = Delegate.CreateDelegate(item.my.PropertyType, ((Delegate)obj2).Target, ((Delegate)obj2).Method); } item.my.SetValue(this, obj2, null); } } catch (Exception ex) { ConfigurationManager.Logger.LogWarning((object)("Failed to copy value " + item.my.Name + " from provided tag object " + type.FullName + " - " + ex.Message)); } } } else { CustomDrawer = delegate { action(this); }; } } else { Browsable = browsableAttribute.Browsable; } } else { ReadOnly = readOnlyAttribute.IsReadOnly; } } else { DefaultValue = defaultValueAttribute.Value; } } else { Description = descriptionAttribute.Description; } } else { Category = categoryAttribute.Category; } } else { DispName = displayNameAttribute.DisplayName; } } } } internal class SettingFieldDrawer { private sealed class ColorCacheEntry { public Color Last; public Texture2D Tex; } private static IEnumerable<KeyCode> _keysToCheck; private static readonly Dictionary<SettingEntryBase, ComboBox> _comboBoxCache; private static readonly Dictionary<SettingEntryBase, ColorCacheEntry> _colorCache; private static ConfigurationManager _instance; private static SettingEntryBase _currentKeyboardShortcutToSet; private static GUIStyle _categoryHeaderSkin; private static GUIStyle _pluginHeaderSkin; private readonly Dictionary<Type, bool> _canCovertCache = new Dictionary<Type, bool>(); public static Dictionary<Type, Action<SettingEntryBase>> SettingDrawHandlers { get; } public static bool SettingKeyboardShortcut => _currentKeyboardShortcutToSet != null; static SettingFieldDrawer() { _comboBoxCache = new Dictionary<SettingEntryBase, ComboBox>(); _colorCache = new Dictionary<SettingEntryBase, ColorCacheEntry>(); SettingDrawHandlers = new Dictionary<Type, Action<SettingEntryBase>> { { typeof(bool), DrawBoolField }, { typeof(KeyboardShortcut), DrawKeyboardShortcut }, { typeof(KeyCode), DrawKeyCode }, { typeof(Color), DrawColor }, { typeof(Vector2), DrawVector2 }, { typeof(Vector3), DrawVector3 }, { typeof(Vector4), DrawVector4 }, { typeof(Quaternion), DrawQuaternion } }; } public SettingFieldDrawer(ConfigurationManager instance) { _instance = instance; } public void DrawSettingValue(SettingEntryBase setting) { if (setting.CustomDrawer != null) { setting.CustomDrawer((setting is ConfigSettingEntry configSettingEntry) ? configSettingEntry.Entry : null); } else if (setting.CustomHotkeyDrawer != null) { bool isCurrentlyAcceptingInput = _currentKeyboardShortcutToSet == setting; bool flag = isCurrentlyAcceptingInput; setting.CustomHotkeyDrawer((setting is ConfigSettingEntry configSettingEntry2) ? configSettingEntry2.Entry : null, ref isCurrentlyAcceptingInput); if (isCurrentlyAcceptingInput != flag) { _currentKeyboardShortcutToSet = (isCurrentlyAcceptingInput ? setting : null); } } else if (setting.ShowRangeAsPercent.HasValue && setting.AcceptableValueRange.Key != null) { DrawRangeField(setting); } else if (setting.AcceptableValues != null) { DrawListField(setting); } else if (!DrawFieldBasedOnValueType(setting)) { if (setting.SettingType.IsEnum) { DrawEnumField(setting); } else { DrawUnknownField(setting, _instance.RightColumnWidth); } } } public static void ClearCache() { _comboBoxCache.Clear(); foreach (KeyValuePair<SettingEntryBase, ColorCacheEntry> item in _colorCache) { Object.Destroy((Object)(object)item.Value.Tex); } _colorCache.Clear(); } public static void DrawCenteredLabel(string text, params GUILayoutOption[] options) { GUILayout.BeginHorizontal(options); GUILayout.FlexibleSpace(); GUILayout.Label(text, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } public static void DrawCategoryHeader(string text) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (_categoryHeaderSkin == null) { _categoryHeaderSkin = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)1, wordWrap = true, stretchWidth = true, fontSize = 14 }; } GUILayout.Label(text, _categoryHeaderSkin, (GUILayoutOption[])(object)new GUILayoutOption[0]); } public static bool DrawPluginHeader(GUIContent content, bool isCollapsed) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (_pluginHeaderSkin == null) { _pluginHeaderSkin = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)1, wordWrap = true, stretchWidth = true, fontSize = 15 }; } if (isCollapsed) { content.text += "\n..."; } return GUILayout.Button(content, _pluginHeaderSkin, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } public static bool DrawCurrentDropdown() { if (ComboBox.CurrentDropdownDrawer != null) { ComboBox.CurrentDropdownDrawer(); ComboBox.CurrentDropdownDrawer = null; return true; } return false; } private static void DrawListField(SettingEntryBase setting) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) object[] acceptableValues = setting.AcceptableValues; if (acceptableValues.Length == 0) { throw new ArgumentException("AcceptableValueListAttribute returned an empty list of acceptable values. You need to supply at least 1 option."); } if (!setting.SettingType.IsInstanceOfType(acceptableValues.FirstOrDefault((object x) => x != null))) { throw new ArgumentException("AcceptableValueListAttribute returned a list with items of type other than the settng type itself."); } if ((object)setting.SettingType == typeof(KeyCode)) { DrawKeyCode(setting); return; } Rect settingWindowRect = _instance.SettingWindowRect; DrawComboboxField(setting, acceptableValues, ((Rect)(ref settingWindowRect)).yMax); } private static bool DrawFieldBasedOnValueType(SettingEntryBase setting) { if (SettingDrawHandlers.TryGetValue(setting.SettingType, out var value)) { value(setting); return true; } return false; } private static void DrawBoolField(SettingEntryBase setting) { bool flag = (bool)setting.Get(); bool flag2 = GUILayout.Toggle(flag, flag ? "Enabled" : "Disabled", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (flag2 != flag) { setting.Set(flag2); } } private static void DrawEnumField(SettingEntryBase setting) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (setting.SettingType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any()) { DrawFlagsField(setting, Enum.GetValues(setting.SettingType), _instance.RightColumnWidth); return; } Array values = Enum.GetValues(setting.SettingType); Rect settingWindowRect = _instance.SettingWindowRect; DrawComboboxField(setting, values, ((Rect)(ref settingWindowRect)).yMax); } private static void DrawFlagsField(SettingEntryBase setting, IList enumValues, int maxWidth) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) long num = Convert.ToInt64(setting.Get()); var array = (from Enum x in enumValues select new { name = x.ToString(), val = Convert.ToInt64(x) }).ToArray(); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)maxWidth) }); int i = 0; while (i < array.Length) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); int num2 = 0; for (; i < array.Length; i++) { var anon = array[i]; if (anon.val != 0L) { int num3 = (int)GUI.skin.toggle.CalcSize(new GUIContent(anon.name)).x; num2 += num3; if (num2 > maxWidth) { break; } GUI.changed = false; bool flag = GUILayout.Toggle((num & anon.val) == anon.val, anon.name, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (GUI.changed) { long value = (flag ? (num | anon.val) : (num & ~anon.val)); setting.Set(Enum.ToObject(setting.SettingType, value)); } } } GUILayout.EndHorizontal(); } GUI.changed = false; GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } private static void DrawComboboxField(SettingEntryBase setting, IList list, float windowYmax) { //IL_003f: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) GUIContent val = ObjectToGuiContent(setting.Get()); Rect rect = GUILayoutUtility.GetRect(val, GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (!_comboBoxCache.TryGetValue(setting, out var value)) { value = new ComboBox(rect, val, list.Cast<object>().Select(ObjectToGuiContent).ToArray(), GUI.skin.button, windowYmax); _comboBoxCache[setting] = value; } else { value.Rect = rect; value.ButtonContent = val; } value.Show(delegate(int id) { if (id >= 0 && id < list.Count) { setting.Set(list[id]); } }); } private static GUIContent ObjectToGuiContent(object x) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown if (x is Enum) { Type type = x.GetType(); DescriptionAttribute descriptionAttribute = type.GetMember(x.ToString()).FirstOrDefault()?.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false).Cast<DescriptionAttribute>().FirstOrDefault(); if (descriptionAttribute == null) { return new GUIContent(x.ToString().ToProperCase()); } return new GUIContent(descriptionAttribute.Description); } return new GUIContent(x.ToString()); } private static void DrawRangeField(SettingEntryBase setting) { object obj = setting.Get(); float num = (float)Convert.ToDouble(obj, CultureInfo.InvariantCulture); float num2 = (float)Convert.ToDouble(setting.AcceptableValueRange.Key, CultureInfo.InvariantCulture); float num3 = (float)Convert.ToDouble(setting.AcceptableValueRange.Value, CultureInfo.InvariantCulture); float num4 = GUILayout.HorizontalSlider(num, num2, num3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (Math.Abs(num4 - num) > Mathf.Abs(num3 - num2) / 1000f) { object newVal = Convert.ChangeType(num4, setting.SettingType, CultureInfo.InvariantCulture); setting.Set(newVal); } if (setting.ShowRangeAsPercent == true) { DrawCenteredLabel(Mathf.Round(100f * Mathf.Abs(num4 - num2) / Mathf.Abs(num3 - num2)) + "%", GUILayout.Width(50f)); return; } string text = obj.ToString().AppendZeroIfFloat(setting.SettingType); string text2 = GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (!(text2 != text)) { return; } try { float num5 = (float)Convert.ToDouble(text2, CultureInfo.InvariantCulture); float num6 = Mathf.Clamp(num5, num2, num3); setting.Set(Convert.ChangeType(num6, setting.SettingType, CultureInfo.InvariantCulture)); } catch (FormatException) { } } private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth) { if (setting.ObjToStr != null && setting.StrToObj != null) { string text = setting.ObjToStr(setting.Get()).AppendZeroIfFloat(setting.SettingType); string text2 = GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width((float)rightColumnWidth), GUILayout.MaxWidth((float)rightColumnWidth) }); if (text2 != text) { setting.Set(setting.StrToObj(text2)); } } else { object obj = setting.Get(); string text3 = ((obj == null) ? "NULL" : obj.ToString().AppendZeroIfFloat(setting.SettingType)); if (CanCovert(text3, setting.SettingType)) { string text4 = GUILayout.TextField(text3, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width((float)rightColumnWidth), GUILayout.MaxWidth((float)rightColumnWidth) }); if (text4 != text3) { setting.Set(Convert.ChangeType(text4, setting.SettingType, CultureInfo.InvariantCulture)); } } else { GUILayout.TextArea(text3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) }); } } GUILayout.FlexibleSpace(); } private bool CanCovert(string value, Type type) { if (_canCovertCache.ContainsKey(type)) { return _canCovertCache[type]; } try { object obj = Convert.ChangeType(value, type); _canCovertCache[type] = true; return true; } catch { _canCovertCache[type] = false; return false; } } private static void DrawKeyCode(SettingEntryBase setting) { //IL_00f0: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label("Press any key", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIUtility.keyboardControl = -1; IInputSystem current = UnityInput.Current; if (_keysToCheck == null) { _keysToCheck = current.SupportedKeyCodes.Except((IEnumerable<KeyCode>)(object)new KeyCode[2] { (KeyCode)323, default(KeyCode) }).ToArray(); } foreach (KeyCode item in _keysToCheck) { if (current.GetKeyUp(item)) { setting.Set(item); _currentKeyboardShortcutToSet = null; break; } } if (GUILayout.Button("Cancel", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = null; } } else { object[] acceptableValues = setting.AcceptableValues; Array list = ((acceptableValues != null && acceptableValues.Length > 1) ? setting.AcceptableValues : Enum.GetValues(setting.SettingType)); Rect settingWindowRect = _instance.SettingWindowRect; DrawComboboxField(setting, list, ((Rect)(ref settingWindowRect)).yMax); if (GUILayout.Button(new GUIContent("Set...", (Texture)null, "Set the key by pressing any key on your keyboard."), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = setting; } } } private static void DrawKeyboardShortcut(SettingEntryBase setting) { //IL_0125: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label("Press any key combination", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIUtility.keyboardControl = -1; IInputSystem current = UnityInput.Current; if (_keysToCheck == null) { _keysToCheck = current.SupportedKeyCodes.Except((IEnumerable<KeyCode>)(object)new KeyCode[2] { (KeyCode)323, default(KeyCode) }).ToArray(); } foreach (KeyCode item in _keysToCheck) { if (current.GetKeyUp(item)) { setting.Set((object)new KeyboardShortcut(item, _keysToCheck.Where((Func<KeyCode, bool>)current.GetKey).ToArray())); _currentKeyboardShortcutToSet = null; break; } } if (GUILayout.Button("Cancel", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = null; } } else { if (GUILayout.Button(setting.Get().ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { _currentKeyboardShortcutToSet = setting; } if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { setting.Set(KeyboardShortcut.Empty); _currentKeyboardShortcutToSet = null; } } } private static void DrawVector2(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0010: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (Vector2)obj.Get(); Vector2 val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); if (val != val2) { obj.Set(val); } } private static void DrawVector3(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0010: 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_003e: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Vector3)obj.Get(); Vector3 val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); val.z = DrawSingleVectorSlider(val.z, "Z"); if (val != val2) { obj.Set(val); } } private static void DrawVector4(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0010: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) Vector4 val = (Vector4)obj.Get(); Vector4 val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); val.z = DrawSingleVectorSlider(val.z, "Z"); val.w = DrawSingleVectorSlider(val.w, "W"); if (val != val2) { obj.Set(val); } } private static void DrawQuaternion(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0010: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) Quaternion val = (Quaternion)obj.Get(); Quaternion val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); val.z = DrawSingleVectorSlider(val.z, "Z"); val.w = DrawSingleVectorSlider(val.w, "W"); if (val != val2) { obj.Set(val); } } private static float DrawSingleVectorSlider(float setting, string label) { GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); float.TryParse(GUILayout.TextField(setting.ToString("F", CultureInfo.InvariantCulture), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }), NumberStyles.Any, CultureInfo.InvariantCulture, out var result); return result; } private static void DrawColor(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_0031: Expected O, but got Unknown //IL_0032: 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_003f: 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) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) Color val = (Color)obj.Get(); if (!_colorCache.TryGetValue(obj, out var value)) { value = new ColorCacheEntry { Tex = new Texture2D(40, 10, (TextureFormat)5, false), Last = val }; value.Tex.FillTexture(val); _colorCache[obj] = value; } GUILayout.Label("R", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.r = GUILayout.HorizontalSlider(val.r, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("G", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.g = GUILayout.HorizontalSlider(val.g, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("B", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.b = GUILayout.HorizontalSlider(val.b, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("A", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.a = GUILayout.HorizontalSlider(val.a, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Space(4f); if (val != value.Last) { obj.Set(val); value.Tex.FillTexture(val); value.Last = val; } GUILayout.Label((Texture)(object)value.Tex, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } } public sealed class ValueChangedEventArgs<TValue> : EventArgs { public TValue NewValue { get; } public ValueChangedEventArgs(TValue newValue) { NewValue = newValue; } } } namespace ConfigurationManager.Utilities { internal class ComboBox { private static bool forceToUnShow; private static int useControlID = -1; private readonly string buttonStyle; private bool isClickedComboButton; private readonly GUIContent[] listContent; private readonly GUIStyle listStyle; private readonly int _windowYmax; private Vector2 _scrollPosition = Vector2.zero; public Rect Rect { get; set; } public GUIContent ButtonContent { get; set; } public static Action CurrentDropdownDrawer { get; set; } public ComboBox(Rect rect, GUIContent buttonContent, GUIContent[] listContent, GUIStyle listStyle, float windowYmax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) Rect = rect; ButtonContent = buttonContent; this.listContent = listContent; buttonStyle = "button"; this.listStyle = listStyle; _windowYmax = (int)windowYmax; } public void Show(Action<int> onItemSelected) { //IL_0031: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (forceToUnShow) { forceToUnShow = false; isClickedComboButton = false; } bool flag = false; int controlID = GUIUtility.GetControlID((FocusType)2); Vector2 val = Vector2.zero; if ((int)Event.current.GetTypeForControl(controlID) == 1 && isClickedComboButton) { flag = true; val = Event.current.mousePosition; } if (GUI.Button(Rect, ButtonContent, GUIStyle.op_Implicit(buttonStyle))) { if (useControlID == -1) { useControlID = controlID; isClickedComboButton = false; } if (useControlID != controlID) { forceToUnShow = true; useControlID = controlID; } isClickedComboButton = true; } if (isClickedComboButton) { GUI.enabled = false; GUI.color = new Color(1f, 1f, 1f, 2f); Rect rect = Rect; float x = ((Rect)(ref rect)).x; rect = Rect; Vector2 location = GUIUtility.GUIToScreenPoint(new Vector2(x, ((Rect)(ref rect)).y + listStyle.CalcHeight(listContent[0], 1f))); rect = Rect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Rect)(ref rect)).width, listStyle.CalcHeight(listContent[0], 1f) * (float)listContent.Length); Rect innerRect = new Rect(0f, 0f, val2.x, val2.y); Rect outerRectScreen = new Rect(location.x, location.y, val2.x, val2.y); if (((Rect)(ref outerRectScreen)).yMax > (float)_windowYmax) { ((Rect)(ref outerRectScreen)).height = (float)_windowYmax - ((Rect)(ref outerRectScreen)).y; ref Rect reference = ref outerRectScreen; ((Rect)(ref reference)).width = ((Rect)(ref reference)).width + 20f; } if (val != Vector2.zero && ((Rect)(ref outerRectScreen)).Contains(GUIUtility.GUIToScreenPoint(val))) { flag = false; } CurrentDropdownDrawer = delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) //IL_003e: 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_0050: 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) //IL_005d: 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) //IL_0069: 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) GUI.enabled = true; Vector2 val3 = GUIUtility.ScreenToGUIPoint(location); Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(val3.x, val3.y, ((Rect)(ref outerRectScreen)).width, ((Rect)(ref outerRectScreen)).height); ImguiUtils.DrawContolBackground(val4); _scrollPosition = GUI.BeginScrollView(val4, _scrollPosition, innerRect, false, false); int num = GUI.SelectionGrid(innerRect, -1, listContent, 1, listStyle); if (num != -1) { onItemSelected(num); isClickedComboButton = false; } GUI.EndScrollView(true); }; } if (flag) { isClickedComboButton = false; } } } internal static class ImguiUtils { private static Texture2D _tooltipBg; private static Texture2D _windowBackground; public static void DrawWindowBackground(Rect position) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0069: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_windowBackground)) { Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false); val.SetPixel(0, 0, new Color(0.5f, 0.5f, 0.5f, 1f)); val.Apply(); _windowBackground = val; } GUI.Box(position, GUIContent.none, new GUIStyle { normal = new GUIStyleState { background = _windowBackground } }); } public static void DrawContolBackground(Rect position, Color color = default(Color)) { //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_003a: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0055: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_tooltipBg)) { Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false); val.SetPixel(0, 0, Color.black); val.Apply(); _tooltipBg = val; } GUI.Box(position, GUIContent.none, new GUIStyle { normal = new GUIStyleState { background = _tooltipBg } }); } } internal static class Utils { public static string ToProperCase(this string str) { if (string.IsNullOrEmpty(str)) { return string.Empty; } if (str.Length < 2) { return str; } string text = str.Substring(0, 1).ToUpper(); for (int i = 1; i < str.Length; i++) { if (char.IsUpper(str[i])) { text += " "; } text += str[i]; } return text; } public static string AppendZero(this string s) { if (s.Contains(".")) { return s; } return s + ".0"; } public static string AppendZeroIfFloat(this string s, Type type) { if ((object)type != typeof(float) && (object)type != typeof(double) && (object)type != typeof(decimal)) { return s; } return s.AppendZero(); } public static void FillTexture(this Texture2D tex, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < ((Texture)tex).width; i++) { for (int j = 0; j < ((Texture)tex).height; j++) { tex.SetPixel(i, j, color); } } tex.Apply(false); } public static void OpenLog() { List<string> list = new List<string>(); string text = Path.Combine(Application.dataPath, ".."); list.Add(Path.Combine(text, "output_log.txt")); list.Add(Path.Combine(Application.dataPath, "output_log.txt")); PropertyInfo property = typeof(Application).GetProperty("consoleLogPath", BindingFlags.Static | BindingFlags.Public); if ((object)property != null) { string item = property.GetValue(null, null) as string; list.Add(item); } if (Directory.Exists(Application.persistentDataPath)) { string item2 = Directory.GetFiles(Application.persistentDataPath, "output_log.txt", SearchOption.AllDirectories).FirstOrDefault(); list.Add(item2); } string path2 = list.Where(File.Exists).OrderByDescending(File.GetLastWriteTimeUtc).FirstOrDefault(); if (!TryOpen(path2)) { list.Clear(); list.AddRange(Directory.GetFiles(text, "LogOutput.log*", SearchOption.AllDirectories)); list.AddRange(Directory.GetFiles(text, "output_log.txt", SearchOption.AllDirectories)); path2 = list.Where(File.Exists).OrderByDescending(File.GetLastWriteTimeUtc).FirstOrDefault(); if (!TryOpen(path2)) { throw new FileNotFoundException("No log files were found"); } } static bool TryOpen(string path) { if (path == null) { return false; } try { Process.Start(new ProcessStartInfo(path) { UseShellExecute = true }); return true; } catch { return false; } } } public static string GetWebsite(BaseUnityPlugin bepInPlugin) { if ((Object)(object)bepInPlugin == (Object)null) { return null; } try { string location = bepInPlugin.Info.Location; if (!File.Exists(location)) { return null; } FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(location); return new string[5] { versionInfo.CompanyName, versionInfo.FileDescription, versionInfo.Comments, versionInfo.LegalCopyright, versionInfo.LegalTrademarks }.FirstOrDefault((string x) => Uri.IsWellFormedUriString(x, UriKind.Absolute)); } catch (Exception ex) { ManualLogSource logger = ConfigurationManager.Logger; PluginInfo info = bepInPlugin.Info; object obj; if (info == null) { obj = null; } else { BepInPlugin metadata = info.Metadata; obj = ((metadata != null) ? metadata.Name : null); } logger.LogWarning((object)("Failed to get URI for " + (string?)obj + " - " + ex.Message)); return null; } } public static void OpenWebsite(string url) { try { if (string.IsNullOrEmpty(url)) { throw new Exception("Empty URL"); } Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); } catch (Exception ex) { ConfigurationManager.Logger.Log((LogLevel)12, (object)("Failed to open URL " + url + "\nCause: " + ex.Message)); } } } }
plugins/BepInEx_Unofficial-BepInEx_GraphicsSettings/GraphicsSettings.dll
Decompiled 2 years agousing System; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("BepInEx.GraphicsSettings")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BepInEx.GraphicsSettings")] [assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9bba5dae-624e-4ff0-80a2-f14029ee34e9")] [assembly: AssemblyFileVersion("1.3")] [assembly: AssemblyVersion("1.0.0.0")] namespace GraphicsSettings; internal sealed class ConfigurationManagerAttributes { public bool? ShowRangeAsPercent; public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public string Description; public string DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func<object, string> ObjToStr; public Func<string, object> StrToObj; } [BepInPlugin("keelhauled.graphicssettings", "Graphics Settings", "1.3")] public class GraphicsSettings : BaseUnityPlugin { public const string GUID = "keelhauled.graphicssettings"; public const string Version = "1.3"; private const string CATEGORY_GENERAL = "General"; private const string CATEGORY_RENDER = "Rendering"; private const string DESCRIPTION_RESOLUTION = "Dummy setting for the custom drawer. Resolution is saved automatically by the game after clicking apply."; private const string DESCRIPTION_ANISOFILTER = "Improves distant textures when they are being viewer from indirect angles."; private const string DESCRIPTION_VSYNC = "VSync synchronizes the output video of the graphics card to the refresh rate of the monitor. This prevents tearing and produces a smoother video output.\nHalf vsync synchronizes the output to half the refresh rate of your monitor."; private const string DESCRIPTION_FRAMERATELIMIT = "Limits your framerate to whatever value is set. -1 equals unlocked framerate.\nVSync has to be disabled for this setting to take effect."; private const string DESCRIPTION_ANTIALIASING = "Smooths out jagged edges on objects."; private const string DESCRIPTION_RUNINBACKGROUND = "Should the game be running when it is in the background (when the window is not focused)?\n"; private const string DESCRIPTION_OPTIMIZEINBACKGROUND = "Optimize the game when it is the background and unfocused. Settings such as anti-aliasing will be turned off or reduced in this state."; private string resolutionX = Screen.width.ToString(); private string resolutionY = Screen.height.ToString(); private bool framerateToggle; private WinAPI.WindowStyleFlags backupStandard; private WinAPI.WindowStyleFlags backupExtended; private bool backupDone; private Object configManager; private bool configManagerSearch; private int lastAntiAliasingValue = -1; private ConfigEntry<string> Resolution { get; set; } private ConfigEntry<SettingEnum.DisplayMode> DisplayMode { get; set; } private ConfigEntry<int> SelectedMonitor { get; set; } private ConfigEntry<SettingEnum.VSyncType> VSync { get; set; } private ConfigEntry<int> FramerateLimit { get; set; } private ConfigEntry<SettingEnum.AntiAliasingMode> AntiAliasing { get; set; } private ConfigEntry<SettingEnum.AnisotropicFilteringMode> AnisotropicFiltering { get; set; } private ConfigEntry<SettingEnum.RunInBackgroundMode> RunInBackground { get; set; } private ConfigEntry<bool> OptimizeInBackground { get; set; } private void Awake() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown Resolution = ((BaseUnityPlugin)this).Config.AddSetting<string>("Rendering", "Resolution", "", new ConfigDescription("Dummy setting for the custom drawer. Resolution is saved automatically by the game after clicking apply.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 9, HideDefaultButton = true, CustomDrawer = ResolutionDrawer } })); DisplayMode = ((BaseUnityPlugin)this).Config.AddSetting<SettingEnum.DisplayMode>("Rendering", "Display mode", SettingEnum.DisplayMode.Default, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 10 } })); SelectedMonitor = ((BaseUnityPlugin)this).Config.AddSetting<int>("Rendering", "Selected monitor", 0, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueList<int>(Enumerable.Range(0, Display.displays.Length).ToArray()), new object[1] { new ConfigurationManagerAttributes { Order = 8 } })); VSync = ((BaseUnityPlugin)this).Config.AddSetting<SettingEnum.VSyncType>("Rendering", "VSync", SettingEnum.VSyncType.Default, new ConfigDescription("VSync synchronizes the output video of the graphics card to the refresh rate of the monitor. This prevents tearing and produces a smoother video output.\nHalf vsync synchronizes the output to half the refresh rate of your monitor.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 7 } })); FramerateLimit = ((BaseUnityPlugin)this).Config.AddSetting<int>("Rendering", "Framerate limit", Application.targetFrameRate, new ConfigDescription("Limits your framerate to whatever value is set. -1 equals unlocked framerate.\nVSync has to be disabled for this setting to take effect.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 6, HideDefaultButton = true, CustomDrawer = FramerateLimitDrawer } })); AntiAliasing = ((BaseUnityPlugin)this).Config.AddSetting<SettingEnum.AntiAliasingMode>("Rendering", "Anti-aliasing multiplier", SettingEnum.AntiAliasingMode.Default, new ConfigDescription("Smooths out jagged edges on objects.", (AcceptableValueBase)null, new object[0])); AnisotropicFiltering = ((BaseUnityPlugin)this).Config.AddSetting<SettingEnum.AnisotropicFilteringMode>("Rendering", "Anisotropic filtering", SettingEnum.AnisotropicFilteringMode.Default, new ConfigDescription("Improves distant textures when they are being viewer from indirect angles.", (AcceptableValueBase)null, new object[0])); RunInBackground = ((BaseUnityPlugin)this).Config.AddSetting<SettingEnum.RunInBackgroundMode>("General", "Run in background", SettingEnum.RunInBackgroundMode.Default, new ConfigDescription("Should the game be running when it is in the background (when the window is not focused)?\n", (AcceptableValueBase)null, new object[0])); OptimizeInBackground = ((BaseUnityPlugin)this).Config.AddSetting<bool>("General", "Optimize in background", true, new ConfigDescription("Optimize the game when it is the background and unfocused. Settings such as anti-aliasing will be turned off or reduced in this state.", (AcceptableValueBase)null, new object[0])); if (DisplayMode.Value == SettingEnum.DisplayMode.BorderlessFullscreen) { ((MonoBehaviour)this).StartCoroutine(RemoveBorder()); } DisplayMode.SettingChanged += delegate { SetDisplayMode(); }; SelectedMonitor.SettingChanged += delegate { ((MonoBehaviour)this).StartCoroutine(SelectMonitor()); }; InitSetting<int>(FramerateLimit, SetFramerateLimit); InitSetting<SettingEnum.VSyncType>(VSync, delegate { if (VSync.Value != SettingEnum.VSyncType.Default) { QualitySettings.vSyncCount = (int)VSync.Value; } }); InitSetting<SettingEnum.AntiAliasingMode>(AntiAliasing, delegate { if (AntiAliasing.Value != SettingEnum.AntiAliasingMode.Default) { QualitySettings.antiAliasing = (int)AntiAliasing.Value; } }); InitSetting<SettingEnum.AnisotropicFilteringMode>(AnisotropicFiltering, delegate { if (AnisotropicFiltering.Value != SettingEnum.AnisotropicFilteringMode.Default) { QualitySettings.anisotropicFiltering = (AnisotropicFiltering)AnisotropicFiltering.Value; } }); InitSetting<SettingEnum.RunInBackgroundMode>(RunInBackground, delegate { if (RunInBackground.Value != SettingEnum.RunInBackgroundMode.Default) { Application.runInBackground = RunInBackground.Value == SettingEnum.RunInBackgroundMode.Yes; } }); } private void OnApplicationFocus(bool hasFocus) { if (OptimizeInBackground.Value) { if (lastAntiAliasingValue < 0 || !hasFocus) { lastAntiAliasingValue = QualitySettings.antiAliasing; } if (!hasFocus) { QualitySettings.antiAliasing = 0; } else if (AntiAliasing.Value != SettingEnum.AntiAliasingMode.Default) { QualitySettings.antiAliasing = (int)AntiAliasing.Value; } else { QualitySettings.antiAliasing = lastAntiAliasingValue; } } } private void ResolutionDrawer(ConfigEntryBase configEntry) { string text = GUILayout.TextField(resolutionX, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); string text2 = GUILayout.TextField(resolutionY, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); if (text != resolutionX && int.TryParse(text, out var result)) { resolutionX = text; } if (text2 != resolutionY && int.TryParse(text2, out result)) { resolutionY = text2; } if (GUILayout.Button("Apply", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { int num = int.Parse(resolutionX); int num2 = int.Parse(resolutionY); if (Screen.width != num || Screen.height != num2) { ((MonoBehaviour)this).StartCoroutine(SetResolution(num, num2)); } } GUILayout.Space(5f); if (GUILayout.Button("Reset", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { Display val = Display.displays[SelectedMonitor.Value]; if (Screen.width != val.renderingWidth || Screen.height != val.renderingHeight) { ((MonoBehaviour)this).StartCoroutine(SetResolution(val.renderingWidth, val.renderingHeight)); } } IEnumerator SetResolution(int width, int height) { Screen.SetResolution(width, height, Screen.fullScreen); yield return null; UpdateConfigManagerSize(); resolutionX = Screen.width.ToString(); resolutionY = Screen.height.ToString(); if (DisplayMode.Value == SettingEnum.DisplayMode.BorderlessFullscreen) { ((MonoBehaviour)this).StartCoroutine(RemoveBorder()); } } } private void FramerateLimitDrawer(ConfigEntryBase configEntry) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) bool flag = GUILayout.Toggle(framerateToggle, "Enabled", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); if (flag != framerateToggle) { framerateToggle = flag; if (flag) { Resolution currentResolution = Screen.currentResolution; int refreshRate = ((Resolution)(ref currentResolution)).refreshRate; FramerateLimit.Value = refreshRate; Application.targetFrameRate = refreshRate; } else { FramerateLimit.Value = -1; Application.targetFrameRate = -1; } } int num = (int)GUILayout.HorizontalSlider((float)FramerateLimit.Value, 30f, 200f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (num != FramerateLimit.Value && framerateToggle) { FramerateLimit.Value = (Application.targetFrameRate = num); if (!framerateToggle) { framerateToggle = true; } } GUILayout.Space(5f); GUILayout.TextField(FramerateLimit.Value.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); } private void SetDisplayMode() { switch (DisplayMode.Value) { case SettingEnum.DisplayMode.Windowed: MakeWindowed(); break; case SettingEnum.DisplayMode.Fullscreen: MakeFullscreen(); break; case SettingEnum.DisplayMode.BorderlessFullscreen: ((MonoBehaviour)this).StartCoroutine(RemoveBorder()); break; case SettingEnum.DisplayMode.Default: break; } } private void SetFramerateLimit() { Application.targetFrameRate = FramerateLimit.Value; framerateToggle = FramerateLimit.Value > 0; } private IEnumerator SelectMonitor() { PlayerPrefs.SetInt("UnitySelectMonitor", SelectedMonitor.Value); Screen.SetResolution(800, 600, Screen.fullScreen); yield return null; Display val = Display.displays[SelectedMonitor.Value]; Screen.SetResolution(val.renderingWidth, val.renderingHeight, Screen.fullScreen); yield return null; UpdateConfigManagerSize(); resolutionX = Screen.width.ToString(); resolutionY = Screen.height.ToString(); if (DisplayMode.Value == SettingEnum.DisplayMode.BorderlessFullscreen) { ((MonoBehaviour)this).StartCoroutine(RemoveBorder()); } } private IEnumerator RemoveBorder() { if (Screen.fullScreen) { Screen.SetResolution(Screen.width, Screen.height, false); yield return null; } IntPtr activeWindow = WinAPI.GetActiveWindow(); if (!backupDone) { backupStandard = WinAPI.GetWindowLongPtr(activeWindow, WinAPI.WindowLongIndex.Style); backupExtended = WinAPI.GetWindowLongPtr(activeWindow, WinAPI.WindowLongIndex.ExtendedStyle); backupDone = true; } WinAPI.WindowStyleFlags dwNewLong = backupStandard & ~WinAPI.WindowStyleFlags.OverlappedWindow; WinAPI.WindowStyleFlags dwNewLong2 = backupExtended & ~(WinAPI.WindowStyleFlags.ExtendedOverlappedWindow | WinAPI.WindowStyleFlags.ClipChildren | WinAPI.WindowStyleFlags.SystemMenu | WinAPI.WindowStyleFlags.ThickFrame | WinAPI.WindowStyleFlags.Group | WinAPI.WindowStyleFlags.ExtendedDlgModalFrame | WinAPI.WindowStyleFlags.ExtendedToolWindow); int width = Screen.width; int height = Screen.height; WinAPI.SetWindowLongPtr(activeWindow, WinAPI.WindowLongIndex.Style, dwNewLong); WinAPI.SetWindowLongPtr(activeWindow, WinAPI.WindowLongIndex.ExtendedStyle, dwNewLong2); WinAPI.SetWindowPos(activeWindow, 0, 0, 0, width, height, WinAPI.SetWindowPosFlags.NoMove); } private void MakeWindowed() { RestoreBorder(); Screen.SetResolution(Screen.width, Screen.height, false); } private void MakeFullscreen() { RestoreBorder(); Screen.SetResolution(Screen.width, Screen.height, true); } private void InitSetting<T>(ConfigEntry<T> configEntry, Action setter) { setter(); configEntry.SettingChanged += delegate { setter(); }; } private void RestoreBorder() { if (backupDone && DisplayMode.Value != SettingEnum.DisplayMode.BorderlessFullscreen) { IntPtr activeWindow = WinAPI.GetActiveWindow(); WinAPI.SetWindowLongPtr(activeWindow, WinAPI.WindowLongIndex.Style, backupStandard); WinAPI.SetWindowLongPtr(activeWindow, WinAPI.WindowLongIndex.ExtendedStyle, backupExtended); } } private void UpdateConfigManagerSize() { if (!configManagerSearch && !Object.op_Implicit(configManager)) { configManagerSearch = true; Type type = Type.GetType("ConfigurationManager.ConfigurationManager, ConfigurationManager", throwOnError: false); if ((object)type != null) { configManager = Object.FindObjectOfType(type); } } if (Object.op_Implicit(configManager)) { Traverse.Create((object)configManager).Method("CalculateWindowRect", new object[0]).GetValue(); } } } internal class SettingEnum { public enum VSyncType { Default = -1, Disabled, Enabled, Half } public enum DisplayMode { Default, Fullscreen, [Description("Borderless fullscreen")] BorderlessFullscreen, Windowed } public enum AntiAliasingMode { Default = -1, Disabled = 0, [Description("2x MSAA")] X2 = 2, [Description("4x MSAA")] X4 = 4, [Description("8x MSAA")] X8 = 8 } public enum AnisotropicFilteringMode { Default = -1, Disable, Enable, ForceEnable } public enum RunInBackgroundMode { Default = -1, No, Yes } } internal static class WinAPI { public enum WindowLongIndex { Style = -16, ExtendedStyle = -20 } [Flags] public enum WindowStyleFlags : uint { Overlapped = 0u, Popup = 0x80000000u, Child = 0x40000000u, Minimize = 0x20000000u, Visible = 0x10000000u, Disabled = 0x8000000u, ClipSiblings = 0x4000000u, ClipChildren = 0x2000000u, Maximize = 0x1000000u, Border = 0x800000u, DialogFrame = 0x400000u, Vscroll = 0x200000u, Hscroll = 0x100000u, SystemMenu = 0x80000u, ThickFrame = 0x40000u, Group = 0x20000u, Tabstop = 0x10000u, MinimizeBox = 0x20000u, MaximizeBox = 0x10000u, Caption = 0xC00000u, Tiled = 0u, Iconic = 0x20000000u, SizeBox = 0x40000u, TiledWindow = 0u, OverlappedWindow = 0xCF0000u, ChildWindow = 0x40000000u, ExtendedDlgModalFrame = 1u, ExtendedNoParentNotify = 4u, ExtendedTopmost = 8u, ExtendedAcceptFiles = 0x10u, ExtendedTransparent = 0x20u, ExtendedMDIChild = 0x40u, ExtendedToolWindow = 0x80u, ExtendedWindowEdge = 0x100u, ExtendedClientEdge = 0x200u, ExtendedContextHelp = 0x400u, ExtendedRight = 0x1000u, ExtendedLeft = 0u, ExtendedRTLReading = 0x2000u, ExtendedLTRReading = 0u, ExtendedLeftScrollbar = 0x4000u, ExtendedRightScrollbar = 0u, ExtendedControlParent = 0x10000u, ExtendedStaticEdge = 0x20000u, ExtendedAppWindow = 0x40000u, ExtendedOverlappedWindow = 0x300u, ExtendedPaletteWindow = 0x188u, ExtendedLayered = 0x80000u, ExtendedNoinheritLayout = 0x100000u, ExtendedLayoutRTL = 0x400000u, ExtendedComposited = 0x2000000u, ExtendedNoActivate = 0x8000000u } [Flags] public enum SetWindowPosFlags { AsyncWindowPos = 0x4000, DeferBase = 0x2000, DrawFrame = 0x20, FrameChanged = 0x20, HideWindow = 0x80, NoActivate = 0x10, NoCopyBits = 0x100, NoMove = 2, NoOwnerZOrder = 0x200, NoReDraw = 8, NoRePosition = 0x200, NoSendChanging = 0x400, NoSize = 1, NoZOrder = 4, ShowWindow = 0x40 } [DllImport("user32.dll")] public static extern IntPtr GetActiveWindow(); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags wFlags); [DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)] public static extern WindowStyleFlags SetWindowLongPtr32(IntPtr hWnd, WindowLongIndex nIndex, WindowStyleFlags dwNewLong); [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)] public static extern WindowStyleFlags SetWindowLongPtr64(IntPtr hWnd, WindowLongIndex nIndex, WindowStyleFlags dwNewLong); public static WindowStyleFlags SetWindowLongPtr(IntPtr hWnd, WindowLongIndex nIndex, WindowStyleFlags dwNewLong) { if (IntPtr.Size != 8) { return SetWindowLongPtr32(hWnd, nIndex, dwNewLong); } return SetWindowLongPtr64(hWnd, nIndex, dwNewLong); } [DllImport("user32.dll", EntryPoint = "GetWindowLong")] public static extern WindowStyleFlags GetWindowLongPtr32(IntPtr hWnd, WindowLongIndex nIndex); [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")] public static extern WindowStyleFlags GetWindowLongPtr64(IntPtr hWnd, WindowLongIndex nIndex); public static WindowStyleFlags GetWindowLongPtr(IntPtr hWnd, WindowLongIndex nIndex) { if (IntPtr.Size != 8) { return GetWindowLongPtr32(hWnd, nIndex); } return GetWindowLongPtr64(hWnd, nIndex); } }
plugins/femboytv-LethalPaintings/LethalPaintings.dll
Decompiled 2 years agousing System; using System.Collections.Generic; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")] [assembly: AssemblyCompany("LethalPaintings")] [assembly: AssemblyConfiguration("release")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalPaintings")] [assembly: AssemblyTitle("LethalPaintings")] [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 LethalPaintings { internal class Patches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")] [HarmonyPostfix] private static void SetScrapValuePatch(GrabbableObject __instance) { if (__instance.itemProperties.itemName == "Painting") { UpdateTexture(Plugin.PaintingFiles, __instance.itemProperties.materialVariants[0]); UpdateTexture(Plugin.PaintingFiles, __instance.itemProperties.materialVariants[1]); } } private static void UpdateTexture(IReadOnlyList<string> files, Material material) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (files.Count != 0) { int index = Plugin.Rand.Next(files.Count); Texture2D val = new Texture2D(2, 2); Logger.LogInfo((object)("Patching " + ((Object)material).name + " with " + files[index])); ImageConversion.LoadImage(val, File.ReadAllBytes(files[index])); material.mainTexture = (Texture)(object)val; } } } [BepInPlugin("LethalPaintings", "LethalPaintings", "1.0.0")] public class Plugin : BaseUnityPlugin { private static List<string> PosterFolders = new List<string>(); public static readonly List<string> PaintingFiles = new List<string>(); public static Random Rand = new Random(); private void Awake() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) PosterFolders = Directory.GetDirectories(Paths.PluginPath, "LethalPaintings", SearchOption.AllDirectories).ToList(); foreach (string posterFolder in PosterFolders) { string[] files = Directory.GetFiles(Path.Combine(posterFolder, "paintings")); foreach (string text in files) { if (Path.GetExtension(text) != ".old") { PaintingFiles.Add(text); } } } Patches.Init(((BaseUnityPlugin)this).Logger); new Harmony("LethalPaintings").PatchAll(typeof(Patches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalPaintings is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalPaintings"; public const string PLUGIN_NAME = "LethalPaintings"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/femboytv-LethalPosters/LethalPosters.dll
Decompiled 2 years agousing System; using System.Collections.Generic; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")] [assembly: AssemblyCompany("LethalPosters")] [assembly: AssemblyConfiguration("release")] [assembly: AssemblyDescription("LethalCopmany posters API")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalPosters")] [assembly: AssemblyTitle("LethalPosters")] [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 LethalPosters { internal class Config { private static ConfigFile ConfigFile { get; set; } static Config() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown ConfigFile = new ConfigFile(Paths.ConfigPath + "\\LethalPosters.cfg", true); foreach (string posterFolder in Plugin.PosterFolders) { int num = posterFolder.IndexOf("plugins\\", StringComparison.Ordinal) + "plugins\\".Length; int num2 = posterFolder.IndexOf("\\LethalPosters", num, StringComparison.Ordinal); string text = posterFolder.Substring(num, num2 - num); if (!ConfigFile.Bind<bool>(text, "Enabled", true, "Enable or disable " + text).Value) { Directory.Move(posterFolder, posterFolder + ".Disabled"); } } } } internal class Patches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void StartPatch() { Logger.LogInfo((object)"Patching Start in StartOfRound"); UpdateMaterials(0); } [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyPostfix] private static void GenerateNewLevelClientRpcPatch(int randomSeed) { Logger.LogInfo((object)"Patching GenerateNewLevelClientRpc in RoundManager"); UpdateMaterials(randomSeed); } private static void UpdateMaterials(int seed) { Logger.LogInfo((object)"Patching the textures"); Plugin.Rand = new Random(seed); Material[] materials = ((Renderer)GameObject.Find("HangarShip/Plane.001").GetComponent<MeshRenderer>()).materials; UpdateTexture(Plugin.PosterFiles, materials[0]); UpdateTexture(Plugin.TipFiles, materials[1]); } private static void UpdateTexture(IReadOnlyList<string> files, Material material) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (files.Count != 0) { int index = Plugin.Rand.Next(files.Count); Texture2D val = new Texture2D(2, 2); Logger.LogInfo((object)("Patching " + ((Object)material).name + " with " + files[index])); ImageConversion.LoadImage(val, File.ReadAllBytes(files[index])); material.mainTexture = (Texture)(object)val; } } } [BepInPlugin("LethalPosters", "LethalPosters", "1.0.0")] public class Plugin : BaseUnityPlugin { public static List<string> PosterFolders = new List<string>(); public static readonly List<string> PosterFiles = new List<string>(); public static readonly List<string> TipFiles = new List<string>(); public static Random Rand = new Random(); private void Awake() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) PosterFolders = Directory.GetDirectories(Paths.PluginPath, "LethalPosters", SearchOption.AllDirectories).ToList(); foreach (string posterFolder in PosterFolders) { string[] files = Directory.GetFiles(Path.Combine(posterFolder, "posters")); foreach (string text in files) { if (Path.GetExtension(text) != ".old") { PosterFiles.Add(text); } } files = Directory.GetFiles(Path.Combine(posterFolder, "tips")); foreach (string text2 in files) { if (Path.GetExtension(text2) != ".old") { TipFiles.Add(text2); } } } Patches.Init(((BaseUnityPlugin)this).Logger); new Harmony("LethalPosters").PatchAll(typeof(Patches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalPosters (1.0.0) is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalPosters"; public const string PLUGIN_NAME = "LethalPosters"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/notnotnotswipez-MoreCompany/MoreCompany.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using MoreCompany.Cosmetics; using MoreCompany.Utils; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("MoreCompany")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MoreCompany")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("511a1e5e-0611-49f1-b60f-cec69c668fd8")] [assembly: AssemblyFileVersion("1.7.1")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.7.1.0")] namespace MoreCompany { [HarmonyPatch(typeof(AudioMixer), "SetFloat")] public static class AudioMixerSetFloatPatch { public static bool Prefix(string name, float value) { if (name.StartsWith("PlayerVolume") || name.StartsWith("PlayerPitch")) { string s = name.Replace("PlayerVolume", "").Replace("PlayerPitch", ""); int num = int.Parse(s); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[num]; AudioSource currentVoiceChatAudioSource = val.currentVoiceChatAudioSource; if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)currentVoiceChatAudioSource)) { if (name.StartsWith("PlayerVolume")) { currentVoiceChatAudioSource.volume = value / 16f; } else if (name.StartsWith("PlayerPitch")) { currentVoiceChatAudioSource.pitch = value; } } return false; } return true; } } [HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")] public static class SendChatToServerPatch { public static bool Prefix(HUDManager __instance, string chatMessage, int playerId = -1) { if (chatMessage.StartsWith("[morecompanycosmetics]")) { ReflectionUtils.InvokeMethod(__instance, "AddPlayerChatMessageServerRpc", new object[2] { chatMessage, 99 }); return false; } return true; } } [HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageServerRpc")] public static class ServerReceiveMessagePatch { public static string previousDataMessage = ""; public static bool Prefix(HUDManager __instance, ref string chatMessage, int playerId) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (chatMessage.StartsWith("[morecompanycosmetics]") && networkManager.IsServer) { previousDataMessage = chatMessage; chatMessage = "[replacewithdata]"; } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static class ConnectClientToPlayerObjectPatch { public static void Postfix(PlayerControllerB __instance) { string text = "[morecompanycosmetics]"; text = text + ";" + __instance.playerClientId; foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics) { text = text + ";" + locallySelectedCosmetic; } HUDManager.Instance.AddTextToChatOnServer(text, -1); } } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] public static class AddChatMessagePatch { public static bool Prefix(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped = "") { if (chatMessage.StartsWith("[replacewithdata]") || chatMessage.StartsWith("[morecompanycosmetics]")) { return false; } return true; } } [HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")] public static class ClientReceiveMessagePatch { public static bool ignoreSample; public static bool Prefix(HUDManager __instance, ref string chatMessage, int playerId) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (networkManager.IsServer) { if (chatMessage.StartsWith("[replacewithdata]")) { chatMessage = ServerReceiveMessagePatch.previousDataMessage; HandleDataMessage(chatMessage); } else if (chatMessage.StartsWith("[morecompanycosmetics]")) { return false; } } else if (chatMessage.StartsWith("[morecompanycosmetics]")) { HandleDataMessage(chatMessage); } return true; } private static void HandleDataMessage(string chatMessage) { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (ignoreSample) { return; } chatMessage = chatMessage.Replace("[morecompanycosmetics]", ""); string[] array = chatMessage.Split(new char[1] { ';' }); string text = array[1]; int num = int.Parse(text); CosmeticApplication component = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[num]).transform.Find("ScavengerModel").Find("metarig")).gameObject.GetComponent<CosmeticApplication>(); if (Object.op_Implicit((Object)(object)component)) { component.ClearCosmetics(); Object.Destroy((Object)(object)component); } CosmeticApplication cosmeticApplication = ((Component)((Component)StartOfRound.Instance.allPlayerScripts[num]).transform.Find("ScavengerModel").Find("metarig")).gameObject.AddComponent<CosmeticApplication>(); cosmeticApplication.ClearCosmetics(); List<string> list = new List<string>(); string[] array2 = array; foreach (string text2 in array2) { if (!(text2 == text)) { list.Add(text2); if (MainClass.showCosmetics) { cosmeticApplication.ApplyCosmetic(text2, startEnabled: true); } } } if (num == StartOfRound.Instance.thisClientPlayerId) { cosmeticApplication.ClearCosmetics(); } foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication.spawnedCosmetics) { Transform transform = ((Component)spawnedCosmetic).transform; transform.localScale *= 0.38f; } MainClass.playerIdsAndCosmetics.Remove(num); MainClass.playerIdsAndCosmetics.Add(num, list); if (!GameNetworkManager.Instance.isHostingGame || num == 0) { return; } ignoreSample = true; foreach (KeyValuePair<int, List<string>> playerIdsAndCosmetic in MainClass.playerIdsAndCosmetics) { string text3 = "[morecompanycosmetics]"; text3 = text3 + ";" + playerIdsAndCosmetic.Key; foreach (string item in playerIdsAndCosmetic.Value) { text3 = text3 + ";" + item; } HUDManager.Instance.AddTextToChatOnServer(text3, -1); } ignoreSample = false; } } [HarmonyPatch(typeof(ForestGiantAI), "LookForPlayers")] public static class LookForPlayersForestGiantPatch { public static void Prefix(ForestGiantAI __instance) { if (__instance.playerStealthMeters.Length != MainClass.newPlayerCount) { __instance.playerStealthMeters = new float[MainClass.newPlayerCount]; for (int i = 0; i < MainClass.newPlayerCount; i++) { __instance.playerStealthMeters[i] = 0f; } } } } [HarmonyPatch(typeof(SpringManAI), "Update")] public static class SpringManAIUpdatePatch { public static bool Prefix(SpringManAI __instance, ref float ___timeSinceHittingPlayer, ref float ___stopAndGoMinimumInterval, ref bool ___wasOwnerLastFrame, ref bool ___stoppingMovement, ref float ___currentChaseSpeed, ref bool ___hasStopped, ref float ___currentAnimSpeed, ref float ___updateDestinationInterval, ref Vector3 ___tempVelocity, ref float ___targetYRotation, ref float ___setDestinationToPlayerInterval, ref float ___previousYRotation) { //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) UpdateBase((EnemyAI)(object)__instance, ref ___updateDestinationInterval, ref ___tempVelocity, ref ___targetYRotation, ref ___setDestinationToPlayerInterval, ref ___previousYRotation); if (((EnemyAI)__instance).isEnemyDead) { return false; } int currentBehaviourStateIndex = ((EnemyAI)__instance).currentBehaviourStateIndex; if (currentBehaviourStateIndex != 0 && currentBehaviourStateIndex == 1) { if (___timeSinceHittingPlayer >= 0f) { ___timeSinceHittingPlayer -= Time.deltaTime; } if (((NetworkBehaviour)__instance).IsOwner) { if (___stopAndGoMinimumInterval > 0f) { ___stopAndGoMinimumInterval -= Time.deltaTime; } if (!___wasOwnerLastFrame) { ___wasOwnerLastFrame = true; if (!___stoppingMovement && ___timeSinceHittingPlayer < 0.12f) { ((EnemyAI)__instance).agent.speed = ___currentChaseSpeed; } else { ((EnemyAI)__instance).agent.speed = 0f; } } bool flag = false; for (int i = 0; i < MainClass.newPlayerCount; i++) { if (((EnemyAI)__instance).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(((Component)__instance).transform.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, ((EnemyAI)__instance).eye.position) > 0.3f) { flag = true; } } if (((EnemyAI)__instance).stunNormalizedTimer > 0f) { flag = true; } if (flag != ___stoppingMovement && ___stopAndGoMinimumInterval <= 0f) { ___stopAndGoMinimumInterval = 0.15f; if (flag) { __instance.SetAnimationStopServerRpc(); } else { __instance.SetAnimationGoServerRpc(); } ___stoppingMovement = flag; } } if (___stoppingMovement) { if (__instance.animStopPoints.canAnimationStop) { if (!___hasStopped) { ___hasStopped = true; __instance.mainCollider.isTrigger = false; if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)__instance).transform.position, 70f, 25, -1f)) { float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position); if (num < 4f) { GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.9f, true); } else if (num < 9f) { GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.4f, true); } } if (___currentAnimSpeed > 2f) { RoundManager.PlayRandomClip(((EnemyAI)__instance).creatureVoice, __instance.springNoises, false, 1f, 0); if (__instance.animStopPoints.animationPosition == 1) { ((EnemyAI)__instance).creatureAnimator.SetTrigger("springBoing"); } else { ((EnemyAI)__instance).creatureAnimator.SetTrigger("springBoingPosition2"); } } } ((EnemyAI)__instance).creatureAnimator.SetFloat("walkSpeed", 0f); ___currentAnimSpeed = 0f; if (((NetworkBehaviour)__instance).IsOwner) { ((EnemyAI)__instance).agent.speed = 0f; return false; } } } else { if (___hasStopped) { ___hasStopped = false; __instance.mainCollider.isTrigger = true; } ___currentAnimSpeed = Mathf.Lerp(___currentAnimSpeed, 6f, 5f * Time.deltaTime); ((EnemyAI)__instance).creatureAnimator.SetFloat("walkSpeed", ___currentAnimSpeed); if (((NetworkBehaviour)__instance).IsOwner) { ((EnemyAI)__instance).agent.speed = Mathf.Lerp(((EnemyAI)__instance).agent.speed, ___currentChaseSpeed, 4.5f * Time.deltaTime); } } } return false; } private static void UpdateBase(EnemyAI __instance, ref float updateDestinationInterval, ref Vector3 tempVelocity, ref float targetYRotation, ref float setDestinationToPlayerInterval, ref float previousYRotation) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) if (__instance.enemyType.isDaytimeEnemy && !__instance.daytimeEnemyLeaving) { ReflectionUtils.InvokeMethod(__instance, typeof(EnemyAI), "CheckTimeOfDayToLeave", null); } if (__instance.stunnedIndefinitely <= 0) { if ((double)__instance.stunNormalizedTimer >= 0.0) { __instance.stunNormalizedTimer -= Time.deltaTime / __instance.enemyType.stunTimeMultiplier; } else { __instance.stunnedByPlayer = null; if ((double)__instance.postStunInvincibilityTimer >= 0.0) { __instance.postStunInvincibilityTimer -= Time.deltaTime * 5f; } } } if (!__instance.ventAnimationFinished && (double)__instance.timeSinceSpawn < (double)__instance.exitVentAnimationTime + 0.004999999888241291 * (double)RoundManager.Instance.numberOfEnemiesInScene) { __instance.timeSinceSpawn += Time.deltaTime; if (!((NetworkBehaviour)__instance).IsOwner) { Vector3 serverPosition = __instance.serverPosition; if (__instance.serverPosition != Vector3.zero) { ((Component)__instance).transform.position = __instance.serverPosition; ((Component)__instance).transform.eulerAngles = new Vector3(((Component)__instance).transform.eulerAngles.x, targetYRotation, ((Component)__instance).transform.eulerAngles.z); } } else if ((double)updateDestinationInterval >= 0.0) { updateDestinationInterval -= Time.deltaTime; } else { __instance.SyncPositionToClients(); updateDestinationInterval = 0.1f; } return; } if (!__instance.ventAnimationFinished) { __instance.ventAnimationFinished = true; if ((Object)(object)__instance.creatureAnimator != (Object)null) { __instance.creatureAnimator.SetBool("inSpawningAnimation", false); } } if (!((NetworkBehaviour)__instance).IsOwner) { if (__instance.currentSearch.inProgress) { __instance.StopSearch(__instance.currentSearch, true); } __instance.SetClientCalculatingAI(false); if (!__instance.inSpecialAnimation) { ((Component)__instance).transform.position = Vector3.SmoothDamp(((Component)__instance).transform.position, __instance.serverPosition, ref tempVelocity, __instance.syncMovementSpeed); ((Component)__instance).transform.eulerAngles = new Vector3(((Component)__instance).transform.eulerAngles.x, Mathf.LerpAngle(((Component)__instance).transform.eulerAngles.y, targetYRotation, 15f * Time.deltaTime), ((Component)__instance).transform.eulerAngles.z); } __instance.timeSinceSpawn += Time.deltaTime; return; } if (__instance.isEnemyDead) { __instance.SetClientCalculatingAI(false); return; } if (!__instance.inSpecialAnimation) { __instance.SetClientCalculatingAI(true); } if (__instance.movingTowardsTargetPlayer && (Object)(object)__instance.targetPlayer != (Object)null) { if ((double)setDestinationToPlayerInterval <= 0.0) { setDestinationToPlayerInterval = 0.25f; __instance.destination = RoundManager.Instance.GetNavMeshPosition(((Component)__instance.targetPlayer).transform.position, RoundManager.Instance.navHit, 2.7f, -1); } else { __instance.destination = new Vector3(((Component)__instance.targetPlayer).transform.position.x, __instance.destination.y, ((Component)__instance.targetPlayer).transform.position.z); setDestinationToPlayerInterval -= Time.deltaTime; } } if (__instance.inSpecialAnimation) { return; } if ((double)updateDestinationInterval >= 0.0) { updateDestinationInterval -= Time.deltaTime; } else { __instance.DoAIInterval(); updateDestinationInterval = __instance.AIIntervalTime; } if (!((double)Mathf.Abs(previousYRotation - ((Component)__instance).transform.eulerAngles.y) <= 6.0)) { previousYRotation = ((Component)__instance).transform.eulerAngles.y; targetYRotation = previousYRotation; if (((NetworkBehaviour)__instance).IsServer) { ReflectionUtils.InvokeMethod(__instance, typeof(EnemyAI), "UpdateEnemyRotationClientRpc", new object[1] { (short)previousYRotation }); } else { ReflectionUtils.InvokeMethod(__instance, typeof(EnemyAI), "UpdateEnemyRotationServerRpc", new object[1] { (short)previousYRotation }); } } } } [HarmonyPatch(typeof(SpringManAI), "DoAIInterval")] public static class SpringManAIIntervalPatch { public static bool Prefix(SpringManAI __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0250: 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_01e6: Unknown result type (might be due to invalid IL or missing references) if (((EnemyAI)__instance).moveTowardsDestination) { ((EnemyAI)__instance).agent.SetDestination(((EnemyAI)__instance).destination); } ((EnemyAI)__instance).SyncPositionToClients(); if (StartOfRound.Instance.allPlayersDead) { return false; } if (((EnemyAI)__instance).isEnemyDead) { return false; } switch (((EnemyAI)__instance).currentBehaviourStateIndex) { default: return false; case 1: if (__instance.searchForPlayers.inProgress) { ((EnemyAI)__instance).StopSearch(__instance.searchForPlayers, true); } if (((EnemyAI)__instance).TargetClosestPlayer(1.5f, false, 70f)) { PlayerControllerB fieldValue = ReflectionUtils.GetFieldValue<PlayerControllerB>(__instance, "previousTarget"); if ((Object)(object)fieldValue != (Object)(object)((EnemyAI)__instance).targetPlayer) { ReflectionUtils.SetFieldValue(__instance, "previousTarget", ((EnemyAI)__instance).targetPlayer); ((EnemyAI)__instance).ChangeOwnershipOfEnemy(((EnemyAI)__instance).targetPlayer.actualClientId); } ((EnemyAI)__instance).movingTowardsTargetPlayer = true; return false; } ((EnemyAI)__instance).SwitchToBehaviourState(0); ((EnemyAI)__instance).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); break; case 0: { if (!((NetworkBehaviour)__instance).IsServer) { ((EnemyAI)__instance).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); return false; } for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (((EnemyAI)__instance).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && !Physics.Linecast(((Component)__instance).transform.position + Vector3.up * 0.5f, ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 30f) { ((EnemyAI)__instance).SwitchToBehaviourState(1); return false; } } if (!__instance.searchForPlayers.inProgress) { ((EnemyAI)__instance).movingTowardsTargetPlayer = false; ((EnemyAI)__instance).StartSearch(((Component)__instance).transform.position, __instance.searchForPlayers); return false; } break; } } return false; } } [HarmonyPatch(typeof(EnemyAI), "GetClosestPlayer")] public static class GetClosestPlayerPatch { public static bool Prefix(EnemyAI __instance, ref PlayerControllerB __result, bool requireLineOfSight = false, bool cannotBeInShip = false, bool cannotBeNearShip = false) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_012b: 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_008a: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = null; __instance.mostOptimalDistance = 2000f; for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (!__instance.PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], cannotBeInShip, false)) { continue; } if (cannotBeNearShip) { if (StartOfRound.Instance.allPlayerScripts[i].isInElevator) { continue; } bool flag = false; for (int j = 0; j < RoundManager.Instance.spawnDenialPoints.Length; j++) { if (Vector3.Distance(RoundManager.Instance.spawnDenialPoints[j].transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 10f) { flag = true; break; } } if (flag) { continue; } } if (!requireLineOfSight || !Physics.Linecast(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position, 256)) { __instance.tempDist = Vector3.Distance(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position); if (__instance.tempDist < __instance.mostOptimalDistance) { __instance.mostOptimalDistance = __instance.tempDist; val = StartOfRound.Instance.allPlayerScripts[i]; } } } __result = val; return false; } } [HarmonyPatch(typeof(EnemyAI), "GetAllPlayersInLineOfSight")] public static class GetAllPlayersInLineOfSightPatch { public static bool Prefix(EnemyAI __instance, ref PlayerControllerB[] __result, float width = 45f, int range = 60, Transform eyeObject = null, float proximityCheck = -1f, int layerMask = -1) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_00b3: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if (layerMask == -1) { layerMask = StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if ((Object)(object)eyeObject == (Object)null) { eyeObject = __instance.eye; } if (__instance.enemyType.isOutsideEnemy && !__instance.enemyType.canSeeThroughFog && (int)TimeOfDay.Instance.currentLevelWeather == 3) { range = Mathf.Clamp(range, 0, 30); } List<PlayerControllerB> list = new List<PlayerControllerB>(MainClass.newPlayerCount); for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (!__instance.PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false)) { continue; } Vector3 position = ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position; if (Vector3.Distance(__instance.eye.position, position) < (float)range && !Physics.Linecast(eyeObject.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { Vector3 val = position - eyeObject.position; if (Vector3.Angle(eyeObject.forward, val) < width || Vector3.Distance(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < proximityCheck) { list.Add(StartOfRound.Instance.allPlayerScripts[i]); } } } if (list.Count == MainClass.newPlayerCount) { __result = StartOfRound.Instance.allPlayerScripts; return false; } if (list.Count > 0) { __result = list.ToArray(); return false; } __result = null; return false; } } [HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")] public static class DressGirlHauntPatch { public static bool Prefix(DressGirlAI __instance) { ReflectionUtils.SetFieldValue(__instance, "timesChoosingAPlayer", ReflectionUtils.GetFieldValue<int>(__instance, "timesChoosingAPlayer") + 1); if (ReflectionUtils.GetFieldValue<int>(__instance, "timesChoosingAPlayer") > 1) { __instance.timer = __instance.hauntInterval - 1f; } __instance.SFXVolumeLerpTo = 0f; ((EnemyAI)__instance).creatureVoice.Stop(); __instance.heartbeatMusic.volume = 0f; if (!ReflectionUtils.GetFieldValue<bool>(__instance, "initializedRandomSeed")) { ReflectionUtils.SetFieldValue(__instance, "ghostGirlRandom", new Random(StartOfRound.Instance.randomMapSeed + 158)); } float num = 0f; float num2 = 0f; int num3 = 0; int num4 = 0; for (int i = 0; i < MainClass.newPlayerCount; i++) { if (StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount > num3) { num3 = StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount; num4 = i; } if (StartOfRound.Instance.allPlayerScripts[i].insanityLevel > num) { num = StartOfRound.Instance.allPlayerScripts[i].insanityLevel; num2 = i; } } int[] array = new int[MainClass.newPlayerCount]; for (int j = 0; j < MainClass.newPlayerCount; j++) { if (!StartOfRound.Instance.allPlayerScripts[j].isPlayerControlled) { array[j] = 0; continue; } array[j] += 80; if (num2 == (float)j && num > 1f) { array[j] += 50; } if (num4 == j) { array[j] += 30; } if (!StartOfRound.Instance.allPlayerScripts[j].hasBeenCriticallyInjured) { array[j] += 10; } if ((Object)(object)StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer != (Object)null && StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer.scrapValue > 150) { array[j] += 30; } } __instance.hauntingPlayer = StartOfRound.Instance.allPlayerScripts[RoundManager.Instance.GetRandomWeightedIndex(array, ReflectionUtils.GetFieldValue<Random>(__instance, "ghostGirlRandom"))]; if (__instance.hauntingPlayer.isPlayerDead) { for (int k = 0; k < StartOfRound.Instance.allPlayerScripts.Length; k++) { if (!StartOfRound.Instance.allPlayerScripts[k].isPlayerDead) { __instance.hauntingPlayer = StartOfRound.Instance.allPlayerScripts[k]; break; } } } Debug.Log((object)$"Little girl: Haunting player with playerClientId: {__instance.hauntingPlayer.playerClientId}; actualClientId: {__instance.hauntingPlayer.actualClientId}"); ((EnemyAI)__instance).ChangeOwnershipOfEnemy(__instance.hauntingPlayer.actualClientId); __instance.hauntingLocalPlayer = (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)__instance.hauntingPlayer; if (ReflectionUtils.GetFieldValue<Coroutine>(__instance, "switchHauntedPlayerCoroutine") != null) { ((MonoBehaviour)__instance).StopCoroutine(ReflectionUtils.GetFieldValue<Coroutine>(__instance, "switchHauntedPlayerCoroutine")); } ReflectionUtils.SetFieldValue(__instance, "switchHauntedPlayerCoroutine", ((MonoBehaviour)__instance).StartCoroutine(ReflectionUtils.InvokeMethod<IEnumerator>(__instance, "setSwitchingHauntingPlayer", null))); return false; } } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] public static class HudChatPatch { public static void Prefix(HUDManager __instance, ref string chatMessage, string nameOfUserWhoTyped = "") { if (!(__instance.lastChatMessage == chatMessage)) { StringBuilder stringBuilder = new StringBuilder(chatMessage); for (int i = 0; i < MainClass.newPlayerCount; i++) { string oldValue = $"[playerNum{i}]"; string playerUsername = StartOfRound.Instance.allPlayerScripts[i].playerUsername; stringBuilder.Replace(oldValue, playerUsername); } chatMessage = stringBuilder.ToString(); } } } [HarmonyPatch(typeof(MenuManager), "Awake")] public static class MenuManagerLogoOverridePatch { public static void Postfix(MenuManager __instance) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) try { GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; GameObject gameObject2 = ((Component)gameObject.transform.Find("MenuContainer").Find("MainButtons").Find("HeaderImage")).gameObject; Image component = gameObject2.GetComponent<Image>(); MainClass.ReadSettingsFromFile(); component.sprite = Sprite.Create(MainClass.mainLogo, new Rect(0f, 0f, (float)((Texture)MainClass.mainLogo).width, (float)((Texture)MainClass.mainLogo).height), new Vector2(0.5f, 0.5f)); CosmeticRegistry.SpawnCosmeticGUI(); Transform val = gameObject.transform.Find("MenuContainer").Find("LobbyHostSettings").Find("Panel") .Find("LobbyHostOptions") .Find("OptionsNormal"); GameObject val2 = Object.Instantiate<GameObject>(MainClass.crewCountUI, val); RectTransform component2 = val2.GetComponent<RectTransform>(); ((Transform)component2).localPosition = new Vector3(96.9f, -70f, -6.7f); TMP_InputField inputField = ((Component)val2.transform.Find("InputField (TMP)")).GetComponent<TMP_InputField>(); inputField.characterLimit = 3; inputField.text = MainClass.newPlayerCount.ToString(); ((UnityEvent<string>)(object)inputField.onValueChanged).AddListener((UnityAction<string>)delegate(string s) { if (int.TryParse(s, out var result)) { MainClass.newPlayerCount = result; MainClass.newPlayerCount = Mathf.Clamp(MainClass.newPlayerCount, 1, MainClass.maxPlayerCount); inputField.text = MainClass.newPlayerCount.ToString(); MainClass.SaveSettingsToFile(); } else if (s.Length != 0) { inputField.text = MainClass.newPlayerCount.ToString(); inputField.caretPosition = 1; } }); } catch (Exception) { } } } [HarmonyPatch(typeof(QuickMenuManager), "AddUserToPlayerList")] public static class AddUserPlayerListPatch { public static bool Prefix(QuickMenuManager __instance, ulong steamId, string playerName, int playerObjectId) { QuickmenuVisualInjectPatch.PopulateQuickMenu(__instance); MainClass.EnablePlayerObjectsBasedOnConnected(); return false; } } [HarmonyPatch(typeof(QuickMenuManager), "RemoveUserFromPlayerList")] public static class RemoveUserPlayerListPatch { public static bool Prefix(QuickMenuManager __instance) { QuickmenuVisualInjectPatch.PopulateQuickMenu(__instance); return false; } } [HarmonyPatch(typeof(QuickMenuManager), "Update")] public static class QuickMenuUpdatePatch { public static bool Prefix(QuickMenuManager __instance) { return false; } } [HarmonyPatch(typeof(QuickMenuManager), "NonHostPlayerSlotsEnabled")] public static class QuickMenuDisplayPatch { public static bool Prefix(QuickMenuManager __instance, ref bool __result) { __result = true; return false; } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] public static class QuickmenuVisualInjectPatch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__2_2; internal void <PopulateQuickMenu>b__2_2() { if (!GameNetworkManager.Instance.disableSteam) { } } } public static GameObject quickMenuScrollInstance; public static void Postfix(QuickMenuManager __instance) { //IL_0050: 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) GameObject gameObject = ((Component)__instance.playerListPanel.transform.Find("Image")).gameObject; GameObject val = Object.Instantiate<GameObject>(MainClass.quickMenuScrollParent); val.transform.SetParent(gameObject.transform); RectTransform component = val.GetComponent<RectTransform>(); ((Transform)component).localPosition = new Vector3(0f, -31.2f, 0f); ((Transform)component).localScale = Vector3.one; quickMenuScrollInstance = val; } public static void PopulateQuickMenu(QuickMenuManager __instance) { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown int childCount = quickMenuScrollInstance.transform.Find("Holder").childCount; List<GameObject> list = new List<GameObject>(); for (int i = 0; i < childCount; i++) { list.Add(((Component)quickMenuScrollInstance.transform.Find("Holder").GetChild(i)).gameObject); } foreach (GameObject item in list) { Object.Destroy((Object)(object)item); } if (!Object.op_Implicit((Object)(object)StartOfRound.Instance)) { return; } for (int j = 0; j < StartOfRound.Instance.allPlayerScripts.Length; j++) { PlayerControllerB playerScript = StartOfRound.Instance.allPlayerScripts[j]; if (!playerScript.isPlayerControlled && !playerScript.isPlayerDead) { continue; } GameObject val = Object.Instantiate<GameObject>(MainClass.playerEntry, quickMenuScrollInstance.transform.Find("Holder")); RectTransform component = val.GetComponent<RectTransform>(); ((Transform)component).localScale = Vector3.one; ((Transform)component).localPosition = new Vector3(0f, 0f - ((Transform)component).localPosition.y, 0f); TextMeshProUGUI component2 = ((Component)val.transform.Find("PlayerNameButton").Find("PName")).GetComponent<TextMeshProUGUI>(); ((TMP_Text)component2).text = playerScript.playerUsername; Slider playerVolume = ((Component)val.transform.Find("PlayerVolumeSlider")).GetComponent<Slider>(); int finalIndex = j; ((UnityEvent<float>)(object)playerVolume.onValueChanged).AddListener((UnityAction<float>)delegate(float f) { if (playerScript.isPlayerControlled || playerScript.isPlayerDead) { float num = f / playerVolume.maxValue + 1f; if (num <= -1f) { SoundManager.Instance.playerVoiceVolumes[finalIndex] = -70f; } else { SoundManager.Instance.playerVoiceVolumes[finalIndex] = num; } } }); if (StartOfRound.Instance.localPlayerController.playerClientId == playerScript.playerClientId) { ((Component)playerVolume).gameObject.SetActive(false); ((Component)val.transform.Find("Text (1)")).gameObject.SetActive(false); } Button component3 = ((Component)val.transform.Find("KickButton")).GetComponent<Button>(); ((UnityEvent)component3.onClick).AddListener((UnityAction)delegate { __instance.KickUserFromServer(finalIndex); }); if (!GameNetworkManager.Instance.isHostingGame) { ((Component)component3).gameObject.SetActive(false); } Button component4 = ((Component)val.transform.Find("ProfileIcon")).GetComponent<Button>(); ButtonClickedEvent onClick = component4.onClick; object obj = <>c.<>9__2_2; if (obj == null) { UnityAction val2 = delegate { if (!GameNetworkManager.Instance.disableSteam) { } }; <>c.<>9__2_2 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } } } [HarmonyPatch(typeof(HUDManager), "UpdateBoxesSpectateUI")] public static class SpectatorBoxUpdatePatch { public static void Postfix(HUDManager __instance) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Dictionary<Animator, PlayerControllerB> fieldValue = ReflectionUtils.GetFieldValue<Dictionary<Animator, PlayerControllerB>>(__instance, "spectatingPlayerBoxes"); int num = -64; int num2 = 0; int num3 = 0; int num4 = -70; int num5 = 230; int num6 = 4; foreach (KeyValuePair<Animator, PlayerControllerB> item in fieldValue) { if (((Component)item.Key).gameObject.activeInHierarchy) { GameObject gameObject = ((Component)item.Key).gameObject; RectTransform component = gameObject.GetComponent<RectTransform>(); int num7 = (int)Math.Floor((double)num3 / (double)num6); int num8 = num3 % num6; int num9 = num8 * num4; int num10 = num7 * num5; component.anchoredPosition = Vector2.op_Implicit(new Vector3((float)(num + num10), (float)(num2 + num9), 0f)); num3++; } } } } [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] public static class HudFillEndGameFix { public static bool Prefix(HUDManager __instance, EndOfGameStats stats) { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Invalid comparison between Unknown and I4 int num = 0; int num2 = 0; for (int i = 0; i < __instance.statsUIElements.playerNamesText.Length; i++) { PlayerControllerB val = __instance.playersManager.allPlayerScripts[i]; ((TMP_Text)__instance.statsUIElements.playerNamesText[i]).text = ""; ((Behaviour)__instance.statsUIElements.playerStates[i]).enabled = false; ((TMP_Text)__instance.statsUIElements.playerNotesText[i]).text = "Notes: \n"; if (val.disconnectedMidGame || val.isPlayerDead || val.isPlayerControlled) { if (val.isPlayerDead) { num++; } else if (val.isPlayerControlled) { num2++; } ((TMP_Text)__instance.statsUIElements.playerNamesText[i]).text = __instance.playersManager.allPlayerScripts[i].playerUsername; ((Behaviour)__instance.statsUIElements.playerStates[i]).enabled = true; if (__instance.playersManager.allPlayerScripts[i].isPlayerDead) { if ((int)__instance.playersManager.allPlayerScripts[i].causeOfDeath == 10) { __instance.statsUIElements.playerStates[i].sprite = __instance.statsUIElements.missingIcon; } else { __instance.statsUIElements.playerStates[i].sprite = __instance.statsUIElements.deceasedIcon; } } else { __instance.statsUIElements.playerStates[i].sprite = __instance.statsUIElements.aliveIcon; } for (int j = 0; j < 3 && j < stats.allPlayerStats[i].playerNotes.Count; j++) { TextMeshProUGUI val2 = __instance.statsUIElements.playerNotesText[i]; ((TMP_Text)val2).text = ((TMP_Text)val2).text + "* " + stats.allPlayerStats[i].playerNotes[j] + "\n"; } } else { ((TMP_Text)__instance.statsUIElements.playerNotesText[i]).text = ""; } } ((TMP_Text)__instance.statsUIElements.quotaNumerator).text = RoundManager.Instance.scrapCollectedInLevel.ToString(); ((TMP_Text)__instance.statsUIElements.quotaDenominator).text = RoundManager.Instance.totalScrapValueInLevel.ToString(); if (StartOfRound.Instance.allPlayersDead) { ((Behaviour)__instance.statsUIElements.allPlayersDeadOverlay).enabled = true; ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "F"; return false; } ((Behaviour)__instance.statsUIElements.allPlayersDeadOverlay).enabled = false; int num3 = 0; float num4 = (float)RoundManager.Instance.scrapCollectedInLevel / RoundManager.Instance.totalScrapValueInLevel; if (num2 == StartOfRound.Instance.connectedPlayersAmount + 1) { num3++; } else if (num > 1) { num3--; } if (num4 >= 0.99f) { num3 += 2; } else if (num4 >= 0.6f) { num3++; } else if (num4 <= 0.25f) { num3--; } switch (num3) { case -1: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "D"; return false; case 0: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "C"; return false; case 1: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "B"; return false; case 2: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "A"; return false; case 3: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "S"; return false; default: return false; } } } [HarmonyPatch(typeof(HUDManager), "Start")] public static class HudStartPatch { public static void Postfix(HUDManager __instance) { //IL_0082: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) EndOfGameStatUIElements statsUIElements = __instance.statsUIElements; GameObject gameObject = ((Component)((Component)statsUIElements.playerNamesText[0]).gameObject.transform.parent).gameObject; GameObject gameObject2 = ((Component)gameObject.transform.parent.parent).gameObject; GameObject gameObject3 = ((Component)gameObject2.transform.Find("BGBoxes")).gameObject; gameObject2.transform.parent.Find("DeathScreen").SetSiblingIndex(3); gameObject3.transform.localScale = new Vector3(2.5f, 1f, 1f); MakePlayerHolder(4, gameObject, statsUIElements, new Vector3(426.9556f, -0.7932f, 0f)); MakePlayerHolder(5, gameObject, statsUIElements, new Vector3(426.9556f, -115.4483f, 0f)); MakePlayerHolder(6, gameObject, statsUIElements, new Vector3(-253.6783f, -115.4483f, 0f)); MakePlayerHolder(7, gameObject, statsUIElements, new Vector3(-253.6783f, -0.7932f, 0f)); for (int i = 8; i < MainClass.newPlayerCount; i++) { MakePlayerHolder(i, gameObject, statsUIElements, new Vector3(10000f, 10000f, 0f)); } } public static void MakePlayerHolder(int index, GameObject original, EndOfGameStatUIElements uiElements, Vector3 localPosition) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) if (index + 1 <= MainClass.newPlayerCount) { GameObject val = Object.Instantiate<GameObject>(original); RectTransform component = val.GetComponent<RectTransform>(); RectTransform component2 = original.GetComponent<RectTransform>(); ((Transform)component).SetParent(((Transform)component2).parent); ((Transform)component).localScale = new Vector3(1f, 1f, 1f); ((Transform)component).localPosition = localPosition; GameObject gameObject = ((Component)val.transform.Find("PlayerName1")).gameObject; GameObject gameObject2 = ((Component)val.transform.Find("Notes")).gameObject; ((Transform)gameObject2.GetComponent<RectTransform>()).localPosition = new Vector3(-95.7222f, 43.3303f, 0f); GameObject gameObject3 = ((Component)val.transform.Find("Symbol")).gameObject; if (index >= uiElements.playerNamesText.Length) { Array.Resize(ref uiElements.playerNamesText, index + 1); Array.Resize(ref uiElements.playerStates, index + 1); Array.Resize(ref uiElements.playerNotesText, index + 1); } uiElements.playerNamesText[index] = gameObject.GetComponent<TextMeshProUGUI>(); uiElements.playerNotesText[index] = gameObject2.GetComponent<TextMeshProUGUI>(); uiElements.playerStates[index] = gameObject3.GetComponent<Image>(); } } } public static class PluginInformation { public const string PLUGIN_NAME = "MoreCompany"; public const string PLUGIN_VERSION = "1.7.1"; public const string PLUGIN_GUID = "me.swipez.melonloader.morecompany"; } [BepInPlugin("me.swipez.melonloader.morecompany", "MoreCompany", "1.7.1")] public class MainClass : BaseUnityPlugin { public static int newPlayerCount = 32; public static int maxPlayerCount = 50; public static bool showCosmetics = true; public static List<PlayerControllerB> notSupposedToExistPlayers = new List<PlayerControllerB>(); public static Texture2D mainLogo; public static GameObject quickMenuScrollParent; public static GameObject playerEntry; public static GameObject crewCountUI; public static GameObject cosmeticGUIInstance; public static GameObject cosmeticButton; public static ManualLogSource StaticLogger; public static Dictionary<int, List<string>> playerIdsAndCosmetics = new Dictionary<int, List<string>>(); public static string cosmeticSavePath = Application.persistentDataPath + "/morecompanycosmetics.txt"; public static string moreCompanySave = Application.persistentDataPath + "/morecompanysave.txt"; public static string dynamicCosmeticsPath = Paths.PluginPath + "/MoreCompanyCosmetics"; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown StaticLogger = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("me.swipez.melonloader.morecompany"); try { val.PatchAll(); } catch (Exception ex) { StaticLogger.LogError((object)("Failed to patch: " + ex)); } ManualHarmonyPatches.ManualPatch(val); StaticLogger.LogInfo((object)"Loading MoreCompany..."); StaticLogger.LogInfo((object)("Checking: " + dynamicCosmeticsPath)); if (!Directory.Exists(dynamicCosmeticsPath)) { StaticLogger.LogInfo((object)"Creating cosmetics directory"); Directory.CreateDirectory(dynamicCosmeticsPath); } StaticLogger.LogInfo((object)"Loaded MoreCompany FULLY"); ReadSettingsFromFile(); ReadCosmeticsFromFile(); StaticLogger.LogInfo((object)"Read settings and cosmetics"); AssetBundle bundle = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.assets", Assembly.GetExecutingAssembly()); AssetBundle val2 = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.cosmetics", Assembly.GetExecutingAssembly()); CosmeticRegistry.LoadCosmeticsFromBundle(val2); val2.Unload(false); SteamFriends.OnGameLobbyJoinRequested += delegate(Lobby lobby, SteamId steamId) { newPlayerCount = ((Lobby)(ref lobby)).MaxMembers; }; SteamMatchmaking.OnLobbyEntered += delegate(Lobby lobby) { newPlayerCount = ((Lobby)(ref lobby)).MaxMembers; }; StaticLogger.LogInfo((object)"Loading USER COSMETICS..."); RecursiveCosmeticLoad(dynamicCosmeticsPath); LoadAssets(bundle); } private void RecursiveCosmeticLoad(string directory) { string[] directories = Directory.GetDirectories(directory); foreach (string directory2 in directories) { RecursiveCosmeticLoad(directory2); } string[] files = Directory.GetFiles(directory); foreach (string text in files) { if (text.EndsWith(".cosmetics")) { AssetBundle val = AssetBundle.LoadFromFile(text); CosmeticRegistry.LoadCosmeticsFromBundle(val); val.Unload(false); } } } private void ReadCosmeticsFromFile() { if (File.Exists(cosmeticSavePath)) { string[] array = File.ReadAllLines(cosmeticSavePath); string[] array2 = array; foreach (string item in array2) { CosmeticRegistry.locallySelectedCosmetics.Add(item); } } } public static void WriteCosmeticsToFile() { string text = ""; foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics) { text = text + locallySelectedCosmetic + "\n"; } File.WriteAllText(cosmeticSavePath, text); } public static void SaveSettingsToFile() { string text = ""; text = text + newPlayerCount + "\n"; text = text + showCosmetics + "\n"; File.WriteAllText(moreCompanySave, text); } public static void ReadSettingsFromFile() { if (File.Exists(moreCompanySave)) { string[] array = File.ReadAllLines(moreCompanySave); try { newPlayerCount = int.Parse(array[0]); showCosmetics = bool.Parse(array[1]); } catch (Exception) { StaticLogger.LogError((object)"Failed to read settings from file, resetting to default"); newPlayerCount = 32; showCosmetics = true; } } } private static void LoadAssets(AssetBundle bundle) { if (Object.op_Implicit((Object)(object)bundle)) { mainLogo = bundle.LoadPersistentAsset<Texture2D>("assets/morecompanyassets/morecompanytransparentred.png"); quickMenuScrollParent = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/quickmenuoverride.prefab"); playerEntry = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/playerlistslot.prefab"); cosmeticGUIInstance = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/testoverlay.prefab"); cosmeticButton = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/cosmeticinstance.prefab"); crewCountUI = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/crewcountfield.prefab"); bundle.Unload(false); } } public static void ResizePlayerCache(Dictionary<uint, Dictionary<int, NetworkObject>> ScenePlacedObjects) { //IL_0091: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown StartOfRound instance = StartOfRound.Instance; if (instance.allPlayerObjects.Length == newPlayerCount) { return; } playerIdsAndCosmetics.Clear(); uint num = 10000u; int num2 = newPlayerCount - instance.allPlayerObjects.Length; int num3 = instance.allPlayerObjects.Length; GameObject val = instance.allPlayerObjects[3]; for (int i = 0; i < num2; i++) { uint num4 = num + (uint)i; GameObject val2 = Object.Instantiate<GameObject>(val); NetworkObject component = val2.GetComponent<NetworkObject>(); ReflectionUtils.SetFieldValue(component, "GlobalObjectIdHash", num4); Scene scene = ((Component)component).gameObject.scene; int handle = ((Scene)(ref scene)).handle; uint num5 = num4; if (!ScenePlacedObjects.ContainsKey(num5)) { ScenePlacedObjects.Add(num5, new Dictionary<int, NetworkObject>()); } if (ScenePlacedObjects[num5].ContainsKey(handle)) { string arg = (((Object)(object)ScenePlacedObjects[num5][handle] != (Object)null) ? ((Object)ScenePlacedObjects[num5][handle]).name : "Null Entry"); throw new Exception(((Object)component).name + " tried to registered with ScenePlacedObjects which already contains " + string.Format("the same {0} value {1} for {2}!", "GlobalObjectIdHash", num5, arg)); } ScenePlacedObjects[num5].Add(handle, component); ((Object)val2).name = $"Player ({4 + i})"; val2.transform.parent = null; PlayerControllerB componentInChildren = val2.GetComponentInChildren<PlayerControllerB>(); notSupposedToExistPlayers.Add(componentInChildren); componentInChildren.playerClientId = (ulong)(4 + i); componentInChildren.isPlayerControlled = false; componentInChildren.isPlayerDead = false; componentInChildren.DropAllHeldItems(false, false); componentInChildren.TeleportPlayer(instance.notSpawnedPosition.position, false, 0f, false, true); UnlockableSuit.SwitchSuitForPlayer(componentInChildren, 0, false); Array.Resize(ref instance.allPlayerObjects, instance.allPlayerObjects.Length + 1); Array.Resize(ref instance.allPlayerScripts, instance.allPlayerScripts.Length + 1); Array.Resize(ref instance.gameStats.allPlayerStats, instance.gameStats.allPlayerStats.Length + 1); Array.Resize(ref instance.playerSpawnPositions, instance.playerSpawnPositions.Length + 1); instance.allPlayerObjects[num3 + i] = val2; instance.gameStats.allPlayerStats[num3 + i] = new PlayerStats(); instance.allPlayerScripts[num3 + i] = componentInChildren; instance.playerSpawnPositions[num3 + i] = instance.playerSpawnPositions[3]; } } public static void EnablePlayerObjectsBasedOnConnected() { int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { for (int j = 0; j < connectedPlayersAmount + 1; j++) { if (!val.isPlayerControlled) { ((Component)val).gameObject.SetActive(false); } else { ((Component)val).gameObject.SetActive(true); } } } } } [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesServerRpc")] public static class SendNewPlayerValuesServerRpcPatch { public static ulong lastId; public static void Prefix(PlayerControllerB __instance, ulong newPlayerSteamId) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && networkManager.IsServer) { lastId = newPlayerSteamId; } } } [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")] public static class SendNewPlayerValuesClientRpcPatch { public static void Prefix(PlayerControllerB __instance, ref ulong[] playerSteamIds) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return; } if (StartOfRound.Instance.mapScreen.radarTargets.Count != MainClass.newPlayerCount) { List<PlayerControllerB> useless = new List<PlayerControllerB>(); foreach (PlayerControllerB notSupposedToExistPlayer in MainClass.notSupposedToExistPlayers) { if (Object.op_Implicit((Object)(object)notSupposedToExistPlayer)) { StartOfRound.Instance.mapScreen.radarTargets.Add(new TransformAndName(((Component)notSupposedToExistPlayer).transform, notSupposedToExistPlayer.playerUsername, false)); } else { useless.Add(notSupposedToExistPlayer); } } MainClass.notSupposedToExistPlayers.RemoveAll((PlayerControllerB x) => useless.Contains(x)); } if (!networkManager.IsServer) { return; } List<ulong> list = new List<ulong>(); for (int i = 0; i < MainClass.newPlayerCount; i++) { if (i == (int)__instance.playerClientId) { list.Add(SendNewPlayerValuesServerRpcPatch.lastId); } else { list.Add(__instance.playersManager.allPlayerScripts[i].playerSteamId); } } playerSteamIds = list.ToArray(); } } public static class HUDManagerBullshitPatch { public static bool ManualPrefix(HUDManager __instance) { return false; } } [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")] public static class SyncShipUnlockablePatch { public static void Prefix(StartOfRound __instance, ref int[] playerSuitIDs, bool shipLightsOn, Vector3[] placeableObjectPositions, Vector3[] placeableObjectRotations, int[] placeableObjects, int[] storedItems, int[] scrapValues, int[] itemSaveData) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && networkManager.IsServer) { int[] array = new int[MainClass.newPlayerCount]; for (int i = 0; i < MainClass.newPlayerCount; i++) { array[i] = __instance.allPlayerScripts[i].currentSuitID; } playerSuitIDs = array; } } } [HarmonyPatch(typeof(NetworkSceneManager), "PopulateScenePlacedObjects")] public static class ScenePlacedObjectsInitPatch { public static void Postfix(ref Dictionary<uint, Dictionary<int, NetworkObject>> ___ScenePlacedObjects) { MainClass.ResizePlayerCache(___ScenePlacedObjects); } } [HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")] public static class LobbyDataJoinablePatch { public static bool Prefix(ref bool __result) { __result = true; return false; } } [HarmonyPatch(typeof(NetworkConnectionManager), "HandleConnectionApproval")] public static class ConnectionApprovalTest { public static void Prefix(ulong ownerClientId, ConnectionApprovalResponse response) { if (Object.op_Implicit((Object)(object)StartOfRound.Instance)) { if (StartOfRound.Instance.connectedPlayersAmount >= MainClass.newPlayerCount) { response.Approved = false; response.Reason = "Server is full"; } else { response.Approved = true; } } } } [HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")] public static class LobbyThingPatch { public static void Prefix(ref int maxMembers) { MainClass.ReadSettingsFromFile(); maxMembers = MainClass.newPlayerCount; } } public class ManualHarmonyPatches { public static void ManualPatch(Harmony HarmonyInstance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(HUDManager), "SyncAllPlayerLevelsServerRpc", new Type[0], (Type[])null), new HarmonyMethod(typeof(HUDManagerBullshitPatch).GetMethod("ManualPrefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public class ReflectionUtils { public static void InvokeMethod(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void InvokeMethod(object obj, Type forceType, string methodName, object[] parameters) { MethodInfo method = forceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void SetPropertyValue(object obj, string propertyName, object value) { Type type = obj.GetType(); PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); property.SetValue(obj, value); } public static T InvokeMethod<T>(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)method.Invoke(obj, parameters); } public static T GetFieldValue<T>(object obj, string fieldName) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)field.GetValue(obj); } public static void SetFieldValue(object obj, string fieldName, object value) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); field.SetValue(obj, value); } } [HarmonyPatch(typeof(ShipTeleporter), "Awake")] public static class ShipTeleporterAwakePatch { public static void Postfix(ShipTeleporter __instance) { int[] array = new int[MainClass.newPlayerCount]; for (int i = 0; i < MainClass.newPlayerCount; i++) { array[i] = -1; } ReflectionUtils.SetFieldValue(__instance, "playersBeingTeleported", array); } } [HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")] public static class SpectatePatches { public static bool Prefix(PlayerControllerB __instance) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) int num = 0; if ((Object)(object)__instance.spectatedPlayerScript != (Object)null) { num = (int)__instance.spectatedPlayerScript.playerClientId; } for (int i = 0; i < MainClass.newPlayerCount; i++) { num = (num + 1) % MainClass.newPlayerCount; if (!__instance.playersManager.allPlayerScripts[num].isPlayerDead && __instance.playersManager.allPlayerScripts[num].isPlayerControlled && (Object)(object)__instance.playersManager.allPlayerScripts[num] != (Object)(object)__instance) { __instance.spectatedPlayerScript = __instance.playersManager.allPlayerScripts[num]; __instance.SetSpectatedPlayerEffects(false); return false; } } if ((Object)(object)__instance.deadBody != (Object)null && ((Component)__instance.deadBody).gameObject.activeSelf) { __instance.spectateCameraPivot.position = __instance.deadBody.bodyParts[0].position; ReflectionUtils.InvokeMethod(__instance, "RaycastSpectateCameraAroundPivot", null); } StartOfRound.Instance.SetPlayerSafeInShip(); return false; } } [HarmonyPatch(typeof(SoundManager), "Start")] public static class SoundManagerStartPatch { public static void Postfix() { int num = MainClass.newPlayerCount - 4; int num2 = 4; for (int i = 0; i < num; i++) { Array.Resize(ref SoundManager.Instance.playerVoicePitches, SoundManager.Instance.playerVoicePitches.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoicePitchTargets, SoundManager.Instance.playerVoicePitchTargets.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoiceVolumes, SoundManager.Instance.playerVoiceVolumes.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoicePitchLerpSpeed, SoundManager.Instance.playerVoicePitchLerpSpeed.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoiceMixers, SoundManager.Instance.playerVoiceMixers.Length + 1); AudioMixerGroup val = ((IEnumerable<AudioMixerGroup>)Resources.FindObjectsOfTypeAll<AudioMixerGroup>()).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup x) => ((Object)x).name.Contains("Voice"))); SoundManager.Instance.playerVoicePitches[num2 + i] = 1f; SoundManager.Instance.playerVoicePitchTargets[num2 + i] = 1f; SoundManager.Instance.playerVoiceVolumes[num2 + i] = 0.5f; SoundManager.Instance.playerVoicePitchLerpSpeed[num2 + i] = 3f; SoundManager.Instance.playerVoiceMixers[num2 + i] = val; } } } [HarmonyPatch(typeof(StartOfRound), "GetPlayerSpawnPosition")] public static class SpawnPositionClampPatch { public static void Prefix(ref int playerNum, bool simpleTeleport = false) { if (playerNum > 3) { playerNum = 3; } } } [HarmonyPatch(typeof(StartOfRound), "OnClientConnect")] public static class OnClientConnectedPatch { public static bool Prefix(StartOfRound __instance, ulong clientId) { if (!((NetworkBehaviour)__instance).IsServer) { return false; } Debug.Log((object)"player connected"); Debug.Log((object)$"connected players #: {__instance.connectedPlayersAmount}"); try { List<int> list = __instance.ClientPlayerList.Values.ToList(); Debug.Log((object)$"Connecting new player on host; clientId: {clientId}"); int num = 0; for (int i = 1; i < MainClass.newPlayerCount; i++) { if (!list.Contains(i)) { num = i; break; } } __instance.allPlayerScripts[num].actualClientId = clientId; __instance.allPlayerObjects[num].GetComponent<NetworkObject>().ChangeOwnership(clientId); Debug.Log((object)$"New player assigned object id: {__instance.allPlayerObjects[num]}"); List<ulong> list2 = new List<ulong>(); for (int j = 0; j < __instance.allPlayerObjects.Length; j++) { NetworkObject component = __instance.allPlayerObjects[j].GetComponent<NetworkObject>(); if (!component.IsOwnedByServer) { list2.Add(component.OwnerClientId); } else if (j == 0) { list2.Add(NetworkManager.Singleton.LocalClientId); } else { list2.Add(999uL); } } int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits; int profitQuota = TimeOfDay.Instance.profitQuota; int quotaFulfilled = TimeOfDay.Instance.quotaFulfilled; int num2 = (int)TimeOfDay.Instance.timeUntilDeadline; ReflectionUtils.InvokeMethod(__instance, "OnPlayerConnectedClientRpc", new object[10] { clientId, __instance.connectedPlayersAmount, list2.ToArray(), num, groupCredits, __instance.currentLevelID, profitQuota, num2, quotaFulfilled, __instance.randomMapSeed }); __instance.ClientPlayerList.Add(clientId, num); Debug.Log((object)$"client id connecting: {clientId} ; their corresponding player object id: {num}"); } catch (Exception arg) { Debug.LogError((object)$"Error occured in OnClientConnected! Shutting server down. clientId: {clientId}. Error: {arg}"); GameNetworkManager.Instance.disconnectionReasonMessage = "Error occured when a player attempted to join the server! Restart the application and please report the glitch!"; GameNetworkManager.Instance.Disconnect(); } return false; } } [HarmonyPatch(typeof(SteamLobbyManager), "LoadServerList")] public static class LoadServerListPatch { public static bool Prefix(SteamLobbyManager __instance) { OverrideMethod(__instance); return false; } private static async void OverrideMethod(SteamLobbyManager __instance) { if (GameNetworkManager.Instance.waitingForLobbyDataRefresh) { return; } ReflectionUtils.SetFieldValue(__instance, "refreshServerListTimer", 0f); ((TMP_Text)__instance.serverListBlankText).text = "Loading server list..."; ReflectionUtils.GetFieldValue<Lobby[]>(__instance, "currentLobbyList"); LobbySlot[] array = Object.FindObjectsOfType<LobbySlot>(); for (int i = 0; i < array.Length; i++) { Object.Destroy((Object)(object)((Component)array[i]).gameObject); } LobbyQuery val; switch (__instance.sortByDistanceSetting) { case 0: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceClose(); break; case 1: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceFar(); break; case 2: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceWorldwide(); break; } Debug.Log((object)"Requested server list"); GameNetworkManager.Instance.waitingForLobbyDataRefresh = true; Lobby[] currentLobbyList; switch (__instance.sortByDistanceSetting) { case 0: val = SteamMatchmaking.LobbyList; val = ((LobbyQuery)(ref val)).FilterDistanceClose(); val = ((LobbyQuery)(ref val)).WithSlotsAvailable(1); val = ((LobbyQuery)(ref val)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString()); currentLobbyList = await ((LobbyQuery)(ref val)).RequestAsync(); break; case 1: val = SteamMatchmaking.LobbyList; val = ((LobbyQuery)(ref val)).FilterDistanceFar(); val = ((LobbyQuery)(ref val)).WithSlotsAvailable(1); val = ((LobbyQuery)(ref val)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString()); currentLobbyList = await ((LobbyQuery)(ref val)).RequestAsync(); break; default: val = SteamMatchmaking.LobbyList; val = ((LobbyQuery)(ref val)).FilterDistanceWorldwide(); val = ((LobbyQuery)(ref val)).WithSlotsAvailable(1); val = ((LobbyQuery)(ref val)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString()); currentLobbyList = await ((LobbyQuery)(ref val)).RequestAsync(); break; } GameNetworkManager.Instance.waitingForLobbyDataRefresh = false; if (currentLobbyList != null) { Debug.Log((object)"Got lobby list!"); ReflectionUtils.InvokeMethod(__instance, "DebugLogServerList", null); if (currentLobbyList.Length == 0) { ((TMP_Text)__instance.serverListBlankText).text = "No available servers to join."; } else { ((TMP_Text)__instance.serverListBlankText).text = ""; } ReflectionUtils.SetFieldValue(__instance, "lobbySlotPositionOffset", 0f); for (int j = 0; j < currentLobbyList.Length; j++) { Friend[] array2 = SteamFriends.GetBlocked().ToArray(); if (array2 != null) { for (int k = 0; k < array2.Length; k++) { Debug.Log((object)$"blocked user: {((Friend)(ref array2[k])).Name}; id: {array2[k].Id}"); if (((Lobby)(ref currentLobbyList[j])).IsOwnedBy(array2[k].Id)) { Debug.Log((object)("Hiding lobby by blocked user: " + ((Friend)(ref array2[k])).Name)); } } } else { Debug.Log((object)"Blocked users list is null"); } GameObject gameObject = Object.Instantiate<GameObject>(__instance.LobbySlotPrefab, __instance.levelListContainer); gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 0f + ReflectionUtils.GetFieldValue<float>(__instance, "lobbySlotPositionOffset")); ReflectionUtils.SetFieldValue(__instance, "lobbySlotPositionOffset", ReflectionUtils.GetFieldValue<float>(__instance, "lobbySlotPositionOffset") - 42f); LobbySlot componentInChildren = gameObject.GetComponentInChildren<LobbySlot>(); ((TMP_Text)componentInChildren.LobbyName).text = ((Lobby)(ref currentLobbyList[j])).GetData("name"); ((TMP_Text)componentInChildren.playerCount).text = $"{((Lobby)(ref currentLobbyList[j])).MemberCount} / {((Lobby)(ref currentLobbyList[j])).MaxMembers}"; componentInChildren.lobbyId = ((Lobby)(ref currentLobbyList[j])).Id; componentInChildren.thisLobby = currentLobbyList[j]; ReflectionUtils.SetFieldValue(__instance, "currentLobbyList", currentLobbyList); } } else { Debug.Log((object)"Lobby list is null after request."); ((TMP_Text)__instance.serverListBlankText).text = "No available servers to join."; } } } [HarmonyPatch(typeof(GameNetworkManager), "Awake")] public static class GameNetworkAwakePatch { public static int originalVersion; public static void Postfix(GameNetworkManager __instance) { originalVersion = __instance.gameVersionNum; if (!AssemblyChecker.HasAssemblyLoaded("lc_api")) { __instance.gameVersionNum = 9999; } } } [HarmonyPatch(typeof(MenuManager), "Awake")] public static class MenuManagerVersionDisplayPatch { public static void Postfix(MenuManager __instance) { if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)__instance.versionNumberText != (Object)null) { ((TMP_Text)__instance.versionNumberText).text = $"v{GameNetworkAwakePatch.originalVersion} (MC)"; } } } } namespace MoreCompany.Utils { public class AssemblyChecker { public static bool HasAssemblyLoaded(string name) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { if (assembly.GetName().Name.ToLower().Equals(name)) { return true; } } return false; } } public class BundleUtilities { public static byte[] GetResourceBytes(string filename, Assembly assembly) { string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.Contains(filename)) { continue; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return array; } return null; } public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly) { return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly)); } } public static class AssetBundleExtension { public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object { Object val = bundle.LoadAsset(name); if (val != (Object)null) { val.hideFlags = (HideFlags)32; return (T)(object)val; } return default(T); } } } namespace MoreCompany.Cosmetics { public class CosmeticApplication : MonoBehaviour { public Transform head; public Transform hip; public Transform lowerArmRight; public Transform shinLeft; public Transform shinRight; public Transform chest; public List<CosmeticInstance> spawnedCosmetics = new List<CosmeticInstance>(); public void Awake() { head = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002") .Find("spine.003") .Find("spine.004"); chest = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002") .Find("spine.003"); lowerArmRight = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002") .Find("spine.003") .Find("shoulder.R") .Find("arm.R_upper") .Find("arm.R_lower"); hip = ((Component)this).transform.Find("spine"); shinLeft = ((Component)this).transform.Find("spine").Find("thigh.L").Find("shin.L"); shinRight = ((Component)this).transform.Find("spine").Find("thigh.R").Find("shin.R"); RefreshAllCosmeticPositions(); } private void OnDisable() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { ((Component)spawnedCosmetic).gameObject.SetActive(false); } } private void OnEnable() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { ((Component)spawnedCosmetic).gameObject.SetActive(true); } } public void ClearCosmetics() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { Object.Destroy((Object)(object)((Component)spawnedCosmetic).gameObject); } spawnedCosmetics.Clear(); } public void ApplyCosmetic(string cosmeticId, bool startEnabled) { if (CosmeticRegistry.cosmeticInstances.ContainsKey(cosmeticId)) { CosmeticInstance cosmeticInstance = CosmeticRegistry.cosmeticInstances[cosmeticId]; GameObject val = Object.Instantiate<GameObject>(((Component)cosmeticInstance).gameObject); val.SetActive(startEnabled); CosmeticInstance component = val.GetComponent<CosmeticInstance>(); spawnedCosmetics.Add(component); if (startEnabled) { ParentCosmetic(component); } } } public void RefreshAllCosmeticPositions() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { ParentCosmetic(spawnedCosmetic); } } private void ParentCosmetic(CosmeticInstance cosmeticInstance) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Transform val = null; switch (cosmeticInstance.cosmeticType) { case CosmeticType.HAT: val = head; break; case CosmeticType.R_LOWER_ARM: val = lowerArmRight; break; case CosmeticType.HIP: val = hip; break; case CosmeticType.L_SHIN: val = shinLeft; break; case CosmeticType.R_SHIN: val = shinRight; break; case CosmeticType.CHEST: val = chest; break; } ((Component)cosmeticInstance).transform.position = val.position; ((Component)cosmeticInstance).transform.rotation = val.rotation; ((Component)cosmeticInstance).transform.parent = val; } } public class CosmeticInstance : MonoBehaviour { public CosmeticType cosmeticType; public string cosmeticId; public Texture2D icon; } public class CosmeticGeneric { public virtual string gameObjectPath { get; } public virtual string cosmeticId { get; } public virtual string textureIconPath { get; } public CosmeticType cosmeticType { get; } public void LoadFromBundle(AssetBundle bundle) { GameObject val = bundle.LoadPersistentAsset<GameObject>(gameObjectPath); Texture2D icon = bundle.LoadPersistentAsset<Texture2D>(textureIconPath); CosmeticInstance cosmeticInstance = val.AddComponent<CosmeticInstance>(); cosmeticInstance.cosmeticId = cosmeticId; cosmeticInstance.icon = icon; cosmeticInstance.cosmeticType = cosmeticType; MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + cosmeticId + " from bundle: " + ((Object)bundle).name)); CosmeticRegistry.cosmeticInstances.Add(cosmeticId, cosmeticInstance); } } public enum CosmeticType { HAT, WRIST, CHEST, R_LOWER_ARM, HIP, L_SHIN, R_SHIN } public class CosmeticRegistry { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__7_0; public static UnityAction <>9__7_1; internal void <SpawnCosmeticGUI>b__7_0() { MainClass.showCosmetics = true; MainClass.SaveSettingsToFile(); } internal void <SpawnCosmeticGUI>b__7_1() { MainClass.showCosmetics = false; MainClass.SaveSettingsToFile(); } } public static Dictionary<string, CosmeticInstance> cosmeticInstances = new Dictionary<string, CosmeticInstance>(); public static GameObject cosmeticGUI; private static GameObject displayGuy; private static CosmeticApplication cosmeticApplication; public static List<string> locallySelectedCosmetics = new List<string>(); public static void LoadCosmeticsFromBundle(AssetBundle bundle) { string[] allAssetNames = bundle.GetAllAssetNames(); foreach (string text in allAssetNames) { if (text.EndsWith(".prefab")) { GameObject val = bundle.LoadPersistentAsset<GameObject>(text); CosmeticInstance component = val.GetComponent<CosmeticInstance>(); if (!((Object)(object)component == (Object)null)) { MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + component.cosmeticId + " from bundle")); cosmeticInstances.Add(component.cosmeticId, component); } } } } public static void LoadCosmeticsFromAssembly(Assembly assembly, AssetBundle bundle) { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(CosmeticGeneric))) { CosmeticGeneric cosmeticGeneric = (CosmeticGeneric)type.GetConstructor(new Type[0]).Invoke(new object[0]); cosmeticGeneric.LoadFromBundle(bundle); } } } public static void SpawnCosmeticGUI() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown cosmeticGUI = Object.Instantiate<GameObject>(MainClass.cosmeticGUIInstance); ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale")).transform.localScale = new Vector3(2f, 2f, 2f); displayGuy = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("ObjectHolder") .Find("ScavengerModel") .Find("metarig")).gameObject; cosmeticApplication = displayGuy.AddComponent<CosmeticApplication>(); GameObject gameObject = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("EnableButton")).gameObject; ButtonClickedEvent onClick = gameObject.GetComponent<Button>().onClick; object obj = <>c.<>9__7_0; if (obj == null) { UnityAction val = delegate { MainClass.showCosmetics = true; MainClass.SaveSettingsToFile(); }; <>c.<>9__7_0 = val; obj = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj); GameObject gameObject2 = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("DisableButton")).gameObject; ButtonClickedEvent onClick2 = gameObject2.GetComponent<Button>().onClick; object obj2 = <>c.<>9__7_1; if (obj2 == null) { UnityAction val2 = delegate { MainClass.showCosmetics = false; MainClass.SaveSettingsToFile(); }; <>c.<>9__7_1 = val2; obj2 = (object)val2; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); if (MainClass.showCosmetics) { gameObject.SetActive(false); gameObject2.SetActive(true); } else { gameObject.SetActive(true); gameObject2.SetActive(false); } PopulateCosmetics(); UpdateCosmeticsOnDisplayGuy(startEnabled: false); } public static void PopulateCosmetics() { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown GameObject gameObject = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("CosmeticsHolder") .Find("Content")).gameObject; List<Transform> list = new List<Transform>(); for (int i = 0; i < gameObject.transform.childCount; i++) { list.Add(gameObject.transform.GetChild(i)); } foreach (Transform item in list) { Object.Destroy((Object)(object)((Component)item).gameObject); } foreach (KeyValuePair<string, CosmeticInstance> cosmeticInstance in cosmeticInstances) { GameObject val = Object.Instantiate<GameObject>(MainClass.cosmeticButton, gameObject.transform); val.transform.localScale = Vector3.one; GameObject disabledOverlay = ((Component)val.transform.Find("Deselected")).gameObject; disabledOverlay.SetActive(true); GameObject enabledOverlay = ((Component)val.transform.Find("Selected")).gameObject; enabledOverlay.SetActive(true); if (IsEquipped(cosmeticInstance.Value.cosmeticId)) { enabledOverlay.SetActive(true); disabledOverlay.SetActive(false); } else { enabledOverlay.SetActive(false); disabledOverlay.SetActive(true); } RawImage component = ((Component)val.transform.Find("Icon")).GetComponent<RawImage>(); component.texture = (Texture)(object)cosmeticInstance.Value.icon; Button component2 = val.GetComponent<Button>(); ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { ToggleCosmetic(cosmeticInstance.Value.cosmeticId); if (IsEquipped(cosmeticInstance.Value.cosmeticId)) { enabledOverlay.SetActive(true); disabledOverlay.SetActive(false); } else { enabledOverlay.SetActive(false); disabledOverlay.SetActive(true); } MainClass.WriteCosmeticsToFile(); UpdateCosmeticsOnDisplayGuy(startEnabled: true); }); } } private static Color HexToColor(string hex) { //IL_0003: 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_0013: 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) Color result = default(Color); ColorUtility.TryParseHtmlString(hex, ref result); return result; } public static void UpdateCosmeticsOnDisplayGuy(bool startEnabled) { cosmeticApplication.ClearCosmetics(); foreach (string locallySelectedCosmetic in locallySelectedCosmetics) { cosmeticApplication.ApplyCosmetic(locallySelectedCosmetic, startEnabled); } foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication.spawnedCosmetics) { RecursiveLayerChange(((Component)spawnedCosmetic).transform, 5); } } private static void RecursiveLayerChange(Transform transform, int layer) { ((Component)transform).gameObject.layer = layer; for (int i = 0; i < transform.childCount; i++) { RecursiveLayerChange(transform.GetChild(i), layer); } } public static bool IsEquipped(string cosmeticId) { return locallySelectedCosmetics.Contains(cosmeticId); } public static void ToggleCosmetic(string cosmeticId) { if (locallySelectedCosmetics.Contains(cosmeticId)) { locallySelectedCosmetics.Remove(cosmeticId); } else { locallySelectedCosmetics.Add(cosmeticId); } } } }
plugins/Owen3H-IntroTweaks/IntroTweaks.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using IntroTweaks.Core; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")] [assembly: AssemblyCompany("IntroTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Configurable, seamless skipping of intro menus in Lethal Company.")] [assembly: AssemblyFileVersion("1.2.2.0")] [assembly: AssemblyInformationalVersion("1.2.2+376e01eb494784877512c3d828b737154e215718")] [assembly: AssemblyProduct("IntroTweaks")] [assembly: AssemblyTitle("IntroTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.2.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 IntroTweaks { [BepInPlugin("io.github.IntroTweaks", "IntroTweaks", "1.2.2")] public class Plugin : BaseUnityPlugin { internal static string SelectedMode; private Harmony patcher; internal static ManualLogSource Logger { get; private set; } public static PluginConfig Config { get; private set; } private void Awake() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Config = new PluginConfig(((BaseUnityPlugin)this).Config); if (!PluginEnabled(logDisabled: true)) { return; } Config.InitBindings(); SelectedMode = Config.AUTO_SELECT_MODE.ToLower(); try { patcher = new Harmony("io.github.IntroTweaks"); patcher.PatchAll(); Logger.LogInfo((object)"Plugin loaded."); } catch (Exception ex) { Logger.LogError((object)ex); } } public bool PluginEnabled(bool logDisabled = false) { bool pLUGIN_ENABLED = Config.PLUGIN_ENABLED; if (!pLUGIN_ENABLED && logDisabled) { Logger.LogInfo((object)"IntroTweaks disabled globally."); } return pLUGIN_ENABLED; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "IntroTweaks"; public const string PLUGIN_NAME = "IntroTweaks"; public const string PLUGIN_VERSION = "1.2.2"; } } namespace IntroTweaks.Patches { [HarmonyPatch(typeof(InitializeGame))] internal class InitializeGamePatch { [HarmonyPrefix] [HarmonyPatch("Start")] private static void DisableBootAnimation(ref bool __runOriginal) { if (Plugin.Config.SKIP_BOOT_ANIMATION) { SceneManager.LoadScene("MainMenu"); __runOriginal = false; } } } [HarmonyPatch(typeof(MenuManager))] internal class MenuManagerPatch { public static int gameVer { get; private set; } public static TextMeshProUGUI versionText { get; private set; } [HarmonyPrefix] [HarmonyPatch("ClickHostButton")] private static void DisableMenuOnHost(MenuManager __instance) { __instance.menuButtons.SetActive(false); if (Plugin.Config.CUSTOM_VERSION_TEXT) { ((Component)((TMP_Text)versionText).transform).gameObject.SetActive(false); } } [HarmonyPrefix] [HarmonyPatch("Awake")] private static bool ReplaceVersionText(MenuManager __instance) { if (Plugin.Config.CUSTOM_VERSION_TEXT) { GameObject gameObject = ((Component)((TMP_Text)__instance.versionNumberText).transform).gameObject; GameObject val = Object.Instantiate<GameObject>(gameObject, __instance.menuButtons.transform); gameObject.SetActive(false); ((Object)val).name = "VersionNumberText"; versionText = InitTextMesh(val.GetComponent<TextMeshProUGUI>()); AnchorToBottom(val.GetComponent<RectTransform>()); } return true; } [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartPatch(MenuManager __instance) { if (Plugin.Config.REMOVE_NEWS_PANEL) { Object.Destroy((Object)(object)__instance.NewsPanel); } if (Plugin.Config.REMOVE_LAN_WARNING) { Object.Destroy((Object)(object)__instance.lanWarningContainer); } if (Plugin.Config.REMOVE_LAUNCHED_IN_LAN) { TextMeshProUGUI launchedInLanModeText = __instance.launchedInLanModeText; GameObject val = ((launchedInLanModeText != null) ? ((Component)((TMP_Text)launchedInLanModeText).transform).gameObject : null); if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } if (Plugin.Config.AUTO_SELECT_HOST) { __instance.ClickHostButton(); } } [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePatch() { if (Plugin.Config.CUSTOM_VERSION_TEXT) { ((TMP_Text)versionText).text = ((TMP_Text)versionText).text.Replace("$VERSION", gameVer.ToString()); } } private static TextMeshProUGUI InitTextMesh(TextMeshProUGUI tmp) { int gameVersionNum = GameNetworkManager.Instance.gameVersionNum; gameVer = Mathf.Abs(Plugin.Config.VERSION_TEXT_FORMAT.ToLower().Equals("short") ? (gameVersionNum - 16440) : gameVersionNum); ((TMP_Text)tmp).text = Plugin.Config.VERSION_TEXT; ((TMP_Text)tmp).fontSize = Mathf.Clamp(Plugin.Config.VERSION_TEXT_SIZE, 10f, 40f); ((TMP_Text)tmp).alignment = (TextAlignmentOptions)514; ((TMP_Text)tmp).enableWordWrapping = false; return tmp; } private static void AnchorToBottom(RectTransform rect) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = new Vector2(0.5f, 0f); rect.anchorMax = new Vector2(0.5f, 0f); rect.anchoredPosition = Vector2.zero; rect.anchoredPosition3D = Vector3.zero; ((Transform)rect).rotation = Quaternion.identity; ((Transform)rect).position = new Vector3(Plugin.Config.VERSION_TEXT_X, Plugin.Config.VERSION_TEXT_Y, -37f); } } [HarmonyPatch(typeof(PreInitSceneScript))] internal class PreSceneInitPatch { [HarmonyPrefix] [HarmonyPatch("SkipToFinalSetting")] private static bool OverrideSkipToFinal() { return false; } [HarmonyPostfix] [HarmonyPatch("Start")] private static void SkipToOnline(PreInitSceneScript __instance, ref bool ___choseLaunchOption) { if (!Plugin.SelectedMode.Equals("off")) { CollectionExtensions.Do<GameObject>((IEnumerable<GameObject>)__instance.LaunchSettingsPanels, (Action<GameObject>)delegate(GameObject p) { p.gameObject.SetActive(false); }); __instance.currentLaunchSettingPanel = 0; ((TMP_Text)__instance.headerText).text = ""; ((Component)__instance.blackTransition).gameObject.SetActive(false); __instance.continueButton.gameObject.SetActive(false); ___choseLaunchOption = true; __instance.mainAudio.PlayOneShot(__instance.selectSFX); IngamePlayerSettings.Instance.SetPlayerFinishedLaunchOptions(); IngamePlayerSettings.Instance.SaveChangedSettings(); if (!IngamePlayerSettings.Instance.encounteredErrorDuringSave) { SceneManager.LoadScene(Plugin.SelectedMode.Equals("online") ? "InitScene" : "InitSceneLANMode"); } } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPrefix] [HarmonyPatch("PlayFirstDayShipAnimation")] private static bool DisableSpeaker() { return !Plugin.Config.DISABLE_FIRST_DAY_SFX; } } } namespace IntroTweaks.Core { public class PluginConfig { private readonly ConfigFile configFile; public bool PLUGIN_ENABLED { get; private set; } public string AUTO_SELECT_MODE { get; private set; } public bool AUTO_SELECT_HOST { get; private set; } public bool SKIP_BOOT_ANIMATION { get; private set; } public bool REMOVE_LAN_WARNING { get; private set; } public bool REMOVE_LAUNCHED_IN_LAN { get; private set; } public bool REMOVE_NEWS_PANEL { get; private set; } public bool CUSTOM_VERSION_TEXT { get; private set; } public string VERSION_TEXT { get; private set; } public string VERSION_TEXT_FORMAT { get; private set; } public float VERSION_TEXT_SIZE { get; private set; } public float VERSION_TEXT_X { get; private set; } public float VERSION_TEXT_Y { get; private set; } public bool DISABLE_FIRST_DAY_SFX { get; private set; } public PluginConfig(ConfigFile cfg) { configFile = cfg; PLUGIN_ENABLED = NewEntry("bEnabled", defaultVal: true, "Enable or disable the plugin globally."); } private T NewEntry<T>(string key, T defaultVal, string description) { return configFile.Bind<T>("io.github.IntroTweaks", key, defaultVal, description).Value; } public void InitBindings() { AUTO_SELECT_MODE = NewEntry("sAutoSelectMode", "ONLINE", "Which mode to automatically enter into after the splash screen.\nValid options: ONLINE, LAN, OFF"); AUTO_SELECT_HOST = NewEntry("bAutoSelectHost", defaultVal: false, "Whether the 'Host' button is automatically selected when the Online/LAN menu loads."); SKIP_BOOT_ANIMATION = NewEntry("bSkipBootAnimation", defaultVal: true, "If the loading animation (booting OS) should be skipped."); REMOVE_LAN_WARNING = NewEntry("bRemoveLanWarning", defaultVal: true, "Remove the warning popup when hosting a LAN session."); REMOVE_LAUNCHED_IN_LAN = NewEntry("bRemoveLaunchedInLanText", defaultVal: true, "Remove the 'Launched in LAN mode' text below the Quit button."); REMOVE_NEWS_PANEL = NewEntry("bRemoveNewsPanel", defaultVal: false, "Remove the panel that displays news such as game updates."); CUSTOM_VERSION_TEXT = NewEntry("bCustomVersionText", defaultVal: true, "Whether to replace the game's version text with a custom alternative."); VERSION_TEXT = NewEntry("sVersionText", "v$VERSION\n[MODDED]", "Replace the game's version text with this custom text in the main menu.\nTo insert the version number, use the $VERSION syntax. E.g. Ver69 would be Ver$VERSION"); VERSION_TEXT_FORMAT = NewEntry("sVersionTextFormat", "FULL", "Determines how to display game version number.\nValid options: FULL, SHORT"); VERSION_TEXT_SIZE = NewEntry("fVersionTextSize", 20f, "The font size of the version text. Min = 10, Max = 40."); VERSION_TEXT_X = NewEntry("fVersionTextXPos", 1089.9f, "The position on the horizontal axis where the version text should be placed.\nPositive = Right, Negative = Left"); VERSION_TEXT_Y = NewEntry("fVersionTextYPos", 555f, "The position on the vertical axis where the version text should be placed.\nPositive = Up, Negative = Down"); DISABLE_FIRST_DAY_SFX = NewEntry("bDisableFirstDaySFX", defaultVal: false, "Toggles the first day ship speaker SFX."); } } internal static class Metadata { public const string GUID = "io.github.IntroTweaks"; public const string NAME = "IntroTweaks"; public const string VERSION = "1.2.2"; } }
plugins/RugbugRedfern-Skinwalkers/SkinwalkerMod.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Dissonance.Config; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SkinwalkerMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SkinwalkerMod")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fd4979a2-cef0-46af-8bf8-97e630b11475")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>(); } } namespace SkinwalkerMod; [BepInPlugin("RugbugRedfern.SkinwalkerMod", "Skinwalker Mod", "1.0.8")] internal class PluginLoader : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("RugbugRedfern.SkinwalkerMod"); private const string modGUID = "RugbugRedfern.SkinwalkerMod"; private const string modVersion = "1.0.8"; private static bool initialized; public static PluginLoader Instance { get; private set; } private void Awake() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown if (initialized) { return; } initialized = true; Instance = this; harmony.PatchAll(Assembly.GetExecutingAssembly()); 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); } } } SkinwalkerLogger.Initialize("RugbugRedfern.SkinwalkerMod"); SkinwalkerLogger.Log("SKINWALKER MOD STARTING UP 1.0.8"); SkinwalkerConfig.InitConfig(); SceneManager.sceneLoaded += SkinwalkerNetworkManagerHandler.ClientConnectInitializer; GameObject val = new GameObject("Skinwalker Mod"); val.AddComponent<SkinwalkerModPersistent>(); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); } public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "") { config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description); } } internal class SkinwalkerBehaviour : MonoBehaviour { private AudioSource audioSource; public const float PLAY_INTERVAL_MIN = 15f; public const float PLAY_INTERVAL_MAX = 40f; private const float MAX_DIST = 100f; private float nextTimeToPlayAudio; private EnemyAI ai; public void Initialize(EnemyAI ai) { this.ai = ai; audioSource = ai.creatureVoice; SetNextTime(); } private void Update() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time > nextTimeToPlayAudio)) { return; } SetNextTime(); float num = -1f; if (Object.op_Implicit((Object)(object)ai) && !ai.isEnemyDead) { if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position)) < 100f) { AudioClip sample = SkinwalkerModPersistent.Instance.GetSample(); if (Object.op_Implicit((Object)(object)sample)) { SkinwalkerLogger.Log(((Object)this).name + " played voice line 1"); audioSource.PlayOneShot(sample); } else { SkinwalkerLogger.Log(((Object)this).name + " played voice line 0"); } } else { SkinwalkerLogger.Log(((Object)this).name + " played voice line no (too far away) " + num); } } else { SkinwalkerLogger.Log(((Object)this).name + " played voice line no (dead) EnemyAI: " + (object)ai); } } private void SetNextTime() { if (SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value <= 0f) { nextTimeToPlayAudio = Time.time + 100000000f; } else { nextTimeToPlayAudio = Time.time + Random.Range(15f, 40f) / SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value; } } private T CopyComponent<T>(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component val = destination.AddComponent(type); FieldInfo[] fields = type.GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(val, fieldInfo.GetValue(original)); } return (T)(object)((val is T) ? val : null); } } internal class SkinwalkerConfig { public static ConfigEntry<bool> VoiceEnabled_BaboonHawk; public static ConfigEntry<bool> VoiceEnabled_Bracken; public static ConfigEntry<bool> VoiceEnabled_BunkerSpider; public static ConfigEntry<bool> VoiceEnabled_Centipede; public static ConfigEntry<bool> VoiceEnabled_CoilHead; public static ConfigEntry<bool> VoiceEnabled_EyelessDog; public static ConfigEntry<bool> VoiceEnabled_ForestGiant; public static ConfigEntry<bool> VoiceEnabled_GhostGirl; public static ConfigEntry<bool> VoiceEnabled_GiantWorm; public static ConfigEntry<bool> VoiceEnabled_HoardingBug; public static ConfigEntry<bool> VoiceEnabled_Hygrodere; public static ConfigEntry<bool> VoiceEnabled_Jester; public static ConfigEntry<bool> VoiceEnabled_Masked; public static ConfigEntry<bool> VoiceEnabled_Nutcracker; public static ConfigEntry<bool> VoiceEnabled_SporeLizard; public static ConfigEntry<bool> VoiceEnabled_Thumper; public static ConfigEntry<float> VoiceLineFrequency; public static void InitConfig() { PluginLoader.Instance.BindConfig(ref VoiceLineFrequency, "Voice Settings", "VoiceLineFrequency", 1f, "1 is the default, and voice lines will occur every " + 15f.ToString("0") + " to " + 40f.ToString("0") + " seconds per enemy. Setting this to 2 means they will occur twice as often, 0.5 means half as often, etc."); PluginLoader.Instance.BindConfig(ref VoiceEnabled_BaboonHawk, "Monster Voices", "Baboon Hawk", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Bracken, "Monster Voices", "Bracken", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_BunkerSpider, "Monster Voices", "Bunker Spider", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Centipede, "Monster Voices", "Centipede", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_CoilHead, "Monster Voices", "Coil Head", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_EyelessDog, "Monster Voices", "Eyeless Dog", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_ForestGiant, "Monster Voices", "Forest Giant", defaultValue: false); PluginLoader.Instance.BindConfig(ref VoiceEnabled_GhostGirl, "Monster Voices", "Ghost Girl", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_GiantWorm, "Monster Voices", "Giant Worm", defaultValue: false); PluginLoader.Instance.BindConfig(ref VoiceEnabled_HoardingBug, "Monster Voices", "Hoarding Bug", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Hygrodere, "Monster Voices", "Hygrodere", defaultValue: false); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Jester, "Monster Voices", "Jester", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Masked, "Monster Voices", "Masked", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Nutcracker, "Monster Voices", "Nutcracker", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_SporeLizard, "Monster Voices", "Spore Lizard", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Thumper, "Monster Voices", "Thumper", defaultValue: true); SkinwalkerLogger.Log("VoiceEnabled_BaboonHawk" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BaboonHawk.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Bracken" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Bracken.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_BunkerSpider" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BunkerSpider.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Centipede" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Centipede.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_CoilHead" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_CoilHead.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_EyelessDog" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_EyelessDog.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_ForestGiant" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_ForestGiant.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_GhostGirl" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GhostGirl.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_GiantWorm" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GiantWorm.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_HoardingBug" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_HoardingBug.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Hygrodere" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Hygrodere.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Jester" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Jester.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Masked" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Masked.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Nutcracker" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Nutcracker.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_SporeLizard" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_SporeLizard.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Thumper" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Thumper.Value}]"); SkinwalkerLogger.Log("VoiceLineFrequency" + $" VALUE LOADED FROM CONFIG: [{VoiceLineFrequency.Value}]"); } } internal static class SkinwalkerLogger { internal static ManualLogSource logSource; public static void Initialize(string modGUID) { logSource = Logger.CreateLogSource(modGUID); } public static void Log(object message) { logSource.LogInfo(message); } public static void LogError(object message) { logSource.LogError(message); } public static void LogWarning(object message) { logSource.LogWarning(message); } } public class SkinwalkerModPersistent : MonoBehaviour { private string audioFolder; private List<AudioClip> cachedAudio = new List<AudioClip>(); private float nextTimeToCheckFolder = 30f; private float nextTimeToCheckEnemies = 30f; private const float folderScanInterval = 8f; private const float enemyScanInterval = 5f; public static SkinwalkerModPersistent Instance { get; private set; } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) Instance = this; ((Component)this).transform.position = Vector3.zero; SkinwalkerLogger.Log("Skinwalker Mod Object Initialized"); audioFolder = Path.Combine(Application.dataPath, "..", "Dissonance_Diagnostics"); EnableRecording(); if (!Directory.Exists(audioFolder)) { Directory.CreateDirectory(audioFolder); } } private void Start() { try { if (Directory.Exists(audioFolder)) { Directory.Delete(audioFolder, recursive: true); } } catch (Exception message) { SkinwalkerLogger.Log(message); } } private void OnApplicationQuit() { DisableRecording(); } private void EnableRecording() { DebugSettings.Instance.EnablePlaybackDiagnostics = true; DebugSettings.Instance.RecordFinalAudio = true; } private void Update() { if (Time.realtimeSinceStartup > nextTimeToCheckFolder) { nextTimeToCheckFolder = Time.realtimeSinceStartup + 8f; if (!Directory.Exists(audioFolder)) { SkinwalkerLogger.Log("Audio folder not present. Don't worry about it, it will be created automatically when you play with friends. (" + audioFolder + ")"); return; } string[] files = Directory.GetFiles(audioFolder); SkinwalkerLogger.Log($"Got audio file paths ({files.Length})"); string[] array = files; foreach (string path in array) { ((MonoBehaviour)this).StartCoroutine(LoadWavFile(path, delegate(AudioClip audioClip) { cachedAudio.Add(audioClip); })); } } if (!(Time.realtimeSinceStartup > nextTimeToCheckEnemies)) { return; } nextTimeToCheckEnemies = Time.realtimeSinceStartup + 5f; EnemyAI[] array2 = Object.FindObjectsOfType<EnemyAI>(true); EnemyAI[] array3 = array2; SkinwalkerBehaviour skinwalkerBehaviour = default(SkinwalkerBehaviour); foreach (EnemyAI val in array3) { SkinwalkerLogger.Log("IsEnemyEnabled " + ((Object)val).name + " " + IsEnemyEnabled(val)); if (IsEnemyEnabled(val) && !((Component)val).TryGetComponent<SkinwalkerBehaviour>(ref skinwalkerBehaviour)) { ((Component)val).gameObject.AddComponent<SkinwalkerBehaviour>().Initialize(val); } } } private bool IsEnemyEnabled(EnemyAI enemy) { if ((Object)(object)enemy == (Object)null) { return false; } return ((Object)((Component)enemy).gameObject).name switch { "MaskedPlayerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Masked.Value, "NutcrackerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Nutcracker.Value, "BaboonHawkEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BaboonHawk.Value, "Flowerman(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Bracken.Value, "SandSpider(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BunkerSpider.Value, "RedLocustBees(Clone)" => false, "Centipede(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Centipede.Value, "SpringMan(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_CoilHead.Value, "MouthDog(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_EyelessDog.Value, "ForestGiant(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_ForestGiant.Value, "DressGirl(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GhostGirl.Value, "SandWorm(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GiantWorm.Value, "HoarderBug(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_HoardingBug.Value, "Blob(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Hygrodere.Value, "JesterEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Jester.Value, "PufferEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_SporeLizard.Value, "Crawler(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Thumper.Value, "DocileLocustBees(Clone)" => false, "DoublewingedBird(Clone)" => false, _ => true, }; } internal IEnumerator LoadWavFile(string path, Action<AudioClip> callback) { UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20); try { yield return www.SendWebRequest(); if ((int)www.result == 1) { SkinwalkerLogger.Log("Loaded clip from path " + path); AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www); if (audioClip.length > 0.9f) { callback(audioClip); } try { File.Delete(path); } catch (Exception e) { SkinwalkerLogger.LogWarning(e); } } } finally { ((IDisposable)www)?.Dispose(); } } private void DisableRecording() { DebugSettings.Instance.EnablePlaybackDiagnostics = false; DebugSettings.Instance.RecordFinalAudio = false; if (Directory.Exists(audioFolder)) { Directory.Delete(audioFolder, recursive: true); } } public AudioClip GetSample() { if (cachedAudio.Count > 0) { int index = Random.Range(0, cachedAudio.Count - 1); AudioClip result = cachedAudio[index]; cachedAudio.RemoveAt(index); return result; } while (cachedAudio.Count > 200) { cachedAudio.RemoveAt(0); } return null; } public void ClearCache() { cachedAudio.Clear(); } } internal static class SkinwalkerNetworkManagerHandler { internal static void ClientConnectInitializer(Scene sceneName, LoadSceneMode sceneEnum) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (((Scene)(ref sceneName)).name == "SampleSceneRelay") { GameObject val = new GameObject("SkinwalkerNetworkManager"); val.AddComponent<NetworkObject>(); val.AddComponent<SkinwalkerNetworkManager>(); Debug.Log((object)"Initialized SkinwalkerNetworkManager"); } } } internal class SkinwalkerNetworkManager : NetworkBehaviour { public NetworkVariable<bool> VoiceEnabled_BaboonHawk = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Bracken = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_BunkerSpider = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Centipede = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_CoilHead = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_EyelessDog = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_ForestGiant = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_GhostGirl = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_GiantWorm = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_HoardingBug = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Hygrodere = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Jester = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Masked = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Nutcracker = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_SporeLizard = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Thumper = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> VoiceLineFrequency = new NetworkVariable<float>(1f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public static SkinwalkerNetworkManager Instance { get; private set; } private void Awake() { Instance = this; if (GameNetworkManager.Instance.isHostingGame) { VoiceEnabled_BaboonHawk.Value = SkinwalkerConfig.VoiceEnabled_BaboonHawk.Value; VoiceEnabled_Bracken.Value = SkinwalkerConfig.VoiceEnabled_Bracken.Value; VoiceEnabled_BunkerSpider.Value = SkinwalkerConfig.VoiceEnabled_BunkerSpider.Value; VoiceEnabled_Centipede.Value = SkinwalkerConfig.VoiceEnabled_Centipede.Value; VoiceEnabled_CoilHead.Value = SkinwalkerConfig.VoiceEnabled_CoilHead.Value; VoiceEnabled_EyelessDog.Value = SkinwalkerConfig.VoiceEnabled_EyelessDog.Value; VoiceEnabled_ForestGiant.Value = SkinwalkerConfig.VoiceEnabled_ForestGiant.Value; VoiceEnabled_GhostGirl.Value = SkinwalkerConfig.VoiceEnabled_GhostGirl.Value; VoiceEnabled_GiantWorm.Value = SkinwalkerConfig.VoiceEnabled_GiantWorm.Value; VoiceEnabled_HoardingBug.Value = SkinwalkerConfig.VoiceEnabled_HoardingBug.Value; VoiceEnabled_Hygrodere.Value = SkinwalkerConfig.VoiceEnabled_Hygrodere.Value; VoiceEnabled_Jester.Value = SkinwalkerConfig.VoiceEnabled_Jester.Value; VoiceEnabled_Masked.Value = SkinwalkerConfig.VoiceEnabled_Masked.Value; VoiceEnabled_Nutcracker.Value = SkinwalkerConfig.VoiceEnabled_Nutcracker.Value; VoiceEnabled_SporeLizard.Value = SkinwalkerConfig.VoiceEnabled_SporeLizard.Value; VoiceEnabled_Thumper.Value = SkinwalkerConfig.VoiceEnabled_Thumper.Value; VoiceLineFrequency.Value = SkinwalkerConfig.VoiceLineFrequency.Value; SkinwalkerLogger.Log("HOST SENDING CONFIG TO CLIENTS"); } SkinwalkerLogger.Log("SkinwalkerNetworkManager Awake"); } public override void OnDestroy() { ((NetworkBehaviour)this).OnDestroy(); SkinwalkerLogger.Log("SkinwalkerNetworkManager OnDestroy"); SkinwalkerModPersistent.Instance?.ClearCache(); } protected override void __initializeVariables() { if (VoiceEnabled_BaboonHawk == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BaboonHawk cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_BaboonHawk).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk, "VoiceEnabled_BaboonHawk"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk); if (VoiceEnabled_Bracken == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Bracken cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Bracken).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Bracken, "VoiceEnabled_Bracken"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Bracken); if (VoiceEnabled_BunkerSpider == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BunkerSpider cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_BunkerSpider).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider, "VoiceEnabled_BunkerSpider"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider); if (VoiceEnabled_Centipede == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Centipede cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Centipede).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Centipede, "VoiceEnabled_Centipede"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Centipede); if (VoiceEnabled_CoilHead == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_CoilHead cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_CoilHead).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_CoilHead, "VoiceEnabled_CoilHead"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_CoilHead); if (VoiceEnabled_EyelessDog == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_EyelessDog cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_EyelessDog).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_EyelessDog, "VoiceEnabled_EyelessDog"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_EyelessDog); if (VoiceEnabled_ForestGiant == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_ForestGiant cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_ForestGiant).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_ForestGiant, "VoiceEnabled_ForestGiant"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_ForestGiant); if (VoiceEnabled_GhostGirl == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GhostGirl cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_GhostGirl).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GhostGirl, "VoiceEnabled_GhostGirl"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GhostGirl); if (VoiceEnabled_GiantWorm == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GiantWorm cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_GiantWorm).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GiantWorm, "VoiceEnabled_GiantWorm"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GiantWorm); if (VoiceEnabled_HoardingBug == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_HoardingBug cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_HoardingBug).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_HoardingBug, "VoiceEnabled_HoardingBug"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_HoardingBug); if (VoiceEnabled_Hygrodere == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Hygrodere cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Hygrodere).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Hygrodere, "VoiceEnabled_Hygrodere"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Hygrodere); if (VoiceEnabled_Jester == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Jester cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Jester).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Jester, "VoiceEnabled_Jester"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Jester); if (VoiceEnabled_Masked == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Masked cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Masked).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Masked, "VoiceEnabled_Masked"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Masked); if (VoiceEnabled_Nutcracker == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Nutcracker cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Nutcracker).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Nutcracker, "VoiceEnabled_Nutcracker"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Nutcracker); if (VoiceEnabled_SporeLizard == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_SporeLizard cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_SporeLizard).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_SporeLizard, "VoiceEnabled_SporeLizard"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_SporeLizard); if (VoiceEnabled_Thumper == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Thumper cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Thumper).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Thumper, "VoiceEnabled_Thumper"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Thumper); if (VoiceLineFrequency == null) { throw new Exception("SkinwalkerNetworkManager.VoiceLineFrequency cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceLineFrequency).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceLineFrequency, "VoiceLineFrequency"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceLineFrequency); ((NetworkBehaviour)this).__initializeVariables(); } protected internal override string __getTypeName() { return "SkinwalkerNetworkManager"; } }
plugins/Sligili-More_Emotes/MoreEmotes1.1.3.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using MoreEmotes.Patch; using Tools; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FuckYouMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FuckYouMod")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5ecc2bf2-af12-4e83-a6f1-cf2eacbf3060")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace Tools { public class Reflection { public static object GetInstanceField(Type type, object instance, string fieldName) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = type.GetField(fieldName, bindingAttr); return field.GetValue(instance); } public static object CallMethod(object instance, string methodName, params object[] args) { MethodInfo method = instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { return method.Invoke(instance, args); } return null; } } } namespace MoreEmotes { [BepInPlugin("MoreEmotes", "MoreEmotes-Sligili", "1.1.3")] public class FuckYouModInitialization : BaseUnityPlugin { private Harmony _harmony; private ConfigEntry<string> config_KeyEmote3; private ConfigEntry<string> config_KeyEmote4; private ConfigEntry<string> config_KeyEmote5; private ConfigEntry<string> config_KeyEmote6; private ConfigEntry<bool> config_toggleEmote3; private ConfigEntry<bool> config_toggleEmote4; private ConfigEntry<bool> config_toggleEmote5; private ConfigEntry<bool> config_toggleEmote6; private void Awake() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreEmotes loaded"); EmotePatch.animationsBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animationsbundle")); EmotePatch.animatorBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animatorbundle")); EmotePatch.local = EmotePatch.animatorBundle.LoadAsset<RuntimeAnimatorController>("Assets/MoreEmotes/NEWmetarig.controller"); EmotePatch.others = EmotePatch.animatorBundle.LoadAsset<RuntimeAnimatorController>("Assets/MoreEmotes/NEWmetarigOtherPlayers.controller"); CustomAudioAnimationEvent.claps[0] = EmotePatch.animationsBundle.LoadAsset<AudioClip>("Assets/MoreEmotes/SingleClapEmote1.wav"); CustomAudioAnimationEvent.claps[1] = EmotePatch.animationsBundle.LoadAsset<AudioClip>("Assets/MoreEmotes/SingleClapEmote2.wav"); ConfigFile(); IncompatibilityAids(); _harmony = new Harmony("MoreEmotes"); _harmony.PatchAll(typeof(EmotePatch)); } private void IncompatibilityAids() { foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { BepInPlugin metadata = pluginInfo.Value.Metadata; if (metadata.GUID.Equals("com.malco.lethalcompany.moreshipupgrades") || metadata.GUID.Equals("Stoneman.LethalProgression")) { EmotePatch.IncompatibleStuff = true; break; } } } private void ConfigFile() { config_KeyEmote3 = ((BaseUnityPlugin)this).Config.Bind<string>("MIDDLEFINGER", "EmoteKey", "3", "SUPPORTED KEYS A-Z | 0-9 | F1-F12 "); config_toggleEmote3 = ((BaseUnityPlugin)this).Config.Bind<bool>("MIDDLEFINGER", "Enable", true, "ENABLE MIDDLEFINGER EMOTE KEY"); EmotePatch.keyBind_Emote3 = config_KeyEmote3.Value; EmotePatch.enable3 = config_toggleEmote3.Value; config_KeyEmote4 = ((BaseUnityPlugin)this).Config.Bind<string>("THE GRIDDY", "EmoteKey", "6", "SUPPORTED KEYS A-Z | 0-9 | F1-F12 "); config_toggleEmote4 = ((BaseUnityPlugin)this).Config.Bind<bool>("THE GRIDDY", "Enable", true, "ENABLE THE GRIDDY EMOTE KEY"); EmotePatch.keyBind_Emote4 = config_KeyEmote4.Value; EmotePatch.enable4 = config_toggleEmote4.Value; config_KeyEmote5 = ((BaseUnityPlugin)this).Config.Bind<string>("SHY", "EmoteKey", "5", "SUPPORTED KEYS A-Z | 0-9 | F1-F12 "); config_toggleEmote5 = ((BaseUnityPlugin)this).Config.Bind<bool>("SHY", "Enable", true, "ENABLE SHY EMOTE KEY"); EmotePatch.keyBind_Emote5 = config_KeyEmote5.Value; EmotePatch.enable5 = config_toggleEmote5.Value; config_KeyEmote6 = ((BaseUnityPlugin)this).Config.Bind<string>("CLAP", "EmoteKey", "4", "SUPPORTED KEYS A-Z | 0-9 | F1-F12 "); config_toggleEmote6 = ((BaseUnityPlugin)this).Config.Bind<bool>("CLAP", "Enable", true, "ENABLE CLAP EMOTE KEY"); EmotePatch.keyBind_Emote6 = config_KeyEmote6.Value; EmotePatch.enable6 = config_toggleEmote6.Value; } } public static class PluginInfo { public const string Guid = "MoreEmotes"; public const string Name = "MoreEmotes-Sligili"; public const string Ver = "1.1.3"; } } namespace MoreEmotes.Patch { internal class EmotePatch { public static AssetBundle animationsBundle; public static AssetBundle animatorBundle; public static bool enable3; public static bool enable4; public static bool enable5; public static bool enable6; public static string keyBind_Emote3; public static string keyBind_Emote4; public static string keyBind_Emote5; public static string keyBind_Emote6; private static CallbackContext context; public static RuntimeAnimatorController local; public static RuntimeAnimatorController others; private static int currentEmoteID; private static float svMovSpeed; public static bool IncompatibleStuff; [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPostfix] private static void StartPostfix(PlayerControllerB __instance) { GameObject gameObject = ((Component)((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel")).transform.Find("metarig")).gameObject; CustomAudioAnimationEvent customAudioAnimationEvent = gameObject.AddComponent<CustomAudioAnimationEvent>(); svMovSpeed = __instance.movementSpeed; customAudioAnimationEvent.player = __instance; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void UpdatePostfix(PlayerControllerB __instance) { if (!__instance.isPlayerControlled || !((NetworkBehaviour)__instance).IsOwner) { __instance.playerBodyAnimator.runtimeAnimatorController = others; return; } if ((Object)(object)__instance.playerBodyAnimator != (Object)(object)local) { __instance.playerBodyAnimator.runtimeAnimatorController = local; } currentEmoteID = __instance.playerBodyAnimator.GetInteger("emoteNumber"); if (!IncompatibleStuff) { bool flag = (bool)Reflection.CallMethod(__instance, "CheckConditionsForEmote") && currentEmoteID == 4 && __instance.performingEmote; __instance.movementSpeed = (flag ? (svMovSpeed / 2f) : svMovSpeed); } CheckEmoteInput(keyBind_Emote3, enable3, needsEmptyHands: false, 3, __instance); CheckEmoteInput(keyBind_Emote4, enable4, needsEmptyHands: false, 4, __instance); CheckEmoteInput(keyBind_Emote5, enable5, needsEmptyHands: true, 5, __instance); CheckEmoteInput(keyBind_Emote6, enable6, needsEmptyHands: true, 6, __instance); } private static void CheckEmoteInput(string keyBind, bool enabled, bool needsEmptyHands, int emoteID, PlayerControllerB player) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[keyBind], 0f) && enabled && (!player.isHoldingObject || !needsEmptyHands) && (!player.performingEmote || currentEmoteID != emoteID)) { player.PerformEmote(context, emoteID); } } [HarmonyPatch(typeof(PlayerControllerB), "CheckConditionsForEmote")] [HarmonyPrefix] private static bool prefixCheckConditions(ref bool __result, PlayerControllerB __instance) { bool flag = (bool)Reflection.GetInstanceField(typeof(PlayerControllerB), __instance, "isJumping"); if (currentEmoteID == 4) { __result = !__instance.inSpecialInteractAnimation && !__instance.isPlayerDead && !flag && __instance.moveInputVector.x == 0f && !__instance.isSprinting && !__instance.isCrouching && !__instance.isClimbingLadder && !__instance.isGrabbingObjectAnimation && !__instance.inTerminalMenu && !__instance.isTypingChat; return false; } return true; } [HarmonyPatch(typeof(PlayerControllerB), "PerformEmote")] [HarmonyPrefix] private static void PerformEmotePrefix(CallbackContext context, int emoteID, PlayerControllerB __instance) { if ((emoteID >= 3 || ((CallbackContext)(ref context)).performed) && ((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer) && (bool)Reflection.CallMethod(__instance, "CheckConditionsForEmote") && !(__instance.timeSinceStartingEmote < 0.5f)) { __instance.timeSinceStartingEmote = 0f; __instance.performingEmote = true; __instance.playerBodyAnimator.SetInteger("emoteNumber", emoteID); __instance.StartPerformingEmoteServerRpc(); } } } public class CustomAudioAnimationEvent : MonoBehaviour { private Animator animator; private AudioSource SoundsSource; public static AudioClip[] claps = (AudioClip[])(object)new AudioClip[2]; public PlayerControllerB player; private void Start() { animator = ((Component)this).GetComponent<Animator>(); SoundsSource = player.movementAudio; } public void PlayClapSound() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (player.performingEmote && (!((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || animator.GetInteger("emoteNumber") == 6)) { bool flag = player.isInHangarShipRoom && player.playersManager.hangarDoorsClosed; RoundManager.Instance.PlayAudibleNoise(((Component)player).transform.position, 22f, 0.6f, 0, flag, 6); SoundsSource.pitch = Random.Range(0.59f, 0.79f); SoundsSource.PlayOneShot(claps[Random.Range(0, claps.Length)]); } } public void PlayFootstepSound() { if (player.performingEmote && (!((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || animator.GetInteger("emoteNumber") == 4) && ((Vector2)(ref player.moveInputVector)).sqrMagnitude == 0f) { player.PlayFootstepLocal(); player.PlayFootstepServer(); } } } }
plugins/Suskitech-AlwaysHearActiveWalkies/AlwaysHearWalkie.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LCAlwaysHearWalkieMod.Patches; using Microsoft.CodeAnalysis; 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("AlwaysHearWalkie")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.4.2.0")] [assembly: AssemblyInformationalVersion("1.4.2+4173bc4d88b293dfbed3e97cfc3a082065ce4da9")] [assembly: AssemblyProduct("Always Hear Active Walkies")] [assembly: AssemblyTitle("AlwaysHearWalkie")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.2.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 BepInEx5.PluginTemplate { [BepInPlugin("suskitech.LCAlwaysHearActiveWalkie", "LC Always Hear Active Walkies", "1.4.2")] public class LCAlwaysHearWalkieMod : BaseUnityPlugin { public static ManualLogSource Log; private const string modGUID = "suskitech.LCAlwaysHearActiveWalkie"; private const string modName = "LC Always Hear Active Walkies"; private const string modVersion = "1.4.2"; private readonly Harmony harmony = new Harmony("suskitech.LCAlwaysHearActiveWalkie"); private static LCAlwaysHearWalkieMod Instance; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Log = Logger.CreateLogSource("suskitech.LCAlwaysHearActiveWalkie"); Log.LogInfo((object)"\\ /"); Log.LogInfo((object)"/|\\"); Log.LogInfo((object)" |----|"); Log.LogInfo((object)" |[__]| Always Hear Active Walkies"); Log.LogInfo((object)" |. .| Version 1.4.2 Loaded"); Log.LogInfo((object)" |____|"); harmony.PatchAll(typeof(LCAlwaysHearWalkieMod)); harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(WalkieTalkiePatch)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "AlwaysHearWalkie"; public const string PLUGIN_NAME = "Always Hear Active Walkies"; public const string PLUGIN_VERSION = "1.4.2"; } } namespace LCAlwaysHearWalkieMod.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { private static float AudibleDistance = 20f; private static float throttleInterval = 0.4f; private static float throttle = 0f; private static float AverageDistanceToHeldWalkie = 2f; private static float WalkieRecordingRange = 20f; private static float PlayerToPlayerSpatialHearingRange = 20f; [HarmonyPatch("Update")] [HarmonyPostfix] private static void alwaysHearWalkieTalkiesPatch(ref bool ___holdingWalkieTalkie, ref PlayerControllerB __instance) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) throttle += Time.deltaTime; if (throttle < throttleInterval) { return; } throttle = 0f; if ((Object)(object)__instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || GameNetworkManager.Instance.localPlayerController.isPlayerDead) { return; } List<WalkieTalkie> list = new List<WalkieTalkie>(); List<WalkieTalkie> list2 = new List<WalkieTalkie>(); for (int i = 0; i < WalkieTalkie.allWalkieTalkies.Count; i++) { float num = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[i]).transform.position, ((Component)__instance).transform.position); if (num <= AudibleDistance) { if (((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).isBeingUsed) { list.Add(WalkieTalkie.allWalkieTalkies[i]); } } else { list2.Add(WalkieTalkie.allWalkieTalkies[i]); } } bool flag = list.Count > 0; if (flag != __instance.holdingWalkieTalkie) { ___holdingWalkieTalkie = flag; for (int j = 0; j < list2.Count; j++) { if (j < list.Count) { list2[j].thisAudio.Stop(); } } } if (!flag) { return; } PlayerControllerB val = ((!GameNetworkManager.Instance.localPlayerController.isPlayerDead || !((Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)) ? GameNetworkManager.Instance.localPlayerController : GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript); for (int k = 0; k < StartOfRound.Instance.allPlayerScripts.Length; k++) { if ((!StartOfRound.Instance.allPlayerScripts[k].isPlayerControlled && !StartOfRound.Instance.allPlayerScripts[k].isPlayerDead) || (Object)(object)StartOfRound.Instance.allPlayerScripts[k] == (Object)(object)GameNetworkManager.Instance.localPlayerController || StartOfRound.Instance.allPlayerScripts[k].isPlayerDead) { continue; } PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[k]; if (!val2.holdingWalkieTalkie) { continue; } float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)val2).transform.position); float num3 = float.MaxValue; float num4 = float.MaxValue; for (int l = 0; l < WalkieTalkie.allWalkieTalkies.Count; l++) { if (!((GrabbableObject)WalkieTalkie.allWalkieTalkies[l]).isBeingUsed) { continue; } float num5 = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[l].target).transform.position, ((Component)val).transform.position); if (num5 < num4) { num4 = num5; } if (!WalkieTalkie.allWalkieTalkies[l].speakingIntoWalkieTalkie) { float num6 = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[l]).transform.position, ((Component)val2).transform.position); if (num6 < num3) { num3 = num6; } } } float num7 = Mathf.Min(1f - Mathf.InverseLerp(AverageDistanceToHeldWalkie, WalkieRecordingRange, num3), 1f - Mathf.InverseLerp(AverageDistanceToHeldWalkie, WalkieRecordingRange, num4)); float num8 = 1f - Mathf.InverseLerp(0f, PlayerToPlayerSpatialHearingRange, num2); val2.voicePlayerState.Volume = Mathf.Max(num7, num8); } } } [HarmonyPatch(typeof(WalkieTalkie))] internal class WalkieTalkiePatch { [HarmonyPatch("EnableWalkieTalkieListening")] [HarmonyPrefix] private static bool alwaysHearWalkieTalkiesEnableWalkieTalkieListeningPatch(bool enable) { if (!enable) { return false; } return true; } } }
plugins/Sv_Matt-HideModList/HideModList.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; [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("HideModList")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Hides the LC api modlist info")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HideModList")] [assembly: AssemblyTitle("HideModList")] [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 HideModList { [HarmonyPatch(typeof(HUDManager), "DisplayTip")] public static class DisplayTipPatch { public static bool Prefix(HUDManager __instance, string headerText, string bodyText, bool isWarning = false, bool useSave = false, string prefsKey = "LC_Tip1") { if (headerText.StartsWith("Mod List")) { return false; } return true; } } [BepInPlugin("HideModList", "HideModList", "1.0.0")] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("plugin.HideModList"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin HideModList is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "HideModList"; public const string PLUGIN_NAME = "HideModList"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/tinyhoot-ShipLobby/ShipLobby/ShipLobby.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ShipLobby")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("ShipLobby")] [assembly: AssemblyCopyright("Copyright © tinyhoot 2023")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0.2")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] namespace ShipLobby { [BepInPlugin("com.github.tinyhoot.ShipLobby", "ShipLobby", "1.0.2")] internal class ShipLobby : BaseUnityPlugin { public const string GUID = "com.github.tinyhoot.ShipLobby"; public const string NAME = "ShipLobby"; public const string VERSION = "1.0.2"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.github.tinyhoot.ShipLobby").PatchAll(Assembly.GetExecutingAssembly()); } } } namespace ShipLobby.Patches { [HarmonyPatch] internal class GameNetworkManagerPatcher { private static QuickMenuManager _quickMenuManager; [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "Singleton_OnClientConnectedCallback")] private static void LogConnect() { ShipLobby.Log.LogDebug((object)"Player connected."); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "Singleton_OnClientDisconnectCallback")] private static void LogDisconnect() { ShipLobby.Log.LogDebug((object)"Player disconnected."); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")] private static void FixConnectionApproval(GameNetworkManager __instance, ConnectionApprovalResponse response) { if (!response.Approved && !(response.Reason != "Game has already started!") && __instance.gameHasStarted && StartOfRound.Instance.inShipPhase) { ShipLobby.Log.LogDebug((object)"Approving incoming late connection."); response.Reason = ""; response.Approved = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(QuickMenuManager), "InviteFriendsButton")] private static void FixFriendInviteButton() { if (GameNetworkManager.Instance.gameHasStarted && StartOfRound.Instance.inShipPhase) { GameNetworkManager.Instance.InviteFriendsUI(); } } [HarmonyPrefix] [HarmonyPatch(typeof(GameNetworkManager), "LeaveLobbyAtGameStart")] private static bool PreventSteamLobbyLeaving(GameNetworkManager __instance) { ShipLobby.Log.LogDebug((object)"Preventing the closing of Steam lobby."); return false; } [HarmonyPrefix] [HarmonyPatch(typeof(StartOfRound), "StartGame")] private static void CloseSteamLobby(StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsServer && __instance.inShipPhase) { ShipLobby.Log.LogDebug((object)"Setting lobby to not joinable."); GameNetworkManager.Instance.SetLobbyJoinable(false); } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "EndOfGame")] private static IEnumerator ReopenSteamLobby(IEnumerator coroutine, StartOfRound __instance) { while (coroutine.MoveNext()) { yield return coroutine.Current; } if (!((NetworkBehaviour)__instance).IsServer) { yield break; } yield return (object)new WaitForSeconds(0.5f); yield return (object)new WaitUntil((Func<bool>)(() => !__instance.firingPlayersCutsceneRunning)); ShipLobby.Log.LogDebug((object)"Reopening lobby, setting to joinable."); GameNetworkManager instance = GameNetworkManager.Instance; if (instance.currentLobby.HasValue) { instance.SetLobbyJoinable(true); if ((Object)(object)_quickMenuManager == (Object)null) { _quickMenuManager = Object.FindObjectOfType<QuickMenuManager>(); } _quickMenuManager.inviteFriendsTextAlpha.alpha = 1f; } } } }
plugins/wallen-ChangeName/ChangeName.dll.old
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LC_API.ServerAPI; using TMPro; 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("ChangeName")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Change in-game name")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9ad07e918fa6011a98cef2e1281a0a7577b70a07")] [assembly: AssemblyProduct("ChangeName")] [assembly: AssemblyTitle("ChangeName")] [assembly: AssemblyVersion("1.0.0.0")] namespace ChangeName { [BepInPlugin("me.wallen.changename", "Change Player Names", "1.0.0")] public class ChangeNamePlugin : BaseUnityPlugin { private const string GUID = "me.wallen.changename"; private const string NAME = "Change Player Names"; private const string VERSION = "1.0.0"; private static ChangeNamePlugin Instance; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown Instance = this; LogInfo("Loading..."); Harmony val = new Harmony("me.wallen.changename"); val.PatchAll(); Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, new Action<string, string>(NameDatabase.NDNetGetString)); LogInfo("Loading Complete!"); } internal static void LogDebug(string message) { Instance.Log(message, (LogLevel)32); } internal static void LogInfo(string message) { Instance.Log(message, (LogLevel)16); } internal static void LogWarning(string message) { Instance.Log(message, (LogLevel)4); } internal static void LogError(string message) { Instance.Log(message, (LogLevel)2); } internal static void LogError(Exception ex) { Instance.Log(ex.Message + "\n" + ex.StackTrace, (LogLevel)2); } private void Log(string message, LogLevel logLevel) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.Log(logLevel, (object)message); } } internal static class NameDatabase { internal static bool shouldUpdateNames = false; internal static bool shouldSendNames = false; public const string SIG_BEGIN_UPDATE_NAMES = "CHANGE_NAME_BEGIN_UPDATE_NAMES"; public const string SIG_UPDATE_NAME = "CHANGE_NAME_UPDATE_NAME"; public const string SIG_END_UPDATE_NAMES = "CHANGE_NAME_END_UPDATE_NAMES"; public const string SIG_PLAYER_JOIN = "CHANGE_NAME_PLAYER_JOIN"; public const string SIG_NEW_LEVEL = "CHANGE_NAME_NEW_LEVEL"; private const string SIG_NEW_ROUND = "CHANGE_NAME_NEW_ROUND"; private static Dictionary<ulong, string> names = new Dictionary<ulong, string>(); internal static string GetName(ulong id) { if (!names.ContainsKey(id)) { ChangeNamePlugin.LogWarning("[NameDatabase.GetName] Failed to get name"); return ""; } return names[id]; } internal static void SetName(ulong id, string name) { if (!names.ContainsKey(id)) { names.Add(id, name); } else { names[id] = name; } } internal static bool HasName(string name) { return names.ContainsValue(name); } internal static bool HasId(ulong id) { return names.ContainsKey(id); } internal static ulong GetUsableIdFromPlayer(PlayerControllerB player) { if (!GameNetworkManager.Instance.disableSteam) { return player.playerSteamId; } return player.playerClientId; } internal static void UpdateName(string oldName, string newName) { if (!names.ContainsValue(oldName)) { ChangeNamePlugin.LogWarning("[NameDatabase.UpdateName] Tried to update name " + oldName + " but it does not exist"); ChangeNamePlugin.LogWarning(names.ToString()); } else { ulong key = names.FirstOrDefault((KeyValuePair<ulong, string> x) => x.Value == oldName).Key; names[key] = newName; } shouldUpdateNames = true; } internal static int NumberOfNames() { return names.Count; } internal static void NDNetGetString(string data, string signature) { switch (signature) { case "CHANGE_NAME_PLAYER_JOIN": case "CHANGE_NAME_NEW_ROUND": if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { shouldSendNames = true; } break; case "CHANGE_NAME_BEGIN_UPDATE_NAMES": ChangeNamePlugin.LogInfo("[NameDatabase] Beginning name update process."); break; case "CHANGE_NAME_UPDATE_NAME": { KeyValuePair<ulong, string>? keyValuePair = DecodeName(data); if (keyValuePair.HasValue) { KeyValuePair<ulong, string> value = keyValuePair.Value; ChangeNamePlugin.LogInfo("[NameDatabase] New name received: " + value.Key + " : " + value.Value); names[value.Key] = value.Value; } break; } case "CHANGE_NAME_END_UPDATE_NAMES": ChangeNamePlugin.LogInfo("[NameDatabase] End of name update process."); shouldUpdateNames = true; break; } } internal static void NDNetSendNames() { Networking.Broadcast(string.Empty, "CHANGE_NAME_BEGIN_UPDATE_NAMES"); foreach (KeyValuePair<ulong, string> name in names) { string text = EncodeName(name); Networking.Broadcast(text, "CHANGE_NAME_UPDATE_NAME"); } Networking.Broadcast(string.Empty, "CHANGE_NAME_END_UPDATE_NAMES"); } private static string EncodeName(KeyValuePair<ulong, string> namePair) { return $"{namePair.Key}:{namePair.Value}"; } private static KeyValuePair<ulong, string>? DecodeName(string encoded) { string[] array = encoded.Split(':'); if (array.Length == 2 && ulong.TryParse(array[0], out var result)) { return new KeyValuePair<ulong, string>(result, array[1]); } return null; } private static string EncodeNames(Dictionary<ulong, string> names) { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair<ulong, string> name in names) { stringBuilder.Append($"{name.Key}:{name.Value};"); } return stringBuilder.ToString(); } private static Dictionary<ulong, string> DecodeNames(string encoded) { string[] array = encoded.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); Dictionary<ulong, string> dictionary = new Dictionary<ulong, string>(); string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(':'); dictionary[ulong.Parse(array3[0])] = array3[1]; } return dictionary; } private static string DictionaryToString(Dictionary<ulong, string> dictionary) { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair<ulong, string> item in dictionary) { stringBuilder.AppendLine($"Key: {item.Key}, Value: {item.Value}"); } return stringBuilder.ToString(); } } } namespace ChangeName.Patches { [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] internal class HUDManager_AddChatMessage { private static string lastChatMessage = ""; private static void Postfix(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped) { if (lastChatMessage == chatMessage) { return; } lastChatMessage = chatMessage; ChangeNamePlugin.LogDebug(chatMessage); if (chatMessage.Contains("!name")) { string text = chatMessage.Substring(chatMessage.IndexOf("!name") + "!name".Length).Trim(); if (NameDatabase.HasName(text)) { __instance.AddTextToChatOnServer("Duplicate names are not allowed!", -1); } else if (((NetworkBehaviour)__instance.playersManager).IsHost) { NameDatabase.UpdateName(nameOfUserWhoTyped, text); NameDatabase.shouldSendNames = true; NameDatabase.shouldUpdateNames = true; } } } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] internal class PlayerControllerB_ConnectClientToPlayerObject { private static void Postfix(PlayerControllerB __instance) { ChangeNamePlugin.LogDebug("Steam Disabled: " + GameNetworkManager.Instance.disableSteam); ChangeNamePlugin.LogDebug("Is Host: " + ((NetworkBehaviour)__instance).IsHost); ChangeNamePlugin.LogDebug("Player steam ID: " + __instance.playerSteamId); ChangeNamePlugin.LogDebug("Player client ID: " + __instance.playerClientId); ChangeNamePlugin.LogDebug("Actual client ID: " + __instance.actualClientId); ChangeNamePlugin.LogDebug("Player Username: " + __instance.playerUsername); Networking.Broadcast("", "CHANGE_NAME_PLAYER_JOIN"); } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] internal class PlayerControllerB_Update { private static float lastUpdateTime; private static void Postfix(PlayerControllerB __instance) { if (!(lastUpdateTime + 2f < Time.time)) { return; } if (((NetworkBehaviour)__instance).IsHost) { PlayerControllerB[] allPlayerScripts = __instance.playersManager.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!NameDatabase.HasId(NameDatabase.GetUsableIdFromPlayer(val))) { NameDatabase.SetName(NameDatabase.GetUsableIdFromPlayer(val), val.playerUsername); } } if (NameDatabase.shouldSendNames) { NameDatabase.NDNetSendNames(); NameDatabase.shouldSendNames = false; } } if (NameDatabase.shouldUpdateNames) { PlayerControllerB[] allPlayerScripts2 = __instance.playersManager.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts2) { string name = NameDatabase.GetName(NameDatabase.GetUsableIdFromPlayer(val2)); foreach (TransformAndName radarTarget in StartOfRound.Instance.mapScreen.radarTargets) { Transform transform = radarTarget.transform; if (radarTarget.name == val2.playerUsername) { StartOfRound.Instance.mapScreen.ChangeNameOfTargetTransform(transform, name); } } val2.playerUsername = name; ((TMP_Text)val2.usernameBillboardText).text = name; } NameDatabase.shouldUpdateNames = false; } lastUpdateTime = Time.time; } } [HarmonyPatch(typeof(StartOfRound), "ArriveAtLevel")] internal class StartOfRound_ArriveAtLevel { private static void Postfix(StartOfRound __instance) { } } }
plugins/x753-More_Suits/MoreSuits.dll
Decompiled 2 years agousing System; using System.Collections.Generic; 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 HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("MoreSuits")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A mod that adds more suit options to Lethal Company")] [assembly: AssemblyFileVersion("1.3.3.0")] [assembly: AssemblyInformationalVersion("1.3.3")] [assembly: AssemblyProduct("MoreSuits")] [assembly: AssemblyTitle("MoreSuits")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.3.0")] [module: UnverifiableCode] namespace MoreSuits; [BepInPlugin("x753.More_Suits", "More Suits", "1.3.3")] public class MoreSuitsMod : BaseUnityPlugin { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPatch(ref StartOfRound __instance) { //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_03dd: Unknown result type (might be due to invalid IL or missing references) try { if (SuitsAdded) { return; } for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++) { UnlockableItem val = __instance.unlockablesList.unlockables[i]; if (!((Object)(object)val.suitMaterial != (Object)null) || !val.alreadyUnlocked) { continue; } List<string> list = Directory.GetDirectories(Paths.PluginPath, "moresuits", SearchOption.AllDirectories).ToList(); List<string> list2 = new List<string>(); List<string> list3 = DisabledSuits.Value.ToLower().Replace(".png", "").Split(',') .ToList(); List<string> list4 = new List<string>(); if (!LoadAllSuits.Value) { foreach (string item in list) { if (File.Exists(Path.Combine(item, "!less-suits.txt"))) { string[] collection = new string[9] { "glow", "kirby", "knuckles", "luigi", "mario", "minion", "skeleton", "slayer", "smile" }; list4.AddRange(collection); break; } } } foreach (string item2 in list) { if (item2 != "") { string[] files = Directory.GetFiles(item2, "*.png"); list2.AddRange(files); } } list2.Sort(); foreach (string item3 in list2) { if (list3.Contains(Path.GetFileNameWithoutExtension(item3).ToLower())) { continue; } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (list4.Contains(Path.GetFileNameWithoutExtension(item3).ToLower()) && item3.Contains(directoryName)) { continue; } UnlockableItem val2; Material val3; if (Path.GetFileNameWithoutExtension(item3).ToLower() == "default") { val2 = val; val3 = val2.suitMaterial; } else { val2 = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val)); val3 = Object.Instantiate<Material>(val2.suitMaterial); } byte[] array = File.ReadAllBytes(item3); Texture2D val4 = new Texture2D(2, 2); ImageConversion.LoadImage(val4, array); val3.mainTexture = (Texture)(object)val4; val2.unlockableName = Path.GetFileNameWithoutExtension(item3); try { string path = Path.Combine(Path.GetDirectoryName(item3), "advanced", val2.unlockableName + ".json"); if (File.Exists(path)) { string[] array2 = File.ReadAllLines(path); for (int j = 0; j < array2.Length; j++) { string[] array3 = array2[j].Trim().Split(':'); if (array3.Length != 2) { continue; } string text = array3[0].Trim('"', ' ', ','); string text2 = array3[1].Trim('"', ' ', ','); float result2; Vector4 vector; if (text == "PRICE" && int.TryParse(text2, out var result)) { try { AddToRotatingShop(val2, result, __instance.unlockablesList.unlockables.Count); } catch (Exception ex) { Debug.Log((object)("Something went wrong with More Suits! Could not add a suit to the rotating shop. Error: " + ex)); } } else if (text2 == "KEYWORD") { val3.EnableKeyword(text); } else if (text2.Contains(".png")) { byte[] array4 = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(item3), "advanced", text2)); Texture2D val5 = new Texture2D(2, 2); ImageConversion.LoadImage(val5, array4); val3.SetTexture(text, (Texture)(object)val5); } else if (float.TryParse(text2, out result2)) { val3.SetFloat(text, result2); } else if (TryParseVector4(text2, out vector)) { val3.SetVector(text, vector); } } } } catch (Exception ex2) { Debug.Log((object)("Something went wrong with More Suits! Error: " + ex2)); } val2.suitMaterial = val3; if (val2.unlockableName.ToLower() != "default") { __instance.unlockablesList.unlockables.Add(val2); } } SuitsAdded = true; break; } } catch (Exception ex3) { Debug.Log((object)("Something went wrong with More Suits! Error: " + ex3)); } } [HarmonyPatch("PositionSuitsOnRack")] [HarmonyPrefix] private static bool PositionSuitsOnRackPatch(ref StartOfRound __instance) { //IL_0065: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) List<UnlockableSuit> list = (from suit in Object.FindObjectsOfType<UnlockableSuit>().ToList() orderby suit.syncedSuitID.Value select suit).ToList(); int num = 0; foreach (UnlockableSuit item in list) { AutoParentToShip component = ((Component)item).gameObject.GetComponent<AutoParentToShip>(); component.overrideOffset = true; component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + __instance.rightmostSuitPosition.forward * 0.18f * (float)num; component.rotationOffset = new Vector3(0f, 90f, 0f); num++; } return false; } } private const string modGUID = "x753.More_Suits"; private const string modName = "More Suits"; private const string modVersion = "1.3.3"; private readonly Harmony harmony = new Harmony("x753.More_Suits"); private static MoreSuitsMod Instance; public static bool SuitsAdded; public static ConfigEntry<string> DisabledSuits; public static ConfigEntry<bool> LoadAllSuits; private static TerminalNode cancelPurchase; private static TerminalKeyword buyKeyword; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } DisabledSuits = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Disabled Suit List", "UglySuit751.png,UglySuit752.png,UglySuit753.png", "Comma-separated list of suits that shouldn't be loaded"); LoadAllSuits = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Ignore !less-suits.txt", false, "If true, ignores the !less-suits.txt file and will attempt to load every suit, except those in the disabled list. This should be true if you're not worried about having too many suits."); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin More Suits is loaded!"); } private static void AddToRotatingShop(UnlockableItem newSuit, int price, int unlockableID) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown Terminal val = Object.FindObjectOfType<Terminal>(); for (int i = 0; i < val.terminalNodes.allKeywords.Length; i++) { if (((Object)val.terminalNodes.allKeywords[i]).name == "Buy") { buyKeyword = val.terminalNodes.allKeywords[i]; break; } } newSuit.alreadyUnlocked = false; newSuit.shopSelectionNode = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)newSuit.shopSelectionNode).name = newSuit.unlockableName + "SuitBuy1"; newSuit.shopSelectionNode.creatureName = newSuit.unlockableName + " suit"; newSuit.shopSelectionNode.displayText = "You have requested to order " + newSuit.unlockableName + " suits.\nTotal cost of item: [totalCost].\n\nPlease CONFIRM or DENY.\n\n"; newSuit.shopSelectionNode.clearPreviousText = true; newSuit.shopSelectionNode.shipUnlockableID = unlockableID; newSuit.shopSelectionNode.itemCost = price; newSuit.shopSelectionNode.overrideOptions = true; CompatibleNoun val2 = new CompatibleNoun(); val2.noun = ScriptableObject.CreateInstance<TerminalKeyword>(); val2.noun.word = "confirm"; val2.noun.isVerb = true; val2.result = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val2.result).name = newSuit.unlockableName + "SuitBuyConfirm"; val2.result.creatureName = ""; val2.result.displayText = "Ordered " + newSuit.unlockableName + " suits! Your new balance is [playerCredits].\n\n"; val2.result.clearPreviousText = true; val2.result.shipUnlockableID = unlockableID; val2.result.buyUnlockable = true; val2.result.itemCost = price; val2.result.terminalEvent = ""; CompatibleNoun val3 = new CompatibleNoun(); val3.noun = ScriptableObject.CreateInstance<TerminalKeyword>(); val3.noun.word = "deny"; val3.noun.isVerb = true; if ((Object)(object)cancelPurchase == (Object)null) { cancelPurchase = ScriptableObject.CreateInstance<TerminalNode>(); } val3.result = cancelPurchase; ((Object)val3.result).name = "MoreSuitsCancelPurchase"; val3.result.displayText = "Cancelled order.\n"; newSuit.shopSelectionNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { val2, val3 }; TerminalKeyword val4 = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val4).name = newSuit.unlockableName + "Suit"; val4.word = newSuit.unlockableName.ToLower() + " suit"; val4.defaultVerb = buyKeyword; CompatibleNoun val5 = new CompatibleNoun(); val5.noun = val4; val5.result = newSuit.shopSelectionNode; List<CompatibleNoun> list = buyKeyword.compatibleNouns.ToList(); list.Add(val5); buyKeyword.compatibleNouns = list.ToArray(); List<TerminalKeyword> list2 = val.terminalNodes.allKeywords.ToList(); list2.Add(val4); list2.Add(val2.noun); list2.Add(val3.noun); val.terminalNodes.allKeywords = list2.ToArray(); } public static bool TryParseVector4(string input, out Vector4 vector) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) vector = Vector4.zero; string[] array = input.Split(','); if (array.Length == 4 && float.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2) && float.TryParse(array[2], out var result3) && float.TryParse(array[3], out var result4)) { vector = new Vector4(result, result2, result3, result4); return true; } return false; } }
plugins/Zduniusz-24HourClock/24HourClock.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] [assembly: AssemblyCompany("_24HourClock")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("My first plugin")] [assembly: AssemblyTitle("_24HourClock")] [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 _24HourClock { [BepInPlugin("com.zduniusz.lethalcompany.24hourclock", "24HourClock", "1.0.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch] private class Patch { [HarmonyPatch(typeof(HUDManager), "SetClock")] [HarmonyPrefix] private static bool SetClock(ref TextMeshProUGUI ___clockNumber, ref float timeNormalized, ref float numberOfHours) { int num = (int)(timeNormalized * (60f * numberOfHours)) + 360; int num2 = (int)Mathf.Floor((float)(num / 60)); int num3 = num % 60; ((TMP_Text)___clockNumber).text = $"{num2:00}:{num3:00}".TrimStart(new char[1] { '0' }); return false; } } private const string PLUGIN_GUID = "com.zduniusz.lethalcompany.24hourclock"; private const string PLUGIN_NAME = "24HourClock"; private const string PLUGIN_VERSION = "1.0.0"; private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("com.zduniusz.lethalcompany.24hourclock").PatchAll(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "_24HourClock"; public const string PLUGIN_NAME = "My first plugin"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/Zduniusz-LBtoKG/lbtokg.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; 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(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("lbtokg")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("My first plugin")] [assembly: AssemblyTitle("lbtokg")] [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 lbtokg { [BepInPlugin("com.zduniusz.lethalcompany.lbtokg", "LbToKg", "1.0.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch] private class Patch { [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] private static void SetClock(ref TextMeshProUGUI ___weightCounter, ref Animator ___weightCounterAnimator) { float num = Mathf.RoundToInt(Mathf.Clamp((GameNetworkManager.Instance.localPlayerController.carryWeight - 1f) * 0.4535f, 0f, 100f) * 105f); float num2 = Mathf.RoundToInt(Mathf.Clamp(GameNetworkManager.Instance.localPlayerController.carryWeight - 1f, 0f, 100f) * 105f); ((TMP_Text)___weightCounter).text = $"{num} kg"; ___weightCounterAnimator.SetFloat("weight", num2 / 130f); } } private const string PLUGIN_GUID = "com.zduniusz.lethalcompany.lbtokg"; private const string PLUGIN_NAME = "LbToKg"; private const string PLUGIN_VERSION = "1.0.0"; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) new Harmony("com.zduniusz.lethalcompany.lbtokg").PatchAll(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "lbtokg"; public const string PLUGIN_NAME = "My first plugin"; public const string PLUGIN_VERSION = "1.0.0"; } }