using System;
using System.Collections;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UsefulZapGun.Methods;
using UsefulZapGun.NetcodePatcher;
using UsefulZapGun.Network;
using UsefulZapGun.Patches;
using UsefulZapGun.Patches.Enemy;
using UsefulZapGun.Patches.Items;
using UsefulZapGun.Scripts.Hazards;
using UsefulZapGun.Scripts.Items;
[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("UsefulZapGun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+99ffbb5faa8bfcaaa771c91bd3c77d36c6e96d3b")]
[assembly: AssemblyProduct("UsefulZapGun")]
[assembly: AssemblyTitle("UsefulZapGun")]
[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 UsefulZapGun
{
internal class UZGConfig
{
private static ConfigFile cfg;
internal static ConfigEntry<bool> enableLogging;
internal static ConfigEntry<int> zapgunPrice;
internal static ConfigEntry<bool> enableDifficultyMultiplierPatch;
internal static ConfigEntry<float> distanceDivider;
internal static ConfigEntry<string> enemyListString;
internal static Dictionary<Item, ConfigEntry<float>> multiplayerDict = new Dictionary<Item, ConfigEntry<float>>();
internal static List<string> enemyList;
internal static Dictionary<EnemyType, ConfigEntry<float>> timeDict = new Dictionary<EnemyType, ConfigEntry<float>>();
internal static ConfigEntry<bool> enableExplosion;
internal static ConfigEntry<bool> setForestGiantsOnFire;
internal static ConfigEntry<float> timeToStartAFire;
internal static ConfigEntry<bool> evaporateBlob;
internal static ConfigEntry<float> timeToEvaporate;
internal static ConfigEntry<bool> enableDOTEnemy;
internal static ConfigEntry<bool> enableDOTPlayers;
internal static ConfigEntry<int> zapDamage;
internal static ConfigEntry<int> zapDamageToPlayer;
internal static ConfigEntry<float> zapTimeToDamage;
internal static ConfigEntry<bool> enableItemCharging;
internal static ConfigEntry<float> chargeLifeTime;
internal static ConfigEntry<bool> enableWeaponCharging;
internal static ConfigEntry<float> needForShovelCharge;
internal static ConfigEntry<bool> enableZapHazards;
internal static ConfigEntry<float> timeNeedForTurretDisable;
internal static ConfigEntry<int> spiketrapZapNeeded;
internal static void ConfigSetup(ConfigFile PluginConfig)
{
cfg = PluginConfig;
enableLogging = cfg.Bind<bool>("General", "Enable logging", true, (ConfigDescription)null);
zapgunPrice = cfg.Bind<int>("General", "Zap gun price", 400, (ConfigDescription)null);
enableDifficultyMultiplierPatch = cfg.Bind<bool>("General", "Enable Difficulty Multiplier Patch", true, "Formula: result = vanilaValue * Distance(localPlayer, enemy)/distanceDivider");
distanceDivider = cfg.Bind<float>("General", "Distance Divider", 5f, (ConfigDescription)null);
setForestGiantsOnFire = cfg.Bind<bool>("Enemies", "Set forest giants on fire", true, (ConfigDescription)null);
timeToStartAFire = cfg.Bind<float>("Enemies", "Time to start a fire", 3f, (ConfigDescription)null);
evaporateBlob = cfg.Bind<bool>("Enemies", "Evaporate blob", true, (ConfigDescription)null);
enemyListString = cfg.Bind<string>("Enemies", "Enemy list", "Red Locust Bees,Butler Bees", (ConfigDescription)null);
enableExplosion = cfg.Bind<bool>("Enemies", "Enable enemy explosion", true, (ConfigDescription)null);
enableDOTEnemy = cfg.Bind<bool>("DOT", "Damage enemy with zap", false, (ConfigDescription)null);
enableDOTPlayers = cfg.Bind<bool>("DOT", "Damage players with zap", false, (ConfigDescription)null);
zapDamage = cfg.Bind<int>("DOT", "Zapgun damage to enemy", 1, (ConfigDescription)null);
zapDamageToPlayer = cfg.Bind<int>("DOT", "Zapgun damage to player", 10, (ConfigDescription)null);
zapTimeToDamage = cfg.Bind<float>("DOT", "Time to damage (seconds)", 1f, (ConfigDescription)null);
enemyList = enemyListString.Value.Split(',').ToList();
enableItemCharging = cfg.Bind<bool>("Items", "Enable equipment charging", true, "Charging ratio: chargeMultiplier * (Time.deltaTime / item.itemProperties.batteryUsage)");
enableWeaponCharging = cfg.Bind<bool>("Weapon", "Enable weapon charging", true, "x2 damage for charged weapon (shovel, stop sign, mace (code rebirth), etc.");
chargeLifeTime = cfg.Bind<float>("Weapon", "Time until charge runs out", 15f, (ConfigDescription)null);
needForShovelCharge = cfg.Bind<float>("Weapon", "Zap gun charge% for charged state", 33f, (ConfigDescription)null);
enableZapHazards = cfg.Bind<bool>("Hazards", "Enable hazard zap", true, (ConfigDescription)null);
timeNeedForTurretDisable = cfg.Bind<float>("Hazards", "Time need for turret", 3f, (ConfigDescription)null);
spiketrapZapNeeded = cfg.Bind<int>("Hazards", "Zaps before deactivating the spiketrap", 2, (ConfigDescription)null);
CheckConfig();
}
private static void CheckConfig()
{
enemyList.Remove("Bruce");
if (zapDamage.Value <= 0)
{
zapDamage.Value = 1;
}
}
internal static void CreateAndCheckConfigEntryForItem(Item item, float multiplayer)
{
ConfigEntry<float> value = cfg.Bind<float>("Items", item.itemName + ": charge multiplayer", multiplayer, (ConfigDescription)null);
multiplayerDict.TryAdd(item, value);
}
internal static void CreateAndCheckConfigEntryForEnemy(EnemyType enemy, float time)
{
ConfigEntry<float> val = cfg.Bind<float>("Enemies", enemy.enemyName + ": time needed for explosion", time, (ConfigDescription)null);
if (val.Value <= 0f)
{
val.Value = 1f;
}
timeDict.TryAdd(enemy, val);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("mborsh.UsefulZapGun", "UsefulZapGun", "0.4.1")]
public class Plugin : BaseUnityPlugin
{
internal enum spamType
{
info,
message,
warning,
debug,
error,
fatal
}
private const string modGUID = "mborsh.UsefulZapGun";
private const string modName = "UsefulZapGun";
private const string modVersion = "0.4.1";
private readonly Harmony harmony = new Harmony("mborsh.UsefulZapGun");
private static ManualLogSource mls;
private static Plugin Instance;
internal static bool enemiesAndItemsFound;
private static string sAssemblyLocation;
public static AssetBundle mainAssetBundle;
private static ConfigFile cfg;
private static void NetcodePatcher()
{
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);
}
}
}
}
private void Awake()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
NetcodePatcher();
Instance = this;
mls = Logger.CreateLogSource("UsefulZapGun");
mls = ((BaseUnityPlugin)this).Logger;
sAssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
mainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(sAssemblyLocation, "zapgunnetworkobject"));
cfg = new ConfigFile(Path.Combine(Paths.ConfigPath, "mborsh.UsefulZapGun.cfg"), true);
UZGConfig.ConfigSetup(cfg);
mls.LogInfo((object)"UsefulZapGun 0.4.1 loaded. Patching.");
PatchAllStuff();
}
internal static void SpamLog(string message, spamType type)
{
if (UZGConfig.enableLogging.Value)
{
switch (type)
{
case spamType.info:
mls.LogInfo((object)message);
break;
case spamType.message:
mls.LogMessage((object)message);
break;
case spamType.warning:
mls.LogWarning((object)message);
break;
case spamType.debug:
mls.LogDebug((object)message);
break;
case spamType.error:
mls.LogError((object)message);
break;
case spamType.fatal:
mls.LogFatal((object)message);
break;
}
}
}
private void PatchAllStuff()
{
harmony.PatchAll(typeof(GameNetworkManagerPatch));
harmony.PatchAll(typeof(MenuManagerPatch));
harmony.PatchAll(typeof(PlayerControllerBPatch));
harmony.PatchAll(typeof(TerminalPatch));
harmony.PatchAll(typeof(EnemyAICollisionDetectPatch));
harmony.PatchAll(typeof(EnemyAIPatch));
harmony.PatchAll(typeof(PatcherToolPatch));
if (UZGConfig.enableZapHazards.Value)
{
harmony.PatchAll(typeof(MapHazardsPatch));
}
if (UZGConfig.enableWeaponCharging.Value)
{
harmony.PatchAll(typeof(ShovelPatch));
}
if (UZGConfig.enableItemCharging.Value)
{
harmony.PatchAll(typeof(GrabbableObjectPatch));
}
}
}
}
namespace UsefulZapGun.Scripts.Items
{
internal class ConductiveShockableScript : MonoBehaviour, IShockableWithGun
{
private GrabbableObject itemScript;
private void Start()
{
itemScript = ((Component)this).GetComponent<GrabbableObject>();
}
public bool CanBeShocked()
{
return (Object)(object)itemScript.playerHeldBy == (Object)null;
}
public float GetDifficultyMultiplier()
{
return 0f;
}
public NetworkObject GetNetworkObject()
{
return ((NetworkBehaviour)itemScript).NetworkObject;
}
public Vector3 GetShockablePosition()
{
//IL_000c: 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_002a: 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)
return ((Component)itemScript).transform.position + new Vector3(0f, 0.2f, 0f);
}
public Transform GetShockableTransform()
{
return ((Component)this).transform;
}
public void ShockWithGun(PlayerControllerB shockedByPlayer)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
Plugin.SpamLog("Shock conductive item (" + itemScript.itemProperties.itemName + ")", Plugin.spamType.message);
if (!((Object)(object)shockedByPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController))
{
itemScript.grabbable = false;
PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
((MonoBehaviour)this).StartCoroutine(WaitFrameAndDamage(zapgun, shockedByPlayer));
}
}
private IEnumerator WaitFrameAndDamage(PatcherTool zapgun, PlayerControllerB shockedByPlayer)
{
yield return (object)new WaitForEndOfFrame();
yield return (object)new WaitForEndOfFrame();
zapgun.StopShockingAnomalyOnClient(true);
yield return (object)new WaitForEndOfFrame();
shockedByPlayer.DamagePlayer(15, true, true, (CauseOfDeath)11, 0, false, default(Vector3));
}
public void StopShockingWithGun()
{
itemScript.grabbable = true;
}
}
internal class EquipmentShockableScript : MonoBehaviour, IShockableWithGun
{
private GrabbableObject itemScript;
private float chargeMultiplier;
private Coroutine chargeCoroutine;
private void Start()
{
itemScript = ((Component)this).GetComponent<GrabbableObject>();
string itemName = itemScript.itemProperties.itemName;
chargeMultiplier = UZGConfig.multiplayerDict[itemScript.itemProperties].Value;
}
public bool CanBeShocked()
{
return itemScript.insertedBattery.charge < 1f && (Object)(object)itemScript.playerHeldBy == (Object)null;
}
public float GetDifficultyMultiplier()
{
return 0.3f;
}
public NetworkObject GetNetworkObject()
{
return ((NetworkBehaviour)itemScript).NetworkObject;
}
public Vector3 GetShockablePosition()
{
//IL_000c: 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_002a: 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)
return ((Component)itemScript).transform.position + new Vector3(0f, 0.2f, 0f);
}
public Transform GetShockableTransform()
{
return ((Component)this).transform;
}
public void ShockWithGun(PlayerControllerB shockedByPlayer)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
Plugin.SpamLog("Shock item with battery (" + itemScript.itemProperties.itemName + ")", Plugin.spamType.message);
itemScript.grabbable = false;
PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
chargeCoroutine = ((MonoBehaviour)this).StartCoroutine(ChargeItem(zapgun, itemScript));
}
public void StopShockingWithGun()
{
((MonoBehaviour)this).StopCoroutine(chargeCoroutine);
itemScript.grabbable = true;
Plugin.SpamLog($"charge = {itemScript.insertedBattery.charge}", Plugin.spamType.debug);
itemScript.SyncBatteryServerRpc((int)(itemScript.insertedBattery.charge * 100f));
}
private IEnumerator ChargeItem(PatcherTool zapgun, GrabbableObject item)
{
if (item.insertedBattery.empty)
{
item.insertedBattery.empty = false;
}
while (item.insertedBattery.charge < 1f)
{
yield return (object)new WaitForEndOfFrame();
Battery insertedBattery = item.insertedBattery;
insertedBattery.charge += chargeMultiplier * (Time.deltaTime / item.itemProperties.batteryUsage);
}
zapgun.StopShockingAnomalyOnClient(true);
}
}
internal class WeaponShockableScript : MonoBehaviour, IShockableWithGun
{
private Shovel itemScript;
private bool charged;
private Coroutine chargeCoroutine;
private float batteryChargeNeedUntilChargedState;
private void Start()
{
itemScript = ((Component)this).GetComponent<Shovel>();
charged = false;
batteryChargeNeedUntilChargedState = UZGConfig.needForShovelCharge.Value / 100f;
}
public bool CanBeShocked()
{
return (Object)(object)((GrabbableObject)itemScript).playerHeldBy == (Object)null && !charged;
}
public float GetDifficultyMultiplier()
{
return 0.3f;
}
public NetworkObject GetNetworkObject()
{
return ((NetworkBehaviour)itemScript).NetworkObject;
}
public Vector3 GetShockablePosition()
{
//IL_000c: 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_002a: 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)
return ((Component)itemScript).transform.position + new Vector3(0f, 0.2f, 0f);
}
public Transform GetShockableTransform()
{
return ((Component)this).transform;
}
public void ShockWithGun(PlayerControllerB shockedByPlayer)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Plugin.SpamLog("Shock weapon (" + ((GrabbableObject)itemScript).itemProperties.itemName + ")", Plugin.spamType.message);
PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
if (charged)
{
WaitFrameAndDamage(zapgun, shockedByPlayer);
return;
}
chargeCoroutine = ((MonoBehaviour)this).StartCoroutine(ChargeWeapon(zapgun));
((GrabbableObject)itemScript).grabbable = false;
}
public void StopShockingWithGun()
{
if (chargeCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(chargeCoroutine);
}
((GrabbableObject)itemScript).grabbable = true;
}
private IEnumerator WaitFrameAndDamage(PatcherTool zapgun, PlayerControllerB shockedByPlayer)
{
yield return (object)new WaitForEndOfFrame();
yield return (object)new WaitForEndOfFrame();
zapgun.StopShockingAnomalyOnClient(true);
yield return (object)new WaitForEndOfFrame();
shockedByPlayer.DamagePlayer(15, true, true, (CauseOfDeath)11, 0, false, default(Vector3));
}
private IEnumerator ChargeWeapon(PatcherTool zapgun)
{
float chargeNeeded = ((GrabbableObject)zapgun).insertedBattery.charge - batteryChargeNeedUntilChargedState;
while (((GrabbableObject)zapgun).insertedBattery.charge > 0f && ((GrabbableObject)zapgun).insertedBattery.charge >= chargeNeeded)
{
yield return (object)new WaitForEndOfFrame();
}
NetworkObjectReference shovelNORef = new NetworkObjectReference(GetNetworkObject());
GameNetworkManagerPatch.hostNetHandler.SyncShovelDamageServerRpc(shovelNORef);
zapgun.StopShockingAnomalyOnClient(true);
}
private IEnumerator WaitUntilChargeRunsOut(float seconds)
{
yield return (object)new WaitForSeconds(seconds);
charged = false;
Shovel obj = itemScript;
obj.shovelHitForce /= 2;
}
internal void SyncDamageOnLocalClient(float seconds = 0f)
{
charged = true;
Shovel obj = itemScript;
obj.shovelHitForce *= 2;
((MonoBehaviour)this).StartCoroutine(WaitUntilChargeRunsOut(seconds));
}
}
}
namespace UsefulZapGun.Scripts.Hazards
{
internal class LandmineShockableScript : MonoBehaviour, IShockableWithGun
{
private Landmine mineScript;
private bool isShocked;
private void Start()
{
mineScript = ((Component)this).GetComponent<Landmine>();
}
public bool CanBeShocked()
{
return !mineScript.hasExploded && !isShocked;
}
public float GetDifficultyMultiplier()
{
return 0f;
}
public NetworkObject GetNetworkObject()
{
return ((NetworkBehaviour)mineScript).NetworkObject;
}
public Vector3 GetShockablePosition()
{
//IL_000c: 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_002a: 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)
return ((Component)mineScript).transform.position + new Vector3(0f, 0.5f, 0f);
}
public Transform GetShockableTransform()
{
return ((Component)this).transform;
}
public void ShockWithGun(PlayerControllerB shockedByPlayer)
{
Plugin.SpamLog("Shock landmine", Plugin.spamType.message);
isShocked = (Object)(object)shockedByPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController;
}
public void StopShockingWithGun()
{
mineScript.ExplodeMineServerRpc();
}
}
internal class SpiketrapShockableScript : MonoBehaviour, IShockableWithGun
{
internal int zapCount;
private SpikeRoofTrap spikeScript;
private Coroutine coroutine;
private bool localPlayer;
private void Start()
{
zapCount = 0;
spikeScript = ((Component)((Component)this).transform.parent.Find("Trigger")).GetComponent<SpikeRoofTrap>();
}
public bool CanBeShocked()
{
return spikeScript.trapActive && !localPlayer;
}
public float GetDifficultyMultiplier()
{
return 0.4f;
}
public NetworkObject GetNetworkObject()
{
return ((NetworkBehaviour)spikeScript).NetworkObject;
}
public Vector3 GetShockablePosition()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
return ((Component)this).transform.position;
}
public Transform GetShockableTransform()
{
return ((Component)this).transform;
}
public void ShockWithGun(PlayerControllerB shockedByPlayer)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
Plugin.SpamLog("Shock spiketrap", Plugin.spamType.message);
PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
coroutine = ((MonoBehaviour)this).StartCoroutine(WaitAndStopShocking(zapgun));
localPlayer = (Object)(object)shockedByPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController;
}
public void StopShockingWithGun()
{
if (coroutine != null)
{
((MonoBehaviour)this).StopCoroutine(coroutine);
}
localPlayer = false;
}
internal void SyncCanShockOnLocalClient(bool sync)
{
spikeScript.trapActive = sync;
((Behaviour)((Component)this).GetComponent<Light>()).enabled = sync;
}
private IEnumerator WaitAndStopShocking(PatcherTool zapgun)
{
yield return (object)new WaitForSeconds(1f);
if (zapgun.shockedTargetScript == this && ((GrabbableObject)zapgun).isBeingUsed && localPlayer)
{
NetworkObjectReference NORef = new NetworkObjectReference(GetNetworkObject());
GameNetworkManagerPatch.hostNetHandler.SyncZapCountServerRpc(NORef, zapCount + 1);
zapgun.StopShockingAnomalyOnClient(true);
}
}
}
internal class TurretShockableScript : MonoBehaviour, IShockableWithGun
{
private Turret turretScript;
private Coroutine coroutine;
private void Start()
{
turretScript = ((Component)this).GetComponent<Turret>();
}
public bool CanBeShocked()
{
return turretScript.turretActive;
}
public float GetDifficultyMultiplier()
{
return 0.9f;
}
public NetworkObject GetNetworkObject()
{
return ((NetworkBehaviour)turretScript).NetworkObject;
}
public Vector3 GetShockablePosition()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
return ((Component)this).transform.position;
}
public Transform GetShockableTransform()
{
return ((Component)this).transform;
}
public void ShockWithGun(PlayerControllerB shockedByPlayer)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
Plugin.SpamLog("Shock turret", Plugin.spamType.message);
PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
coroutine = ((MonoBehaviour)this).StartCoroutine(Wait(zapgun, shockedByPlayer));
}
public void StopShockingWithGun()
{
if (coroutine != null)
{
((MonoBehaviour)this).StopCoroutine(coroutine);
}
}
private IEnumerator Wait(PatcherTool zapgun, PlayerControllerB player)
{
yield return (object)new WaitForSeconds(UZGConfig.timeNeedForTurretDisable.Value);
if (zapgun.shockedTargetScript == this && ((GrabbableObject)zapgun).isBeingUsed)
{
((MonoBehaviour)this).StartCoroutine(BerserkAndDisable(player));
}
}
private IEnumerator BerserkAndDisable(PlayerControllerB player)
{
turretScript.turretMode = (TurretMode)3;
turretScript.EnterBerserkModeServerRpc((int)player.playerClientId);
yield return (object)new WaitForSeconds(10.4f);
yield return (object)new WaitForEndOfFrame();
turretScript.turretMode = (TurretMode)0;
yield return (object)new WaitForEndOfFrame();
turretScript.ToggleTurretServerRpc(false);
}
}
}
namespace UsefulZapGun.Patches
{
internal class GameNetworkManagerPatch
{
internal static GameObject netHandler;
internal static UZGNetwork hostNetHandler;
[HarmonyPrefix]
[HarmonyPatch(typeof(StartOfRound), "Start")]
public static void SpawnNetworkHandler()
{
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(netHandler);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Start")]
public static void FindNetworkHandler()
{
hostNetHandler = Object.FindAnyObjectByType<UZGNetwork>();
Plugin.SpamLog("hostNetHandler found", Plugin.spamType.debug);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
private static void AddPrefabsToNetwork()
{
netHandler = Plugin.mainAssetBundle.LoadAsset<GameObject>("zapgunnetworkobject.prefab");
netHandler.AddComponent<UZGNetwork>();
NetworkManager.Singleton.AddNetworkPrefab(netHandler);
}
}
internal class MapHazardsPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(Turret), "Start")]
private static void TurretStartPatch(ref Turret __instance)
{
((Component)__instance).gameObject.AddComponent<TurretShockableScript>();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Landmine), "Start")]
private static void LandmineStartPatch(ref Landmine __instance)
{
((Component)__instance).gameObject.AddComponent<LandmineShockableScript>();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SpikeRoofTrap), "Start")]
private static void SpiketrapStartPatch(ref SpikeRoofTrap __instance)
{
GameObject gameObject = ((Component)__instance).gameObject;
gameObject = ((Component)gameObject.transform.parent.Find("Spot Light")).gameObject;
BoxCollider val = gameObject.AddComponent<BoxCollider>();
((Collider)val).isTrigger = true;
gameObject.AddComponent<SpiketrapShockableScript>();
gameObject.layer = 21;
((Component)gameObject.transform.parent).gameObject.layer = 21;
((Component)gameObject.transform.parent.parent).gameObject.layer = 21;
((Component)gameObject.transform.parent.parent.parent).gameObject.layer = 21;
}
}
internal class MenuManagerPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(MenuManager), "Start")]
private static void FindAllEnemiesPatch()
{
if (Plugin.enemiesAndItemsFound)
{
return;
}
EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>();
EnemyType[] array2 = array;
foreach (EnemyType val in array2)
{
if (!string.IsNullOrEmpty(val.enemyName))
{
Plugin.SpamLog(val.enemyName + " has been found!", Plugin.spamType.message);
if (UZGConfig.enemyList.Contains(val.enemyName))
{
UZGConfig.CreateAndCheckConfigEntryForEnemy(val, 3f);
val.canBeStunned = true;
val.canBeDestroyed = true;
Plugin.SpamLog(val.enemyName + " can be stunned and destoyed now!", Plugin.spamType.info);
}
}
}
Plugin.SpamLog("---------------------------------------------------------", Plugin.spamType.message);
if (UZGConfig.enableItemCharging.Value)
{
Item[] array3 = Resources.FindObjectsOfTypeAll<Item>();
Item[] array4 = array3;
foreach (Item val2 in array4)
{
if (val2.requiresBattery && !string.IsNullOrEmpty(val2.itemName))
{
UZGConfig.CreateAndCheckConfigEntryForItem(val2, val2.batteryUsage / 22f);
Plugin.SpamLog(val2.itemName + " has been found!", Plugin.spamType.message);
}
}
}
Plugin.enemiesAndItemsFound = true;
}
}
internal class PlayerControllerBPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "IShockableWithGun.ShockWithGun")]
private static void ShockWithGunPatch(ref PlayerControllerB __instance, PlayerControllerB shockedByPlayer)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
Plugin.SpamLog("Shock Player", Plugin.spamType.message);
if (UZGConfig.enableDOTPlayers.Value)
{
NetworkBehaviourReference val = default(NetworkBehaviourReference);
((NetworkBehaviourReference)(ref val))..ctor((NetworkBehaviour)(object)__instance);
GameNetworkManagerPatch.hostNetHandler.DOTPlayerServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)__instance), (int)shockedByPlayer.playerClientId);
}
}
}
internal class TerminalPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(Terminal), "Awake")]
[HarmonyPriority(200)]
private static void AwakePatch(ref Terminal __instance)
{
Item[] buyableItemsList = __instance.buyableItemsList;
foreach (Item val in buyableItemsList)
{
if (val.itemName == "Zap gun")
{
val.creditsWorth = UZGConfig.zapgunPrice.Value;
Plugin.SpamLog("Zap gun price: " + val.creditsWorth, Plugin.spamType.message);
break;
}
}
}
}
}
namespace UsefulZapGun.Patches.Items
{
internal class GrabbableObjectPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(GrabbableObject), "Start")]
private static void StartPatch(ref GrabbableObject __instance)
{
if (!(__instance is Shovel))
{
EquipmentShockableScript equipmentShockableScript = default(EquipmentShockableScript);
ConductiveShockableScript conductiveShockableScript = default(ConductiveShockableScript);
if (__instance.itemProperties.requiresBattery && !((Component)__instance).gameObject.TryGetComponent<EquipmentShockableScript>(ref equipmentShockableScript) && __instance.itemProperties.requiresBattery)
{
((Component)__instance).gameObject.AddComponent<EquipmentShockableScript>();
}
else if (!((Component)__instance).gameObject.TryGetComponent<ConductiveShockableScript>(ref conductiveShockableScript) && __instance.itemProperties.isConductiveMetal)
{
((Component)__instance).gameObject.AddComponent<ConductiveShockableScript>();
}
}
}
}
internal class PatcherToolPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PatcherTool), "BeginShockingAnomalyOnClient")]
private static void AddZapGun(ref PatcherTool __instance)
{
ZapGunMethods.zapGuns.Add(__instance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PatcherTool), "StopShockingAnomalyOnClient")]
private static void RemoveZapGun(ref PatcherTool __instance)
{
if (!ZapGunMethods.zapGuns.Remove(__instance))
{
Plugin.SpamLog($"Couldn't remove the zap gun! networkObjectID: {((NetworkBehaviour)__instance).NetworkObjectId}", Plugin.spamType.warning);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PatcherTool), "Start")]
private static void StartPatch(ref int ___anomalyMask)
{
___anomalyMask = 2621512;
}
}
internal class ShovelPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(GrabbableObject), "Start")]
private static void StartPatch(ref GrabbableObject __instance)
{
WeaponShockableScript weaponShockableScript = default(WeaponShockableScript);
if (__instance is Shovel && !((Component)__instance).gameObject.TryGetComponent<WeaponShockableScript>(ref weaponShockableScript))
{
((Component)__instance).gameObject.AddComponent<WeaponShockableScript>();
}
}
}
}
namespace UsefulZapGun.Patches.Enemy
{
internal class EnemyAICollisionDetectPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(EnemyAICollisionDetect), "IShockableWithGun.ShockWithGun")]
private static void ShockWithGunPatch(ref EnemyAICollisionDetect __instance, PlayerControllerB shockedByPlayer)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Expected O, but got Unknown
Plugin.SpamLog("Shock Enemy", Plugin.spamType.message);
if (UZGConfig.timeDict.ContainsKey(__instance.mainScript.enemyType) && UZGConfig.enableExplosion.Value)
{
ZapGunMethods.WaitAndExplode(__instance, __instance.mainScript, UZGConfig.timeDict[__instance.mainScript.enemyType].Value);
return;
}
NetworkBehaviourReference enemyNBRef = default(NetworkBehaviourReference);
((NetworkBehaviourReference)(ref enemyNBRef))..ctor((NetworkBehaviour)(object)__instance.mainScript);
NetworkBehaviourReference playerWhoHitNBRef = default(NetworkBehaviourReference);
((NetworkBehaviourReference)(ref playerWhoHitNBRef))..ctor((NetworkBehaviour)(object)shockedByPlayer);
GameNetworkManagerPatch.hostNetHandler.DOTEnemyServerRpc(enemyNBRef, playerWhoHitNBRef);
if (__instance.mainScript is ForestGiantAI && UZGConfig.setForestGiantsOnFire.Value && !UZGConfig.timeDict.ContainsKey(__instance.mainScript.enemyType))
{
ZapGunMethods.StartFire(__instance, (ForestGiantAI)__instance.mainScript);
}
else if (__instance.mainScript is BlobAI && UZGConfig.evaporateBlob.Value && !UZGConfig.timeDict.ContainsKey(__instance.mainScript.enemyType))
{
ZapGunMethods.StartEvaporation(__instance, (BlobAI)__instance.mainScript);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EnemyAICollisionDetect), "IShockableWithGun.GetDifficultyMultiplier")]
private static void GetDifficultyMultiplierPatch(ref EnemyAICollisionDetect __instance, ref float __result)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
if (UZGConfig.enableDifficultyMultiplierPatch.Value && UZGConfig.distanceDivider.Value != 0f)
{
Plugin.SpamLog("GetDifficultyMultilier before = " + __result, Plugin.spamType.debug);
__result *= Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)__instance.mainScript).transform.position) / UZGConfig.distanceDivider.Value;
Plugin.SpamLog("GetDifficultyMultilier after = " + __result, Plugin.spamType.debug);
}
}
}
internal class EnemyAIPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(EnemyAI), "KillEnemyServerRpc")]
private static void KillEnemyServerRpcPatch(ref EnemyAI __instance)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
foreach (PatcherTool zapGun in ZapGunMethods.zapGuns)
{
EnemyAICollisionDetect val = (EnemyAICollisionDetect)zapGun.shockedTargetScript;
if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)val.mainScript == (Object)(object)__instance)
{
zapGun.StopShockingAnomalyOnClient(true);
}
}
}
}
}
namespace UsefulZapGun.Network
{
internal class UZGNetwork : NetworkBehaviour
{
internal PatcherTool zapgun;
[ServerRpc(RequireOwnership = false)]
internal void BlowUpEnemyServerRpc(NetworkObjectReference enemyNORef)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: 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(2089966051u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref enemyNORef, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2089966051u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
NetworkObject val3 = default(NetworkObject);
if (((NetworkObjectReference)(ref enemyNORef)).TryGet(ref val3, (NetworkManager)null))
{
if (!UZGConfig.enemyList.Contains(((Component)val3).GetComponent<EnemyAI>().enemyType.enemyName))
{
Plugin.SpamLog("The client is trying to send an enemy that is not in the config!!!", Plugin.spamType.error);
}
else if (UZGConfig.enableExplosion.Value)
{
Vector3 position = ((Component)val3).gameObject.transform.position;
EnemyAI component = ((Component)val3).gameObject.GetComponent<EnemyAI>();
if (component.enemyType.canDie)
{
component.KillEnemyServerRpc(false);
}
else
{
component.KillEnemyServerRpc(true);
}
BlowUpEnemyClientRpc(position);
}
}
else
{
Plugin.SpamLog("The client is trying to send a non-existent enemy!!!", Plugin.spamType.error);
}
}
[ClientRpc]
private void BlowUpEnemyClientRpc(Vector3 position)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0089: 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)
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(1035235681u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1035235681u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
((MonoBehaviour)this).StartCoroutine(ZapGunMethods.ExplodeNextFrame(position));
}
}
}
[ServerRpc(RequireOwnership = false)]
internal void SyncShovelDamageServerRpc(NetworkObjectReference shovelNORef)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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)
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(3194388427u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref shovelNORef, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3194388427u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
NetworkObject val3 = default(NetworkObject);
if (((NetworkObjectReference)(ref shovelNORef)).TryGet(ref val3, (NetworkManager)null))
{
if (!UZGConfig.enableWeaponCharging.Value)
{
Plugin.SpamLog("The client is trying to charge a weapon!!!", Plugin.spamType.error);
return;
}
WeaponShockableScript component = ((Component)val3).gameObject.GetComponent<WeaponShockableScript>();
SyncShovelDamageClientRpc(shovelNORef, UZGConfig.chargeLifeTime.Value);
}
else
{
Plugin.SpamLog("The client is trying to send a non-existent shovel!!!", Plugin.spamType.error);
}
}
[ClientRpc]
private void SyncShovelDamageClientRpc(NetworkObjectReference shovelNORef, float seconds)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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(1596931241u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref shovelNORef, default(ForNetworkSerializable));
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref seconds, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1596931241u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
NetworkObject val3 = default(NetworkObject);
((NetworkObjectReference)(ref shovelNORef)).TryGet(ref val3, (NetworkManager)null);
((Component)val3).GetComponent<WeaponShockableScript>().SyncDamageOnLocalClient(seconds);
}
}
}
[ClientRpc]
private void SyncCanShockSpikeClientRpc(NetworkObjectReference obj, bool canShock)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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(1887262031u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref canShock, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1887262031u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
NetworkObject val3 = default(NetworkObject);
((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null);
SpiketrapShockableScript componentInChildren = ((Component)val3).GetComponentInChildren<SpiketrapShockableScript>();
componentInChildren.SyncCanShockOnLocalClient(canShock);
}
}
}
[ServerRpc(RequireOwnership = false)]
internal void SyncZapCountServerRpc(NetworkObjectReference obj, int zapCount)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: 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(23251114u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
BytePacker.WriteValueBitPacked(val2, zapCount);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 23251114u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
if (zapCount >= UZGConfig.spiketrapZapNeeded.Value)
{
SyncCanShockSpikeClientRpc(obj, canShock: false);
}
SyncZapCountClientRpc(obj, zapCount);
}
}
[ClientRpc]
private void SyncZapCountClientRpc(NetworkObjectReference obj, int zapCount)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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(2552547060u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
BytePacker.WriteValueBitPacked(val2, zapCount);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2552547060u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
NetworkObject val3 = default(NetworkObject);
((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null);
SpiketrapShockableScript componentInChildren = ((Component)val3).GetComponentInChildren<SpiketrapShockableScript>();
if (componentInChildren.zapCount > zapCount)
{
SyncZapCountServerRpc(obj, componentInChildren.zapCount + 1);
}
else
{
componentInChildren.zapCount = zapCount;
}
}
}
[ServerRpc(RequireOwnership = false)]
internal void DOTPlayerServerRpc(NetworkBehaviourReference playerNBRef, int playerWhoHit)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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)
//IL_00a4: 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(2387514609u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerNBRef, default(ForNetworkSerializable));
BytePacker.WriteValueBitPacked(val2, playerWhoHit);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2387514609u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
PlayerControllerB val3 = default(PlayerControllerB);
if (((NetworkBehaviourReference)(ref playerNBRef)).TryGet<PlayerControllerB>(ref val3, (NetworkManager)null))
{
if (!UZGConfig.enableDOTPlayers.Value || UZGConfig.zapDamageToPlayer.Value == 0)
{
return;
}
foreach (PatcherTool zapGun in ZapGunMethods.zapGuns)
{
if (((GrabbableObject)zapGun).isBeingUsed && zapGun.shockedTargetScript == val3)
{
zapgun = zapGun;
}
}
((MonoBehaviour)this).StartCoroutine(DOT.DOTPlayer(val3, playerWhoHit, UZGConfig.zapDamageToPlayer.Value, UZGConfig.zapTimeToDamage.Value, zapgun));
}
else
{
Plugin.SpamLog("Can't find targetedPlayer!!!", Plugin.spamType.error);
}
}
[ServerRpc(RequireOwnership = false)]
internal void DOTEnemyServerRpc(NetworkBehaviourReference enemyNBRef, NetworkBehaviourReference playerWhoHitNBRef)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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(2311549797u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref enemyNBRef, default(ForNetworkSerializable));
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerWhoHitNBRef, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2311549797u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
EnemyAI val3 = default(EnemyAI);
if (((NetworkBehaviourReference)(ref enemyNBRef)).TryGet<EnemyAI>(ref val3, (NetworkManager)null))
{
PlayerControllerB playerWhoHit = default(PlayerControllerB);
if (((NetworkBehaviourReference)(ref playerWhoHitNBRef)).TryGet<PlayerControllerB>(ref playerWhoHit, (NetworkManager)null))
{
if (!UZGConfig.enableDOTEnemy.Value)
{
return;
}
EnemyAICollisionDetect componentInChildren = ((Component)val3).GetComponentInChildren<EnemyAICollisionDetect>();
if ((Object)(object)componentInChildren == (Object)null)
{
Plugin.SpamLog("Can't find EnemyAICollisionDetect!!!", Plugin.spamType.error);
return;
}
foreach (PatcherTool zapGun in ZapGunMethods.zapGuns)
{
if (((GrabbableObject)zapGun).isBeingUsed && zapGun.shockedTargetScript == componentInChildren)
{
zapgun = zapGun;
}
}
((MonoBehaviour)this).StartCoroutine(DOT.DOTEnemy(componentInChildren, playerWhoHit, UZGConfig.zapDamage.Value, UZGConfig.zapTimeToDamage.Value, zapgun));
}
else
{
Plugin.SpamLog("Can't find playerWhoHit!!!", Plugin.spamType.error);
}
}
else
{
Plugin.SpamLog("The client is trying to send a non-existent enemy!!!", Plugin.spamType.error);
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_UZGNetwork()
{
//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
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(2089966051u, new RpcReceiveHandler(__rpc_handler_2089966051));
NetworkManager.__rpc_func_table.Add(1035235681u, new RpcReceiveHandler(__rpc_handler_1035235681));
NetworkManager.__rpc_func_table.Add(3194388427u, new RpcReceiveHandler(__rpc_handler_3194388427));
NetworkManager.__rpc_func_table.Add(1596931241u, new RpcReceiveHandler(__rpc_handler_1596931241));
NetworkManager.__rpc_func_table.Add(1887262031u, new RpcReceiveHandler(__rpc_handler_1887262031));
NetworkManager.__rpc_func_table.Add(23251114u, new RpcReceiveHandler(__rpc_handler_23251114));
NetworkManager.__rpc_func_table.Add(2552547060u, new RpcReceiveHandler(__rpc_handler_2552547060));
NetworkManager.__rpc_func_table.Add(2387514609u, new RpcReceiveHandler(__rpc_handler_2387514609));
NetworkManager.__rpc_func_table.Add(2311549797u, new RpcReceiveHandler(__rpc_handler_2311549797));
}
private static void __rpc_handler_2089966051(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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference enemyNORef = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref enemyNORef, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((UZGNetwork)(object)target).BlowUpEnemyServerRpc(enemyNORef);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1035235681(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
target.__rpc_exec_stage = (__RpcExecStage)2;
((UZGNetwork)(object)target).BlowUpEnemyClientRpc(position);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3194388427(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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference shovelNORef = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref shovelNORef, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((UZGNetwork)(object)target).SyncShovelDamageServerRpc(shovelNORef);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1596931241(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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference shovelNORef = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref shovelNORef, default(ForNetworkSerializable));
float seconds = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref seconds, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((UZGNetwork)(object)target).SyncShovelDamageClientRpc(shovelNORef, seconds);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1887262031(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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference obj = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
bool canShock = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref canShock, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((UZGNetwork)(object)target).SyncCanShockSpikeClientRpc(obj, canShock);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_23251114(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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference obj = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
int zapCount = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref zapCount);
target.__rpc_exec_stage = (__RpcExecStage)1;
((UZGNetwork)(object)target).SyncZapCountServerRpc(obj, zapCount);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2552547060(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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference obj = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
int zapCount = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref zapCount);
target.__rpc_exec_stage = (__RpcExecStage)2;
((UZGNetwork)(object)target).SyncZapCountClientRpc(obj, zapCount);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2387514609(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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkBehaviourReference playerNBRef = default(NetworkBehaviourReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerNBRef, default(ForNetworkSerializable));
int playerWhoHit = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref playerWhoHit);
target.__rpc_exec_stage = (__RpcExecStage)1;
((UZGNetwork)(object)target).DOTPlayerServerRpc(playerNBRef, playerWhoHit);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2311549797(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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkBehaviourReference enemyNBRef = default(NetworkBehaviourReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref enemyNBRef, default(ForNetworkSerializable));
NetworkBehaviourReference playerWhoHitNBRef = default(NetworkBehaviourReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerWhoHitNBRef, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((UZGNetwork)(object)target).DOTEnemyServerRpc(enemyNBRef, playerWhoHitNBRef);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "UZGNetwork";
}
}
}
namespace UsefulZapGun.Methods
{
internal class DOT
{
internal static IEnumerator DOTPlayer(PlayerControllerB player, int playerWhoHit, int damageToPlayer, float time, PatcherTool zapgun)
{
while (zapgun.shockedTargetScript == player && ((GrabbableObject)zapgun).isBeingUsed)
{
player.DamagePlayerFromOtherClientServerRpc(damageToPlayer, ((Component)player).transform.position, playerWhoHit);
yield return (object)new WaitForSeconds(time);
}
}
internal static IEnumerator DOTEnemy(EnemyAICollisionDetect enemyAICol, PlayerControllerB playerWhoHit, int force, float time, PatcherTool zapgun)
{
while (zapgun.shockedTargetScript == enemyAICol && ((GrabbableObject)zapgun).isBeingUsed)
{
((IHittable)enemyAICol).Hit(force, ((Component)enemyAICol).transform.position, playerWhoHit, false, -1);
yield return (object)new WaitForSeconds(time);
}
}
}
internal class ZapGunMethods
{
internal static List<PatcherTool> zapGuns = new List<PatcherTool>();
private static Coroutine coroutine;
internal static IEnumerator ExplodeNextFrame(Vector3 position)
{
//IL_0007: 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)
yield return (object)new WaitForEndOfFrame();
Landmine.SpawnExplosion(position, true, 0f, 5f, 20, 3f, (GameObject)null, false);
}
internal static void WaitAndExplode(EnemyAICollisionDetect enemyCol, EnemyAI enemyScript, float time)
{
foreach (PatcherTool zapGun in zapGuns)
{
if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)((GrabbableObject)zapGun).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && zapGun.shockedTargetScript == enemyCol)
{
coroutine = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitAndExplodeCoroutine(zapGun, enemyCol, enemyScript, time));
}
}
}
private static IEnumerator WaitAndExplodeCoroutine(PatcherTool zapgun, EnemyAICollisionDetect enemyCol, EnemyAI enemyScript, float time)
{
while (time > 0f)
{
yield return (object)new WaitForSeconds(0.1f);
time -= 0.1f;
Plugin.SpamLog($"time = {time}", Plugin.spamType.debug);
if (!((GrabbableObject)zapgun).isBeingUsed || zapgun.shockedTargetScript != enemyCol)
{
Plugin.SpamLog("Stop charging explosion!", Plugin.spamType.debug);
((MonoBehaviour)StartOfRound.Instance).StopCoroutine(coroutine);
}
}
zapgun.StopShockingAnomalyOnClient(true);
yield return (object)new WaitForEndOfFrame();
NetworkObjectReference enemyNORef = new NetworkObjectReference(((NetworkBehaviour)enemyScript).NetworkObject);
GameNetworkManagerPatch.hostNetHandler.BlowUpEnemyServerRpc(enemyNORef);
}
internal static void StartFire(EnemyAICollisionDetect enemyCol, ForestGiantAI enemyScript)
{
foreach (PatcherTool zapGun in zapGuns)
{
if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)((GrabbableObject)zapGun).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && zapGun.shockedTargetScript == enemyCol)
{
coroutine = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitAndStartFire(enemyScript, zapGun, enemyCol));
}
}
}
private static IEnumerator WaitAndStartFire(ForestGiantAI enemyScript, PatcherTool zapgun, EnemyAICollisionDetect enemyCol)
{
float time = UZGConfig.timeToStartAFire.Value;
while (time > 0f)
{
yield return (object)new WaitForSeconds(0.1f);
time -= 0.1f;
Plugin.SpamLog($"time = {time}", Plugin.spamType.debug);
if (!((GrabbableObject)zapgun).isBeingUsed || zapgun.shockedTargetScript != enemyCol)
{
Plugin.SpamLog("Stop zapping giant!", Plugin.spamType.debug);
((MonoBehaviour)StartOfRound.Instance).StopCoroutine(coroutine);
}
}
yield return (object)new WaitForEndOfFrame();
((EnemyAI)enemyScript).HitFromExplosion(Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)enemyScript).transform.position));
}
internal static void StartEvaporation(EnemyAICollisionDetect enemyCol, BlobAI enemyScript)
{
foreach (PatcherTool zapGun in zapGuns)
{
if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)((GrabbableObject)zapGun).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && zapGun.shockedTargetScript == enemyCol)
{
coroutine = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(Evaporate(enemyScript, zapGun, enemyCol));
}
}
}
private static IEnumerator Evaporate(BlobAI enemyScript, PatcherTool zapgun, EnemyAICollisionDetect enemyCol)
{
float blobYScale = 1f;
while (blobYScale > 0f)
{
blobYScale = ((Component)enemyScript).gameObject.transform.localScale.y;
Plugin.SpamLog($"blob Y scale: {blobYScale}", Plugin.spamType.debug);
yield return (object)new WaitForSeconds(0.1f);
Transform transform = ((Component)enemyScript).transform;
transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f);
if (zapgun.shockedTargetScript != enemyCol || !((GrabbableObject)zapgun).isBeingUsed)
{
Plugin.SpamLog("Stop zapping blob!", Plugin.spamType.debug);
((MonoBehaviour)StartOfRound.Instance).StopCoroutine(coroutine);
}
}
zapgun.StopShockingAnomalyOnClient(true);
yield return (object)new WaitForEndOfFrame();
if (((EnemyAI)enemyScript).enemyType.canDie)
{
((EnemyAI)enemyScript).KillEnemyServerRpc(false);
}
else
{
((EnemyAI)enemyScript).KillEnemyServerRpc(true);
}
}
}
}
namespace UsefulZapGun.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}