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 VEM Expanded v1.0.0
VEMExtended.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using Dissonance; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using VEMExtended.Behaviours; using VEMExtended.Item_Behaviours; using VEMExtended.NetcodePatcher; using VEMExtended.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("VEMExtended")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("VEMExtended")] [assembly: AssemblyTitle("VEMExtended")] [assembly: AssemblyVersion("1.0.0.0")] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 VEMExtended { [BepInPlugin("rico.VEMExpanded", "VEM Expanded", "1.0.0")] public class Plugin : BaseUnityPlugin { private static Harmony _hi; private const string GUID = "rico.VEMExpanded"; private const string NAME = "VEM Expanded"; private const string VERSION = "1.0.0"; public static Plugin instance; public AssetBundle bundle; private static void NetcodePatcher() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } public void Awake() { NetcodePatcher(); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "vemassets"); bundle = AssetBundle.LoadFromFile(text); Item val = bundle.LoadAsset<Item>("Assets/VEM/HorlosWatch/HorlosWatchItem.asset"); Item obj = bundle.LoadAsset<Item>("Assets/VEM/ReubenViool/ReubenVioolItem.asset"); Item val2 = bundle.LoadAsset<Item>("Assets/VEM/CharlGoldKrink/CharlKrinkItem.asset"); Item val3 = bundle.LoadAsset<Item>("Assets/VEM/AndriesMicrophone/AndriesMicItem.asset"); Item val4 = bundle.LoadAsset<Item>("Assets/VEM/RicoLaptop/RicoLaptopItem.asset"); ExtendMicDistance extendMicDistance = val3.spawnPrefab.AddComponent<ExtendMicDistance>(); ((GrabbableObject)extendMicDistance).grabbable = true; ((GrabbableObject)extendMicDistance).grabbableToEnemies = true; ((GrabbableObject)extendMicDistance).isInFactory = true; ((GrabbableObject)extendMicDistance).itemProperties = val3; LaptopTerminal laptopTerminal = val4.spawnPrefab.AddComponent<LaptopTerminal>(); ((GrabbableObject)laptopTerminal).grabbable = true; ((GrabbableObject)laptopTerminal).grabbableToEnemies = true; ((GrabbableObject)laptopTerminal).isInFactory = true; ((GrabbableObject)laptopTerminal).itemProperties = val4; Utilities.FixMixerGroups(val.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(obj.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(obj.spawnPrefab); Utilities.FixMixerGroups(val2.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab); Utilities.FixMixerGroups(val3.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab); Utilities.FixMixerGroups(val4.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab); val.minValue = 100; val.maxValue = 190; obj.minValue = 350; obj.maxValue = 600; Items.RegisterScrap(val, 25, (LevelTypes)(-1)); Items.RegisterScrap(obj, 10, (LevelTypes)256); Items.RegisterScrap(val2, 20, (LevelTypes)512); Items.RegisterScrap(val3, 35, (LevelTypes)(-1)); Items.RegisterShopItem(val4, 0); string text2 = "-~-~-~-~-~-~-~-~-~-~-~-~-~- VEM EXTENDED -~-~-~-~-~-~-~-~-~-~-~-~-~-\r\n \r\n .(#/ *(. ,, \r\n , / ./##((((* * .*(// * \r\n * */ .* * ( \r\n * */(. # %, \r\n ., * .. ,. * / . \r\n , * / ./# \r\n ( .% # * *, .* \r\n / ./ ,* # \r\n /. #**. ( (. \r\n ,%#((#* .%# \r\n *, / \r\n # ,* / / \r\n .( (, * / \r\n * / \r\n / ./ \r\n ., #, # \r\n #, ,/ , *. \r\n / , / .. \r\n / * ,, .. \r\n ,. * ./ / \r\n # ** "; _hi = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "rico.VEMExpanded"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"VEM Extended 1.0.0 has succesfully loaded!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"credits: etienne (tester), andries (tester)"); ((BaseUnityPlugin)this).Logger.LogInfo((object)text2); } private void OnDestroy() { } } [HarmonyPatch] public class NetworkObjectManager { private static AssetBundle networkBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "networkassets")); private static GameObject networkPrefab; [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager))] [HarmonyPatch("Start")] public static void Init() { if (!((Object)(object)networkPrefab != (Object)null)) { networkPrefab = networkBundle.LoadAsset<GameObject>("Assets/VEM/Utilities/VEM_NetworkHandler.prefab"); networkPrefab.AddComponent<VEM_NetworkHandler>(); NetworkManager.Singleton.AddNetworkPrefab(networkPrefab); } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound))] [HarmonyPatch("Awake")] private static void SpawnNetworkHandler() { //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) if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity).GetComponent<NetworkObject>().Spawn(true); } } } [HarmonyPatch] public class VEMSubscription_Manager { [HarmonyPostfix] [HarmonyPatch(typeof(RoundManager))] [HarmonyPatch("GenerateNewFloor")] private static void SubscribeToMicUpdate() { VEM_NetworkHandler.updateMic += VEMEvent_Manager.updateMicRange; Console.WriteLine("Added updateMicRange method to event"); } [HarmonyPostfix] [HarmonyPatch(typeof(RoundManager))] [HarmonyPatch("DespawnPropsAtEndOfRound")] private static void UnSubscribeToMicUpdate() { Console.WriteLine("Removed updateMicRange method from event"); VEM_NetworkHandler.updateMic -= VEMEvent_Manager.updateMicRange; } } public class VEMEvent_Manager { public static void updateMicRange(string eventName, string playbackUUID, int rangeModification) { Console.WriteLine("called updateMicRange"); Console.WriteLine("target: " + playbackUUID); string localPlayerName = GameObject.Find("DissonanceSetup").GetComponent<DissonanceComms>().LocalPlayerName; Console.WriteLine("local: " + localPlayerName); if (!(playbackUUID == localPlayerName)) { GameObject.Find("Player " + playbackUUID + " voice comms").GetComponent<AudioSource>().maxDistance = rangeModification; } } } } namespace VEMExtended.Networking { public class VEM_NetworkHandler : NetworkBehaviour { public static VEM_NetworkHandler Instance { get; private set; } public static event Action<string, string, int> updateMic; [ServerRpc(RequireOwnership = false)] public void updateMicServerRpc(string playbackUUID, int rangeModification) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) //IL_00c7: 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(2867906748u, val, (RpcDelivery)0); bool flag = playbackUUID != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(playbackUUID, false); } BytePacker.WriteValueBitPacked(val2, rangeModification); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2867906748u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { string arg = "updateMic"; if (VEM_NetworkHandler.updateMic != null) { VEM_NetworkHandler.updateMic(arg, playbackUUID, rangeModification); } } } [ClientRpc] public void updateMicClientRpc(string playbackUUID, int rangeModification) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) //IL_00c7: 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 != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2162863389u, val, (RpcDelivery)0); bool flag = playbackUUID != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(playbackUUID, false); } BytePacker.WriteValueBitPacked(val2, rangeModification); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2162863389u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { string arg = "updateMic"; if (VEM_NetworkHandler.updateMic != null) { VEM_NetworkHandler.updateMic(arg, playbackUUID, rangeModification); } } } public override void OnNetworkSpawn() { VEM_NetworkHandler.updateMic = null; Instance = this; ((NetworkBehaviour)this).OnNetworkSpawn(); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_VEM_NetworkHandler() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(2867906748u, new RpcReceiveHandler(__rpc_handler_2867906748)); NetworkManager.__rpc_func_table.Add(2162863389u, new RpcReceiveHandler(__rpc_handler_2162863389)); } private static void __rpc_handler_2867906748(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string playbackUUID = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref playbackUUID, false); } int rangeModification = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref rangeModification); target.__rpc_exec_stage = (__RpcExecStage)1; ((VEM_NetworkHandler)(object)target).updateMicServerRpc(playbackUUID, rangeModification); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2162863389(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string playbackUUID = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref playbackUUID, false); } int rangeModification = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref rangeModification); target.__rpc_exec_stage = (__RpcExecStage)2; ((VEM_NetworkHandler)(object)target).updateMicClientRpc(playbackUUID, rangeModification); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "VEM_NetworkHandler"; } } } namespace VEMExtended.Item_Behaviours { public class showTime : PhysicsProp { public bool previousPocketstate; public bool previousHoldstate; public PlayerControllerB previousHolderObject; public override void Start() { ((GrabbableObject)this).Start(); previousHoldstate = false; previousPocketstate = false; previousHolderObject = null; } public override void Update() { ((GrabbableObject)this).Update(); if (Object.op_Implicit((Object)(object)((GrabbableObject)this).playerHeldBy)) { if (((GrabbableObject)this).playerHeldBy.actualClientId != ((NetworkBehaviour)this).NetworkManager.LocalClientId) { return; } previousHolderObject = ((GrabbableObject)this).playerHeldBy; if (previousHoldstate != ((GrabbableObject)this).isHeld || previousPocketstate != ((GrabbableObject)this).isPocketed) { previousPocketstate = ((GrabbableObject)this).isPocketed; previousHoldstate = ((GrabbableObject)this).isHeld; if (!((GrabbableObject)this).isPocketed && ((GrabbableObject)this).isHeld) { Console.WriteLine("item is now held"); } else { Console.WriteLine("item is now no longer held"); } } } else if ((Object)(object)previousHolderObject != (Object)null && previousHolderObject.actualClientId == ((NetworkBehaviour)this).NetworkManager.LocalClientId) { Console.WriteLine("item is now no longer held"); previousHolderObject = null; previousHoldstate = false; previousPocketstate = false; } } protected override void __initializeVariables() { ((PhysicsProp)this).__initializeVariables(); } protected internal override string __getTypeName() { return "showTime"; } } public class LaptopTerminal : PhysicsProp { public GameObject terminal; public override void ItemActivate(bool used, bool buttonDown = true) { ((GrabbableObject)this).ItemActivate(used, buttonDown); if (buttonDown) { terminal.GetComponent<Terminal>().BeginUsingTerminal(); } } public override void Start() { ((GrabbableObject)this).Start(); string name = $"{((Object)((Component)this).gameObject).name}_Child_{Time.time}"; terminal = Object.Instantiate<GameObject>(GameObject.Find("TerminalScript"), ((Component)this).transform); Object.Destroy((Object)(object)terminal.GetComponent<BoxCollider>()); Object.Destroy((Object)(object)terminal.GetComponent<BoxCollider>()); ((Object)terminal).name = name; terminal.GetComponent<Terminal>().terminalUIScreen = GameObject.Find("TerminalScript").GetComponent<Terminal>().terminalUIScreen; ((Component)terminal.GetComponent<Terminal>().terminalUIScreen).transform.parent = ((Component)this).transform; } public override void Update() { ((GrabbableObject)this).Update(); } protected override void __initializeVariables() { ((PhysicsProp)this).__initializeVariables(); } protected internal override string __getTypeName() { return "LaptopTerminal"; } } } namespace VEMExtended.Behaviours { internal class ExtendMicDistance : PhysicsProp { public bool previousPocketstate; public bool previousHoldstate; public string previousHolderID; public PlayerControllerB previousHolderObject; public override void Start() { ((GrabbableObject)this).Start(); previousHoldstate = false; previousPocketstate = false; previousHolderID = null; previousHolderObject = null; } public override void Update() { ((GrabbableObject)this).Update(); if (Object.op_Implicit((Object)(object)((GrabbableObject)this).playerHeldBy)) { if (((GrabbableObject)this).playerHeldBy.actualClientId != ((NetworkBehaviour)this).NetworkManager.LocalClientId) { return; } previousHolderID = GameObject.Find("DissonanceSetup").GetComponent<DissonanceComms>().LocalPlayerName; previousHolderObject = ((GrabbableObject)this).playerHeldBy; if (previousHoldstate != ((GrabbableObject)this).isHeld || previousPocketstate != ((GrabbableObject)this).isPocketed) { previousPocketstate = ((GrabbableObject)this).isPocketed; previousHoldstate = ((GrabbableObject)this).isHeld; if (!((GrabbableObject)this).isPocketed && ((GrabbableObject)this).isHeld) { string localPlayerName = GameObject.Find("DissonanceSetup").GetComponent<DissonanceComms>().LocalPlayerName; VEM_NetworkHandler.Instance.updateMicServerRpc(localPlayerName, 250); VEM_NetworkHandler.Instance.updateMicClientRpc(localPlayerName, 250); Console.WriteLine("item is now held"); } else { string localPlayerName2 = GameObject.Find("DissonanceSetup").GetComponent<DissonanceComms>().LocalPlayerName; VEM_NetworkHandler.Instance.updateMicServerRpc(localPlayerName2, 50); VEM_NetworkHandler.Instance.updateMicClientRpc(localPlayerName2, 50); Console.WriteLine("item is now no longer held"); } } } else if (previousHolderID != null && (Object)(object)previousHolderObject != (Object)null && previousHolderObject.actualClientId == ((NetworkBehaviour)this).NetworkManager.LocalClientId) { VEM_NetworkHandler.Instance.updateMicServerRpc(previousHolderID, 50); VEM_NetworkHandler.Instance.updateMicClientRpc(previousHolderID, 50); Console.WriteLine("item is now no longer held"); previousHolderID = null; previousHolderObject = null; previousHoldstate = false; previousPocketstate = false; } } protected override void __initializeVariables() { ((PhysicsProp)this).__initializeVariables(); } protected internal override string __getTypeName() { return "ExtendMicDistance"; } } } namespace VEMExtended.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }