Please disclose if your mod was created primarily 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 Invincible Player v1.0.0
Invincible.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Invincible.Patches; using Microsoft.CodeAnalysis; using Unity.Collections; 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("Invincible")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A template for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Invincible")] [assembly: AssemblyTitle("Invincible")] [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 Invincible { [Serializable] public class Config : SyncedInstance<Config> { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequestSync; public static HandleNamedMessageDelegate <1>__OnReceiveSync; } public static ConfigEntry<bool> configMaskedKillDuplication; public bool MaskedDup; public static ConfigEntry<bool> configJesterKillAnim; public bool JesterKill; public static ConfigEntry<bool> configBaboonBirdKillAnim; public bool BBirdKill; public static ConfigEntry<bool> configBrackenKillAnim; public bool BrackenKill; public static ConfigEntry<bool> configFleaClingAnim; public bool FleaCling; public static ConfigEntry<bool> configGiantKillAnim; public bool GiantKill; public Config(ConfigFile cfg) { InitInstance(this); configMaskedKillDuplication = cfg.Bind<bool>("General", "Mask Animation & Duplication", false, "Masked will grab you (cant escape) & duplicate you after kill animation. (Default: false)"); configJesterKillAnim = cfg.Bind<bool>("General", "Jester Kill Animation", false, "Jester will still kill animation if it touches you. (Default: false)"); configBaboonBirdKillAnim = cfg.Bind<bool>("General", "Baboon Hawk Kill Animation", false, "Baboon Hawk will play kill animation if it touches you. (Default: false)"); configBrackenKillAnim = cfg.Bind<bool>("General", "Bracken Kill Animation", false, "Bracken will play kill animation if it touches you. (Default: false)"); configFleaClingAnim = cfg.Bind<bool>("General", "Snare Flea Cling Animation", false, "Snare Flea will play cling animation if it touches you. (Default: false)"); configGiantKillAnim = cfg.Bind<bool>("General", "Giant Kill Animation", false, "Giant will play kill animation if it touches you. (Default: false)"); } public static void BuildServerConfigSync() { SyncedInstance<Config>.Instance.MaskedDup = configMaskedKillDuplication.Value; SyncedInstance<Config>.Instance.JesterKill = configJesterKillAnim.Value; SyncedInstance<Config>.Instance.BBirdKill = configBaboonBirdKillAnim.Value; SyncedInstance<Config>.Instance.BrackenKill = configBrackenKillAnim.Value; SyncedInstance<Config>.Instance.FleaCling = configFleaClingAnim.Value; SyncedInstance<Config>.Instance.GiantKill = configGiantKillAnim.Value; SyncedInstance<Config>.setDefaultToInstance(); } public static void RequestSync() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!SyncedInstance<Config>.IsClient) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1); try { SyncedInstance<Config>.MessageManager.SendNamedMessage("Invincible_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public static void OnRequestSync(ulong clientId, FastBufferReader _) { //IL_0053: 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_0077: Unknown result type (might be due to invalid IL or missing references) if (!SyncedInstance<Config>.IsHost) { return; } SyncedInstance<Config>.mls2.LogInfo((object)$"Config sync request received from client: {clientId}"); byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance); int num = array.Length; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0); SyncedInstance<Config>.MessageManager.SendNamedMessage("Invincible_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3); } catch (Exception arg) { SyncedInstance<Config>.mls2.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}"); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public static void OnReceiveSync(ulong _, FastBufferReader reader) { //IL_002d: 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) if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize)) { SyncedInstance<Config>.mls2.LogError((object)"Config sync error: Could not begin reading buffer."); return; } int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (!((FastBufferReader)(ref reader)).TryBeginRead(num)) { SyncedInstance<Config>.mls2.LogError((object)"Config sync error: Host could not sync."); return; } byte[] data = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0); SyncedInstance<Config>.SyncInstance(data); SyncedInstance<Config>.mls2.LogInfo((object)"Successfully synced config with host."); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void InitializeLocalPlayer() { //IL_0066: 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_0071: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (SyncedInstance<Config>.IsHost) { BuildServerConfigSync(); CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager; object obj = <>O.<0>__OnRequestSync; if (obj == null) { HandleNamedMessageDelegate val = OnRequestSync; <>O.<0>__OnRequestSync = val; obj = (object)val; } messageManager.RegisterNamedMessageHandler("Invincible_OnRequestConfigSync", (HandleNamedMessageDelegate)obj); SyncedInstance<Config>.Synced = true; } else { SyncedInstance<Config>.Synced = false; CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager; object obj2 = <>O.<1>__OnReceiveSync; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnReceiveSync; <>O.<1>__OnReceiveSync = val2; obj2 = (object)val2; } messageManager2.RegisterNamedMessageHandler("Invincible_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2); RequestSync(); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")] public static void PlayerLeave() { SyncedInstance<Config>.RevertSync(); } } [BepInPlugin("MiffyL.Invincible", "Invincible", "1.0.0")] public class Plugin : BaseUnityPlugin { private const string modGUID = "MiffyL.Invincible"; private const string modName = "Invincible"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("MiffyL.Invincible"); public static Plugin Instance; internal ManualLogSource mls; public static Config MyConfig { get; internal set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MiffyL.Invincible is loaded!"); mls = Logger.CreateLogSource("MiffyL.Invincible"); harmony.PatchAll(typeof(Plugin)); harmony.PatchAll(typeof(Config)); harmony.PatchAll(typeof(StartOfRoundPatch)); harmony.PatchAll(typeof(KillAnimPatch)); MyConfig = new Config(((BaseUnityPlugin)this).Config); } } [Serializable] public class SyncedInstance<T> { public static ManualLogSource mls2 = Logger.CreateLogSource("MiffyL.Invincible"); [NonSerialized] protected static int IntSize = 4; internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager; internal static bool IsClient => NetworkManager.Singleton.IsClient; internal static bool IsHost => NetworkManager.Singleton.IsHost; public static T Default { get; private set; } public static T Instance { get; private set; } public static bool Synced { get; internal set; } protected void InitInstance(T instance) { Default = instance; Instance = instance; IntSize = 4; } internal static void SyncInstance(byte[] data) { Instance = DeserializeFromBytes(data); Synced = true; } internal static void RevertSync() { Instance = Default; Synced = false; } public static void setDefaultToInstance() { Default = Instance; } public static byte[] SerializeToBytes(T val) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream memoryStream = new MemoryStream(); try { binaryFormatter.Serialize(memoryStream, val); return memoryStream.ToArray(); } catch (Exception arg) { mls2.LogError((object)$"Error serializing instance: {arg}"); return null; } } public static T DeserializeFromBytes(byte[] data) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream serializationStream = new MemoryStream(data); try { return (T)binaryFormatter.Deserialize(serializationStream); } catch (Exception arg) { mls2.LogError((object)$"Error deserializing instance: {arg}"); return default(T); } } } public static class PluginInfo { public const string PLUGIN_GUID = "Invincible"; public const string PLUGIN_NAME = "Invincible"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Invincible.Patches { internal class KillAnimPatch { [HarmonyPatch(typeof(MaskedPlayerEnemy), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool MaskedKillAnimationPatch() { return SyncedInstance<Config>.Instance.MaskedDup; } [HarmonyPatch(typeof(JesterAI), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool JesterKillAnimationPatch() { return SyncedInstance<Config>.Instance.JesterKill; } [HarmonyPatch(typeof(BaboonBirdAI), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool BBirdKillAnimationPatch() { return SyncedInstance<Config>.Instance.BBirdKill; } [HarmonyPatch(typeof(FlowermanAI), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool BrackenKillAnimationPatch() { return SyncedInstance<Config>.Instance.BrackenKill; } [HarmonyPatch(typeof(CentipedeAI), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool FleaKillAnimationPatch() { return SyncedInstance<Config>.Instance.FleaCling; } [HarmonyPatch(typeof(ForestGiantAI), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool GiantKillAnimationPatch() { return SyncedInstance<Config>.Instance.GiantKill; } [HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(CrawlerAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(DressGirlAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(NutcrackerEnemyAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(SandWormAI), "OnCollideWithPlayer")] [HarmonyPatch(typeof(SpringManAI), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool GeneralOnCollidePatch() { return false; } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] public static void InvinciblePatch(ref bool ___allowLocalPlayerDeath) { ___allowLocalPlayerDeath = false; } } }