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 InstantCounter v0.1.1
InstantCounter.dll
Decompiled 9 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 LCModReverseGrief.Patches; using Microsoft.CodeAnalysis; 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: IgnoresAccessChecksTo("0Harmony")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("BepInEx")] [assembly: IgnoresAccessChecksTo("BepInEx.Harmony")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("UnityEngine.IMGUIModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("InstantCounter")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("made by Asta")] [assembly: AssemblyFileVersion("1.2.2.0")] [assembly: AssemblyInformationalVersion("1.2.2")] [assembly: AssemblyProduct("InstantCounter")] [assembly: AssemblyTitle("InstantCounter")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 InstantCounter { public static class MyPluginInfo { public const string PLUGIN_GUID = "InstantCounter"; public const string PLUGIN_NAME = "InstantCounter"; public const string PLUGIN_VERSION = "1.2.2"; } } namespace LCModReverseGrief { [BepInPlugin("asta.lc.instantcounter.reflect100", "InstantCounter - Reflect 100", "1.0.0")] public sealed class ModeBase : BaseUnityPlugin { private const string ModGuid = "asta.lc.instantcounter.reflect100"; private const string ModName = "InstantCounter - Reflect 100"; private const string ModVersion = "1.0.0"; private readonly Harmony _harmony = new Harmony("asta.lc.instantcounter.reflect100"); internal ManualLogSource mls = null; public static ModeBase Instance { get; private set; } private void Awake() { Instance = this; mls = ((BaseUnityPlugin)this).Logger; mls.LogInfo((object)"InstantCounter - Reflect 100 1.0.0 initialized"); _harmony.PatchAll(typeof(PlayerControllerBPatch)); } } } namespace LCModReverseGrief.Patches { internal class PlayerControllerBPatch { private const int FullHealHealthAmount = 100; private const int KillDamageAmount = 9999; private static readonly Dictionary<int, int> HitCountsByPlayerId = new Dictionary<int, int>(); private static ManualLogSource? Log => ModeBase.Instance?.mls; private static IEnumerator DecayHitCount(int playerId) { yield return (object)new WaitForSeconds(1.2f); int value2 = HitCountsByPlayerId.GetValueOrDefault(playerId, 0); value2 = ((value2 > 0) ? (value2 - 1) : 0); HitCountsByPlayerId[playerId] = value2; ManualLogSource? log = Log; if (log != null) { log.LogInfo((object)$"[InstantCounter]: player{playerId} hit count decayed to {value2}"); } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientClientRpc")] public static bool PlayerDamaged(ref int damageAmount, ref Vector3 hitDirection, ref int playerWhoHit, ref int newHealthAmount, PlayerControllerB __instance) { //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsOwner) { return true; } CentipedeAI[] array = Object.FindObjectsByType<CentipedeAI>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i].clingingToPlayer == (Object)(object)__instance) { ManualLogSource? log = Log; if (log != null) { log.LogInfo((object)$"[InstantCounter]: Accepting the hit from player{playerWhoHit}"); } return true; } } ManualLogSource? log2 = Log; if (log2 != null) { log2.LogInfo((object)$"[InstantCounter]: Detected grief from another player{playerWhoHit}"); } PlayerControllerB val = FindPlayerById(playerWhoHit); int num = HitCountsByPlayerId.GetValueOrDefault(playerWhoHit, 0) + 1; HitCountsByPlayerId[playerWhoHit] = num; ManualLogSource? log3 = Log; if (log3 != null) { log3.LogInfo((object)$"[InstantCounter]: player{playerWhoHit} hit count = {num}"); } IEnumerator enumerator = DecayHitCount(playerWhoHit); if (enumerator != null) { ((MonoBehaviour)__instance).StartCoroutine(enumerator); } if (num >= 2) { if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)__instance) { ManualLogSource? log4 = Log; if (log4 != null) { log4.LogInfo((object)$"[InstantCounter]: player{playerWhoHit} reached 2 hits. Killing attacker + full heal."); } val.DamagePlayerFromOtherClientServerRpc(9999, -hitDirection, (int)__instance.playerClientId); } damageAmount = 0; __instance.health = Mathf.Clamp(__instance.health + 20, 0, 100); newHealthAmount = __instance.health; HitCountsByPlayerId[playerWhoHit] = 0; return true; } return true; } private static PlayerControllerB? FindPlayerById(int playerId) { PlayerControllerB[] array = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if ((int)val.playerClientId == playerId) { return val; } } return null; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }