Decompiled source of SurgeSuppressor v1.0.1

SurgeSuppressor.dll

Decompiled 4 days ago
using System;
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.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using HookDOTS.API;
using HookDOTS.API.Attributes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProfuselyViolentProgression.Core.Utilities;
using ProjectM;
using ProjectM.Gameplay.Systems;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Nicholas Toby")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright (c) Nicholas Toby 2025")]
[assembly: AssemblyDescription("Throttles static shock triggers.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+3fdce6ee52353a1ea22a3d304bcc563e2e3479af")]
[assembly: AssemblyProduct("SurgeSuppressor")]
[assembly: AssemblyTitle("SurgeSuppressor")]
[assembly: AssemblyMetadata("Reloadable", "True")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ProfuselyViolentProgression.Core.Utilities
{
	public static class DebugUtil
	{
		public static void LogComponentTypes(Entity entity)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			LogUtil.LogMessage("-------------------------------------------");
			EntityManager entityManager = WorldUtil.Game.EntityManager;
			Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator();
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				LogUtil.LogMessage(((object)(ComponentType)(ref current)).ToString());
			}
			LogUtil.LogMessage("-------------------------------------------");
		}

		public static void LogPrefabGuid(Entity entity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = WorldUtil.Game.EntityManager;
			if (((EntityManager)(ref entityManager)).HasComponent<PrefabGUID>(entity))
			{
				PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(entity);
				LogUtil.LogInfo("  PrefabGUID: " + LookupPrefabName(componentData));
			}
		}

		public static void LogBuffs(Entity entity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = WorldUtil.Game.EntityManager;
			if (((EntityManager)(ref entityManager)).HasBuffer<BuffBuffer>(entity))
			{
				LogUtil.LogInfo("  buffs:");
				Enumerator<BuffBuffer> enumerator = ((EntityManager)(ref entityManager)).GetBuffer<BuffBuffer>(entity, false).GetEnumerator();
				while (enumerator.MoveNext())
				{
					BuffBuffer current = enumerator.Current;
					LogUtil.LogInfo("    " + LookupPrefabName(current.PrefabGuid));
				}
			}
		}

		public static void LogSpellModSet(Entity entity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = WorldUtil.Game.EntityManager;
			if (((EntityManager)(ref entityManager)).HasComponent<SpellModSetComponent>(entity))
			{
				LogUtil.LogInfo("  spell mods:");
				SpellModSetComponent componentData = ((EntityManager)(ref entityManager)).GetComponentData<SpellModSetComponent>(entity);
				SpellModSet spellMods = componentData.SpellMods;
				LogUtil.LogInfo($"    count:{spellMods.Count}");
				LogUtil.LogInfo("    0:" + LookupPrefabName(spellMods.Mod0.Id));
				LogUtil.LogInfo("    1:" + LookupPrefabName(spellMods.Mod1.Id));
				LogUtil.LogInfo("    2:" + LookupPrefabName(spellMods.Mod2.Id));
				LogUtil.LogInfo("    3:" + LookupPrefabName(spellMods.Mod3.Id));
				LogUtil.LogInfo("    4:" + LookupPrefabName(spellMods.Mod4.Id));
				LogUtil.LogInfo("    5:" + LookupPrefabName(spellMods.Mod5.Id));
				LogUtil.LogInfo("    6:" + LookupPrefabName(spellMods.Mod6.Id));
				LogUtil.LogInfo("    7:" + LookupPrefabName(spellMods.Mod7.Id));
				LogUtil.LogInfo("     ----");
			}
		}

		public static void LogApplyBuffOnGameplayEvent(Entity entity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = WorldUtil.Game.EntityManager;
			if (((EntityManager)(ref entityManager)).HasBuffer<ApplyBuffOnGameplayEvent>(entity))
			{
				LogUtil.LogInfo("  Buffs to apply on gameplay events:");
				Enumerator<ApplyBuffOnGameplayEvent> enumerator = ((EntityManager)(ref entityManager)).GetBuffer<ApplyBuffOnGameplayEvent>(entity, false).GetEnumerator();
				while (enumerator.MoveNext())
				{
					ApplyBuffOnGameplayEvent current = enumerator.Current;
					LogUtil.LogInfo($"    stacks:{current.Stacks}");
					LogUtil.LogInfo("    0:" + LookupPrefabName(current.Buff0));
					LogUtil.LogInfo("    1:" + LookupPrefabName(current.Buff1));
					LogUtil.LogInfo("    2:" + LookupPrefabName(current.Buff2));
					LogUtil.LogInfo("    3:" + LookupPrefabName(current.Buff3));
					LogUtil.LogInfo($"    spellModSource:{current.CustomAbilitySpellModsSource}");
					LogUtil.LogInfo("     ----");
				}
			}
		}

		public static void LogHitColliderCast(Entity entity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = WorldUtil.Game.EntityManager;
			if (((EntityManager)(ref entityManager)).HasBuffer<HitColliderCast>(entity))
			{
				LogUtil.LogInfo("  HitColliderCast [Buffer]:");
				DynamicBuffer<HitColliderCast> buffer = ((EntityManager)(ref entityManager)).GetBuffer<HitColliderCast>(entity, false);
				for (int i = 0; i < buffer.Length; i++)
				{
					HitColliderCast val = buffer[i];
					LogUtil.LogInfo($"    HitColliderCast [{i}]");
					LogUtil.LogInfo($"      CollisionCheckType: {val.CollisionCheckType}");
					LogUtil.LogInfo($"      PrimaryFilterFlags: {val.PrimaryFilterFlags}");
					LogUtil.LogInfo($"      PrimaryTargets_Count: {val.PrimaryTargets_Count}");
					LogUtil.LogInfo($"      SecondaryTargets_Count: {val.SecondaryTargets_Count}");
					LogUtil.LogInfo($"      ContinuousCollision: {val.ContinuousCollision}");
					LogUtil.LogInfo($"      CanHitThroughBlockSpellCollision: {val.CanHitThroughBlockSpellCollision}");
					LogUtil.LogInfo($"      IgnoreImmaterial: {val.IgnoreImmaterial}");
					LogUtil.LogInfo("    ----");
				}
			}
		}

		public static string LookupPrefabName(PrefabGUID prefabGuid)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			PrefabCollectionSystem existingSystemManaged = WorldUtil.Game.GetExistingSystemManaged<PrefabCollectionSystem>();
			PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap;
			NativeParallelHashMap<PrefabGUID, Entity> guidToEntityMap = prefabLookupMap.GuidToEntityMap;
			if (!guidToEntityMap.ContainsKey(prefabGuid))
			{
				return $"GUID Not Found {prefabGuid._Value}";
			}
			return $"{((PrefabLookupMap)(ref prefabLookupMap)).GetName(prefabGuid)} PrefabGUID({((PrefabGUID)(ref prefabGuid)).GuidHash})";
		}
	}
	public static class LogUtil
	{
		public static ManualLogSource Logger;

		public static void Init(ManualLogSource logger)
		{
			Logger = logger;
		}

		public static void LogMessage(object data)
		{
			Logger.LogMessage(data);
		}

		public static void LogInfo(object data)
		{
			Logger.LogInfo(data);
		}

		public static void LogError(object data)
		{
			Logger.LogError(data);
		}

		public static void LogWarning(object data)
		{
			Logger.LogWarning(data);
		}
	}
	public static class WorldUtil
	{
		private static World _clientWorld;

		private static World _serverWorld;

		public static World Server
		{
			get
			{
				if (_serverWorld != null && _serverWorld.IsCreated)
				{
					return _serverWorld;
				}
				_serverWorld = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");
				return _serverWorld;
			}
		}

		public static World Client
		{
			get
			{
				if (_clientWorld != null && _clientWorld.IsCreated)
				{
					return _clientWorld;
				}
				_clientWorld = GetWorld("Client_0") ?? throw new Exception("There is no Client world (yet). Did you install a client mod on the server?");
				return _clientWorld;
			}
		}

		public static World Default => World.DefaultGameObjectInjectionWorld;

		public static World Game => IsClient ? Client : Server;

		public static bool IsServer => Application.productName == "VRisingServer";

		public static bool IsClient => Application.productName == "VRising";

		public static bool IsGameWorldCreated()
		{
			if (_clientWorld != null)
			{
				return _clientWorld.IsCreated;
			}
			if (_serverWorld != null)
			{
				return _serverWorld.IsCreated;
			}
			if (IsClient)
			{
				return GetWorld("Client_0") != null;
			}
			if (IsServer)
			{
				return GetWorld("Server") != null;
			}
			return false;
		}

		private static World GetWorld(string name)
		{
			Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == name)
				{
					_serverWorld = current;
					return current;
				}
			}
			return null;
		}
	}
}
namespace ProfuselyViolentProgression.SurgeSuppressor
{
	[BepInPlugin("SurgeSuppressor", "SurgeSuppressor", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		private Harmony _harmony;

		private HookDOTS _hookDOTS;

		private readonly SurgeSuppressorConfig cfg;

		public Plugin()
		{
			LogUtil.Init(((BasePlugin)this).Log);
			cfg = new SurgeSuppressorConfig(((BasePlugin)this).Config);
		}

		public override void Load()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			SurgeSuppressorUtil.SetSettings(cfg.OnlyProtectPlayers.Value, cfg.ThrottleIntervalMilliseconds.Value);
			_harmony = new Harmony("SurgeSuppressor");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			_hookDOTS = new HookDOTS("SurgeSuppressor", ((BasePlugin)this).Log);
			_hookDOTS.RegisterAnnotatedHooks();
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SurgeSuppressor");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.1");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
		}

		public override bool Unload()
		{
			_hookDOTS.Dispose();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
	public class MultiThrottle<TTarget>
	{
		private TimeSpan _interval;

		private Dictionary<TTarget, DateTime> _blockUntilTimes = new Dictionary<TTarget, DateTime>();

		public MultiThrottle(TimeSpan interval)
		{
			_interval = interval;
		}

		public MultiThrottle(int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0)
		{
			_interval = new TimeSpan(days, hours, minutes, seconds, milliseconds);
		}

		public void ChangeInterval(int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0)
		{
			TimeSpan interval = _interval;
			_interval = new TimeSpan(days, hours, minutes, seconds, milliseconds);
			TimeSpan timeSpan = _interval - interval;
			foreach (var (key, dateTime2) in _blockUntilTimes)
			{
				_blockUntilTimes[key] = dateTime2 + timeSpan;
			}
		}

		public bool CheckAndTrigger(TTarget target)
		{
			if (_blockUntilTimes.ContainsKey(target) && DateTime.Now < _blockUntilTimes[target])
			{
				return true;
			}
			_blockUntilTimes[target] = DateTime.Now.Add(_interval);
			return false;
		}

		public void Prune()
		{
			DateTime now = DateTime.Now;
			foreach (var (key, dateTime2) in _blockUntilTimes)
			{
				if (dateTime2 <= now)
				{
					_blockUntilTimes.Remove(key);
				}
			}
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		private static EntityManager EntityManager = WorldUtil.Game.EntityManager;

		private static EntityQuery Query_DealDamageEvent;

		[EcsSystemUpdatePrefix(typeof(RecursiveGroup), false)]
		public static void TickStartPrefix()
		{
			SurgeSuppressorUtil.NewTickStarted();
		}

		[HarmonyPatch(typeof(RecursiveGroup), "DoRecursiveUpdate")]
		[HarmonyPrefix]
		public static void TrackRecursiveUpdates()
		{
			SurgeSuppressorUtil.RecursiveGroupUpdateStarting();
		}

		[EcsSystemUpdatePostfix(typeof(HandleGameplayEventsRecursiveSystem), true)]
		public static void CheckDealDamageEvents()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if (Query_DealDamageEvent == default(EntityQuery))
			{
				EntityQueryDesc[] array = new EntityQueryDesc[1];
				EntityQueryDesc val = new EntityQueryDesc();
				val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<DealDamageEvent>() });
				array[0] = val;
				Query_DealDamageEvent = ((EntityManager)(ref EntityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
			}
			NativeArray<Entity> val2 = ((EntityQuery)(ref Query_DealDamageEvent)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			NativeArray<DealDamageEvent> val3 = ((EntityQuery)(ref Query_DealDamageEvent)).ToComponentDataArray<DealDamageEvent>(AllocatorHandle.op_Implicit((Allocator)2));
			for (int i = 0; i < val2.Length; i++)
			{
				SurgeSuppressorUtil.DamageWouldBeDealt(val2[i], val3[i]);
			}
		}
	}
	internal class SurgeSuppressorConfig
	{
		internal ConfigEntry<bool> OnlyProtectPlayers;

		internal ConfigEntry<int> ThrottleIntervalMilliseconds;

		internal SurgeSuppressorConfig(ConfigFile configFile)
		{
			OnlyProtectPlayers = configFile.Bind<bool>("General", "OnlyProtectPlayers", true, "If true, only players will be protected. If false, both mobs and players will be protected.");
			ThrottleIntervalMilliseconds = configFile.Bind<int>("General", "ThrottleIntervalMilliseconds", 250, "How long after a static shock, until a protected target can be shocked again.");
		}
	}
	public static class SurgeSuppressorUtil
	{
		public static int TickCount = 0;

		public static int RecursiveGroupPassesThisTick = 0;

		private static MultiThrottle<Entity> ShockThrottle = new MultiThrottle<Entity>(0, 0, 0, 0, 250);

		public static PrefabGUID Storm_Vampire_Buff_Static = new PrefabGUID(-1576512627);

		private static bool OnlyProtectPlayers = true;

		public static string RecursiveGroupTickStamp => $"{TickCount}-{RecursiveGroupPassesThisTick}";

		private static EntityManager EntityManager => WorldUtil.Game.EntityManager;

		public static void NewTickStarted()
		{
			TickCount++;
			RecursiveGroupPassesThisTick = 0;
			ShockThrottle.Prune();
		}

		public static void RecursiveGroupUpdateStarting()
		{
			RecursiveGroupPassesThisTick++;
		}

		public static void SetSettings(bool onlyProtectPlayers, int throttleIntervalMilliseconds)
		{
			OnlyProtectPlayers = onlyProtectPlayers;
			ShockThrottle.ChangeInterval(0, 0, 0, 0, throttleIntervalMilliseconds);
		}

		public static void DamageWouldBeDealt(Entity entity, DealDamageEvent dealDamageEvent)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if ((!OnlyProtectPlayers || IsPlayerCharacter(dealDamageEvent.Target)) && IsDamageSourcedFromStaticShock(dealDamageEvent) && ShockThrottle.CheckAndTrigger(dealDamageEvent.Target))
			{
				EntityManager entityManager = EntityManager;
				((EntityManager)(ref entityManager)).DestroyEntity(entity);
			}
		}

		public static bool IsDamageSourcedFromStaticShock(DealDamageEvent dealDamageEvent)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			EntityManager entityManager = EntityManager;
			if (!((EntityManager)(ref entityManager)).HasComponent<PrefabGUID>(dealDamageEvent.SpellSource))
			{
				return false;
			}
			entityManager = EntityManager;
			PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(dealDamageEvent.SpellSource);
			return ((PrefabGUID)(ref componentData)).Equals(Storm_Vampire_Buff_Static);
		}

		public static bool IsPlayerCharacter(Entity entity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(entity);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SurgeSuppressor";

		public const string PLUGIN_NAME = "SurgeSuppressor";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}