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 MaskedEnemyOverhaulModelAPIFix v1.0.2
MaskOverhaulModelAPI/LCThiccMaskCombination.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using HarmonyLib; using ModelReplacement; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LCThiccMaskCombination")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LCThiccMaskCombination")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0c098703-6551-44c4-a5b0-1325e3ba2fbb")] [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 LCThiccMaskCombination { [BepInPlugin("FxRbit.LCThiccMaskCombination", "Lethal Masked Overhaul Model API Fix", "1.0.0.0")] public class ThiccMaskCombinationBase : BaseUnityPlugin { private const string modGUID = "FxRbit.LCThiccMaskCombination"; private const string modName = "Lethal Masked Overhaul Model API Fix"; private const string modVersion = "1.0.0.0"; private readonly Harmony harmony = new Harmony("FxRbit.LCThiccMaskCombination"); public static ThiccMaskCombinationBase Instance; public ManualLogSource Logger; public static SpawnableEnemyWithRarity maskedPrefab; public static SpawnableEnemyWithRarity flowerPrefab; private void Awake() { Logger = Logger.CreateLogSource("FxRbit.LCThiccMaskCombination"); if ((Object)(object)Instance == (Object)null) { Instance = this; } harmony.PatchAll(); Logger.LogInfo((object)"Plugin FxRbit.LCThiccMaskCombination is loaded! >:3"); harmony.PatchAll(typeof(ThiccMaskCombinationBase)); } public static void ResetMaskModelReplacement(ref MaskedPlayerEnemy __instance) { if (!((Object)(object)((Component)__instance).gameObject.GetComponent<BodyReplacementBase>() == (Object)null)) { ModelReplacementAPI.Instance.Logger.LogInfo((object)("Reinstantiating model replacement for " + ((object)__instance)?.ToString() + " ")); Type type = ((object)((Component)__instance).gameObject.GetComponent<BodyReplacementBase>()).GetType(); Object.Destroy((Object)(object)((Component)__instance).gameObject.GetComponent<BodyReplacementBase>()); ((Component)__instance).gameObject.AddComponent(type); } } public static void SetMaskModelReplacement(ref MaskedPlayerEnemy __instance, Type type) { if (!type.IsSubclassOf(typeof(BodyReplacementBase))) { ModelReplacementAPI.Instance.Logger.LogError((object)("Cannot set body replacement of type " + type.Name + ", must inherit from BodyReplacementBase")); } else { if (!ModelReplacementAPI.isLan) { return; } Transform val = ((Component)__instance).transform.Find("ScavengerModel").Find("metarig"); BodyReplacementBase component = ((Component)__instance).gameObject.GetComponent<BodyReplacementBase>(); int currentSuitID = __instance.mimickingPlayer.currentSuitID; string unlockableName = StartOfRound.Instance.unlockablesList.unlockables[currentSuitID].unlockableName; if ((Object)(object)component != (Object)null) { if (((object)component).GetType() == type) { if (!(component.suitName != unlockableName)) { return; } ModelReplacementAPI.Instance.Logger.LogInfo((object)$"Suit Change detected {component.suitName} => {unlockableName}, Replacing {type}."); Object.Destroy((Object)(object)component); } else { ModelReplacementAPI.Instance.Logger.LogInfo((object)$"Model Replacement Change detected {((object)component).GetType()} => {type}, changing model."); Object.Destroy((Object)(object)component); } } Component obj = ((Component)((Component)__instance).transform).gameObject.AddComponent(type); BodyReplacementBase val2 = (BodyReplacementBase)(object)((obj is BodyReplacementBase) ? obj : null); val2.suitName = unlockableName; } } } } namespace LCThiccMaskCombination.Patches { [HarmonyPatch(typeof(MaskedPlayerEnemy))] public class ThiccMaskPatch { [HarmonyPatch("SetSuit")] [HarmonyPrefix] public static void SetModelReplacement(ref MaskedPlayerEnemy __instance, int suitId) { BodyReplacementBase component = ((Component)__instance.mimickingPlayer).gameObject.GetComponent<BodyReplacementBase>(); if ((Object)(object)component == (Object)null && Chainloader.PluginInfos.ContainsKey("meow.ModelReplacementAPI")) { ThiccMaskCombinationBase.ResetMaskModelReplacement(ref __instance); ThiccMaskCombinationBase.SetMaskModelReplacement(ref __instance, ((object)((Component)__instance).gameObject.GetComponent<BodyReplacementBase>()).GetType()); } } } }