using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using InteractiveTerminalAPI.UI;
using InteractiveTerminalAPI.UI.Application;
using InteractiveTerminalAPI.UI.Cursor;
using InteractiveTerminalAPI.UI.Screen;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using lethalCompanyRevive.Helpers;
using lethalCompanyRevive.Managers;
using lethalCompanyRevive.Misc;
using lethalCompanyRevive.NetcodePatcher;
using lethalCompanyRevive.UI.Application;
[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")]
[assembly: AssemblyProduct("lethalCompanyRevive")]
[assembly: AssemblyTitle("lethalCompanyRevive")]
[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 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;
if (!cfg.EnableRevive.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Revive functionality is disabled via config.");
return;
}
PatchAllMethods();
NetcodePatch();
InteractiveTerminalManager.RegisterApplication<ReviveApplication>("revive", false);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Revive functionality 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);
}
}
}
}
}
}
namespace lethalCompanyRevive.UI.Application
{
internal class ReviveApplication : InteractiveTerminalApplication
{
private CursorMenu mainMenu;
private IScreen mainScreen;
public override void Initialization()
{
if (!Plugin.cfg.EnableRevive.Value)
{
CloseUI();
return;
}
PlayerControllerB[] players = Helper.Players;
if (players == null || players.Length == 0)
{
ShowNoPlayersUI();
return;
}
PlayerControllerB[] deadPlayers = players.Where((PlayerControllerB p) => (Object)(object)p != (Object)null && p.isPlayerDead).ToArray();
if (deadPlayers.Length == 0)
{
ShowNoDeadPlayersUI();
return;
}
int singleCost = ComputeDisplayCost();
CursorElement[] array = (CursorElement[])(object)new CursorElement[deadPlayers.Length + 2];
array[0] = CursorElement.Create($"Revive All ({deadPlayers.Length * singleCost})", "", (Action)delegate
{
ConfirmReviveAll(deadPlayers);
}, (Func<CursorElement, bool>)((CursorElement elem) => CanAffordWithDailyLimit(deadPlayers.Length * singleCost)), true);
for (int i = 0; i < deadPlayers.Length; i++)
{
PlayerControllerB p2 = deadPlayers[i];
string text = $"Revive {p2.playerUsername} ({singleCost})";
array[i + 1] = CursorElement.Create(text, "", (Action)delegate
{
ConfirmReviveSingle(p2, singleCost);
}, (Func<CursorElement, bool>)((CursorElement elem) => CanAffordWithDailyLimit(singleCost)), true);
}
array[^1] = CursorElement.Create("Exit", "", (Action)delegate
{
CloseUI();
}, (Func<CursorElement, bool>)null, true);
mainMenu = CursorMenu.Create(0, '>', array, (Func<CursorElement, CursorElement, int>[])null);
mainScreen = (IScreen)(object)BoxedScreen.Create("Revive", (ITextElement[])(object)new ITextElement[3]
{
(ITextElement)TextElement.Create("Select a dead player or revive them all."),
(ITextElement)TextElement.Create(" "),
(ITextElement)mainMenu
});
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, mainMenu, true);
}
private int ComputeDisplayCost()
{
string text = Plugin.cfg.ReviveCostAlgorithm.Value.ToLower();
int value = Plugin.cfg.BaseReviveCost.Value;
switch (text)
{
case "flat":
return value;
case "exponential":
return value;
default:
{
if ((Object)(object)TimeOfDay.Instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null)
{
return 100;
}
float num = TimeOfDay.Instance.profitQuota;
int num2 = StartOfRound.Instance.connectedPlayersAmount + 1;
int num3 = (int)(num / (float)num2);
if (num3 < 1)
{
num3 = 1;
}
return num3;
}
}
}
private bool CanAffordWithDailyLimit(int neededCredits)
{
if ((Object)(object)ReviveStore.Instance != (Object)null && !ReviveStore.Instance.CanReviveNow())
{
return false;
}
Terminal terminal = Helper.Terminal;
return (Object)(object)terminal != (Object)null && terminal.groupCredits >= neededCredits;
}
private void ConfirmReviveSingle(PlayerControllerB p, int cost)
{
if (!CanAffordWithDailyLimit(cost))
{
((InteractiveTerminalApplication)this).ErrorMessage("Revive", (Action)delegate
{
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, mainMenu, true);
}, "Not enough credits or daily limit reached.");
return;
}
((InteractiveTerminalApplication)this).Confirm("Revive", $"Revive {p.playerUsername} for {cost} credits?", (Action)delegate
{
DoReviveSingle(p);
}, (Action)delegate
{
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, mainMenu, true);
}, "");
}
private void DoReviveSingle(PlayerControllerB p)
{
if ((Object)(object)ReviveStore.Instance == (Object)null)
{
((InteractiveTerminalApplication)this).ErrorMessage("Revive", (Action)delegate
{
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, mainMenu, true);
}, "ReviveStore missing.");
return;
}
ReviveStore.Instance.RequestReviveServerRpc(p.playerClientId);
((InteractiveTerminalApplication)this).ErrorMessage("Revive", (Action)delegate
{
CloseUI();
}, "Reviving " + p.playerUsername + "...");
}
private void ConfirmReviveAll(PlayerControllerB[] players)
{
int num = ComputeDisplayCost();
int num2 = players.Length * num;
if (!CanAffordWithDailyLimit(num2))
{
((InteractiveTerminalApplication)this).ErrorMessage("Revive", (Action)delegate
{
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, mainMenu, true);
}, "Not enough credits or daily limit reached.");
return;
}
StringBuilder stringBuilder = new StringBuilder("Revive all:\n\n");
PlayerControllerB[] array = players;
foreach (PlayerControllerB val in array)
{
stringBuilder.AppendLine(val.playerUsername);
}
stringBuilder.AppendLine($"\nTotal Cost: {num2}");
((InteractiveTerminalApplication)this).Confirm("Revive All", stringBuilder.ToString(), (Action)delegate
{
DoReviveAll(players);
}, (Action)delegate
{
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, mainMenu, true);
}, "");
}
private void DoReviveAll(PlayerControllerB[] players)
{
if ((Object)(object)ReviveStore.Instance == (Object)null)
{
((InteractiveTerminalApplication)this).ErrorMessage("Revive", (Action)delegate
{
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, mainMenu, true);
}, "ReviveStore missing.");
return;
}
foreach (PlayerControllerB val in players)
{
if ((Object)(object)val != (Object)null && val.isPlayerDead)
{
ReviveStore.Instance.RequestReviveServerRpc(val.playerClientId);
}
}
((InteractiveTerminalApplication)this).ErrorMessage("Revive", (Action)delegate
{
CloseUI();
}, "Reviving all dead players...");
}
private void ShowNoPlayersUI()
{
CursorMenu val = CursorMenu.Create(0, '>', (CursorElement[])(object)new CursorElement[1] { CursorElement.Create("Exit", "", (Action)delegate
{
CloseUI();
}, (Func<CursorElement, bool>)null, true) }, (Func<CursorElement, CursorElement, int>[])null);
mainScreen = (IScreen)(object)BoxedScreen.Create("Revive", (ITextElement[])(object)new ITextElement[3]
{
(ITextElement)TextElement.Create("No players found."),
(ITextElement)TextElement.Create(" "),
(ITextElement)val
});
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, val, true);
}
private void ShowNoDeadPlayersUI()
{
CursorMenu val = CursorMenu.Create(0, '>', (CursorElement[])(object)new CursorElement[1] { CursorElement.Create("Exit", "", (Action)delegate
{
CloseUI();
}, (Func<CursorElement, bool>)null, true) }, (Func<CursorElement, CursorElement, int>[])null);
mainScreen = (IScreen)(object)BoxedScreen.Create("Revive", (ITextElement[])(object)new ITextElement[3]
{
(ITextElement)TextElement.Create("No dead players to revive."),
(ITextElement)TextElement.Create(" "),
(ITextElement)val
});
((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen(mainScreen, val, true);
}
private void CloseUI()
{
if ((Object)(object)InteractiveTerminalManager.Instance != (Object)null)
{
Object.Destroy((Object)(object)((Component)InteractiveTerminalManager.Instance).gameObject);
}
}
}
}
namespace lethalCompanyRevive.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal static class DisconnectPatch
{
[HarmonyPostfix]
[HarmonyPatch("Disconnect")]
private static void OnGameDisconnect()
{
if ((Object)(object)ReviveStore.Instance != (Object)null)
{
ReviveStore.Instance.ResetAllValues();
NetworkObject component = ((Component)ReviveStore.Instance).GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null && component.IsSpawned)
{
component.Despawn(true);
}
else
{
Object.Destroy((Object)(object)((Component)ReviveStore.Instance).gameObject);
}
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyPatch("PassTimeToNextDay")]
public static class PassTimeResetRevivesPatch
{
[HarmonyPostfix]
public static void Postfix()
{
if ((Object)(object)ReviveStore.Instance != (Object)null)
{
ReviveStore.Instance.ResetDailyRevives();
Helper.PrintSystem("[ReviveStore] Daily revives reset at the start of the new day/round.");
}
}
}
}
namespace lethalCompanyRevive.Network
{
[HarmonyPatch]
public class ReviveNetworkManager
{
private static GameObject networkPrefab;
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
public static void Init()
{
if (!((Object)(object)networkPrefab != (Object)null))
{
networkPrefab = NetworkPrefabs.CreateNetworkPrefab("ReviveStore");
networkPrefab.AddComponent<ReviveStore>();
NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
private static void SpawnNetworkHandler()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.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, UnlockPrice, Description, Prefab, Prices);
}
}
public class PluginConfig
{
private readonly ConfigFile configFile;
public ConfigEntry<bool> EnableRevive;
public ConfigEntry<int> BaseReviveCost;
public ConfigEntry<string> ReviveCostAlgorithm;
public ConfigEntry<bool> EnableMaxRevivesPerDay;
public ConfigEntry<int> MaxRevivesPerDay;
public PluginConfig(ConfigFile file)
{
configFile = file;
}
public void InitBindings()
{
EnableRevive = configFile.Bind<bool>("General", "EnableRevive", true, "Enable or disable the entire revive feature.");
BaseReviveCost = configFile.Bind<int>("Costs", "BaseReviveCost", 100, "Base cost used in the revive formula.");
ReviveCostAlgorithm = configFile.Bind<string>("Costs", "ReviveCostAlgorithm", "Quota", "How the revive cost is calculated: Flat, Exponential, or Quota");
EnableMaxRevivesPerDay = configFile.Bind<bool>("Limits", "EnableMaxRevivesPerDay", false, "If true, limits how many revives can happen each real-life day.");
MaxRevivesPerDay = configFile.Bind<int>("Limits", "MaxRevivesPerDay", 3, "Max revives allowed per day (if EnableMaxRevivesPerDay is 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 internalStaticField = BindingFlags.Static | 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 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
{
return null;
}
}
private Reflector SetField(string variableName, object value, BindingFlags flags)
{
try
{
ObjType.GetField(variableName, flags).SetValue(Obj, value);
return this;
}
catch
{
return null;
}
}
private Reflector SetProperty(string propertyName, object value, BindingFlags flags)
{
try
{
ObjType.GetProperty(propertyName, flags).SetValue(Obj, value, null);
return this;
}
catch
{
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<object>(variableName);
return (obj == null) ? null : new Reflector(obj);
}
public Reflector GetInternalStaticField(string variableName)
{
object obj = GetInternalStaticField<object>(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 int dailyRevivesUsed;
public static ReviveStore Instance { get; private set; }
public override void OnNetworkSpawn()
{
if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
NetworkObject component = ((Component)Instance).GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null && component.IsSpawned)
{
component.Despawn(true);
}
}
Instance = this;
((NetworkBehaviour)this).OnNetworkSpawn();
}
public override void OnNetworkDespawn()
{
((NetworkBehaviour)this).OnNetworkDespawn();
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
}
[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)
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) || !Plugin.cfg.EnableRevive.Value || !CanReviveNow())
{
return;
}
PlayerControllerB player = Helper.GetPlayer(playerId.ToString());
if (!((Object)(object)player == (Object)null) && player.isPlayerDead)
{
int cost = ComputeReviveCost(dailyRevivesUsed);
if (CanAfford(cost))
{
DeductCredits(cost);
ReviveSinglePlayer(player);
IncrementDailyRevives();
}
}
}
public void ResetDailyRevives()
{
dailyRevivesUsed = 0;
}
public bool CanReviveNow()
{
if (!Plugin.cfg.EnableRevive.Value)
{
return false;
}
if (Plugin.cfg.EnableMaxRevivesPerDay.Value && dailyRevivesUsed >= Plugin.cfg.MaxRevivesPerDay.Value)
{
return false;
}
return true;
}
private void IncrementDailyRevives()
{
if (Plugin.cfg.EnableMaxRevivesPerDay.Value)
{
dailyRevivesUsed++;
}
}
private bool CanAfford(int cost)
{
GameObject obj = GameObject.Find("TerminalScript");
Terminal val = ((obj != null) ? obj.GetComponent<Terminal>() : null);
return (Object)(object)val != (Object)null && val.groupCredits >= cost;
}
private void DeductCredits(int cost)
{
GameObject obj = GameObject.Find("TerminalScript");
Terminal val = ((obj != null) ? obj.GetComponent<Terminal>() : null);
if (!((Object)(object)val == (Object)null))
{
val.groupCredits -= cost;
SyncCreditsServerRpc(val.groupCredits);
}
}
[ServerRpc(RequireOwnership = false)]
private 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)
{
return;
}
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))
{
GameObject obj = GameObject.Find("TerminalScript");
Terminal val3 = ((obj != null) ? obj.GetComponent<Terminal>() : null);
if ((Object)(object)val3 != (Object)null)
{
val3.groupCredits = newCredits;
}
}
}
private int ComputeReviveCost(int usageIndex)
{
string text = Plugin.cfg.ReviveCostAlgorithm.Value.ToLower();
int value = Plugin.cfg.BaseReviveCost.Value;
switch (text)
{
case "flat":
return value;
case "exponential":
return (int)((float)value * Mathf.Pow(2f, (float)usageIndex));
default:
{
if ((Object)(object)TimeOfDay.Instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null)
{
return 100;
}
int num = StartOfRound.Instance.connectedPlayersAmount + 1;
float num2 = TimeOfDay.Instance.profitQuota;
int num3 = (int)(num2 / (float)num);
if (num3 < 1)
{
num3 = 1;
}
return num3;
}
}
}
private void ReviveSinglePlayer(PlayerControllerB p)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
Vector3 playerSpawnPosition = GetPlayerSpawnPosition(GetPlayerIndex(p.playerUsername), simpleTeleport: false);
NetworkBehaviourReference netRef = default(NetworkBehaviourReference);
((NetworkBehaviourReference)(ref netRef))..ctor((NetworkBehaviour)(object)p);
RevivePlayer(playerSpawnPosition, netRef);
}
private void RevivePlayer(Vector3 position, NetworkBehaviourReference netRef)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
RevivePlayerClientRpc(position, netRef);
SyncLivingPlayersServerRpc();
}
[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_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: 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);
}
NetworkBehaviour val3 = default(NetworkBehaviour);
if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || !((NetworkBehaviourReference)(ref netRef)).TryGet(ref val3, (NetworkManager)null))
{
return;
}
PlayerControllerB component = ((Component)val3).GetComponent<PlayerControllerB>();
if ((Object)(object)component == (Object)null)
{
return;
}
int playerIndex = GetPlayerIndex(component.playerUsername);
component.ResetPlayerBloodObjects(component.isPlayerDead || component.isPlayerControlled);
component.isClimbingLadder = false;
component.clampLooking = false;
component.inVehicleAnimation = false;
component.disableMoveInput = false;
component.disableLookInput = false;
component.disableInteract = false;
component.ResetZAndXRotation();
((Collider)component.thisController).enabled = true;
component.health = 100;
component.hasBeenCriticallyInjured = false;
component.disableSyncInAnimation = false;
if (component.isPlayerDead)
{
component.isPlayerDead = false;
component.isPlayerControlled = true;
component.isInElevator = true;
component.isInHangarShipRoom = true;
component.isInsideFactory = false;
component.parentedToElevatorLastFrame = false;
component.overrideGameOverSpectatePivot = null;
if (((NetworkBehaviour)component).IsOwner)
{
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;
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.inShockingMinigame = false;
component.inSpecialInteractAnimation = false;
component.freeRotationInInteractAnimation = false;
component.inAnimationWithEnemy = null;
component.holdingWalkieTalkie = false;
component.speakingToWalkieTalkie = false;
component.isSinking = false;
component.isUnderwater = false;
component.sinkingValue = 0f;
component.statusEffectAudio.Stop();
component.DisableJetpackControlsLocally();
component.health = 100;
component.mapRadarDotAnimator.SetBool("dead", false);
component.externalForceAutoFade = Vector3.zero;
if (((NetworkBehaviour)component).IsOwner)
{
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;
component.reverbPreset = StartOfRound.Instance.shipReverb;
}
}
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)
{
((Component)component.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
}
}
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if ((Object)(object)localPlayerController == (Object)(object)component)
{
localPlayerController.bleedingHeavily = false;
localPlayerController.criticallyInjured = false;
if ((Object)(object)localPlayerController.playerBodyAnimator != (Object)null)
{
localPlayerController.playerBodyAnimator.SetBool("Limp", false);
}
localPlayerController.health = 100;
HUDManager.Instance.UpdateHealthUI(100, false);
localPlayerController.spectatedPlayerScript = null;
((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
HUDManager.Instance.RemoveSpectateUI();
HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
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 && ((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);
}
if (((NetworkBehaviour)this).IsServer)
{
StartOfRound instance = StartOfRound.Instance;
instance.livingPlayers++;
StartOfRound.Instance.allPlayersDead = false;
}
StartOfRound.Instance.UpdatePlayerVoiceEffects();
}
[ServerRpc(RequireOwnership = false)]
private void SyncLivingPlayersServerRpc()
{
//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)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1147924058u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1147924058u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
StartOfRound instance = StartOfRound.Instance;
int num = 0;
PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
foreach (PlayerControllerB val3 in allPlayerScripts)
{
if ((Object)(object)val3 != (Object)null && val3.isPlayerControlled && !val3.isPlayerDead)
{
num++;
}
}
instance.livingPlayers = num;
instance.allPlayersDead = num == 0;
SyncLivingPlayersClientRpc(num, instance.allPlayersDead);
}
[ClientRpc]
private void SyncLivingPlayersClientRpc(int newLiving, bool allDead)
{
//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_0071: 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)
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(1421352405u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, newLiving);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref allDead, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1421352405u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
StartOfRound instance = StartOfRound.Instance;
instance.livingPlayers = newLiving;
instance.allPlayersDead = allDead;
}
}
}
private int GetPlayerIndex(string username)
{
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance == (Object)null)
{
return -1;
}
PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
for (int i = 0; i < allPlayerScripts.Length; i++)
{
if ((Object)(object)allPlayerScripts[i] != (Object)null && allPlayerScripts[i].playerUsername == username)
{
return i;
}
}
return -1;
}
private Vector3 GetPlayerSpawnPosition(int playerNum, bool simpleTeleport)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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_00dc: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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)
//IL_0119: 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_0155: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance == (Object)null || instance.playerSpawnPositions == null)
{
return Vector3.zero;
}
if (simpleTeleport || playerNum < 0 || playerNum >= instance.playerSpawnPositions.Length)
{
return instance.playerSpawnPositions[0].position;
}
Transform[] playerSpawnPositions = instance.playerSpawnPositions;
if (playerSpawnPositions.Length == 0)
{
return Vector3.zero;
}
if (!Physics.CheckSphere(playerSpawnPositions[playerNum].position, 0.2f, 67108864, (QueryTriggerInteraction)1))
{
return playerSpawnPositions[playerNum].position;
}
if (!Physics.CheckSphere(playerSpawnPositions[playerNum].position + Vector3.up, 0.2f, 67108864, (QueryTriggerInteraction)1))
{
return playerSpawnPositions[playerNum].position + Vector3.up * 0.5f;
}
for (int i = 0; i < playerSpawnPositions.Length; i++)
{
if (i != playerNum)
{
if (!Physics.CheckSphere(playerSpawnPositions[i].position, 0.12f, -67108865, (QueryTriggerInteraction)1))
{
return playerSpawnPositions[i].position;
}
if (!Physics.CheckSphere(playerSpawnPositions[i].position + Vector3.up, 0.12f, 67108864, (QueryTriggerInteraction)1))
{
return playerSpawnPositions[i].position + Vector3.up * 0.5f;
}
}
}
Random random = new Random(65);
float y = playerSpawnPositions[0].position.y;
Vector3 val = default(Vector3);
for (int j = 0; j < 15; j++)
{
Bounds bounds = instance.shipInnerRoomBounds.bounds;
int minValue = (int)((Bounds)(ref bounds)).min.x;
int maxValue = (int)((Bounds)(ref bounds)).max.x;
int minValue2 = (int)((Bounds)(ref bounds)).min.z;
int maxValue2 = (int)((Bounds)(ref bounds)).max.z;
float num = random.Next(minValue, maxValue);
float num2 = random.Next(minValue2, maxValue2);
((Vector3)(ref val))..ctor(num, y, num2);
if (!Physics.CheckSphere(val, 0.12f, 67108864, (QueryTriggerInteraction)1))
{
return val;
}
}
return playerSpawnPositions[0].position + Vector3.up * 0.5f;
}
public void ResetAllValues()
{
dailyRevivesUsed = 0;
}
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
//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
NetworkManager.__rpc_func_table.Add(1810806528u, new RpcReceiveHandler(__rpc_handler_1810806528));
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(2289497067u, new RpcReceiveHandler(__rpc_handler_2289497067));
NetworkManager.__rpc_func_table.Add(1147924058u, new RpcReceiveHandler(__rpc_handler_1147924058));
NetworkManager.__rpc_func_table.Add(1421352405u, new RpcReceiveHandler(__rpc_handler_1421352405));
}
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;
}
}
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_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_1147924058(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;
((ReviveStore)(object)target).SyncLivingPlayersServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1421352405(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_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_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int newLiving = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref newLiving);
bool allDead = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref allDead, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((ReviveStore)(object)target).SyncLivingPlayersClientRpc(newLiving, allDead);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "ReviveStore";
}
}
}
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
{
}
}