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 ChargerElectrocution v1.0.0
IdentityTheft.ChargerElectrocution.dll
Decompiled 2 years 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 ChargerElectrocution.MonoBehaviours; using ChargerElectrocution.Patches; using GameNetcodeStuff; using Microsoft.CodeAnalysis; using On; 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: AssemblyCompany("IdentityTheft.ChargerElectrocution")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0334730083a9df1435fe6462dc67772c8b438f08")] [assembly: AssemblyProduct("ChargerElectrocution")] [assembly: AssemblyTitle("IdentityTheft.ChargerElectrocution")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 ChargerElectrocution { [BepInPlugin("IdentityTheft.ChargerElectrocution", "ChargerElectrocution", "1.0.0")] public class ChargerElectrocution : BaseUnityPlugin { public static ChargerElectrocution Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; global::ChargerElectrocution.Patches.ItemChargerElectrocution.Load(); Logger.LogInfo((object)"IdentityTheft.ChargerElectrocution v1.0.0 has loaded!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "IdentityTheft.ChargerElectrocution"; public const string PLUGIN_NAME = "ChargerElectrocution"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ChargerElectrocution.Patches { public class ItemChargerElectrocution { [CompilerGenerated] private static class <>O { public static hook_ChargeItem <0>__ItemCharger_ChargeItem; public static hook_Update <1>__ItemCharger_Update; public static hook_Start <2>__GameNetworkManager_Start; } public static void Load() { //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_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown object obj = <>O.<0>__ItemCharger_ChargeItem; if (obj == null) { hook_ChargeItem val = ItemCharger_ChargeItem; <>O.<0>__ItemCharger_ChargeItem = val; obj = (object)val; } ItemCharger.ChargeItem += (hook_ChargeItem)obj; object obj2 = <>O.<1>__ItemCharger_Update; if (obj2 == null) { hook_Update val2 = ItemCharger_Update; <>O.<1>__ItemCharger_Update = val2; obj2 = (object)val2; } ItemCharger.Update += (hook_Update)obj2; object obj3 = <>O.<2>__GameNetworkManager_Start; if (obj3 == null) { hook_Start val3 = GameNetworkManager_Start; <>O.<2>__GameNetworkManager_Start = val3; obj3 = (object)val3; } GameNetworkManager.Start += (hook_Start)obj3; } private static void GameNetworkManager_Start(orig_Start orig, GameNetworkManager self) { orig.Invoke(self); NetworkManager component = ((Component)self).GetComponent<NetworkManager>(); object obj; if (component == null) { obj = null; } else { NetworkConfig networkConfig = component.NetworkConfig; if (networkConfig == null) { obj = null; } else { NetworkPrefabs prefabs = networkConfig.Prefabs; obj = ((prefabs != null) ? prefabs.Prefabs : null); } } IReadOnlyList<NetworkPrefab> readOnlyList = (IReadOnlyList<NetworkPrefab>)obj; if (readOnlyList == null) { return; } foreach (NetworkPrefab item in readOnlyList) { GameObject val = item?.Prefab; if (val != null && val.GetComponent<GrabbableObject>()?.itemProperties?.isConductiveMetal == true) { val.AddComponent<global::ChargerElectrocution.MonoBehaviours.ItemChargerElectrocution>(); } } } private static void ItemCharger_Update(orig_Update orig, ItemCharger self) { orig.Invoke(self); if (self.updateInterval == 0f && !((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)) { self.triggerScript.interactable = (Object)(object)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer != (Object)null && (GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties.requiresBattery || GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties.isConductiveMetal); } } private static void ItemCharger_ChargeItem(orig_ChargeItem orig, ItemCharger self) { GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null) { return; } if (!currentlyHeldObjectServer.itemProperties.requiresBattery) { if (currentlyHeldObjectServer.itemProperties.isConductiveMetal) { ((Component)currentlyHeldObjectServer).GetComponent<global::ChargerElectrocution.MonoBehaviours.ItemChargerElectrocution>().Electrocute(self); } } else { orig.Invoke(self); } } } } namespace ChargerElectrocution.MonoBehaviours { public class ItemChargerElectrocution : NetworkBehaviour { private Coroutine? _electrocutionCoroutine; public AudioSource? strikeAudio; public ParticleSystem? strikeParticle; public void Electrocute(ItemCharger socket) { Debug.Log((object)"Attempting electrocution"); if (_electrocutionCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_electrocutionCoroutine); } _electrocutionCoroutine = ((MonoBehaviour)this).StartCoroutine(ElectrocutionDelayed(socket)); } public void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) StormyWeather val = Object.FindObjectOfType<StormyWeather>(true); GameObject gameObject = ((Component)val.targetedStrikeAudio).gameObject; strikeAudio = Object.Instantiate<GameObject>(gameObject, ((Component)this).transform).GetComponent<AudioSource>(); ((Component)strikeAudio).transform.localPosition = Vector3.zero; ((Component)strikeAudio).gameObject.SetActive(true); strikeParticle = Object.Instantiate<GameObject>(((Component)val.explosionEffectParticle).gameObject, ((Component)this).transform).GetComponent<ParticleSystem>(); ((Component)strikeParticle).transform.localPosition = Vector3.zero; ((Component)strikeParticle).gameObject.SetActive(true); } private IEnumerator ElectrocutionDelayed(ItemCharger socket) { ChargerElectrocution.Logger.LogInfo((object)"Electrocution started"); socket.zapAudio.Play(); yield return (object)new WaitForSeconds(0.75f); socket.chargeStationAnimator.SetTrigger("zap"); if (((NetworkBehaviour)this).NetworkObject.IsOwner) { if (!((NetworkBehaviour)this).NetworkObject.IsOwnedByServer) { ElectrocutedServerRpc(((Component)this).transform.position); yield break; } ElectrocutedClientRpc(((Component)this).transform.position); Electrocuted(((Component)this).transform.position); } } private void Electrocuted(Vector3 position) { //IL_0009: 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) StormyWeather val = Object.FindObjectOfType<StormyWeather>(true); CreateExplosion(position); ParticleSystem? obj = strikeParticle; if (obj != null) { obj.Play(); } val.PlayThunderEffects(position, strikeAudio); } private void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) float num = 5f; ChargerElectrocution.Logger.LogInfo((object)"Spawning explosion at pos: {explosionPosition}"); if (spawnExplosionEffect) { GameObject explosionPrefab = StartOfRound.Instance.explosionPrefab; Quaternion val = Quaternion.Euler(-90f, 0f, 0f); RoundManager instance = RoundManager.Instance; object obj; if (instance == null) { obj = null; } else { GameObject mapPropsContainer = instance.mapPropsContainer; obj = ((mapPropsContainer != null) ? mapPropsContainer.transform : null); } Object.Instantiate<GameObject>(explosionPrefab, explosionPosition, val, (Transform)obj).SetActive(true); } float num2 = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition); float num3 = num2; float num4 = num3; if (!(num4 < 14f)) { if (num4 < 25f) { HUDManager.Instance.ShakeCamera((ScreenShakeType)0); } } else { HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } Collider[] array = Physics.OverlapSphere(explosionPosition, num, 2621448, (QueryTriggerInteraction)2); foreach (Collider val2 in array) { float num5 = Vector3.Distance(explosionPosition, ((Component)val2).transform.position); if ((!(num5 > 4f) || !Physics.Linecast(explosionPosition, ((Component)val2).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) && ((Component)val2).gameObject.layer == 3) { PlayerControllerB component = ((Component)val2).gameObject.GetComponent<PlayerControllerB>(); if (Object.op_Implicit((Object)(object)component) && ((NetworkBehaviour)component).IsOwner) { component.DamagePlayer((int)(20f * (1f - Mathf.Clamp01(num5 / num))), true, true, (CauseOfDeath)11, 0, false, default(Vector3)); break; } } } Collider[] array2 = Physics.OverlapSphere(explosionPosition, 10f, ~LayerMask.GetMask(new string[1] { "Colliders" })); foreach (Collider val3 in array2) { Rigidbody component2 = ((Component)val3).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component2)) { component2.AddExplosionForce(70f, explosionPosition, 10f); } } } [ServerRpc] private void ElectrocutedServerRpc(Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ElectrocutedClientRpc(position); } [ClientRpc] private void ElectrocutedClientRpc(Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Electrocuted(position); } } }