using System;
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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using lethalCompanyRevive.Helpers;
using lethalCompanyRevive.Managers;
using lethalCompanyRevive.Misc;
using lethalCompanyRevive.NetcodePatcher;
[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("lethalCompanyRevive")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+adfc50d1c4a3f69bb6234aeacf43647d41521455")]
[assembly: AssemblyProduct("lethalCompanyRevive")]
[assembly: AssemblyTitle("lethalCompanyRevive")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace lethalCompanyRevive
{
[BepInPlugin("com.deja.lethalcompany.lethalCompanyRevive", "Revive Crewmates", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("com.deja.lethalcompany.lethalCompanyRevive");
public static Plugin instance;
public static ManualLogSource mls;
public static PluginConfig cfg { get; private set; }
private void Awake()
{
cfg = new PluginConfig(((BaseUnityPlugin)this).Config);
cfg.InitBindings();
mls = ((BaseUnityPlugin)this).Logger;
instance = this;
PatchAllMethods();
NetcodePatch();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Revive functionality has been initialized.");
}
private void PatchAllMethods()
{
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
private static void NetcodePatch()
{
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 string GetJsonContent()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string name = "lethalCompanyRevive.Misc.InfoStrings.json";
using StreamReader streamReader = new StreamReader(executingAssembly.GetManifestResourceStream(name));
return streamReader.ReadToEnd();
}
}
}
namespace lethalCompanyRevive.Patches
{
[HarmonyPatch(typeof(Terminal))]
internal class TerminalPatcher
{
private static UpgradeBus upgradeBus;
[HarmonyPostfix]
[HarmonyPatch("ParsePlayerSentence")]
private static void CustomParser(ref Terminal __instance, ref TerminalNode __result)
{
string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
string[] array = text.Split(' ');
if (!(array[0] == "revive") || array.Length != 2)
{
return;
}
try
{
string text2 = array[1];
PlayerControllerB player = Helper.GetPlayer(text2);
Debug.Log((object)("Attempting to revive player with name: " + text2));
Debug.Log((object)player);
if ((Object)(object)player == (Object)null)
{
__result = CreateTerminalNode("Player '" + text2 + "' does not exist.", clearPreviousText: true);
return;
}
if (!player.isPlayerDead)
{
__result = CreateTerminalNode("Player '" + text2 + "' is not dead.", clearPreviousText: true);
return;
}
if (__instance.groupCredits < 100)
{
__result = CreateTerminalNode($"Not enough credits {__instance.groupCredits}/100", clearPreviousText: true);
return;
}
ulong playerClientId = player.playerClientId;
if ((Object)(object)upgradeBus == (Object)null)
{
GameObject val = GameObject.Find("UpgradeBus");
if ((Object)(object)val != (Object)null)
{
upgradeBus = val.GetComponent<UpgradeBus>();
}
}
Debug.Log((object)("Revive command detected for player: " + text2));
__result = UpgradeBus.Instance.ConstructNode();
UpgradeBus.Instance.HandleReviveRequest(playerClientId);
}
catch (Exception ex)
{
Debug.Log((object)ex);
}
}
public static PlayerControllerB GetPlayerByName(string playerName)
{
Debug.Log((object)"GetPlayerByName");
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
PlayerControllerB[] array2 = array;
foreach (PlayerControllerB val in array2)
{
if (val.playerUsername == playerName)
{
return val;
}
}
return null;
}
private static TerminalNode CreateTerminalNode(string displayText, bool clearPreviousText)
{
Debug.Log((object)"CreateTerminalNode");
TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
val.displayText = displayText;
val.clearPreviousText = clearPreviousText;
return val;
}
}
}
namespace lethalCompanyRevive.Network
{
[HarmonyPatch]
public class ReviveNetworkManager
{
private static GameObject networkPrefab;
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
public static void Init()
{
Debug.Log((object)"Init");
if (!((Object)(object)networkPrefab != (Object)null))
{
networkPrefab = NetworkPrefabs.CreateNetworkPrefab("ReviveStore");
ReviveStore reviveStore = networkPrefab.AddComponent<ReviveStore>();
UpgradeBus upgradeBus = networkPrefab.AddComponent<UpgradeBus>();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
private static void SpawnNetworkHandler()
{
//IL_003a: 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)
Debug.Log((object)"SpawnNetworkHandler");
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
Debug.Log((object)"IsHost or IsServer");
GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
}
}
namespace lethalCompanyRevive.Misc
{
public class CustomTerminalNode
{
public string Name;
public int[] Prices;
public int UnlockPrice;
public string Description;
public GameObject Prefab;
public bool Unlocked = false;
public float salePerc = 1f;
public CustomTerminalNode(string name, int unlockPrice, string description, GameObject prefab, int[] prices = null)
{
if (prices == null)
{
prices = new int[0];
}
Name = name;
Prices = prices;
Description = description;
Prefab = prefab;
UnlockPrice = unlockPrice;
}
public static CustomTerminalNode CreateReviveNode()
{
return new CustomTerminalNode("Revive", 100, "Revive a fallen teammate", null);
}
public CustomTerminalNode Copy()
{
return new CustomTerminalNode(Name = Name, UnlockPrice = UnlockPrice, Description = Description, Prefab = Prefab, Prices = Prices);
}
}
public class PluginConfig
{
private readonly ConfigFile configFile;
public bool REVIVE { get; set; }
public PluginConfig(ConfigFile cfg)
{
configFile = cfg;
}
private T ConfigEntry<T>(string section, string key, T defaultVal, string description)
{
return configFile.Bind<T>(section, key, defaultVal, description).Value;
}
public void InitBindings()
{
REVIVE = ConfigEntry("Revive Players", "Revive all players in the ship.", defaultVal: true, "");
}
}
internal static class Metadata
{
public const string GUID = "com.deja.lethalcompany.lethalCompanyRevive";
public const string NAME = "Revive Crewmates";
public const string VERSION = "1.0.0";
}
public class Reflector
{
private const BindingFlags privateOrInternal = BindingFlags.Instance | BindingFlags.NonPublic;
private const BindingFlags internalStatic = BindingFlags.Static | BindingFlags.NonPublic;
private const BindingFlags internalField = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField;
private const BindingFlags internalProperty = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty;
private const BindingFlags internalMethod = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod;
private const BindingFlags internalStaticField = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField;
private const BindingFlags internalStaticProperty = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetProperty;
private const BindingFlags internalStaticMethod = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod;
private object Obj { get; }
private Type ObjType { get; }
private Reflector(object obj)
{
Obj = obj;
ObjType = obj.GetType();
}
private T? GetField<T>(string variableName, BindingFlags flags)
{
try
{
return (T)ObjType.GetField(variableName, flags).GetValue(Obj);
}
catch (InvalidCastException)
{
return default(T);
}
}
private Reflector? GetProperty(string propertyName, BindingFlags flags)
{
try
{
return new Reflector(ObjType.GetProperty(propertyName, flags).GetValue(Obj, null));
}
catch (Exception)
{
return null;
}
}
private Reflector? SetField(string variableName, object value, BindingFlags flags)
{
try
{
ObjType.GetField(variableName, flags).SetValue(Obj, value);
return this;
}
catch (Exception)
{
return null;
}
}
private Reflector? SetProperty(string propertyName, object value, BindingFlags flags)
{
try
{
ObjType.GetProperty(propertyName, flags).SetValue(Obj, value, null);
return this;
}
catch (Exception)
{
return null;
}
}
private T? InvokeMethod<T>(string methodName, BindingFlags flags, params object[] args)
{
try
{
return (T)ObjType.GetMethod(methodName, flags).Invoke(Obj, args);
}
catch (InvalidCastException)
{
return default(T);
}
}
public T? GetInternalField<T>(string variableName)
{
return GetField<T>(variableName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
}
public T? GetInternalStaticField<T>(string variableName)
{
return GetField<T>(variableName, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField);
}
public Reflector? GetInternalField(string variableName)
{
object obj = GetInternalField(variableName);
return (obj == null) ? null : new Reflector(obj);
}
public Reflector? GetInternalStaticField(string variableName)
{
object obj = GetInternalStaticField(variableName);
return (obj == null) ? null : new Reflector(obj);
}
public Reflector? SetInternalField(string variableName, object value)
{
return SetField(variableName, value, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
}
public Reflector? SetInternalStaticField(string variableName, object value)
{
return SetField(variableName, value, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField);
}
public Reflector? GetInternalProperty(string propertyName)
{
return GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty);
}
public Reflector? SetInternalProperty(string propertyName, object value)
{
return SetProperty(propertyName, value, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty);
}
public T? InvokeInternalMethod<T>(string methodName, params object[] args)
{
return InvokeMethod<T>(methodName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, args);
}
public Reflector? InvokeInternalMethod(string methodName, params object[] args)
{
object obj = InvokeInternalMethod<object>(methodName, args);
return (obj == null) ? null : new Reflector(obj);
}
public static Reflector Target(object obj)
{
return new Reflector(obj);
}
}
public readonly ref struct Result
{
public bool Success { get; }
public string? Message { get; }
public Result(bool success, string? message = null)
{
Success = success;
Message = message;
}
public Result(string message)
: this(success: false, message)
{
}
}
}
namespace lethalCompanyRevive.Managers
{
public class ReviveStore : NetworkBehaviour
{
private const int ReviveCost = 100;
public static ReviveStore Instance { get; private set; }
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
Debug.Log((object)"OnNetworkSpawn");
}
private bool CanAffordRevive()
{
Terminal component = GameObject.Find("TerminalScript").GetComponent<Terminal>();
return component.groupCredits >= 100;
}
private void DeductCredits()
{
Terminal component = GameObject.Find("TerminalScript").GetComponent<Terminal>();
component.groupCredits -= 100;
SyncCreditsServerRpc(component.groupCredits);
}
[ClientRpc]
private void RevivePlayerClientRpc(Vector3 spawnPosition, NetworkBehaviourReference netRef)
{
//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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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_01ce: 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(2289497067u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnPosition);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netRef, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2289497067u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
NetworkBehaviour val3 = default(NetworkBehaviour);
((NetworkBehaviourReference)(ref netRef)).TryGet(ref val3, (NetworkManager)null);
PlayerControllerB component = ((Component)val3).GetComponent<PlayerControllerB>();
Debug.Log((object)("RevivePlayerClientRpc called for player: " + component.playerUsername));
Debug.Log((object)"Revive Player");
int playerIndex = GetPlayerIndex(component.playerUsername);
Debug.Log((object)$"Player Index: {playerIndex}");
Debug.Log((object)"Reviving players A");
component.ResetPlayerBloodObjects(component.isPlayerDead);
component.isClimbingLadder = false;
component.ResetZAndXRotation();
((Collider)component.thisController).enabled = true;
component.health = 100;
component.disableLookInput = false;
Debug.Log((object)"Reviving players B");
if (component.isPlayerDead)
{
component.isPlayerDead = false;
component.isPlayerControlled = true;
component.isInElevator = true;
component.isInHangarShipRoom = true;
component.isInsideFactory = false;
component.wasInElevatorLastFrame = false;
StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
component.TeleportPlayer(spawnPosition, false, 0f, false, true);
component.setPositionOfDeadPlayer = false;
component.DisablePlayerModel(StartOfRound.Instance.allPlayerObjects[playerIndex], true, true);
((Behaviour)component.helmetLight).enabled = false;
Debug.Log((object)"Reviving players C");
component.Crouch(false);
component.criticallyInjured = false;
if ((Object)(object)component.playerBodyAnimator != (Object)null)
{
component.playerBodyAnimator.SetBool("Limp", false);
}
component.bleedingHeavily = false;
component.activatingItem = false;
component.twoHanded = false;
component.inSpecialInteractAnimation = false;
component.disableSyncInAnimation = false;
component.inAnimationWithEnemy = null;
component.holdingWalkieTalkie = false;
component.speakingToWalkieTalkie = false;
Debug.Log((object)"Reviving players D");
component.isSinking = false;
component.isUnderwater = false;
component.sinkingValue = 0f;
component.statusEffectAudio.Stop();
component.DisableJetpackControlsLocally();
component.health = 100;
Debug.Log((object)"Reviving players E");
component.mapRadarDotAnimator.SetBool("dead", false);
HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
component.hasBegunSpectating = false;
HUDManager.Instance.RemoveSpectateUI();
HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
component.hinderedMultiplier = 1f;
component.isMovementHindered = 0;
component.sourcesCausingSinking = 0;
Debug.Log((object)"Reviving players E2");
component.reverbPreset = StartOfRound.Instance.shipReverb;
}
Debug.Log((object)"Reviving players F");
SoundManager.Instance.earsRingingTimer = 0f;
component.voiceMuffledByEnemy = false;
SoundManager.Instance.playerVoicePitchTargets[playerIndex] = 1f;
SoundManager.Instance.SetPlayerPitch(1f, playerIndex);
if ((Object)(object)component.currentVoiceChatIngameSettings == (Object)null)
{
StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
}
if ((Object)(object)component.currentVoiceChatIngameSettings != (Object)null)
{
if ((Object)(object)component.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
{
component.currentVoiceChatIngameSettings.InitializeComponents();
}
if ((Object)(object)component.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
{
return;
}
((Component)component.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
}
Debug.Log((object)"Reviving players G");
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
localPlayerController.bleedingHeavily = false;
localPlayerController.criticallyInjured = false;
localPlayerController.playerBodyAnimator.SetBool("Limp", false);
localPlayerController.health = 100;
HUDManager.Instance.UpdateHealthUI(100, false);
localPlayerController.spectatedPlayerScript = null;
((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
Debug.Log((object)"Reviving players H");
StartOfRound.Instance.SetSpectateCameraToGameOverMode(false, localPlayerController);
RagdollGrabbableObject[] array = Object.FindObjectsOfType<RagdollGrabbableObject>();
for (int i = 0; i < array.Length; i++)
{
if (!((GrabbableObject)array[i]).isHeld)
{
if (((NetworkBehaviour)this).IsServer)
{
if (((NetworkBehaviour)array[i]).NetworkObject.IsSpawned)
{
((NetworkBehaviour)array[i]).NetworkObject.Despawn(true);
}
else
{
Object.Destroy((Object)(object)((Component)array[i]).gameObject);
}
}
}
else if (((GrabbableObject)array[i]).isHeld && (Object)(object)((GrabbableObject)array[i]).playerHeldBy != (Object)null)
{
((GrabbableObject)array[i]).playerHeldBy.DropAllHeldItems(true, false);
}
}
DeadBodyInfo[] array2 = Object.FindObjectsOfType<DeadBodyInfo>();
for (int j = 0; j < array2.Length; j++)
{
Object.Destroy((Object)(object)((Component)array2[j]).gameObject);
}
StartOfRound instance = StartOfRound.Instance;
instance.livingPlayers++;
StartOfRound.Instance.allPlayersDead = false;
StartOfRound.Instance.UpdatePlayerVoiceEffects();
}
private int GetPlayerIndex(string playerName)
{
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
Debug.Log((object)$"All Players: {allPlayerScripts}");
for (int i = 0; i < allPlayerScripts.Length; i++)
{
Debug.Log((object)("Player: " + (object)allPlayerScripts[i]));
if ((Object)(object)allPlayerScripts[i] != (Object)null && allPlayerScripts[i].playerUsername == playerName)
{
return i;
}
}
return -1;
}
private Vector3 GetPlayerSpawnPosition(int playerNum, bool simpleTeleport = false)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: 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)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"Get Player Spawn Position");
if (simpleTeleport)
{
return StartOfRound.Instance.playerSpawnPositions[0].position;
}
Debug.DrawRay(StartOfRound.Instance.playerSpawnPositions[playerNum].position, Vector3.up, Color.red, 15f);
if (!Physics.CheckSphere(StartOfRound.Instance.playerSpawnPositions[playerNum].position, 0.2f, 67108864, (QueryTriggerInteraction)1))
{
return StartOfRound.Instance.playerSpawnPositions[playerNum].position;
}
if (!Physics.CheckSphere(StartOfRound.Instance.playerSpawnPositions[playerNum].position + Vector3.up, 0.2f, 67108864, (QueryTriggerInteraction)1))
{
return StartOfRound.Instance.playerSpawnPositions[playerNum].position + Vector3.up * 0.5f;
}
for (int i = 0; i < StartOfRound.Instance.playerSpawnPositions.Length; i++)
{
if (i != playerNum)
{
Debug.DrawRay(StartOfRound.Instance.playerSpawnPositions[i].position, Vector3.up, Color.green, 15f);
if (!Physics.CheckSphere(StartOfRound.Instance.playerSpawnPositions[i].position, 0.12f, -67108865, (QueryTriggerInteraction)1))
{
return StartOfRound.Instance.playerSpawnPositions[i].position;
}
if (!Physics.CheckSphere(StartOfRound.Instance.playerSpawnPositions[i].position + Vector3.up, 0.12f, 67108864, (QueryTriggerInteraction)1))
{
return StartOfRound.Instance.playerSpawnPositions[i].position + Vector3.up * 0.5f;
}
}
}
Random random = new Random(65);
float y = StartOfRound.Instance.playerSpawnPositions[0].position.y;
Vector3 val = default(Vector3);
for (int j = 0; j < 15; j++)
{
Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
int minValue = (int)((Bounds)(ref bounds)).min.x;
bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
float num = random.Next(minValue, (int)((Bounds)(ref bounds)).max.x);
bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
int minValue2 = (int)((Bounds)(ref bounds)).min.z;
bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
((Vector3)(ref val))..ctor(num, y, (float)random.Next(minValue2, (int)((Bounds)(ref bounds)).max.z));
val = ((Component)StartOfRound.Instance.shipInnerRoomBounds).transform.InverseTransformPoint(val);
Debug.DrawRay(val, Vector3.up, Color.yellow, 15f);
if (!Physics.CheckSphere(val, 0.12f, 67108864, (QueryTriggerInteraction)1))
{
return StartOfRound.Instance.playerSpawnPositions[j].position;
}
}
return StartOfRound.Instance.playerSpawnPositions[0].position + Vector3.up * 0.5f;
}
[ServerRpc(RequireOwnership = false)]
public void SyncCreditsServerRpc(int newCredits)
{
//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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(865861551u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, newCredits);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 865861551u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SyncCreditsClientRpc(newCredits);
}
}
}
[ClientRpc]
private void SyncCreditsClientRpc(int newCredits)
{
//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2107201390u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, newCredits);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2107201390u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Terminal component = GameObject.Find("TerminalScript").GetComponent<Terminal>();
component.groupCredits = newCredits;
}
}
}
private void RevivePlayer(Vector3 position, NetworkBehaviourReference netRef)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)$"Server: {((NetworkBehaviour)this).IsServer}, Host: {((NetworkBehaviour)this).IsHost}");
RevivePlayerClientRpc(position, netRef);
}
[ServerRpc(RequireOwnership = false)]
public void RequestReviveServerRpc(ulong playerId)
{
//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)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: 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_0134: 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(1810806528u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1810806528u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
Debug.Log((object)$"RequestReviveServerRpc called for playerId: {playerId}");
PlayerControllerB player = Helper.GetPlayer(playerId.ToString());
NetworkBehaviourReference netRef = default(NetworkBehaviourReference);
((NetworkBehaviourReference)(ref netRef))..ctor((NetworkBehaviour)(object)player);
if ((Object)(object)player != (Object)null && player.isPlayerDead && CanAffordRevive())
{
DeductCredits();
int playerIndex = GetPlayerIndex(player.playerUsername);
Vector3 playerSpawnPosition = GetPlayerSpawnPosition(playerIndex);
RevivePlayer(playerSpawnPosition, netRef);
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_ReviveStore()
{
//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
NetworkManager.__rpc_func_table.Add(2289497067u, new RpcReceiveHandler(__rpc_handler_2289497067));
NetworkManager.__rpc_func_table.Add(865861551u, new RpcReceiveHandler(__rpc_handler_865861551));
NetworkManager.__rpc_func_table.Add(2107201390u, new RpcReceiveHandler(__rpc_handler_2107201390));
NetworkManager.__rpc_func_table.Add(1810806528u, new RpcReceiveHandler(__rpc_handler_1810806528));
}
private static void __rpc_handler_2289497067(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_0060: 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)
{
Vector3 spawnPosition = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPosition);
NetworkBehaviourReference netRef = default(NetworkBehaviourReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netRef, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)2;
((ReviveStore)(object)target).RevivePlayerClientRpc(spawnPosition, netRef);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_865861551(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)
{
int newCredits = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref newCredits);
target.__rpc_exec_stage = (__RpcExecStage)1;
((ReviveStore)(object)target).SyncCreditsServerRpc(newCredits);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2107201390(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)
{
int newCredits = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref newCredits);
target.__rpc_exec_stage = (__RpcExecStage)2;
((ReviveStore)(object)target).SyncCreditsClientRpc(newCredits);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1810806528(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 playerId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((ReviveStore)(object)target).RequestReviveServerRpc(playerId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "ReviveStore";
}
}
public class UpgradeBus : MonoBehaviour
{
public List<CustomTerminalNode> terminalNodes = new List<CustomTerminalNode>();
public static UpgradeBus Instance { get; private set; }
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
else
{
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
InitializeReviveNode();
}
private void InitializeReviveNode()
{
CustomTerminalNode item = CustomTerminalNode.CreateReviveNode();
terminalNodes.Add(item);
}
public void HandleReviveRequest(ulong playerId)
{
Debug.Log((object)$"Handle Revive Request for Player ID {playerId}");
((Component)this).GetComponent<ReviveStore>().RequestReviveServerRpc(playerId);
}
public TerminalNode ConstructNode()
{
TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
val.clearPreviousText = true;
foreach (CustomTerminalNode terminalNode in terminalNodes)
{
string arg = ((terminalNode.salePerc == 1f) ? "" : "SALE");
if (!terminalNode.Unlocked)
{
val.displayText += $"\\n{terminalNode.Name} // {(int)((float)terminalNode.UnlockPrice * terminalNode.salePerc)} // {arg} ";
}
else
{
val.displayText = val.displayText + "\n" + terminalNode.Name + " // UNLOCKED ";
}
}
if (val.displayText == "")
{
val.displayText = "No upgrades available";
}
val.displayText += "\n\n";
return val;
}
}
}
namespace lethalCompanyRevive.Helpers
{
public static class Helper
{
public static HUDManager? HUDManager => HUDManager.Instance;
public static RoundManager? RoundManager => RoundManager.Instance;
public static PlayerControllerB? LocalPlayer => GameNetworkManager.Instance.localPlayerController;
public static PlayerControllerB[]? Players => StartOfRound?.allPlayerScripts;
public static StartOfRound? StartOfRound => StartOfRound.Instance;
public static Terminal? Terminal => (HUDManager == null) ? null : Reflector.Target(HUDManager).GetInternalField<Terminal>("terminalScript");
public static void PrintSystem(string? message)
{
if (message == null)
{
Console.WriteLine("SYSTEM: [null message]");
}
else
{
Console.WriteLine("SYSTEM: " + message);
}
}
public static Vector3 Copy(this Vector3 vector)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(vector.x, vector.y, vector.z);
}
public static Quaternion Copy(this Quaternion quaternion)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
return new Quaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
}
public static GameObject Copy(this Transform transform)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
GameObject val = new GameObject();
val.transform.position = transform.position.Copy();
val.transform.eulerAngles = transform.eulerAngles.Copy();
return val;
}
public static PlayerControllerB? GetPlayer(string playerNameOrId)
{
PlayerControllerB[] players = Players;
Debug.Log((object)$"Players: {players}");
if (players == null || players.Length == 0)
{
Debug.Log((object)"No players found.");
return null;
}
Debug.Log((object)("Searching for player with name or ID: " + playerNameOrId));
PlayerControllerB val = ((IEnumerable<PlayerControllerB>)players).FirstOrDefault((Func<PlayerControllerB, bool>)delegate(PlayerControllerB player)
{
if ((Object)(object)player != (Object)null)
{
Debug.Log((object)("Checking player: " + player.playerUsername));
return player.playerUsername == playerNameOrId;
}
return false;
});
if ((Object)(object)val != (Object)null)
{
Debug.Log((object)("Found player by name: " + val.playerUsername));
return val;
}
PlayerControllerB val2 = ((IEnumerable<PlayerControllerB>)players).FirstOrDefault((Func<PlayerControllerB, bool>)delegate(PlayerControllerB player)
{
if ((Object)(object)player != (Object)null)
{
Debug.Log((object)$"Checking player ID: {player.playerClientId}");
return player.playerClientId.ToString() == playerNameOrId;
}
return false;
});
if ((Object)(object)val2 != (Object)null)
{
Debug.Log((object)("Found player by ID: " + val2.playerUsername));
return val2;
}
Debug.Log((object)"Player not found.");
return null;
}
public static PlayerControllerB? GetPlayer(int playerId)
{
return GetPlayer(playerId.ToString());
}
}
}
namespace lethalCompanyRevive.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}