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 KomaroMichinokuSuit v0.1.0
KomaroMod.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using ModelReplacement.Scripts.Player; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("KomaroMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("KomaroMod")] [assembly: AssemblyTitle("KomaroMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ModelReplacement { public static class Assets { public static string mainAssetBundleName = "komaromodel"; public static AssetBundle MainAssetBundle = null; private static string GetAssemblyName() { return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_"); } public static void PopulateAssets() { if ((Object)(object)MainAssetBundle == (Object)null) { Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName); using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName); MainAssetBundle = AssetBundle.LoadFromStream(stream); } } } public class MRKOMARO : BodyReplacementBase { public MRKOMARO() { base.RemoveHelmet = true; } protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset<GameObject>("Komaro"); } protected override GameObject LoadAssetsAndReturnViewModel() { GameObject val = Assets.MainAssetBundle.LoadAsset<GameObject>("KomaroFirstPersonArms"); if ((Object)(object)val == (Object)null) { return null; } return val; } } [BepInPlugin("com.komaro.modelreplacement", "Komaro Model Replacement", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] public static class KomaroCameraPositionPatch { private static float desiredCameraOffset; private static float appliedCameraOffset; private static bool hasCachedCameraOffset; private static BodyReplacementBase cachedReplacement; private static PlayerControllerB cachedPlayer; [HarmonyPrefix] public static void Prefix(PlayerControllerB __instance) { //IL_0041: 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) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController) && !((Object)(object)__instance.cameraContainerTransform == (Object)null) && appliedCameraOffset != 0f) { Transform cameraContainerTransform = __instance.cameraContainerTransform; Vector3 position = cameraContainerTransform.position; position.y -= appliedCameraOffset; cameraContainerTransform.position = position; appliedCameraOffset = 0f; } } [HarmonyPostfix] public static void Postfix(PlayerControllerB __instance) { //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) BodyReplacementBase val = default(BodyReplacementBase); if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController || (Object)(object)__instance.gameplayCamera == (Object)null || (Object)(object)__instance.cameraContainerTransform == (Object)null || !ModelReplacementAPI.GetPlayerModelReplacement(__instance, ref val) || (Object)(object)val == (Object)null || (Object)(object)val.replacementModel == (Object)null) { return; } if (!(val is MRKOMARO)) { hasCachedCameraOffset = false; desiredCameraOffset = 0f; appliedCameraOffset = 0f; cachedReplacement = null; cachedPlayer = null; return; } if (!hasCachedCameraOffset || (Object)(object)cachedReplacement != (Object)(object)val || (Object)(object)cachedPlayer != (Object)(object)__instance) { Transform val2 = null; Transform[] componentsInChildren = val.replacementModel.GetComponentsInChildren<Transform>(true); foreach (Transform val3 in componentsInChildren) { if (((Object)val3).name == "ValveBiped.Bip01_Head1") { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return; } desiredCameraOffset = val2.position.y + 0.35f - __instance.cameraContainerTransform.position.y; cachedReplacement = val; cachedPlayer = __instance; hasCachedCameraOffset = true; } Transform cameraContainerTransform = __instance.cameraContainerTransform; Vector3 position = cameraContainerTransform.position; position.y += desiredCameraOffset; cameraContainerTransform.position = position; appliedCameraOffset = desiredCameraOffset; } } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] public static class KomaroHelmetVisibilityPatch { private static MeshRenderer helmetRenderer = null; private static bool originalHelmetEnabled = true; [HarmonyPostfix] public static void Postfix(PlayerControllerB __instance) { if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController) { return; } if ((Object)(object)helmetRenderer == (Object)null) { GameObject val = GameObject.Find("Systems/Rendering/PlayerHUDHelmetModel"); if ((Object)(object)val == (Object)null) { return; } helmetRenderer = val.GetComponentInChildren<MeshRenderer>(); if ((Object)(object)helmetRenderer == (Object)null) { return; } originalHelmetEnabled = ((Renderer)helmetRenderer).enabled; } BodyReplacementBase val2 = default(BodyReplacementBase); bool flag = ModelReplacementAPI.GetPlayerModelReplacement(__instance, ref val2) && val2 is MRKOMARO; ((Renderer)helmetRenderer).enabled = !flag && originalHelmetEnabled; } } [HarmonyPatch(typeof(ViewModelUpdater), "Update")] public static class KomaroViewModelCameraAlignmentPatch { private static readonly FieldInfo armsMetarigField = typeof(ViewModelUpdater).GetField("armsMetarig", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); [HarmonyPostfix] public static void Postfix(ViewModelUpdater __instance) { //IL_00b0: 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_00bb: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) if (__instance == null || (Object)(object)__instance.replacementViewModel == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { return; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; BodyReplacementBase val = default(BodyReplacementBase); if (!((Object)(object)localPlayerController == (Object)null) && !((Object)(object)localPlayerController.cameraContainerTransform == (Object)null) && ModelReplacementAPI.GetPlayerModelReplacement(localPlayerController, ref val) && val is MRKOMARO && val.viewModelAvatar != null && !((Object)(object)val.viewModelAvatar.replacementViewModel != (Object)(object)__instance.replacementViewModel) && !(armsMetarigField == null)) { object? value = armsMetarigField.GetValue(__instance); Transform val2 = (Transform)((value is Transform) ? value : null); if (!((Object)(object)val2 == (Object)null)) { Transform transform = __instance.replacementViewModel.transform; Vector3 val3 = localPlayerController.cameraContainerTransform.position - val2.position; transform.position += val3; } } } } [HarmonyPatch(typeof(BodyReplacementBase), "LoadViewModelreplacement")] internal static class KomaroCustomViewModelGenerationPatch { private struct GenerationState { public bool ShouldRestore; public bool PreviousGlobalSetting; public bool PreviousModelSetting; } [HarmonyPrefix] [HarmonyPriority(0)] private static void Prefix(BodyReplacementBase __instance, out GenerationState __state) { __state = default(GenerationState); if (__instance is MRKOMARO) { __state.ShouldRestore = true; __state.PreviousGlobalSetting = ModelReplacementAPI.EnforceViewModelGeneration.Value; __state.PreviousModelSetting = __instance.GenerateViewModel; ModelReplacementAPI.EnforceViewModelGeneration.Value = false; __instance.GenerateViewModel = false; } } [HarmonyFinalizer] private static Exception Finalizer(BodyReplacementBase __instance, GenerationState __state, Exception __exception) { if (__state.ShouldRestore) { __instance.GenerateViewModel = __state.PreviousModelSetting; ModelReplacementAPI.EnforceViewModelGeneration.Value = __state.PreviousGlobalSetting; } return __exception; } } public static ConfigFile config; public static ConfigEntry<bool> enableModelForAllSuits { get; private set; } public static ConfigEntry<bool> enableModelAsDefault { get; private set; } public static ConfigEntry<string> suitNamesToEnableModel { get; private set; } public static void LogDiagnostic(string message) { } private static void InitConfig() { enableModelForAllSuits = config.Bind<bool>("Suits to Replace Settings", "Enable Model for all Suits", false, "Enable to model replace every suit. Set to false to specify suits"); enableModelAsDefault = config.Bind<bool>("Suits to Replace Settings", "Enable Model as default", false, "Enable to model replace every suit that hasn't been otherwise registered."); suitNamesToEnableModel = config.Bind<string>("Suits to Replace Settings", "Suits to enable Model for", "Komaro", "Enter a comma separated list of suit names.(Additionally, [Green suit,Pajama suit,Hazard suit])"); } private void Awake() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) config = ((BaseUnityPlugin)this).Config; InitConfig(); Assets.PopulateAssets(); if (enableModelForAllSuits.Value) { ModelReplacementAPI.RegisterModelReplacementOverride(typeof(MRKOMARO)); } if (enableModelAsDefault.Value) { ModelReplacementAPI.RegisterModelReplacementDefault(typeof(MRKOMARO)); } string[] array = suitNamesToEnableModel.Value.Split(','); for (int i = 0; i < array.Length; i++) { ModelReplacementAPI.RegisterSuitModelReplacement(array[i], typeof(MRKOMARO)); } new Harmony("com.komaro.modelreplacement").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.komaro.modelreplacement is loaded!"); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }