Please disclose if any significant portion of your mod was created 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 Scrap Insurance v1.0.3
BepInEx/plugins/ScrapInsurance/ScrapInsurance.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using MoreShipUpgrades.Patches.RoundComponents; using ScrapInsurance.Misc; using ScrapInsurance.NetcodePatcher; using ScrapInsurance.Patches.HUD; using ScrapInsurance.Patches.RoundComponents; using ScrapInsurance.Patches.TerminalComponents; using ScrapInsurance.Util; using Unity.Netcode; using UnityEngine; [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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MoreShipUpgrades.Patches.RoundComponents { [HarmonyPatch(typeof(RoundManager))] internal static class RoundManagerTranspilerPatcher { [HarmonyPatch("DespawnPropsAtEndOfRound")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> DespawnPropsAtEndOfRoundTranspiler(IEnumerable<CodeInstruction> instructions) { FieldInfo field = typeof(StartOfRound).GetField("allPlayersDead"); MethodInfo method = typeof(ScrapInsuranceBehaviour).GetMethod("GetScrapInsuranceStatus"); List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: true, andInstruction: true, orInstruction: false, requireInstance: false, "Couldn't find all players dead field"); return codes; } } } namespace ScrapInsurance { [BepInPlugin("com.github.WhiteSpike.ScrapInsurance", "Scrap Insurance", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static readonly Harmony harmony = new Harmony("com.github.WhiteSpike.ScrapInsurance"); internal static readonly ManualLogSource mls = Logger.CreateLogSource("Scrap Insurance"); public static PluginConfig Config; internal static GameObject networkPrefab; private void Awake() { Config = new PluginConfig(((BaseUnityPlugin)this).Config); IEnumerable<Type> enumerable; try { enumerable = Assembly.GetExecutingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { enumerable = ex.Types.Where((Type t) => t != null); } foreach (Type item in enumerable) { MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } PatchMainVersion(); networkPrefab = NetworkPrefabs.CreateNetworkPrefab("Scrap Insurance"); networkPrefab.AddComponent<ScrapInsuranceBehaviour>(); mls.LogInfo((object)"Scrap Insurance 1.0.2 has been loaded successfully."); } internal static void PatchMainVersion() { PatchVitalComponents(); } private static void PatchVitalComponents() { harmony.PatchAll(typeof(HudManagerPatcher)); harmony.PatchAll(typeof(StartOfRoundPatcher)); harmony.PatchAll(typeof(RoundManagerPatcher)); harmony.PatchAll(typeof(RoundManagerTranspilerPatcher)); harmony.PatchAll(typeof(TerminalPatcher)); mls.LogInfo((object)"Game managers have been patched"); } } public static class PluginInfo { public const string PLUGIN_GUID = "ScrapInsurance"; public const string PLUGIN_NAME = "ScrapInsurance"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ScrapInsurance.Util { internal static class Tools { private static Terminal terminal; public static void FindCodeInstruction(ref int index, ref List<CodeInstruction> codes, object findValue, MethodInfo addCode, bool skip = false, bool requireInstance = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, string errorMessage = "Not found") { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown bool flag = false; while (index < codes.Count) { if (CheckCodeInstruction(codes[index], findValue)) { flag = true; if (!skip) { if (andInstruction) { codes.Insert(index + 1, new CodeInstruction(OpCodes.And, (object)null)); } if (!andInstruction && orInstruction) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Or, (object)null)); } if (notInstruction) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Not, (object)null)); } codes.Insert(index + 1, new CodeInstruction(OpCodes.Call, (object)addCode)); if (requireInstance) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); } } break; } index++; } if (!flag) { Plugin.mls.LogError((object)errorMessage); } index++; } public static int FindLocalField(int index, ref List<CodeInstruction> codes, int localIndex, object addCode, bool skip = false, bool store = false, bool requireInstance = false, string errorMessage = "Not found") { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown bool flag = false; while (index < codes.Count) { if (CheckCodeInstruction(codes[index], localIndex, store)) { flag = true; if (!skip) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Call, addCode)); if (requireInstance) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); } } break; } index++; } if (!flag) { Plugin.mls.LogError((object)errorMessage); } return index + 1; } public static void FindString(ref int index, ref List<CodeInstruction> codes, string findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindField(ref int index, ref List<CodeInstruction> codes, FieldInfo findField, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findField, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindMethod(ref int index, ref List<CodeInstruction> codes, MethodInfo findMethod, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findMethod, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindFloat(ref int index, ref List<CodeInstruction> codes, float findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindInteger(ref int index, ref List<CodeInstruction> codes, sbyte findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindSub(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Sub; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } public static void FindDiv(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Div; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } public static void FindAdd(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Add; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } public static void FindMul(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Mul; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } private static bool CheckCodeInstruction(CodeInstruction code, int localIndex, bool store = false) { if (!store) { return localIndex switch { 0 => code.opcode == OpCodes.Ldloc_0, 1 => code.opcode == OpCodes.Ldloc_1, 2 => code.opcode == OpCodes.Ldloc_2, 3 => code.opcode == OpCodes.Ldloc_3, _ => code.opcode == OpCodes.Ldloc && (int)code.operand == localIndex, }; } return localIndex switch { 0 => code.opcode == OpCodes.Stloc_0, 1 => code.opcode == OpCodes.Stloc_1, 2 => code.opcode == OpCodes.Stloc_2, 3 => code.opcode == OpCodes.Stloc_3, _ => code.opcode == OpCodes.Stloc && (int)code.operand == localIndex, }; } private static bool CheckCodeInstruction(CodeInstruction code, object findValue) { if (findValue is sbyte) { return CheckIntegerCodeInstruction(code, findValue); } if (findValue is float) { return code.opcode == OpCodes.Ldc_R4 && code.operand.Equals(findValue); } if (findValue is string) { return code.opcode == OpCodes.Ldstr && code.operand.Equals(findValue); } if (findValue is MethodInfo) { return (code.opcode == OpCodes.Call || code.opcode == OpCodes.Callvirt) && code.operand == findValue; } if (findValue is FieldInfo) { return (code.opcode == OpCodes.Ldfld || code.opcode == OpCodes.Stfld) && code.operand == findValue; } if (findValue is OpCode) { return code.opcode == (OpCode)findValue; } return false; } private static bool CheckIntegerCodeInstruction(CodeInstruction code, object findValue) { return (sbyte)findValue switch { 0 => code.opcode == OpCodes.Ldc_I4_0, 1 => code.opcode == OpCodes.Ldc_I4_1, 2 => code.opcode == OpCodes.Ldc_I4_2, 3 => code.opcode == OpCodes.Ldc_I4_3, 4 => code.opcode == OpCodes.Ldc_I4_4, 5 => code.opcode == OpCodes.Ldc_I4_5, 6 => code.opcode == OpCodes.Ldc_I4_6, 7 => code.opcode == OpCodes.Ldc_I4_7, 8 => code.opcode == OpCodes.Ldc_I4_8, _ => code.opcode == OpCodes.Ldc_I4_S && code.operand.Equals(findValue), }; } public static void ShuffleList<T>(List<T> list) { if (list == null) { throw new ArgumentNullException("list"); } Random random = new Random(); int num = list.Count; while (num > 1) { num--; int index = random.Next(num + 1); T value = list[index]; list[index] = list[num]; list[num] = value; } } public static bool SpawnMob(string mob, Vector3 position, int numToSpawn) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < RoundManager.Instance.currentLevel.Enemies.Count; i++) { if (RoundManager.Instance.currentLevel.Enemies[i].enemyType.enemyName == mob) { for (int j = 0; j < numToSpawn; j++) { RoundManager.Instance.SpawnEnemyOnServer(position, 0f, i); } return true; } } return false; } internal static string GenerateInfoForUpgrade(string infoFormat, int initialPrice, int[] incrementalPrices, Func<int, float> infoFunction) { string text = string.Format(infoFormat, 1, initialPrice, infoFunction(0)); for (int i = 0; i < incrementalPrices.Length; i++) { float num = infoFunction(i + 1); text = ((num % 1f != 0f) ? (text + string.Format(infoFormat, i + 2, incrementalPrices[i], num)) : (text + string.Format(infoFormat, i + 2, incrementalPrices[i], Mathf.RoundToInt(num)))); } return text; } public static Color ConvertValueToColor(string hex, Color defaultValue) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003d: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (hex == null || !ColorUtility.TryParseHtmlString("#" + hex.Trim('#', ' '), ref result)) { return defaultValue; } return result; } internal static string WrapText(string text, int availableLength, string leftPadding = "", string rightPadding = "", bool padLeftFirst = true) { int num = availableLength - leftPadding.Length - rightPadding.Length; string text2 = ""; string text3 = ""; int num2 = 0; int num3 = -1; bool flag = true; bool flag2 = false; for (int i = 0; i < text.Length; i++) { char c = text[i]; if (c == '<') { flag2 = true; } if (c == ' ' && !flag2) { num3 = text3.Length; } if (c != '\n') { text3 += c; if (!flag2) { num2++; } } if (c == '>' && flag2) { flag2 = false; } if (num2 < num && c != '\n') { continue; } if (c != '\n' && c != ' ') { if (num3 != -1) { string text4 = ((padLeftFirst || !flag) ? leftPadding : "") + text3.Substring(0, num3) + new string(' ', Mathf.Max(0, num - num3)) + rightPadding; text2 = text2 + text4 + "\n"; text3 = text3.Substring(num3 + 1); } else { string text5 = ((padLeftFirst || !flag) ? leftPadding : "") + text3 + rightPadding; text2 = text2 + text5 + "\n"; text3 = ""; } } else { if (text3 != "") { text2 = text2 + ((padLeftFirst || !flag) ? leftPadding : "") + text3 + new string(' ', Mathf.Max(0, num - num2)) + rightPadding + "\n"; } text3 = ""; } num3 = -1; flag = false; num2 = text3.Length; } if (text3 != "") { text2 = text2 + ((padLeftFirst || !flag) ? leftPadding : "") + text3 + new string(' ', Mathf.Max(0, num - num2)) + rightPadding + "\n"; } return text2; } internal static void SpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f, int nonLethalDamage = 50, float physicsForce = 0f, GameObject overridePrefab = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Landmine.SpawnExplosion(explosionPosition, spawnExplosionEffect, killRange, damageRange, nonLethalDamage, physicsForce, overridePrefab, false); } internal static Terminal GetTerminal() { if ((Object)(object)terminal == (Object)null) { terminal = GameObject.Find("TerminalScript").GetComponent<Terminal>(); } return terminal; } } } namespace ScrapInsurance.Patches.TerminalComponents { [HarmonyPatch(typeof(Terminal))] internal static class TerminalPatcher { [HarmonyPostfix] [HarmonyPatch("ParsePlayerSentence")] private static void CustomParser(ref Terminal __instance, ref TerminalNode __result) { string fullText = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded); CommandParser.ParseCommands(fullText, ref __instance, ref __result); } } } namespace ScrapInsurance.Patches.RoundComponents { [HarmonyPatch(typeof(RoundManager))] internal static class RoundManagerPatcher { [HarmonyPatch("DespawnPropsAtEndOfRound")] [HarmonyPostfix] private static void DespawnPropsAtEndOfRoundPostfix() { ScrapInsuranceBehaviour.TurnOffScrapInsurance(); } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRoundPatcher { [HarmonyPrefix] [HarmonyPatch("Awake")] private static void InitLguStore(StartOfRound __instance) { Plugin.mls.LogDebug((object)"Initiating components..."); if (((NetworkBehaviour)__instance).NetworkManager.IsHost || ((NetworkBehaviour)__instance).NetworkManager.IsServer) { GameObject val = Object.Instantiate<GameObject>(Plugin.networkPrefab); ((Object)val).hideFlags = (HideFlags)61; val.GetComponent<NetworkObject>().Spawn(false); Plugin.mls.LogDebug((object)"Spawned behaviour..."); } } } } namespace ScrapInsurance.Patches.HUD { [HarmonyPatch(typeof(HUDManager))] internal static class HudManagerPatcher { [HarmonyPatch("FillEndGameStats")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> FillEndGameStatsTranspiler(IEnumerable<CodeInstruction> instructions) { FieldInfo field = typeof(StartOfRound).GetField("allPlayersDead"); MethodInfo method = typeof(ScrapInsuranceBehaviour).GetMethod("GetScrapInsuranceStatus"); List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: true, andInstruction: true, orInstruction: false, requireInstance: false, "Couldn't find all players dead field"); return codes; } } } namespace ScrapInsurance.Misc { internal static class CommandParser { private static bool confirmPrompt; private const string SCRAP_INSURANCE_COMMAND = ">SCRAP INSURANCE\nActivates an insurance policy on scrap stored in the ship incase of a team wipe occurs.\nCan only be bought while in orbit and will only apply in the next moon land after purchase.\nConsumes {0} credits for each activation of insurance.\n\n"; private static TerminalNode DisplayTerminalMessage(string message, bool clearPreviousText = true) { TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>(); val.displayText = message; val.clearPreviousText = clearPreviousText; return val; } public static void ParseCommands(string fullText, ref Terminal terminal, ref TerminalNode outputNode) { string[] array = fullText.Split(); string text = array[0].ToLower(); string secondWord = ((array.Length > 1) ? array[1].ToLower() : ""); string thirdWord = ((array.Length > 2) ? array[2].ToLower() : ""); string text2 = text; string text3 = text2; if (text3 == "scrap") { outputNode = ExecuteScrapCommands(secondWord, thirdWord, ref terminal, ref outputNode); } else { outputNode = CheckConfirmPrompt(text, ref terminal, ref outputNode); } } private static TerminalNode CheckConfirmPrompt(string firstWord, ref Terminal terminal, ref TerminalNode outputNode) { if (!confirmPrompt) { return outputNode; } confirmPrompt = false; if (string.IsNullOrEmpty(firstWord) || !"confirm".Contains(firstWord, StringComparison.OrdinalIgnoreCase)) { return outputNode; } int num = SyncedEntry<int>.op_Implicit(Plugin.Config.SCRAP_INSURANCE_PRICE); if (((NetworkBehaviour)terminal).IsServer) { terminal.SyncGroupCreditsClientRpc(terminal.groupCredits - num, terminal.numberOfItemsInDropship); } else { terminal.SyncGroupCreditsServerRpc(terminal.groupCredits - num, terminal.numberOfItemsInDropship); } ScrapInsuranceBehaviour.TurnOnScrapInsurance(); return DisplayTerminalMessage("Scrap Insurance has been activated.\nIn case of a team wipe in your next trip, your scrap will be preserved.\n\n"); } private static TerminalNode ExecuteScrapCommands(string secondWord, string thirdWord, ref Terminal terminal, ref TerminalNode outputNode) { if (1 == 0) { } TerminalNode result = ((!(secondWord == "insurance")) ? outputNode : ExecuteScrapInsuranceCommand(thirdWord, ref terminal, ref outputNode)); if (1 == 0) { } return result; } private static TerminalNode ExecuteScrapInsuranceCommand(string thirdWord, ref Terminal terminal, ref TerminalNode outputNode) { if (!string.IsNullOrEmpty(thirdWord) && thirdWord == "help") { return DisplayTerminalMessage($">SCRAP INSURANCE\nActivates an insurance policy on scrap stored in the ship incase of a team wipe occurs.\nCan only be bought while in orbit and will only apply in the next moon land after purchase.\nConsumes {Plugin.Config.SCRAP_INSURANCE_PRICE.Value} credits for each activation of insurance.\n\n"); } if (ScrapInsuranceBehaviour.GetScrapInsuranceStatus()) { return DisplayTerminalMessage("You already purchased insurance to protect your scrap belongings.\n\n"); } if (!StartOfRound.Instance.inShipPhase) { return DisplayTerminalMessage("You can only acquire insurance while in orbit.\n\n"); } int num = SyncedEntry<int>.op_Implicit(Plugin.Config.SCRAP_INSURANCE_PRICE); if (terminal.groupCredits < num) { return DisplayTerminalMessage($"Not enough credits to purchase Scrap Insurance.\nPrice: {num}\nCurrent credits: {terminal.groupCredits}\n\n"); } confirmPrompt = true; return DisplayTerminalMessage($"Type \"confirm\" if you wish to purchase scrap insurance for {num} Company Credits to keep your scrap items in the ship incase of a team wipe.\n\n"); } } [DataContract] public class PluginConfig : SyncedConfig2<PluginConfig> { [field: SyncedEntryField] public SyncedEntry<int> SCRAP_INSURANCE_PRICE { get; set; } public PluginConfig(ConfigFile cfg) : base("com.github.WhiteSpike.ScrapInsurance") { string text = "General"; SCRAP_INSURANCE_PRICE = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, text, "Price of Scrap Insurance", 400, (ConfigDescription)null); ConfigManager.Register<PluginConfig>((SyncedConfig2<PluginConfig>)this); } } internal static class Metadata { public const string GUID = "com.github.WhiteSpike.ScrapInsurance"; public const string NAME = "Scrap Insurance"; public const string VERSION = "1.0.2"; } internal class ScrapInsuranceBehaviour : NetworkBehaviour { internal const string COMMAND_NAME = "Scrap Insurance"; internal const int DEFAULT_PRICE = 400; private static bool insurance; internal static ScrapInsuranceBehaviour instance; private void Start() { Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); insurance = false; instance = this; } public static bool GetScrapInsuranceStatus() { Plugin.mls.LogDebug((object)"Grabbing status of insurance..."); return insurance; } [ServerRpc(RequireOwnership = false)] public void ToggleScrapInsuranceServerRpc(bool toggle) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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(3686051232u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref toggle, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3686051232u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ToggleInsurance(toggle); } } } public static void TurnOnScrapInsurance() { Plugin.mls.LogDebug((object)"Turning on..."); if (((NetworkBehaviour)instance).IsServer) { ToggleInsurance(enabled: true); } else { instance.ToggleScrapInsuranceServerRpc(toggle: true); } } public static void TurnOffScrapInsurance() { Plugin.mls.LogDebug((object)"Turning off..."); if (((NetworkBehaviour)instance).IsServer) { ToggleInsurance(enabled: false); } else { instance.ToggleScrapInsuranceServerRpc(toggle: false); } } private static void ToggleInsurance(bool enabled) { insurance = enabled; } 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 ((NetworkBehaviour)this).__registerRpc(3686051232u, new RpcReceiveHandler(__rpc_handler_3686051232), "ToggleScrapInsuranceServerRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_3686051232(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool toggle = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toggle, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ScrapInsuranceBehaviour)(object)target).ToggleScrapInsuranceServerRpc(toggle); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "ScrapInsuranceBehaviour"; } } } namespace ScrapInsurance.Misc.Util { internal static class Constants { internal const string SCRAP_INSURANCE_PRICE_KEY = "Price of Scrap Insurance"; internal const string SCRAP_INSURANCE_ALREADY_PURCHASED = "You already purchased insurance to protect your scrap belongings.\n\n"; internal const string SCRAP_INSURANCE_ONLY_IN_ORBIT = "You can only acquire insurance while in orbit.\n\n"; internal const string SCRAP_INSURANCE_NOT_ENOUGH_CREDITS_FORMAT = "Not enough credits to purchase Scrap Insurance.\nPrice: {0}\nCurrent credits: {1}\n\n"; internal const string SCRAP_INSURANCE_CONFIRM = "Type \"confirm\" if you wish to purchase scrap insurance for {0} Company Credits to keep your scrap items in the ship incase of a team wipe.\n\n"; internal const string SCRAP_INSURANCE_SUCCESS = "Scrap Insurance has been activated.\nIn case of a team wipe in your next trip, your scrap will be preserved.\n\n"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace ScrapInsurance.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }