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 MontyCore v1.0.0
BepInEx/plugins/MontyMod.dll
Decompiled 5 months agousing System; using System.Collections.Generic; 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.Logging; using GameNetcodeStuff; using HarmonyLib; using JLL; using JLL.API.LevelProperties; using LethalCompanyInputUtils.Api; using LethalLevelLoader; using Microsoft.CodeAnalysis; using MontyMod.Managers; using MontyMod.NetcodePatcher; using MontyMod.Patches; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Video; [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("MontyMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MontyMod")] [assembly: AssemblyTitle("MontyMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 MontyMod { [BepInPlugin("JacobG5.MontyMod", "MontyMod", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string modGUID = "JacobG5.MontyMod"; public const string modName = "MontyMod"; public const string modVersion = "0.1.0"; private Harmony Harmony; public static ExtendedMod montyMod; internal AssetBundle Bundle; internal readonly List<VideoClip> Videos = new List<VideoClip>(); internal readonly List<AudioClip> Audios = new List<AudioClip>(); internal GameObject Jerry; internal GameObject OgoPrefab; internal readonly List<Material> OgoMats = new List<Material>(); internal readonly List<AudioClip> OgoSong = new List<AudioClip>(); public static Plugin Instance { get; private set; } public static ManualLogSource mls { get; private set; } internal static MontyInput Input { get; private set; } public void Awake() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown Instance = this; mls = Logger.CreateLogSource("JacobG5.MontyMod"); Input = new MontyInput(); string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "monty")); if ((Object)(object)Bundle == (Object)null) { mls.LogError((object)"Failed to load assets."); return; } Harmony = new Harmony("JacobG5.MontyMod"); montyMod = ExtendedMod.Create("MontyMod", "JacobG5"); Jerry = Bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/Monty/Jerry.prefab"); OgoPrefab = Bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/Monty/Ogo.prefab"); OgoPrefab.AddComponent<DespawnTimer>(); OgoMats.AddRange(new List<Material> { Bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Monty/Ogomats/0.mat"), Bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Monty/Ogomats/1.mat"), Bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Monty/Ogomats/2.mat"), Bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Monty/Ogomats/3.mat"), Bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Monty/Ogomats/4.mat"), Bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Monty/Ogomats/5.mat") }); for (int i = 1; i < 63; i++) { OgoSong.Add(Bundle.LoadAsset<AudioClip>($"Assets/LethalCompany/Mods/Monty/OgoSounds/ogo-{i}.mp3")); } AddClip("Assets/LethalCompany/Mods/Monty/TvTime"); Item val = Bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/Monty/fishItem.asset"); ExtendedItem val2 = ExtendedItem.Create(val, montyMod, (ContentType)1); val2.LevelMatchingProperties.planetNames.Add(new StringWithRarity("March", 46)); val2.LevelMatchingProperties.levelTags.AddRange(new List<StringWithRarity> { new StringWithRarity("Canyon", 4), new StringWithRarity("Valley", 16) }); Harmony.PatchAll(typeof(StartOfRoundPatch)); Harmony.PatchAll(typeof(HudManagerPatch)); JLL.Instance.networkObject.AddComponent<MontyNetwork>(); Input.OgoKey.performed += delegate { if (MontyInput.CanKeybind()) { MontyNetwork.Instance.RequestFishServerRpc((int)StartOfRound.Instance.localPlayerController.playerClientId); } }; PatchedContent.RegisterExtendedMod(montyMod); mls.LogInfo((object)": )"); Type[] array = new Type[1] { typeof(MontyNetwork) }; foreach (Type type in array) { if (type == null) { continue; } try { if (type.IsNested || !typeof(NetworkBehaviour).IsAssignableFrom(type)) { continue; } 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); } } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"Error while Patching Netcode Class.\n{arg}"); } } } private void AddClip(string name) { Videos.Add(Bundle.LoadAsset<VideoClip>(name + ".mp4")); Audios.Add(Bundle.LoadAsset<AudioClip>(name + ".mp3")); } } } namespace MontyMod.Patches { [HarmonyPatch(typeof(HUDManager))] internal static class HudManagerPatch { private static CanvasGroup FishElement; [HarmonyPatch("Awake")] [HarmonyPrefix] public static void Awake_Prefix(HUDManager __instance) { GameObject val = Object.Instantiate<GameObject>(Plugin.Instance.Jerry, ((Component)__instance.gasImageAlpha).transform.parent); FishElement = val.GetComponent<CanvasGroup>(); FishElement.alpha = 0f; } [HarmonyPatch("UnderwaterScreenFilters")] [HarmonyPostfix] public static void UnderwaterScreenFilters_Postfix(HUDManager __instance) { if (__instance.setUnderwaterFilter) { FishElement.alpha = Mathf.Lerp(FishElement.alpha, 1f, 0.005f * Time.deltaTime); } else { FishElement.alpha = Mathf.Lerp(FishElement.alpha, 0f, 10f * Time.deltaTime); } } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRoundPatch { private static bool Patched; [HarmonyPatch("Awake")] [HarmonyPrefix] public static void Awake_Prefix(StartOfRound __instance) { if (Patched) { return; } Patched = true; foreach (UnlockableItem unlockable in __instance.unlockablesList.unlockables) { if (unlockable.unlockableType != 1 || !((Object)(object)unlockable.prefabObject != (Object)null)) { continue; } TVScript componentInChildren = unlockable.prefabObject.GetComponentInChildren<TVScript>(); if ((Object)(object)componentInChildren == (Object)null) { continue; } int num = componentInChildren.tvClips.Length + Plugin.Instance.Videos.Count; VideoClip[] array = (VideoClip[])(object)new VideoClip[num]; AudioClip[] array2 = (AudioClip[])(object)new AudioClip[num]; for (int i = 0; i < num; i++) { if (i < componentInChildren.tvClips.Length) { array[i] = componentInChildren.tvClips[i]; array2[i] = componentInChildren.tvAudioClips[i]; } else { int index = i - componentInChildren.tvClips.Length; array[i] = Plugin.Instance.Videos[index]; array2[i] = Plugin.Instance.Audios[index]; } } componentInChildren.tvClips = array; componentInChildren.tvAudioClips = array2; } } } } namespace MontyMod.Managers { public class DespawnTimer : MonoBehaviour { public float killTime = 120f; public float aliveTime = 0f; public void Update() { aliveTime += Time.deltaTime; if (aliveTime > killTime) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class MontyInput : LcInputActions { [InputAction(/*Could not decode attribute arguments.*/)] public InputAction OgoKey { get; set; } public static bool CanKeybind() { if ((Object)(object)MontyNetwork.Instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { return false; } if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { return false; } if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { return false; } if (((Behaviour)HUDManager.Instance.typingIndicator).enabled || GameNetworkManager.Instance.localPlayerController.isTypingChat || (JLevelPropertyRegistry.GetTerminal().terminalInUse && GameNetworkManager.Instance.localPlayerController.inTerminalMenu)) { return false; } return true; } } public class MontyNetwork : NetworkBehaviour { private int ogoPlace = 0; public static MontyNetwork Instance { get; private set; } public void OnEnable() { Instance = this; } public void OnDisable() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } [ServerRpc(RequireOwnership = false)] public void RequestFishServerRpc(int playerId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_011e: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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) //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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(390447772u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 390447772u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (playerId >= 0 && playerId < StartOfRound.Instance.allPlayerScripts.Length) { PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId]; Vector3 position = ((Component)val3.gameplayCamera).transform.position + ((Component)val3.gameplayCamera).transform.forward * 1.5f; Vector3 velocity = (((Component)val3.gameplayCamera).transform.forward + new Vector3(0f, 0.4f, 0f)) * Random.Range(12f, 18f); ShootFishClientRpc(position, ((Component)val3).gameObject.transform.rotation, velocity, Random.Range(0, Plugin.Instance.OgoMats.Count)); } } } [ClientRpc] private void ShootFishClientRpc(Vector3 position, Quaternion rotation, Vector3 velocity, int color) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Invalid comparison between Unknown and I4 //IL_005f: 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_0098: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(280919324u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref velocity); BytePacker.WriteValueBitPacked(val2, color); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 280919324u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; GameObject val3 = Object.Instantiate<GameObject>(Plugin.Instance.OgoPrefab, position, rotation); Rigidbody[] componentsInChildren = val3.GetComponentsInChildren<Rigidbody>(); foreach (Rigidbody val4 in componentsInChildren) { val4.AddForce(velocity, (ForceMode)1); } SkinnedMeshRenderer val5 = default(SkinnedMeshRenderer); if (val3.TryGetComponent<SkinnedMeshRenderer>(ref val5)) { ((Renderer)val5).materials = (Material[])(object)new Material[1] { Plugin.Instance.OgoMats[color] }; } AudioSource val6 = default(AudioSource); if (val3.TryGetComponent<AudioSource>(ref val6)) { val6.PlayOneShot(Plugin.Instance.OgoSong[ogoPlace]); ogoPlace++; if (ogoPlace >= Plugin.Instance.OgoSong.Count) { ogoPlace = 0; } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(390447772u, new RpcReceiveHandler(__rpc_handler_390447772), "RequestFishServerRpc"); ((NetworkBehaviour)this).__registerRpc(280919324u, new RpcReceiveHandler(__rpc_handler_280919324), "ShootFishClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_390447772(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); target.__rpc_exec_stage = (__RpcExecStage)1; ((MontyNetwork)(object)target).RequestFishServerRpc(playerId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_280919324(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_004a: 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_0068: 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_0070: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); Quaternion rotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref rotation); Vector3 velocity = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref velocity); int color = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref color); target.__rpc_exec_stage = (__RpcExecStage)1; ((MontyNetwork)(object)target).ShootFishClientRpc(position, rotation, velocity, color); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "MontyNetwork"; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace MontyMod.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }