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 Coins v1.0.2
Coins/Snowlance.Coins.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Snowlance.Coins.NetcodePatcher; 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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: AssemblyCompany("Snowlance.Coins")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+8ebbb9b819df874f35e156e623e2a28de1abfc49")] [assembly: AssemblyProduct("Coins")] [assembly: AssemblyTitle("Snowlance.Coins")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [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; } } [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 Coins { internal class CoinBehavior : NetworkBehaviour { public AudioClip CoinCollectSFX; private static Terminal terminal; public void Start() { if ((Object)(object)terminal == (Object)null) { terminal = Object.FindObjectOfType<Terminal>(); } } public void OnTriggerEnter(Collider other) { PlayerControllerB val = default(PlayerControllerB); if (((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val)) { val.statusEffectAudio.PlayOneShot(CoinCollectSFX, Plugin.configCoinVolume.Value); CollectCoinServerRpc(); } } [ServerRpc(RequireOwnership = false)] public void CollectCoinServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3398974476u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3398974476u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && Plugin.IsServerOrHost) { CollectCoinClientRpc(); ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } } [ClientRpc] public void CollectCoinClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1517459593u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1517459593u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { Terminal obj = terminal; obj.groupCredits += Plugin.configCoinValue.Value; } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_CoinBehavior() { //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(3398974476u, new RpcReceiveHandler(__rpc_handler_3398974476)); NetworkManager.__rpc_func_table.Add(1517459593u, new RpcReceiveHandler(__rpc_handler_1517459593)); } private static void __rpc_handler_3398974476(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((CoinBehavior)(object)target).CollectCoinServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1517459593(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((CoinBehavior)(object)target).CollectCoinClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "CoinBehavior"; } } internal class TESTING : MonoBehaviour { private static ManualLogSource logger = Plugin.LoggerInstance; private static bool toggle; [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] public static void PingScan_performedPostFix() { } [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] public static void SubmitChat_performedPrefix(HUDManager __instance) { try { string text = __instance.chatTextField.text; string[] array = text.Split(" "); switch (array[0]) { case "/crash": Application.Quit(); break; case "/refresh": RoundManager.Instance.RefreshEnemiesList(); HoarderBugAI.RefreshGrabbableObjectsInMapList(); break; case "/levels": { SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val2 in levels) { logger.LogDebug((object)((Object)val2).name); } break; } case "/dungeon": logger.LogDebug((object)((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name); break; case "/dungeons": { IndoorMapType[] dungeonFlowTypes = RoundManager.Instance.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { logger.LogDebug((object)((Object)val.dungeonFlow).name); } break; } } } catch { logger.LogError((object)"Invalid chat command"); } } } [BepInPlugin("Snowlance.Coins", "Coins", "1.0.2")] public class Plugin : BaseUnityPlugin { public static Plugin PluginInstance; public static ManualLogSource LoggerInstance; private readonly Harmony harmony = new Harmony("Snowlance.Coins"); public static AssetBundle? ModAssets; public static GameObject CoinPrefab; public static ConfigEntry<int> configCoinValue; public static ConfigEntry<float> configInsideAmount; public static ConfigEntry<float> configCoinVolume; public static PlayerControllerB localPlayer => GameNetworkManager.Instance.localPlayerController; public static bool IsServerOrHost => NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost; public static PlayerControllerB PlayerFromId(ulong id) { return StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.actualClientId == id).First(); } private void Awake() { if ((Object)(object)PluginInstance == (Object)null) { PluginInstance = this; } LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger; harmony.PatchAll(); InitializeNetworkBehaviours(); configCoinValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Coin Value", 1, "How many credits will be added when a coin is collected"); configInsideAmount = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Inside Amount", 1f, "The percentage of AI nodes from 0-1 that a coin will spawn on inside."); configCoinVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Coin Volume", 0.5f, "The volume of the collect coin sound effect when a coin is collected. Needs to be 0-1."); string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "coin_assets")); if ((Object)(object)ModAssets == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets."); return; } LoggerInstance.LogDebug((object)("Got AssetBundle at: " + Path.Combine(directoryName, "coin_assets"))); CoinPrefab = ModAssets.LoadAsset<GameObject>("Assets/ModAssets/Coin.prefab"); if ((Object)(object)CoinPrefab == (Object)null) { LoggerInstance.LogError((object)"CoinPrefab is null"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.Coins v1.0.2 has loaded!"); } private static void InitializeNetworkBehaviours() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { 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); } } } LoggerInstance.LogDebug((object)"Finished initializing network behaviours"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Snowlance.Coins"; public const string PLUGIN_NAME = "Coins"; public const string PLUGIN_VERSION = "1.0.2"; } } namespace Coins.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { private static ManualLogSource logger = Plugin.LoggerInstance; [HarmonyPostfix] [HarmonyPatch("Start")] public static void GameNetworkManagerPostfix() { NetworkManager.Singleton.AddNetworkPrefab(Plugin.CoinPrefab); logger.LogDebug((object)"Added network prefab for coin"); } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { private static ManualLogSource logger = Plugin.LoggerInstance; private const float verticalOffset = 0.5f; [HarmonyPostfix] [HarmonyPatch("OnShipLandedMiscEvents")] public static void OnShipLandedMiscEventsPostfix() { //IL_00b1: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsServerOrHost || Plugin.configInsideAmount.Value == 0f) { return; } int num = (int)((float)RoundManager.Instance.insideAINodes.Length * Plugin.configInsideAmount.Value); logger.LogDebug((object)$"Spawning {num} coins inside"); List<GameObject> list = RoundManager.Instance.insideAINodes.ToList(); for (int i = 0; i < num; i++) { GameObject randomAINode = GetRandomAINode(list); list.Remove(randomAINode); if ((Object)(object)randomAINode == (Object)null) { i--; continue; } CoinBehavior component = Object.Instantiate<GameObject>(Plugin.CoinPrefab, randomAINode.transform.position + Vector3.up * 0.5f, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform).GetComponent<CoinBehavior>(); ((NetworkBehaviour)component).NetworkObject.Spawn(true); } } private static GameObject GetRandomAINode(List<GameObject> nodes) { int index = Random.Range(0, nodes.Count); return nodes[index]; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace Snowlance.Coins.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }