using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TimeBomb.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
[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("TimeBomb")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Lucille Johnson mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TimeBomb")]
[assembly: AssemblyTitle("TimeBomb")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TimeBomb
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TimeBomb";
public const string PLUGIN_NAME = "TimeBomb";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LucilleJohnson
{
internal class DeleteAfter : MonoBehaviour
{
private float duration = 4f;
private void Start()
{
((MonoBehaviour)this).StartCoroutine(DeleteIn(duration));
}
private IEnumerator DeleteIn(float dur)
{
yield return (object)new WaitForSeconds(dur);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void AddToPrefabs(ref GameNetworkManager __instance)
{
((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.Instance.TimeBombPrefab);
((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.Instance.LJPrefab);
((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.Instance.NetworkManagerPrefab);
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void SpawnLJNetworkManager(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsHost)
{
Object.Instantiate<GameObject>(Plugin.Instance.NetworkManagerPrefab).GetComponent<NetworkObject>().Spawn(false);
}
}
}
internal class LJAI : EnemyAI
{
public List<AudioClip> sfx;
public GameObject ljFlashPrefab;
public GameObject bombPrefab;
public float bombDist = 0.05f;
private bool alreadyActivated = false;
private bool ljFlashActivated = false;
private ulong bombNetworkObjectId;
private GameObject bomb = null;
private PlayerControllerB attachTarget;
private UnityAction<PlayerControllerB> TeleportAction;
private Coroutine teleportCoroutine;
public override void Start()
{
((EnemyAI)this).Start();
base.moveTowardsDestination = false;
TeleportAction = (UnityAction<PlayerControllerB>)(object)Delegate.Combine((Delegate?)(object)TeleportAction, (Delegate?)(object)new UnityAction<PlayerControllerB>(OnTeleport));
((UnityEvent<PlayerControllerB>)(object)StartOfRound.Instance.playerTeleportedEvent).AddListener(TeleportAction);
}
public override void Update()
{
//IL_00ea: 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_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (bomb == null)
{
if (bombNetworkObjectId != 0)
{
bomb = ((Component)IdToBomb(bombNetworkObjectId)).gameObject;
if ((Object)(object)bomb != (Object)null)
{
((GrabbableObject)bomb.GetComponent<PhysicsProp>()).grabbable = false;
((GrabbableObject)bomb.GetComponent<PhysicsProp>()).grabbableToEnemies = false;
}
}
}
else if ((Object)(object)bomb == (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
if ((Object)(object)bomb != (Object)null && (Object)(object)attachTarget != (Object)null && !attachTarget.isPlayerDead)
{
PhysicsProp component = bomb.GetComponent<PhysicsProp>();
float num = (360f - ((Component)attachTarget).transform.eulerAngles.y) * (MathF.PI / 180f);
bomb.transform.position = ((Component)attachTarget).transform.position + bombDist * new Vector3(0f - Mathf.Sin(num), 0f, Mathf.Cos(num)) + Vector3.up * 1.5f;
((GrabbableObject)component).startFallingPosition = bomb.transform.position;
((GrabbableObject)component).targetFloorPosition = bomb.transform.position;
bomb.transform.eulerAngles = new Vector3(0f, ((Component)attachTarget).transform.eulerAngles.y - 90f, 0f);
}
else if ((Object)(object)bomb != (Object)null && (Object)(object)attachTarget != (Object)null && attachTarget.isPlayerDead)
{
TimeBombProp component2 = bomb.GetComponent<TimeBombProp>();
component2.SetGrabbableServerRpc();
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public void OnTeleport(PlayerControllerB player)
{
Debug.Log((object)"Player teleported!");
if (teleportCoroutine == null && (Object)(object)bomb != (Object)null)
{
teleportCoroutine = ((MonoBehaviour)this).StartCoroutine(TeleportCoroutine(player));
}
}
private IEnumerator TeleportCoroutine(PlayerControllerB player)
{
Debug.Log((object)"Teleport Coroutine Started!");
yield return null;
if ((Object)(object)attachTarget == (Object)null)
{
teleportCoroutine = null;
yield break;
}
float dist = float.MaxValue;
ShipTeleporter[] array = Object.FindObjectsByType<ShipTeleporter>((FindObjectsSortMode)0);
foreach (ShipTeleporter teleporter in array)
{
Transform tele = ((Component)teleporter).transform.Find("AnimContainer").Find("TeleportPosition");
float num = dist;
Vector3 val = ((Component)attachTarget).transform.position - tele.position;
dist = Mathf.Min(num, ((Vector3)(ref val)).magnitude);
}
Debug.Log((object)$"Distance from teleporter: {dist}");
if (dist >= 2f)
{
teleportCoroutine = null;
yield break;
}
yield return (object)new WaitForSeconds(0.5f);
if (!((Object)(object)bomb == (Object)null) && (Object)(object)player == (Object)(object)attachTarget && !player.isPlayerDead)
{
Debug.Log((object)"Bomb detached!");
TimeBombProp bombProp = bomb.GetComponent<TimeBombProp>();
bombProp.SetGrabbableServerRpc();
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public override void OnDestroy()
{
((EnemyAI)this).OnDestroy();
((UnityEvent<PlayerControllerB>)(object)StartOfRound.Instance.playerTeleportedEvent).RemoveListener(TeleportAction);
}
public void OnTriggerEnter(Collider other)
{
if (alreadyActivated)
{
return;
}
Debug.Log((object)"LJ Triggered!");
if (((Component)other).CompareTag("Player") || ((Component)((Component)other).transform.parent).CompareTag("Player"))
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if (!((Component)other).CompareTag("Player"))
{
component = ((Component)((Component)other).transform.parent).GetComponent<PlayerControllerB>();
}
if ((Object)(object)component != (Object)null && !component.isPlayerDead && !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !alreadyActivated)
{
Debug.Log((object)"LJ Activated!");
TriggerServerRpc(component.playerClientId);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void TriggerServerRpc(ulong triggererId)
{
//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_0071: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3610995932u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, triggererId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3610995932u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !alreadyActivated)
{
alreadyActivated = true;
LJFlashClientRpc(triggererId);
((MonoBehaviour)this).StartCoroutine(SpawnBombServerCoroutine(triggererId));
}
}
}
private IEnumerator SpawnBombServerCoroutine(ulong triggererId)
{
yield return (object)new WaitForSeconds(0.2f);
bomb = Object.Instantiate<GameObject>(bombPrefab);
NetworkObject bombNetObj = bomb.GetComponent<NetworkObject>();
bombNetObj.Spawn(false);
((GrabbableObject)bomb.GetComponent<PhysicsProp>()).grabbable = false;
((GrabbableObject)bomb.GetComponent<PhysicsProp>()).grabbableToEnemies = false;
AttachBombClientRpc(triggererId, bombNetObj.NetworkObjectId);
yield return (object)new WaitForSeconds(3f);
bomb.GetComponent<TimeBombProp>().ActivateBomb();
}
[ClientRpc]
public void LJFlashClientRpc(ulong triggererId)
{
//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_0071: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1481855219u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, triggererId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1481855219u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
alreadyActivated = true;
if (!ljFlashActivated && GameNetworkManager.Instance.localPlayerController.playerClientId == triggererId)
{
LJFlash();
ljFlashActivated = true;
}
}
}
[ClientRpc]
public void AttachBombClientRpc(ulong triggererId, ulong networkObjectId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3814598918u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, triggererId);
BytePacker.WriteValueBitPacked(val2, networkObjectId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3814598918u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
((Component)this).GetComponent<AudioSource>().volume = 0f;
bombNetworkObjectId = networkObjectId;
attachTarget = IdToPlayer(triggererId);
}
}
}
private void LJFlash()
{
Transform transform = GameObject.Find("Systems").transform;
AudioSource component = ((Component)transform.Find("Audios").Find("UIAudio")).GetComponent<AudioSource>();
component.PlayOneShot(sfx[Random.Range(0, sfx.Count)]);
Canvas component2 = ((Component)transform.Find("UI").Find("Canvas")).GetComponent<Canvas>();
Object.Instantiate<GameObject>(ljFlashPrefab, ((Component)component2).gameObject.transform).AddComponent<DeleteAfter>();
}
private PlayerControllerB IdToPlayer(ulong triggererId)
{
PlayerControllerB[] array = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)1);
foreach (PlayerControllerB val in array)
{
if (val.playerClientId == triggererId)
{
return val;
}
}
return null;
}
private TimeBombProp IdToBomb(ulong networkObjectId)
{
TimeBombProp[] array = Object.FindObjectsByType<TimeBombProp>((FindObjectsSortMode)1);
foreach (TimeBombProp timeBombProp in array)
{
if (((NetworkBehaviour)timeBombProp).NetworkObjectId == networkObjectId)
{
return timeBombProp;
}
}
return null;
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_LJAI()
{
//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
NetworkManager.__rpc_func_table.Add(3610995932u, new RpcReceiveHandler(__rpc_handler_3610995932));
NetworkManager.__rpc_func_table.Add(1481855219u, new RpcReceiveHandler(__rpc_handler_1481855219));
NetworkManager.__rpc_func_table.Add(3814598918u, new RpcReceiveHandler(__rpc_handler_3814598918));
}
private static void __rpc_handler_3610995932(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong triggererId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref triggererId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((LJAI)(object)target).TriggerServerRpc(triggererId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1481855219(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong triggererId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref triggererId);
target.__rpc_exec_stage = (__RpcExecStage)2;
((LJAI)(object)target).LJFlashClientRpc(triggererId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3814598918(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0043: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong triggererId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref triggererId);
ulong networkObjectId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref networkObjectId);
target.__rpc_exec_stage = (__RpcExecStage)2;
((LJAI)(object)target).AttachBombClientRpc(triggererId, networkObjectId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "LJAI";
}
}
public class LJConfig
{
public static ConfigEntry<int> LJSpawnRarity;
public static ConfigEntry<int> LJSpawnLimit;
public static void Load()
{
LJSpawnRarity = Plugin.config.Bind<int>("Enemies", "Lucille Johnson Spawn Rate", 30, "How often does Lucille Johnson spawn? Bigger number for more spawn frequency.");
LJSpawnLimit = Plugin.config.Bind<int>("Enemies", "Lucille Johnson Spawn Limit", 1, "How many Lucille Johnsons can spawn? Bigger number for more spawns at once.");
}
}
internal class LJNetworkManager : NetworkBehaviour
{
public static LJNetworkManager Instance;
private void Awake()
{
Instance = this;
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "LJNetworkManager";
}
}
[BepInPlugin("2991e0dc-44d3-4fd2-9f65-3a447d782dfe", "TimeBomb", "0.1")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "2991e0dc-44d3-4fd2-9f65-3a447d782dfe";
private const string PLUGIN_NAME = "TimeBomb";
private const string PLUGIN_VERSION = "0.1";
public static Plugin Instance;
public GameObject TimeBombPrefab;
public GameObject LJPrefab;
public GameObject NetworkManagerPrefab;
public static ConfigFile config;
private void Awake()
{
config = ((BaseUnityPlugin)this).Config;
LJConfig.Load();
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);
}
}
}
Instance = this;
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "timebomb");
AssetBundle val = AssetBundle.LoadFromFile(text);
NetworkManagerPrefab = val.LoadAsset<GameObject>("Assets/TimeBomb/LJNetworkManager.prefab");
NetworkManagerPrefab.AddComponent<LJNetworkManager>();
AudioClip beep = val.LoadAsset<AudioClip>("Assets/TimeBomb/beep0.wav");
AudioClip beep2 = val.LoadAsset<AudioClip>("Assets/TimeBomb/beep1.wav");
AudioClip dudSFX = val.LoadAsset<AudioClip>("Assets/TimeBomb/dud.wav");
Item val2 = val.LoadAsset<Item>("Assets/TimeBomb/TimeBombItem.asset");
TimeBombProp timeBombProp = val2.spawnPrefab.AddComponent<TimeBombProp>();
((GrabbableObject)timeBombProp).grabbable = true;
((GrabbableObject)timeBombProp).grabbableToEnemies = true;
((GrabbableObject)timeBombProp).itemProperties = val2;
timeBombProp.beep0 = beep;
timeBombProp.beep1 = beep2;
timeBombProp.dudSFX = dudSFX;
TimeBombPrefab = val2.spawnPrefab;
NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
Utilities.FixMixerGroups(val2.spawnPrefab);
AudioClip item = val.LoadAsset<AudioClip>("Assets/TimeBomb/glitch0.wav");
AudioClip item2 = val.LoadAsset<AudioClip>("Assets/TimeBomb/glitch1.wav");
AudioClip item3 = val.LoadAsset<AudioClip>("Assets/TimeBomb/glitch2.wav");
AudioClip item4 = val.LoadAsset<AudioClip>("Assets/TimeBomb/glitch3.wav");
GameObject ljFlashPrefab = val.LoadAsset<GameObject>("Assets/TimeBomb/TimeBombOverlay.prefab");
EnemyType val3 = val.LoadAsset<EnemyType>("Assets/TimeBomb/LJ.asset");
LJAI lJAI = val3.enemyPrefab.AddComponent<LJAI>();
lJAI.sfx = new List<AudioClip> { item, item2, item3, item4 };
lJAI.ljFlashPrefab = ljFlashPrefab;
lJAI.bombPrefab = val2.spawnPrefab;
((EnemyAI)lJAI).enemyType = val3;
val3.MaxCount = LJConfig.LJSpawnLimit.Value;
LJPrefab = val3.enemyPrefab;
NetworkPrefabs.RegisterNetworkPrefab(val3.enemyPrefab);
TerminalKeyword val4 = val.LoadAsset<TerminalKeyword>("Assets/TimeBomb/LJKeyword.asset");
Enemies.RegisterEnemy(val3, LJConfig.LJSpawnRarity.Value, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, val4);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "2991e0dc-44d3-4fd2-9f65-3a447d782dfe");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 2991e0dc-44d3-4fd2-9f65-3a447d782dfe is loaded!");
}
}
internal class TimeBombProp : PhysicsProp
{
private Coroutine explode = null;
public AudioClip beep0;
public AudioClip beep1;
public AudioClip dudSFX;
private bool alreadyActivated = false;
private bool alreadyDetonated = false;
private bool dud = false;
private float dudChance = 5f;
public int TimePhaseA = 40;
public int TimePhaseB = 30;
public int TimePhaseC = 20;
private AudioSource audioSource;
public void Awake()
{
audioSource = ((Component)this).GetComponent<AudioSource>();
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && explode == null)
{
ActivateBomb();
}
}
public void ActivateBomb()
{
if (!alreadyActivated)
{
alreadyActivated = true;
StartBombServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
public void StartBombServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3257605038u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3257605038u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
Debug.Log((object)$"TimeBomb (Server): Player used bomb. Dud: {dud}");
dud = Random.Range(0f, 100f) < dudChance;
alreadyActivated = true;
StartBombClientRpc(dud);
}
}
}
[ClientRpc]
public void StartBombClientRpc(bool dud)
{
//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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1403438466u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref dud, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1403438466u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Debug.Log((object)$"TimeBomb (Client): Player used bomb. Dud: {dud}");
this.dud = dud;
alreadyActivated = true;
if (explode == null)
{
explode = ((MonoBehaviour)this).StartCoroutine((IEnumerator)TimeBombCoroutine());
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SetGrabbableServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2935319038u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2935319038u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SetGrabbableClientRpc();
}
}
}
[ClientRpc]
public void SetGrabbableClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(558465907u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 558465907u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
((GrabbableObject)this).FallToGround(false);
((GrabbableObject)this).grabbable = true;
((GrabbableObject)this).grabbableToEnemies = true;
}
}
}
public void ConvertToScrap()
{
((Component)this).GetComponentInChildren<ScanNodeProperties>().scrapValue = 100;
((GrabbableObject)((Component)this).GetComponent<PhysicsProp>()).scrapValue = 100;
explode = null;
alreadyActivated = false;
alreadyDetonated = false;
}
private IEnumerator<object> TimeBombCoroutine()
{
Debug.Log((object)"TimeBomb: Starting timer");
for (int k = 0; k < TimePhaseA; k++)
{
audioSource.PlayOneShot(beep0);
if (StartOfRound.Instance.inShipPhase)
{
ConvertToScrap();
yield break;
}
yield return (object)new WaitForSeconds(1f);
}
for (int j = 0; j < TimePhaseB; j++)
{
audioSource.PlayOneShot(beep0);
if (StartOfRound.Instance.inShipPhase)
{
ConvertToScrap();
yield break;
}
yield return (object)new WaitForSeconds(0.5f);
}
for (int i = 0; i < TimePhaseC; i++)
{
audioSource.PlayOneShot(beep1);
if (StartOfRound.Instance.inShipPhase)
{
ConvertToScrap();
yield break;
}
yield return (object)new WaitForSeconds(0.25f);
}
Debug.Log((object)"TimeBomb: Exploding");
if (GameNetworkManager.Instance.isHostingGame)
{
DetonateClientRpc();
}
}
[ClientRpc]
public void DetonateClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3420457884u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3420457884u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !alreadyDetonated)
{
alreadyDetonated = true;
Detonate();
}
}
}
public void Detonate()
{
//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_0011: Unknown result type (might be due to invalid IL or missing references)
CreateExplosion(((Component)this).transform.position + Vector3.up, spawnExplosionEffect: true, (!dud) ? 100 : 0, 5.7f, 6.4f, 6, (CauseOfDeath)3, null, dud ? dudSFX : null);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 1f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null, AudioClip playSound = null)
{
//IL_00d0: 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_006f: 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)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: 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)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"Spawning explosion at pos: {explosionPosition}");
Transform val = null;
if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
{
val = RoundManager.Instance.mapPropsContainer.transform;
}
if (spawnExplosionEffect)
{
GameObject val2 = Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val);
if ((Object)(object)playSound != (Object)null)
{
AudioSource componentInChildren = val2.GetComponentInChildren<AudioSource>();
componentInChildren.clip = playSound;
componentInChildren.Play();
}
val2.SetActive(true);
}
float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
if (num < 14f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
}
else if (num < 25f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
}
Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
PlayerControllerB val3 = null;
for (int i = 0; i < array.Length; i++)
{
float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
{
continue;
}
if (((Component)array[i]).gameObject.layer == 3)
{
val3 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)val3 != (Object)null && ((NetworkBehaviour)val3).IsOwner)
{
float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
val3.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, default(Vector3));
}
}
else if (((Component)array[i]).gameObject.layer == 19)
{
EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
{
componentInChildren2.mainScript.HitEnemyOnLocalClient(enemyHitForce, default(Vector3), attacker, false);
}
}
}
int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
array = Physics.OverlapSphere(explosionPosition, 10f, num4);
for (int j = 0; j < array.Length; j++)
{
Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.AddExplosionForce(70f, explosionPosition, 10f);
}
}
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_TimeBombProp()
{
//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
NetworkManager.__rpc_func_table.Add(3257605038u, new RpcReceiveHandler(__rpc_handler_3257605038));
NetworkManager.__rpc_func_table.Add(1403438466u, new RpcReceiveHandler(__rpc_handler_1403438466));
NetworkManager.__rpc_func_table.Add(2935319038u, new RpcReceiveHandler(__rpc_handler_2935319038));
NetworkManager.__rpc_func_table.Add(558465907u, new RpcReceiveHandler(__rpc_handler_558465907));
NetworkManager.__rpc_func_table.Add(3420457884u, new RpcReceiveHandler(__rpc_handler_3420457884));
}
private static void __rpc_handler_3257605038(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((TimeBombProp)(object)target).StartBombServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1403438466(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_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((TimeBombProp)(object)target).StartBombClientRpc(flag);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2935319038(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((TimeBombProp)(object)target).SetGrabbableServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_558465907(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((TimeBombProp)(object)target).SetGrabbableClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3420457884(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((TimeBombProp)(object)target).DetonateClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "TimeBombProp";
}
}
}
namespace TimeBomb.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}