Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LethalCredit v0.1.4
LethalCredit.dll
Decompiled 4 hours agousing System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using LethalCredit.Assets; using LethalCredit.Manager.Bank; using LethalCredit.Manager.Saves; using LethalCredit.NetcodePatcher; using LethalCredit.Network; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using QualityCompany.Events; using QualityCompany.Manager.ShipTerminal; using QualityCompany.Utils; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalCredit")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.4.0")] [assembly: AssemblyInformationalVersion("0.1.4+bdc895264ad859e3eda9a266d96049864ffde4c8")] [assembly: AssemblyProduct("LethalCredit")] [assembly: AssemblyTitle("LethalCredit")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 LethalCredit { internal class ModLogger { private readonly string _moduleName; internal ModLogger(string moduleName) { _moduleName = moduleName; } internal void TryLogDebug(object message) { if (Plugin.Instance.PluginConfig.ShowDebugLogs) { Plugin.Instance.Log.LogDebug((object)$"[{_moduleName}] {message}"); } } internal void LogDebug(object message) { Plugin.Instance.Log.LogDebug((object)$"[{_moduleName}] {message}"); } internal void LogDebugMode(object message) { Plugin.Instance.Log.LogDebug((object)$"[{_moduleName}] {message}"); } internal void LogMessage(object message) { Plugin.Instance.Log.LogMessage((object)$"[{_moduleName}] {message}"); } internal void LogWarning(object message) { Plugin.Instance.Log.LogWarning((object)$"[{_moduleName}] {message}"); } internal void LogInfo(object message) { Plugin.Instance.Log.LogInfo((object)$"[{_moduleName}] {message}"); } internal void LogError(object message) { Plugin.Instance.Log.LogError((object)$"[{_moduleName}] {message}"); } internal void LogFatal(object message) { Plugin.Instance.Log.LogFatal((object)$"[{_moduleName}] {message}"); } } [BepInPlugin("umno.LethalCredit", "LethalCredit", "0.1.3")] [BepInDependency("umno.QualityCompany", "1.5.1")] public class Plugin : BaseUnityPlugin { internal static Plugin Instance; internal ManualLogSource Log; internal PluginConfig PluginConfig; internal string PluginPath; private void Awake() { Instance = this; Log = Logger.CreateLogSource("LethalCredit"); PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); PluginConfig = new PluginConfig(); PluginConfig.Bind(((BaseUnityPlugin)this).Config); NetcodePatcher(); Patch(); LoadAssets(); Log.LogMessage((object)"Plugin LethalCredit v0.1.3 is loaded!"); } private static void NetcodePatcher() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } private void Patch() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown AdvancedTerminalRegistry.Register(Assembly.GetExecutingAssembly(), true, true, (string)null, "lcu", "Lethal Credit Union Bank, here to bank your scrap."); ModNetworkManager.Init(); GameEvents.StartOfRoundStart += (StartOfRoundEvent)delegate { Log.LogMessage((object)"Registered to StartOfRoundStart"); SaveManager.Init(); }; } private void LoadAssets() { AssetManager.LoadModBundle(PluginPath); ModNetworkManager.RegisterNetworkPrefab(AssetManager.LoadBundleAsset<Item>("LCUBucks").spawnPrefab); } } [Serializable] internal class PluginConfig { public string BankIgnoreList { get; set; } = ""; public bool AutoBankAtEndOfRound { get; set; } public bool AllowBankingCredits { get; set; } public int BankCreditsRatePercentage { get; set; } [JsonIgnore] public bool ShowDebugLogs { get; set; } internal void Bind(ConfigFile configFile) { BankIgnoreList = configFile.Bind<string>("Bank", "Bank Ignore list", "shotgun,gunammo,gift", "[HOST] A comma separated list of items to ignore in the ship when depositing items to Lethal Credit Union. Does not have to be the exact name but at least a matching portion. e.g. 'trag' for 'tragedy'").Value; AutoBankAtEndOfRound = configFile.Bind<bool>("Bank", "Auto bank scrap at end of round", false, "[HOST] Whether the bank will automatically deposit all your scrap after leaving a moon.").Value; AllowBankingCredits = configFile.Bind<bool>("Bank", "Allow banking credits", true, "[HOST] Whether the bank will accept you offering up available credits. This is only allowed on the day of deadline.").Value; BankCreditsRatePercentage = configFile.Bind<int>("Bank", "Banking credits rate percentage", 50, "[HOST] The banking percentage rate of giving your credits to The Lethal Credit Union.").Value; ShowDebugLogs = configFile.Bind<bool>("Debug", "ShowDebugLogs", false, "[CLIENT] Turn on/off specific debug logs.").Value; VerifyConfig(); } private void VerifyConfig() { BankIgnoreList = (Utility.IsNullOrWhiteSpace(BankIgnoreList) ? "shotgun,gunammo,gift" : BankIgnoreList); BankCreditsRatePercentage = Math.Clamp(BankCreditsRatePercentage, 10, 100); } internal void ApplyHostConfig(PluginConfig hostConfig) { AutoBankAtEndOfRound = hostConfig.AutoBankAtEndOfRound; BankIgnoreList = hostConfig.BankIgnoreList; AllowBankingCredits = hostConfig.AllowBankingCredits; BankCreditsRatePercentage = hostConfig.BankCreditsRatePercentage; } internal void DebugPrintConfig(ModLogger logger) { foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this)) { string name = property.Name; object value = property.GetValue(this); logger.LogDebug($"{name}={value}"); } } } internal class PluginMetadata { public const string PLUGIN_GUID = "umno.LethalCredit"; public const string PLUGIN_NAME = "LethalCredit"; public const string PLUGIN_VERSION = "0.1.3"; } } namespace LethalCredit.Network { internal class ModNetworkManager { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static GameNetworkManagerEvent <>9__2_0; public static StartOfRoundEvent <>9__2_1; internal void <Init>b__2_0(GameNetworkManager _) { Start(); } internal void <Init>b__2_1(StartOfRound _) { Load(); } } private static GameObject? _networkPrefab; private static readonly List<GameObject> _networkPrefabs = new List<GameObject>(); internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown object obj = <>c.<>9__2_0; if (obj == null) { GameNetworkManagerEvent val = delegate { Start(); }; <>c.<>9__2_0 = val; obj = (object)val; } GameEvents.GameNetworkManagerStart += (GameNetworkManagerEvent)obj; object obj2 = <>c.<>9__2_1; if (obj2 == null) { StartOfRoundEvent val2 = delegate { Load(); }; <>c.<>9__2_1 = val2; obj2 = (object)val2; } GameEvents.StartOfRoundAwake += (StartOfRoundEvent)obj2; } private static void Start() { Plugin.Instance.Log.LogMessage((object)"GameNetworkManager.Start"); _networkPrefab = AssetManager.LoadBundleAsset<GameObject>("NetworkHandler"); _networkPrefab.AddComponent<BankNetworkHandler>(); RegisterNetworkPrefab(_networkPrefab); foreach (GameObject networkPrefab in _networkPrefabs) { if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(networkPrefab)) { NetworkManager.Singleton.AddNetworkPrefab(networkPrefab); } } } private static void Load() { //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) Plugin.Instance.Log.LogMessage((object)"StartOfRound.Awake"); if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && _networkPrefab != null) { Object.Instantiate<GameObject>(_networkPrefab, Vector3.zero, Quaternion.identity).GetComponent<NetworkObject>().Spawn(false); } } public static void RegisterNetworkPrefab(GameObject prefab) { if (!_networkPrefabs.Contains(prefab)) { _networkPrefabs.Add(prefab); } } } } namespace LethalCredit.Manager.Saves { internal class GameSaveData { public int BankBalance { get; set; } internal void ResetGameState() { BankBalance = 0; } } internal class SaveManager { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static GameNetworkManagerEvent <>9__8_0; public static GameNetworkManagerEvent <>9__8_1; public static StartOfRoundEvent <>9__8_2; public static StartOfRoundEvent <>9__8_3; internal void <Init>b__8_0(GameNetworkManager _) { SaveData = new GameSaveData(); } internal void <Init>b__8_1(GameNetworkManager _) { Save(); } internal void <Init>b__8_2(StartOfRound instance) { Logger.LogMessage($"StartOfRound.EndOfGame, allDead? {instance.allPlayersDead}"); if (instance.allPlayersDead) { SaveData.BankBalance = 0; } } internal void <Init>b__8_3(StartOfRound _) { SaveData.BankBalance = 0; Save(); } } private static readonly ModLogger Logger = new ModLogger("SaveManager"); private const string SaveDataKey = "UMNO_LCU_DATA"; internal static GameSaveData SaveData { get; private set; } = new GameSaveData(); private static bool IsHost => GameNetworkManager.Instance.isHostingGame; internal static void Init() { //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_0024: Expected O, but got Unknown //IL_003d: 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_0048: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0085: 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: Expected O, but got Unknown Load(); object obj = <>c.<>9__8_0; if (obj == null) { GameNetworkManagerEvent val = delegate { SaveData = new GameSaveData(); }; <>c.<>9__8_0 = val; obj = (object)val; } GameEvents.Disconnected += (GameNetworkManagerEvent)obj; object obj2 = <>c.<>9__8_1; if (obj2 == null) { GameNetworkManagerEvent val2 = delegate { Save(); }; <>c.<>9__8_1 = val2; obj2 = (object)val2; } GameEvents.SaveGame += (GameNetworkManagerEvent)obj2; object obj3 = <>c.<>9__8_2; if (obj3 == null) { StartOfRoundEvent val3 = delegate(StartOfRound instance) { Logger.LogMessage($"StartOfRound.EndOfGame, allDead? {instance.allPlayersDead}"); if (instance.allPlayersDead) { SaveData.BankBalance = 0; } }; <>c.<>9__8_2 = val3; obj3 = (object)val3; } GameEvents.EndOfGame += (StartOfRoundEvent)obj3; object obj4 = <>c.<>9__8_3; if (obj4 == null) { StartOfRoundEvent val4 = delegate { SaveData.BankBalance = 0; Save(); }; <>c.<>9__8_3 = val4; obj4 = (object)val4; } GameEvents.PlayersFired += (StartOfRoundEvent)obj4; } internal static void Load() { if (IsHost) { string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; Logger.LogDebug("HOST: using game save file at " + currentSaveFileName); string text = (string)ES3.Load("UMNO_LCU_DATA", currentSaveFileName, (object)null); if (text != null) { Logger.LogDebug(" > data found! loading..."); LoadSaveJson(text); } else { Logger.LogDebug(" > no data! starting new..."); Save(); } } } internal static void Save() { if (IsHost) { string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; string text = JsonConvert.SerializeObject((object)SaveData); ES3.Save<string>("UMNO_LCU_DATA", text, currentSaveFileName); } } internal static void ClientLoadFromString(string saveJson) { Logger.TryLogDebug("CLIENT: Save file received from host, updating."); LoadSaveJson(saveJson); } private static void LoadSaveJson(string saveJson) { try { <SaveManager>FB7FAE3DDFAF7D5F62074710CDE44CF9F1C82EDB600E24576D1C4D6F2F532A6E8__SaveData <SaveManager>FB7FAE3DDFAF7D5F62074710CDE44CF9F1C82EDB600E24576D1C4D6F2F532A6E8__SaveData2 = JsonConvert.DeserializeObject<<SaveManager>FB7FAE3DDFAF7D5F62074710CDE44CF9F1C82EDB600E24576D1C4D6F2F532A6E8__SaveData>(saveJson); SaveData = new GameSaveData { BankBalance = <SaveManager>FB7FAE3DDFAF7D5F62074710CDE44CF9F1C82EDB600E24576D1C4D6F2F532A6E8__SaveData2.BankBalance }; Logger.TryLogDebug(JsonConvert.SerializeObject((object)SaveData)); Plugin.Instance.PluginConfig.DebugPrintConfig(Logger); } catch (Exception ex) { Logger.LogError("Save file has been corrupted or edited, resetting. Error: " + ex.Message); SaveData = new GameSaveData(); Save(); } } } [Serializable] internal class <SaveManager>FB7FAE3DDFAF7D5F62074710CDE44CF9F1C82EDB600E24576D1C4D6F2F532A6E8__SaveData { public int BankBalance { get; set; } } } namespace LethalCredit.Manager.Bank { internal class BankNetworkHandler : NetworkBehaviour { private readonly ModLogger Logger = new ModLogger("BankNetworkHandler"); private bool _retrievedPluginConfig; private bool _retrievedSaveFile; public static BankNetworkHandler Instance { get; private set; } private void Start() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Instance = this; if (((NetworkBehaviour)this).IsHost) { GameEvents.DisplayDaysLeft += (HUDEvent)delegate { AutobankScrap(); }; } else { Logger.TryLogDebug("CLIENT: Requesting hosts config..."); RequestPluginConfigServerRpc(); RequestSaveDataServerRpc(); } } [ServerRpc(RequireOwnership = false)] private void RequestPluginConfigServerRpc() { //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) //IL_00c1: 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(4130468701u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4130468701u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Logger.TryLogDebug("HOST: A client is requesting plugin config"); string json = JsonConvert.SerializeObject((object)Plugin.Instance.PluginConfig); SendPluginConfigClientRpc(json); } } } [ClientRpc] private void SendPluginConfigClientRpc(string json) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1345462468u, val, (RpcDelivery)0); bool flag = json != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(json, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1345462468u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) { return; } if (_retrievedPluginConfig) { Logger.TryLogDebug("CLIENT: Config has already been received from host, disregarding."); return; } _retrievedPluginConfig = true; PluginConfig pluginConfig = JsonConvert.DeserializeObject<PluginConfig>(json); if (pluginConfig == null) { Logger.LogError("CLIENT: failed to deserialize plugin config from host, disregarding. raw json: " + json); return; } Logger.TryLogDebug("Config received, deserializing and constructing..."); Plugin.Instance.PluginConfig.ApplyHostConfig(pluginConfig); } [ServerRpc(RequireOwnership = false)] private void RequestSaveDataServerRpc() { //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) //IL_00c1: 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(2940764626u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2940764626u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Logger.TryLogDebug("HOST: A client is requesting save data"); string json = JsonConvert.SerializeObject((object)SaveManager.SaveData); SendSaveDataClientRpc(json); } } } [ClientRpc] private void SendSaveDataClientRpc(string json) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3526860281u, val, (RpcDelivery)0); bool flag = json != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(json, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3526860281u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!((NetworkBehaviour)this).IsHost && !((NetworkBehaviour)this).IsServer && !_retrievedSaveFile) { _retrievedSaveFile = true; SaveManager.ClientLoadFromString(json); } } } [ServerRpc(RequireOwnership = false)] public void DepositServerRpc(ulong[] networkObjectId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1011051222u, val, (RpcDelivery)0); bool flag = networkObjectId != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(networkObjectId, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1011051222u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; ulong[] networkObjectId2 = networkObjectId; Logger.LogDebugMode("DepositServerRpc"); ulong[] array = networkObjectId2; for (int i = 0; i < array.Length; i++) { _ = array[i]; Logger.LogDebugMode($" {networkObjectId2}"); } List<GrabbableObject> list = (from x in ScrapUtils.GetAllScrapInShip() where networkObjectId2.Contains(((NetworkBehaviour)x).NetworkObjectId) select x).ToList(); Logger.LogDebugMode($" Scraps found count: {list.Count}"); int num = 0; foreach (GrabbableObject item in list) { Logger.LogDebugMode($" {networkObjectId2}"); num += item.scrapValue; ((Component)item).GetComponent<NetworkObject>().Despawn(true); } DepositClientRpc(num); } [ClientRpc] private void DepositClientRpc(int depositValue) { //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_00ce: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2751772295u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, depositValue); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2751772295u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; int bankBalance = SaveManager.SaveData.BankBalance; SaveManager.SaveData.BankBalance += depositValue; HudUtils.DisplayNotification($"LCU balance has increased from ${bankBalance} to ${SaveManager.SaveData.BankBalance}"); } } } [ServerRpc(RequireOwnership = false)] internal void WithdrawServerRpc(int amount, ulong playerClientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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(331480255u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, amount); BytePacker.WriteValueBitPacked(val2, playerClientId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 331480255u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; ulong playerClientId2 = playerClientId; GameObject spawnPrefab = ((Item)AssetManager.AssetCache["LCUBucks"]).spawnPrefab; PlayerControllerB val3 = ((IEnumerable<PlayerControllerB>)GameUtils.StartOfRound.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB script) => script.playerClientId == playerClientId2)); if (val3 == null) { Logger.LogFatal($"Tried to execute withdraw with an unknown player script with playerClientId {playerClientId2}"); return; } GameObject val4 = Object.Instantiate<GameObject>(spawnPrefab, ((Component)val3).transform.position, Quaternion.identity); GrabbableObject component = val4.GetComponent<GrabbableObject>(); if (component == null) { Logger.LogFatal(((Object)val4).name + ": did not have a GrabbableObject component"); return; } Logger.TryLogDebug($" > spawned in {((Object)val4).name} for {amount}"); val4.GetComponent<NetworkObject>().Spawn(false); WithdrawClientRpc(amount, val3.playerUsername, new NetworkBehaviourReference((NetworkBehaviour)(object)component)); } [ClientRpc] private void WithdrawClientRpc(int amount, string username, 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2713663247u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, amount); bool flag = username != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(username, false); } ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netRef, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2713663247u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; GrabbableObject val3 = default(GrabbableObject); ((NetworkBehaviourReference)(ref netRef)).TryGet<GrabbableObject>(ref val3, (NetworkManager)null); if (val3 == null) { Logger.LogFatal("Unable to resolve net ref for WithdrawClientRpc!"); return; } ((Component)val3).transform.parent = GameUtils.ShipGameObject.transform; if (amount != 0) { val3.scrapValue = amount; val3.itemProperties.creditsWorth = amount; ((Component)val3).GetComponentInChildren<ScanNodeProperties>().subText = $"Value: ${amount}"; SaveManager.SaveData.BankBalance -= amount; HudUtils.DisplayNotification($"LCU: {username} has withdrawn ${amount}! Balance: ${SaveManager.SaveData.BankBalance}"); Logger.TryLogDebug("Successfully synced values of " + val3.itemProperties.itemName); } } private void AutobankScrap() { if (!Plugin.Instance.PluginConfig.AutoBankAtEndOfRound) { Logger.LogDebug("Autobank is disabled, skipping"); return; } if (GameUtils.IsOnCompany()) { Logger.TryLogDebug("On the company, will not autobank"); return; } Logger.LogDebug("Autobank starting..."); List<GrabbableObject> allIncludedScrapInShip = ScrapUtils.GetAllIncludedScrapInShip(Plugin.Instance.PluginConfig.BankIgnoreList); if (!allIncludedScrapInShip.Any()) { Logger.LogDebug(" > No items to autobank on round ended."); return; } int num = 0; foreach (GrabbableObject item in allIncludedScrapInShip) { Logger.LogDebug($" > {((Object)item).name} for {item.scrapValue}"); NetworkObject component = ((Component)item).GetComponent<NetworkObject>(); if (component == null) { Logger.LogError(" > is null, ignoring"); continue; } if (!component.IsSpawned) { Logger.LogError(" > is NOT spawned?? ignoring"); continue; } component.Despawn(true); num += item.scrapValue; } Logger.LogDebug($"Autobank complete! Banked {allIncludedScrapInShip.Count} scrap for a total of {num}"); AutobankClientRpc(allIncludedScrapInShip.Count, num); SaveManager.Save(); } [ClientRpc] private void AutobankClientRpc(int depositCount, int depositValue) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4170822710u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, depositCount); BytePacker.WriteValueBitPacked(val2, depositValue); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4170822710u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; int bankBalance = SaveManager.SaveData.BankBalance; SaveManager.SaveData.BankBalance += depositValue; Logger.TryLogDebug($"Autobank: balance increased from {bankBalance} to {SaveManager.SaveData.BankBalance}"); HudUtils.DisplayNotification($"LCU has auto-banked {depositCount} scrap items. Balance: ${SaveManager.SaveData.BankBalance}"); } } } [ServerRpc(RequireOwnership = false)] public void BankCreditsServerRpc(int amount) { //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_00ce: 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(2125368227u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, amount); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2125368227u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; BankCreditsClientRpc(amount, BankUtils.GetBankAmountForCredits(amount)); } } } [ClientRpc] private void BankCreditsClientRpc(int amount, int bankedAmount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2460083066u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, amount); BytePacker.WriteValueBitPacked(val2, bankedAmount); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2460083066u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Logger.LogDebug($"Banking {amount} credits for {bankedAmount} LCU bucks"); SaveManager.SaveData.BankBalance += bankedAmount; Terminal terminal = GameUtils.Terminal; terminal.groupCredits -= amount; HudUtils.DisplayNotification($"LCU has banked ${amount} credits. Balance: ${SaveManager.SaveData.BankBalance}"); } } } [ServerRpc(RequireOwnership = false)] internal void ToggleAutobankStatusServerRpc() { //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) //IL_00c1: 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(3838735601u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3838735601u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ToggleAutobankStatusClientRpc(); } } } [ClientRpc] private void ToggleAutobankStatusClientRpc() { //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) //IL_00c1: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3441800974u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3441800974u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Plugin.Instance.PluginConfig.AutoBankAtEndOfRound = !Plugin.Instance.PluginConfig.AutoBankAtEndOfRound; HudUtils.DisplayNotification("Autobank has been " + (Plugin.Instance.PluginConfig.AutoBankAtEndOfRound ? "enabled" : "disabled")); } } } [ClientRpc] internal void SyncBankBalanceClientRpc(int amount) { //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_00ce: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1367712910u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, amount); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1367712910u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; SaveManager.SaveData.BankBalance = amount; HudUtils.DisplayNotification($"LCU: The host has forced bank balance to ${amount}"); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(4130468701u, new RpcReceiveHandler(__rpc_handler_4130468701), "RequestPluginConfigServerRpc"); ((NetworkBehaviour)this).__registerRpc(1345462468u, new RpcReceiveHandler(__rpc_handler_1345462468), "SendPluginConfigClientRpc"); ((NetworkBehaviour)this).__registerRpc(2940764626u, new RpcReceiveHandler(__rpc_handler_2940764626), "RequestSaveDataServerRpc"); ((NetworkBehaviour)this).__registerRpc(3526860281u, new RpcReceiveHandler(__rpc_handler_3526860281), "SendSaveDataClientRpc"); ((NetworkBehaviour)this).__registerRpc(1011051222u, new RpcReceiveHandler(__rpc_handler_1011051222), "DepositServerRpc"); ((NetworkBehaviour)this).__registerRpc(2751772295u, new RpcReceiveHandler(__rpc_handler_2751772295), "DepositClientRpc"); ((NetworkBehaviour)this).__registerRpc(331480255u, new RpcReceiveHandler(__rpc_handler_331480255), "WithdrawServerRpc"); ((NetworkBehaviour)this).__registerRpc(2713663247u, new RpcReceiveHandler(__rpc_handler_2713663247), "WithdrawClientRpc"); ((NetworkBehaviour)this).__registerRpc(4170822710u, new RpcReceiveHandler(__rpc_handler_4170822710), "AutobankClientRpc"); ((NetworkBehaviour)this).__registerRpc(2125368227u, new RpcReceiveHandler(__rpc_handler_2125368227), "BankCreditsServerRpc"); ((NetworkBehaviour)this).__registerRpc(2460083066u, new RpcReceiveHandler(__rpc_handler_2460083066), "BankCreditsClientRpc"); ((NetworkBehaviour)this).__registerRpc(3838735601u, new RpcReceiveHandler(__rpc_handler_3838735601), "ToggleAutobankStatusServerRpc"); ((NetworkBehaviour)this).__registerRpc(3441800974u, new RpcReceiveHandler(__rpc_handler_3441800974), "ToggleAutobankStatusClientRpc"); ((NetworkBehaviour)this).__registerRpc(1367712910u, new RpcReceiveHandler(__rpc_handler_1367712910), "SyncBankBalanceClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_4130468701(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; ((BankNetworkHandler)(object)target).RequestPluginConfigServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1345462468(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string json = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref json, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).SendPluginConfigClientRpc(json); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2940764626(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; ((BankNetworkHandler)(object)target).RequestSaveDataServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3526860281(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string json = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref json, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).SendSaveDataClientRpc(json); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1011051222(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); ulong[] networkObjectId = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).DepositServerRpc(networkObjectId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2751772295(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 depositValue = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref depositValue); target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).DepositClientRpc(depositValue); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_331480255(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int amount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref amount); ulong playerClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).WithdrawServerRpc(amount, playerClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2713663247(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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int amount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref amount); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string username = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref username, false); } NetworkBehaviourReference netRef = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netRef, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).WithdrawClientRpc(amount, username, netRef); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4170822710(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int depositCount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref depositCount); int depositValue = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref depositValue); target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).AutobankClientRpc(depositCount, depositValue); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2125368227(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 amount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref amount); target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).BankCreditsServerRpc(amount); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2460083066(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int amount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref amount); int bankedAmount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref bankedAmount); target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).BankCreditsClientRpc(amount, bankedAmount); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3838735601(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; ((BankNetworkHandler)(object)target).ToggleAutobankStatusServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3441800974(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; ((BankNetworkHandler)(object)target).ToggleAutobankStatusClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1367712910(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 amount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref amount); target.__rpc_exec_stage = (__RpcExecStage)1; ((BankNetworkHandler)(object)target).SyncBankBalanceClientRpc(amount); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "BankNetworkHandler"; } } internal class BankUtils { internal static int GetBankAmountForCredits(int creditsAmount) { float num = (float)Plugin.Instance.PluginConfig.BankCreditsRatePercentage / 100f; return (int)((float)creditsAmount * num); } } } namespace LethalCredit.Commands { internal class Command1Balance { [TerminalCommand] private static TerminalCommandBuilder Balance() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalCommandBuilder("lcu-balance").WithHelpDescription("Check up on your current balance").WithAction((Func<string>)(() => $"Your balance is ${SaveManager.SaveData.BankBalance}")); } } internal class Command2Deposit { private static List<GrabbableObject> _recommendedScraps = new List<GrabbableObject>(); private static int _valueFor; [TerminalCommand] private static TerminalCommandBuilder Deposit() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalCommandBuilder("lcu-deposit").WithHelpDescription("Let LCU gobble up your scrap to a safe place").WithSubCommand(CreateDepositAllCommand()).WithSubCommand(CreateDepositSubCommand()) .AddTextReplacement("[valueFor]", (Func<string>)(() => $"${_valueFor}")) .AddTextReplacement("[depositActualTotal]", (Func<string>)(() => $"${ScrapUtils.ScrapValueOfCollection((IEnumerable<GrabbableObject>)_recommendedScraps)}")) .AddTextReplacement("[depositScrapCombo]", (Func<string>)GenerateDepositScrapComboText) .AddTextReplacement("[numScrapDeposited]", (Func<int>)(() => _recommendedScraps.Count)) .AddTextReplacement("[newBalance]", (Func<string>)(() => $"${SaveManager.SaveData.BankBalance - _valueFor}")) .AddTextReplacement("[bankBalance]", (Func<string>)(() => $"${SaveManager.SaveData.BankBalance}")) .AddTextReplacement("[shipActualTotal]", (Func<string>)(() => $"${ScrapUtils.GetShipTotalIncludedScrapValue(Plugin.Instance.PluginConfig.BankIgnoreList)}")) .WithCondition("d_hasScrapItems", "You do not have any scrap available to for deposit.", (Func<bool>)(() => ScrapUtils.GetAllIncludedScrapInShip(Plugin.Instance.PluginConfig.BankIgnoreList).Count > 0)) .WithCondition("depositMoreThanZero", "Do you really think you can deposit nothing?", (Func<bool>)(() => _valueFor > 0)) .WithCondition("notEnoughScrap", "LCU is not happy with this. You do not enough scrap to deposit [valueFor].\n\nYour currently have a total of [shipActualTotal].", (Func<bool>)(() => _valueFor < ScrapUtils.GetShipTotalIncludedScrapValue(Plugin.Instance.PluginConfig.BankIgnoreList))); static string GenerateDepositScrapComboText() { if (_recommendedScraps == null || _recommendedScraps.Count == 0) { return "No items"; } return _recommendedScraps.Select((GrabbableObject x) => $"{((Object)x.itemProperties).name}: {x.scrapValue}").Aggregate((string first, string next) => first + "\n" + next); } } private static TerminalSubCommandBuilder CreateDepositAllCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("all").WithDescription("Deposit all available scrap in the ship.").WithMessage("Requesting to deposit ALL scrap.\n\nLethal Credit Union will accept the following items for a total of [depositActualTotal]:\n[depositScrapCombo]").EnableConfirmDeny("Deposited [numScrapDeposited] scrap items for [depositActualTotal].", (string)null) .WithConditions(new string[1] { "d_hasScrapItems" }) .WithPreAction((Action)delegate { _recommendedScraps = ScrapUtils.GetAllIncludedScrapInShip(Plugin.Instance.PluginConfig.BankIgnoreList); _valueFor = ScrapUtils.ActualScrapValueOfCollection((IEnumerable<GrabbableObject>)_recommendedScraps); }) .WithAction((Action)delegate { BankNetworkHandler.Instance.DepositServerRpc(_recommendedScraps.Select((GrabbableObject x) => ((NetworkBehaviour)x).NetworkObjectId).ToArray()); }); } private static TerminalSubCommandBuilder CreateDepositSubCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("<deposit_amount>").WithDescription("Deposit as close as possible to input amount").WithMessage("Requesting to deposit value close to [valueFor].\n\nLethal Credit Union will accept the following items for a total of [depositActualTotal]:\n[depositScrapCombo]").EnableConfirmDeny("Deposited [numScrapDeposited] scrap items for [depositActualTotal].", (string)null) .WithConditions(new string[2] { "d_hasScrapItems", "notEnoughScrap" }) .WithInputMatch("^(\\d+)$") .WithPreAction((Action<string>)delegate(string? input) { _valueFor = Convert.ToInt32(input); _recommendedScraps = (from x in GetScrapForDeposit(_valueFor) orderby ((Object)x.itemProperties).name, x.scrapValue descending select x).ToList(); }) .WithAction((Action)delegate { BankNetworkHandler.Instance.DepositServerRpc(_recommendedScraps.Select((GrabbableObject x) => ((NetworkBehaviour)x).NetworkObjectId).ToArray()); }); } private static IEnumerable<GrabbableObject> GetScrapForDeposit(int amount) { if (ScrapUtils.GetShipTotalIncludedScrapValue(Plugin.Instance.PluginConfig.BankIgnoreList) < amount) { return new List<GrabbableObject>(); } int count = 0; List<GrabbableObject> list = (from scrap in ScrapUtils.GetAllIncludedScrapInShip(Plugin.Instance.PluginConfig.BankIgnoreList) orderby scrap.itemProperties.twoHanded descending, scrap.scrapValue descending select scrap).ToList(); List<GrabbableObject> list2 = new List<GrabbableObject>(); while (amount > 300) { GrabbableObject val = list[count++]; list2.Add(val); amount -= val.scrapValue; } list = (from scrap in list.Skip(count) orderby scrap.scrapValue select scrap).ToList(); count = 0; if (amount < list.Last().scrapValue) { list2.Add(list.Last()); return list2; } while (amount > 0) { List<(GrabbableObject, GrabbableObject)> list3 = new List<(GrabbableObject, GrabbableObject)>(); for (int i = count; i < list.Count; i++) { for (int j = i + 1; j < list.Count; j++) { list3.Add((list[i], list[j])); } } (GrabbableObject, GrabbableObject) tuple = list3.FirstOrDefault<(GrabbableObject, GrabbableObject)>(((GrabbableObject First, GrabbableObject Second) combo) => combo.First.scrapValue + combo.Second.scrapValue >= amount); var (val2, val3) = tuple; if ((Object)(object)val2 != (Object)null || (Object)(object)val3 != (Object)null) { list2.Add(tuple.Item1); list2.Add(tuple.Item2); return list2; } GrabbableObject val4 = list[count++]; list2.Add(val4); amount -= val4.scrapValue; } return list2; } } internal class Command3Autobank { [TerminalCommand] private static TerminalCommandBuilder Autobank() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) AdvancedTerminal.AddGlobalTextReplacement("[lcu__autobankStatus]", (Func<string>)(() => (!Plugin.Instance.PluginConfig.AutoBankAtEndOfRound) ? "off" : "on")); return new TerminalCommandBuilder("lcu-autobank").WithHelpDescription("Status: [lcu__autobankStatus]\nTurn LCU autobank feature on / off. Autobank will automatically deposit all matching scrap at the end of a game round.\nNote:This does not update the config").WithAction((Func<string>)delegate { bool num = !Plugin.Instance.PluginConfig.AutoBankAtEndOfRound; BankNetworkHandler.Instance.ToggleAutobankStatusServerRpc(); return num ? "Autobank has been enabled!\n\nAll matching scrap at the end of game rounds will be automatically banked into LCU Bank." : "Autobank has been disabled!"; }); } } internal class Command3Withdraw { private static List<GrabbableObject> _recommendedScraps = new List<GrabbableObject>(); private static int _valueFor; private static int _newBalance; [TerminalCommand] private static TerminalCommandBuilder Withdraw() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalCommandBuilder("lcu-withdraw").WithHelpDescription("Withdraw some money from The Lethal Credit Union Bank").WithSubCommand(CreateWithdrawAllCommand()).WithSubCommand(CreateWithdrawQuotaCommand()) .WithSubCommand(CreateWithdrawSubCommand()) .AddTextReplacement("[valueFor]", (Func<string>)(() => $"${_valueFor}")) .AddTextReplacement("[depositActualTotal]", (Func<string>)(() => $"${ScrapUtils.ScrapValueOfCollection((IEnumerable<GrabbableObject>)_recommendedScraps)}")) .AddTextReplacement("[depositScrapCombo]", (Func<string>)GenerateDepositScrapComboText) .AddTextReplacement("[numScrapDeposited]", (Func<int>)(() => _recommendedScraps.Count)) .AddTextReplacement("[newBalance]", (Func<string>)(() => $"${_newBalance}")) .AddTextReplacement("[bankBalance]", (Func<string>)(() => $"${SaveManager.SaveData.BankBalance}")) .WithCondition("hasEnoughBalance", "You do not have enough money in the bank.\n\nCurrent balance: [bankBalance].", (Func<bool>)(() => SaveManager.SaveData.BankBalance >= _valueFor)); static string GenerateDepositScrapComboText() { if (_recommendedScraps == null || _recommendedScraps.Count == 0) { return "No items"; } return _recommendedScraps.Select((GrabbableObject x) => $"{((Object)x.itemProperties).name}: {x.scrapValue}").Aggregate((string first, string next) => first + "\n" + next); } } private static TerminalSubCommandBuilder CreateWithdrawAllCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("all").WithDescription("Withdraw all LCU bucks").WithMessage("Withdrawing [valueFor].\n\nYour new balance would be [newBalance]").EnableConfirmDeny("Withdrew [valueFor].\n\nYour balance: [newBalance]", (string)null) .WithConditions(new string[1] { "hasEnoughBalance" }) .WithPreAction((Action)delegate { _valueFor = SaveManager.SaveData.BankBalance; _newBalance = 0; }) .WithAction((Action)delegate { BankNetworkHandler.Instance.WithdrawServerRpc(_valueFor, GameNetworkManager.Instance.localPlayerController.playerClientId); }); } private static TerminalSubCommandBuilder CreateWithdrawQuotaCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("quota").WithDescription("Withdraw LCU bucks equivalent to current quota").WithMessage("Withdrawing [valueFor].\n\nYour new balance would be [newBalance]").EnableConfirmDeny("Withdrew [valueFor].\n\nYour balance: [newBalance]", (string)null) .WithConditions(new string[1] { "hasEnoughBalance" }) .WithPreAction((Action)delegate { _valueFor = TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled; _newBalance = SaveManager.SaveData.BankBalance - _valueFor; }) .WithAction((Action)delegate { BankNetworkHandler.Instance.WithdrawServerRpc(_valueFor, GameNetworkManager.Instance.localPlayerController.playerClientId); }); } private static TerminalSubCommandBuilder CreateWithdrawSubCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("<amount>").WithDescription("Withdraw a specific amount of LCU bucks").WithMessage("Withdrawing [valueFor].\n\nYour new balance would be [newBalance]").EnableConfirmDeny("Withdrew [valueFor].\n\nYour balance: [newBalance]", (string)null) .WithConditions(new string[1] { "hasEnoughBalance" }) .WithInputMatch("^(\\d+)$") .WithPreAction((Action<string>)delegate(string? input) { _valueFor = Convert.ToInt32(input); _newBalance = SaveManager.SaveData.BankBalance - _valueFor; }) .WithAction((Action)delegate { BankNetworkHandler.Instance.WithdrawServerRpc(_valueFor, GameNetworkManager.Instance.localPlayerController.playerClientId); }); } } internal class Command4Credits { private static int _creditsFor; private static int _bankValueFor; private static int _newCredits; private static int _newBalance; [TerminalCommand] private static TerminalCommandBuilder Credits() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Instance.PluginConfig.AllowBankingCredits) { return null; } return new TerminalCommandBuilder("lcu-credits").WithHelpDescription("Bank all or some of your credits to The Lethal Credit Union Bank").WithSubCommand(CreateCreditsAllCommand()).WithSubCommand(CreateCreditsAmountCommand()) .AddTextReplacement("[creditsFor]", (Func<string>)(() => $"${_creditsFor}")) .AddTextReplacement("[bankValueFor]", (Func<string>)(() => $"${_bankValueFor}")) .AddTextReplacement("[newCredits]", (Func<string>)(() => $"${_newCredits}")) .AddTextReplacement("[newBalance]", (Func<string>)(() => $"${_newBalance}")) .AddTextReplacement("[currentCredits]", (Func<string>)(() => $"${GameUtils.Terminal.groupCredits}")) .AddTextReplacement("[bankRate]", (Func<string>)(() => $"{Plugin.Instance.PluginConfig.BankCreditsRatePercentage}%")) .WithCondition("notEnoughCredits", "You do not have enough credits.\n\nCurrent credits: [currentCredits].", (Func<bool>)(() => GameUtils.Terminal.groupCredits >= _creditsFor)); } private static TerminalSubCommandBuilder CreateCreditsAllCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("all").WithDescription("Withdraw current quota").WithMessage("Requesting to trade [creditsFor] credits at a rate of [bankRate].\n\nCurrent credits: [currentCredits]\nTrade value: [bankValueFor] LCU bucks\n\nForecasted credits balance: [newCredits]\nForecasted LCU bank balance: [newBalance] LCU bucks").EnableConfirmDeny("Banked [creditsFor] credits for [bankValueFor] LCU bucks.\n\nCredits balance: [newCredits]\nYour balance: [newBalance]", (string)null) .WithConditions(new string[1] { "notEnoughCredits" }) .WithPreAction((Action)delegate { _creditsFor = GameUtils.Terminal.groupCredits; _bankValueFor = BankUtils.GetBankAmountForCredits(_creditsFor); _newCredits = 0; _newBalance = SaveManager.SaveData.BankBalance + _bankValueFor; }) .WithAction((Action)delegate { BankNetworkHandler.Instance.BankCreditsServerRpc(_creditsFor); }); } private static TerminalSubCommandBuilder CreateCreditsAmountCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("<amount>").WithDescription("Bank a specific amount").WithMessage("Requesting to trade [creditsFor] credits at a rate of [bankRate].\n\nCurrent credits: [currentCredits]\nTrade value: [bankValueFor] LCU bucks\n\nForecasted credits balance: [newCredits]\nForecasted LCU bank balance: [newBalance] LCU bucks").EnableConfirmDeny("Banked [creditsFor] credits for [bankValueFor] LCU bucks.\n\nCredits balance: [newCredits]\nYour balance: [newBalance]", (string)null) .WithConditions(new string[1] { "notEnoughCredits" }) .WithInputMatch("^(\\d+)$") .WithPreAction((Action<string>)delegate(string? input) { _creditsFor = Convert.ToInt32(input); _bankValueFor = BankUtils.GetBankAmountForCredits(_creditsFor); _newCredits = GameUtils.Terminal.groupCredits - _creditsFor; _newBalance = SaveManager.SaveData.BankBalance + _bankValueFor; }) .WithAction((Action)delegate { BankNetworkHandler.Instance.BankCreditsServerRpc(_creditsFor); }); } } internal class Command5Force { private static int _value; [TerminalCommand] private static TerminalCommandBuilder Force() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalCommandBuilder("lcu-force").WithHelpDescription("Force update LCU's bank balance. Note: This should be used for beta testing purposes and it is limited to the host.").WithSubCommand(CreateSubCommand()).AddTextReplacement("[bankBalance]", (Func<string>)(() => $"${SaveManager.SaveData.BankBalance}")) .WithCondition("isHost", "You are not host.", (Func<bool>)(() => NetworkManager.Singleton.IsHost)); } private static TerminalSubCommandBuilder CreateSubCommand() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new TerminalSubCommandBuilder("<amount>").WithDescription("BETA TESTING PURPOSES ONLY\n\nForce the bank to have a specific amount.").WithMessage("Your new balance: [bankBalance]").WithConditions(new string[1] { "isHost" }) .WithInputMatch("^(\\d+)$") .WithAction((Action<string>)delegate(string input) { _value = Convert.ToInt32(input); if (_value < 0) { _value = 0; } BankNetworkHandler.Instance.SyncBankBalanceClientRpc(_value); }); } } } namespace LethalCredit.Assets { internal class AssetManager { private static readonly ModLogger Logger = new ModLogger("AssetManager"); internal static AssetBundle CustomAssets; private static string _modRoot; private static readonly Dictionary<string, string> AssetPaths = new Dictionary<string, string> { { "NetworkHandler", "Assets/LethalCredit/Prefabs/ModNetworkHandler.prefab" }, { "ATM", "Assets/LethalCredit/Prefabs/ATM.prefab" }, { "LCUCreditCard", "Assets/LethalCredit/Prefabs/LCUCreditCard.asset" }, { "LCUBucks", "Assets/LethalCredit/Prefabs/LCUBucks.asset" } }; internal static readonly Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>(); public static readonly Dictionary<string, Object> AssetCache = new Dictionary<string, Object>(); internal static void LoadModBundle(string root) { _modRoot = root; CustomAssets = AssetBundle.LoadFromFile(Path.Combine(_modRoot, "lethalcreditbundle")); if (CustomAssets == null) { Logger.LogError("Failed to load custom assets!"); } } public static T LoadBundleAsset<T>(string itemName) where T : Object { if (AssetCache.TryGetValue(itemName, out Object value)) { return (T)(object)value; } if (AssetPaths.TryGetValue(itemName, out string value2)) { T val = TryLoadBundleAsset<T>(ref CustomAssets, value2); AssetCache.Add(itemName, (Object)(object)val); return val; } Logger.LogError(itemName + " was not present in the asset or sample dictionary!"); return default(T); } internal static T TryLoadBundleAsset<T>(ref AssetBundle bundle, string path) where T : Object { T val = bundle.LoadAsset<T>(path); if (val == null) { Logger.LogError("An error has occurred trying to load asset from " + path); return default(T); } Logger.TryLogDebug("Loaded asset located in " + path); return val; } internal static void AddPrefab(string name, GameObject prefab) { Prefabs.Add(name, prefab); } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace LethalCredit.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }