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 LunarRework v1.0.0
Nachito.LunarRework.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; 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 HarmonyLib; using InteractiveTerminalAPI.UI; using InteractiveTerminalAPI.UI.Application; using InteractiveTerminalAPI.UI.Screen; using LethalLevelLoader; using LethalModDataLib.Enums; using LethalModDataLib.Features; using Microsoft.CodeAnalysis; using Nachito.LunarRework.Patches; using Nachito.LunarRework.Plugin; using Nachito.LunarRework.Plugin.UI.Application; using StaticNetcodeLib; using TerminalApi; 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("Nachito.LunarRework")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+912748810ddda13dd740d6271000650dc34ba580")] [assembly: AssemblyProduct("Nachito.LunarRework")] [assembly: AssemblyTitle("Nachito.LunarRework")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 Nachito.LunarRework { [BepInPlugin("Nachito.LunarRework", "Nachito.LunarRework", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Nachito_LunarRework : BaseUnityPlugin { public static int rebirthMoney; public static List<Moons> ModMoons = new List<Moons>(); public static List<ConfigEntry<int>> CapConfig = new List<ConfigEntry<int>>(); public static List<ConfigEntry<int>> PriceConfig = new List<ConfigEntry<int>>(); public static List<ConfigEntry<int>> MultConfig = new List<ConfigEntry<int>>(); public static ConfigEntry<bool>? ShouldAutoReroute; public static Nachito_LunarRework Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Patch(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; MoonPricePatch.rebirthCost = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Rebirth Cost", 8000, "The cost of performing a 'rebirth'."); ShouldAutoReroute = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Auto Re-Route", true, "If the Ship should automatically re-route to the company after every moon."); InteractiveTerminalManager.RegisterApplication<GainTerminalApplication>(new string[2] { "gain", "gains" }, false); Logger.LogInfo((object)"Nachito.LunarRework v1.0.1 has loaded!"); } public void ClearUnusedEntries(ConfigFile cfg) { PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null); dictionary.Clear(); cfg.Save(); } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("Nachito.LunarRework"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } public void AddConfigs(string name, int cap, int mult, int price) { CapConfig.Add(((BaseUnityPlugin)this).Config.Bind<int>("Hard Caps", name + " Cap", cap, "The point in which " + name + " stops recieving extra scrap")); MultConfig.Add(((BaseUnityPlugin)this).Config.Bind<int>("Scrap Gain Amount", name + " Gain", mult, "How much scrap " + name + " gains per day")); PriceConfig.Add(((BaseUnityPlugin)this).Config.Bind<int>("Moon Prices", name + " Price", price, "How much " + name + " costs")); } } [StaticNetcode] public class ServerStuff { public static int rebam; public static int rebmon; public static bool rebshould; public static int credits; private static List<ulong> clientList = new List<ulong>(); [ServerRpc] public static void SyncCreditsAfterRebirthServerRpc(int terminalGroupCredits) { credits = terminalGroupCredits; SyncCredits(); SyncCreditsAfterRebirthClientRpc(credits); } [ServerRpc] public static void SetPriceOfMoonsServerRpc(int amount, string name) { ChangePrices(amount, name); SetPriceOfMoonsClientRpc(amount, name); } [ServerRpc] public static void SyncRebirthVarsServerRpc(int timesReborn, int rebCost, bool shouldRebirth) { rebam = timesReborn; rebmon = rebCost; rebshould = shouldRebirth; SyncRebirthVars(); SyncRebirthVarsClientRpc(rebam, rebmon, rebshould); } [ClientRpc] public static void SyncCreditsAfterRebirthClientRpc(int terminalGroupCredits) { credits = terminalGroupCredits; SyncCredits(); } [ClientRpc] public static void SyncRebirthVarsClientRpc(int timesReborn, int rebCost, bool shouldRebirth) { rebam = timesReborn; rebmon = rebCost; rebshould = shouldRebirth; SyncRebirthVars(); } [ClientRpc] public static void ClearMoonsAndSyncClientRpc(string name, int cap, int mult, int price, int timesNotVisited, int dcap, int dmult) { string name2 = name; Nachito_LunarRework.ModMoons.Remove(Nachito_LunarRework.ModMoons.Find((Moons m) => m.Name == name2)); if (!Nachito_LunarRework.ModMoons.Any((Moons moon) => moon.Name == name2)) { Moons item = new Moons(timesNotVisited, cap, mult, price, name2, dcap, dmult); Nachito_LunarRework.ModMoons.Add(item); } } [ClientRpc] public static void SetPriceOfMoonsClientRpc(int amount, string name) { ChangePrices(amount, name); } private static void SyncCredits() { Terminal val = Object.FindObjectOfType<Terminal>(); val.groupCredits = credits; } private static void ChangePrices(int amount, string name) { string name2 = name; PatchedContent.ExtendedLevels.Find((ExtendedLevel moon) => ((Object)moon).name == name2).RoutePrice = amount; } private static void SyncRebirthVars() { MoonPricePatch.rebirthAmount = rebam; Nachito_LunarRework.rebirthMoney = rebmon; TimeOfDayPatch.shouldRebirth = rebshould; } } public static class PluginInfo { public const string PLUGIN_GUID = "Nachito.LunarRework"; public const string PLUGIN_NAME = "Nachito.LunarRework"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace Nachito.LunarRework.Plugin { public class Moons { public int TimesNotVisited; public int Cap; public int Mult; public string Name; public int Price; public int DefaultCap; public int DefaultMult; public Moons(int timesNotVisited, int cap, int mult, int price, string name, int defaultCap, int defaultMult) { TimesNotVisited = timesNotVisited; Cap = cap; Mult = mult; Name = name; Price = price; DefaultCap = defaultCap; DefaultMult = defaultMult; base..ctor(); } } } namespace Nachito.LunarRework.Plugin.UI.Application { internal class GainTerminalApplication : InteractiveTerminalApplication { public override void Initialization() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown BoxedScreen val = new BoxedScreen(); val.Title = "Moon Gains"; val.elements = (ITextElement[])(object)new ITextElement[1] { (ITextElement)new TextElement { Text = "Moon Gains \n" + MoonsPage() } }; IScreen currentScreen = (IScreen)(object)val; ((TerminalApplication)this).currentScreen = currentScreen; } private string MoonsPage() { string text = string.Empty; foreach (Moons modMoon in Nachito_LunarRework.ModMoons) { text = text + "\n" + modMoon.Name + " (+" + modMoon.TimesNotVisited + "/" + modMoon.Cap + ")"; } return text; } } } namespace Nachito.LunarRework.Patches { [HarmonyPatch(typeof(DepositItemsDesk))] internal class DepositItemsDeskPatch { [HarmonyPatch("SellAndDisplayItemProfits")] [HarmonyPostfix] private static void CreditsPatch(ref int newGroupCredits) { Terminal val = Object.FindObjectOfType<Terminal>(); val.groupCredits = (int)((float)newGroupCredits / StartOfRound.Instance.companyBuyingRate); } } [HarmonyPatch(typeof(StartOfRound))] public class MoonPenaltyPatch { [HarmonyPatch("OnPlayerConnectedClientRpc")] [HarmonyPostfix] private static void Sync() { if (!NetworkManager.Singleton.IsHost) { return; } ServerStuff.SyncRebirthVarsServerRpc(MoonPricePatch.rebirthAmount, Nachito_LunarRework.rebirthMoney, TimeOfDayPatch.shouldRebirth); foreach (ExtendedLevel level in PatchedContent.ExtendedLevels) { Moons moons = Nachito_LunarRework.ModMoons.Find((Moons m) => m.Name == ((Object)level).name.Replace("ExtendedLevel", string.Empty)); if (moons != null) { int price = moons.Price; ServerStuff.SetPriceOfMoonsServerRpc(price, ((Object)level).name); } } List<Moons> list = Nachito_LunarRework.ModMoons.ToList(); foreach (Moons item in list) { ServerStuff.ClearMoonsAndSyncClientRpc(item.Name, item.Cap, item.Mult, item.Price, item.TimesNotVisited, item.DefaultCap, item.DefaultMult); } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void onStart() { if (!NetworkManager.Singleton.IsHost) { return; } foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { string name = ((Object)extendedLevel).name.Replace("ExtendedLevel", string.Empty); List<ConfigEntryBase> list = ((BaseUnityPlugin)Nachito_LunarRework.Instance).Config.GetConfigEntries().ToList(); ConfigEntryBase val = list.Find((ConfigEntryBase c) => c.Definition.Key.Contains(name + "Cap")); ConfigEntryBase val2 = list.Find((ConfigEntryBase m) => m.Definition.Key.Contains(name + "Gain")); ConfigEntryBase val3 = list.Find((ConfigEntryBase p) => p.Definition.Key.Contains(name + "Price")); if (val == null && val2 == null && val3 == null) { if (name.Equals("Experimentation")) { Nachito_LunarRework.Instance.AddConfigs(name, 20, 1, 0); } if (name.Equals("Assurance")) { Nachito_LunarRework.Instance.AddConfigs(name, 15, 1, 0); } if (name.Equals("Vow")) { Nachito_LunarRework.Instance.AddConfigs(name, 16, 1, 0); } if (name.Equals("Offense")) { Nachito_LunarRework.Instance.AddConfigs(name, 18, 2, 0); } if (name.Equals("March")) { Nachito_LunarRework.Instance.AddConfigs(name, 20, 2, 0); } if (name.Equals("Adamance")) { Nachito_LunarRework.Instance.AddConfigs(name, 18, 3, 0); } if (name.Equals("Rend")) { Nachito_LunarRework.Instance.AddConfigs(name, 12, 2, 300); } if (name.Equals("Dine")) { Nachito_LunarRework.Instance.AddConfigs(name, 20, 2, 300); } if (name.Equals("Titan")) { Nachito_LunarRework.Instance.AddConfigs(name, 15, 3, 500); } if (name.Equals("Embrion")) { Nachito_LunarRework.Instance.AddConfigs(name, 30, 2, 70); } if (name.Equals("Artifice")) { Nachito_LunarRework.Instance.AddConfigs(name, 4, 1, 600); } if (!name.Equals("Experimentation") && !name.Equals("Assurance") && !name.Equals("Vow") && !name.Equals("Offense") && !name.Equals("March") && !name.Equals("Adamance") && !name.Equals("Rend") && !name.Equals("Dine") && !name.Equals("Titan") && !name.Equals("Embrion") && !name.Equals("Artifice")) { Nachito_LunarRework.Instance.AddConfigs(name, 10, 1, extendedLevel.RoutePrice); } ConfigEntry<int> val4 = Nachito_LunarRework.CapConfig.Find((ConfigEntry<int> c) => ((ConfigEntryBase)c).Definition.Key == name + " Cap"); ConfigEntry<int> val5 = Nachito_LunarRework.MultConfig.Find((ConfigEntry<int> m) => ((ConfigEntryBase)m).Definition.Key == name + " Gain"); ConfigEntry<int> val6 = Nachito_LunarRework.PriceConfig.Find((ConfigEntry<int> p) => ((ConfigEntryBase)p).Definition.Key == name + " Price"); SyncRebirth(); if (val4 != null && val5 != null && val6 != null) { Nachito_LunarRework.ModMoons.Add(new Moons(SaveLoadHandler.LoadData<int>(name + "Scrap", (SaveLocation)0, 0, true), val4.Value * (MoonPricePatch.rebirthAmount + 1), val5.Value * (MoonPricePatch.rebirthAmount + 1), val6.Value, name, val4.Value, val5.Value)); extendedLevel.RoutePrice = val6.Value; } } else { SyncRebirth(); Nachito_LunarRework.ModMoons.Add(new Moons(SaveLoadHandler.LoadData<int>(name + "Scrap", (SaveLocation)0, 0, true), (int)val.BoxedValue * (MoonPricePatch.rebirthAmount + 1), (int)val2.BoxedValue * (MoonPricePatch.rebirthAmount + 1), (int)val3.BoxedValue, name, (int)val.BoxedValue, (int)val2.BoxedValue)); extendedLevel.RoutePrice = (int)val3.BoxedValue; } } Nachito_LunarRework.Instance.ClearUnusedEntries(((BaseUnityPlugin)Nachito_LunarRework.Instance).Config); ((BaseUnityPlugin)Nachito_LunarRework.Instance).Config.SaveOnConfigSet = true; } [HarmonyPatch("SetShipReadyToLand")] [HarmonyPostfix] private static void IncreaseMoonScrap(StartOfRound __instance) { if (__instance.currentLevelID == 3 || !NetworkManager.Singleton.IsHost) { return; } foreach (Moons modMoon in Nachito_LunarRework.ModMoons) { if (((Object)__instance.currentLevel).name.Replace("Level", string.Empty) != modMoon.Name) { int num = SaveLoadHandler.LoadData<int>(modMoon.Name + "Scrap", (SaveLocation)0, 0, true); if (num < modMoon.Cap) { num += modMoon.Mult; SaveLoadHandler.SaveData<int>(num, modMoon.Name + "Scrap", (SaveLocation)0, true); modMoon.TimesNotVisited = num; } } else { SaveLoadHandler.SaveData<int>(0, modMoon.Name + "Scrap", (SaveLocation)0, true); modMoon.TimesNotVisited = 0; } } List<Moons> list = Nachito_LunarRework.ModMoons.ToList(); foreach (Moons item in list) { ServerStuff.ClearMoonsAndSyncClientRpc(item.Name, item.Cap, item.Mult, item.Price, item.TimesNotVisited, item.DefaultCap, item.DefaultMult); } if (__instance.currentLevel.levelID != 3 && Nachito_LunarRework.ShouldAutoReroute.Value) { Terminal val = Object.FindObjectOfType<Terminal>(); __instance.ChangeLevel(3); __instance.ChangeLevelServerRpc(3, val.groupCredits); } } [HarmonyPatch("StartGame")] [HarmonyPostfix] private static void ChangeScrap(StartOfRound __instance) { if (__instance.currentLevelID == 3 || !NetworkManager.Singleton.IsHost) { return; } foreach (Moons modMoon in Nachito_LunarRework.ModMoons) { if (((Object)__instance.currentLevel).name.Replace("Level", string.Empty) == modMoon.Name) { SelectableLevel currentLevel = __instance.currentLevel; currentLevel.minScrap += modMoon.TimesNotVisited; SelectableLevel currentLevel2 = __instance.currentLevel; currentLevel2.maxScrap += modMoon.TimesNotVisited; } } } public static void SyncRebirth() { if (SaveLoadHandler.LoadData<int>("rebirths", (SaveLocation)0, 0, true) == 0) { SaveLoadHandler.SaveData<int>(0, "rebirths", (SaveLocation)0, true); MoonPricePatch.rebirthAmount = 0; } else { MoonPricePatch.rebirthAmount = SaveLoadHandler.LoadData<int>("rebirths", (SaveLocation)0, 0, true); } if (SaveLoadHandler.LoadData<int>("rebirthCost", (SaveLocation)0, MoonPricePatch.rebirthCost.Value, true) == MoonPricePatch.rebirthCost.Value) { SaveLoadHandler.SaveData<int>(MoonPricePatch.rebirthCost.Value, "rebirthCost", (SaveLocation)0, true); Nachito_LunarRework.rebirthMoney = MoonPricePatch.rebirthCost.Value; } else { Nachito_LunarRework.rebirthMoney = SaveLoadHandler.LoadData<int>("rebirthCost", (SaveLocation)0, MoonPricePatch.rebirthCost.Value, true); } if (!SaveLoadHandler.LoadData<bool>("shouldRebirth", (SaveLocation)0, false, true)) { SaveLoadHandler.SaveData<bool>(false, "shouldRebirth", (SaveLocation)0, true); TimeOfDayPatch.shouldRebirth = false; } else { TimeOfDayPatch.shouldRebirth = SaveLoadHandler.LoadData<bool>("shouldRebirth", (SaveLocation)0, false, true); } } } [HarmonyPatch(typeof(Terminal))] internal class MoonPricePatch { public static Terminal terminal = null; public static string og = string.Empty; public static string og2 = string.Empty; public static string og3 = string.Empty; public static ConfigEntry<int>? rebirthCost; public static bool stop = false; public static bool stop2 = false; public static bool stop3 = false; public static TerminalNode? rebirthNode; public static TerminalNode? rebirthNodeConfirm; public static string RebirthMonologue = string.Empty; public static int rebirthAmount = 0; public static string replace = string.Empty; [HarmonyPatch("Awake")] [HarmonyPrefix] private static void FindTerminal() { terminal = Object.FindObjectOfType<Terminal>(); RebirthMonologue = "REBIRTH\n\nTyping 'yes' will reset your quota back to 130 next quota fulfill.\n\nThe Scrap Gain in each moon will be doubled.\n\nAre You Prepared? (Cost: "; rebirthNode = TerminalApi.CreateTerminalNode(RebirthMonologue, true, ""); rebirthNodeConfirm = TerminalApi.CreateTerminalNode("CONTRACT RENEWED\n\n", true, ""); TerminalKeyword val = TerminalApi.CreateTerminalKeyword("rebirth", false, rebirthNode); TerminalApi.AddTerminalKeyword(val); } [HarmonyPatch("LoadNewNode")] [HarmonyPostfix] private static void RebirthNodeStuff(ref TerminalNode node) { if (!((Object)(object)terminal != (Object)null) || !((Object)(object)node != (Object)null) || !((Object)(object)node == (Object)(object)rebirthNodeConfirm)) { return; } if (terminal.groupCredits >= Nachito_LunarRework.rebirthMoney && NetworkManager.Singleton.IsHost) { int terminalGroupCredits = terminal.groupCredits - Nachito_LunarRework.rebirthMoney; ServerStuff.SyncCreditsAfterRebirthServerRpc(terminalGroupCredits); TimeOfDayPatch.Save(); ServerStuff.SyncRebirthVarsServerRpc(rebirthAmount, Nachito_LunarRework.rebirthMoney, TimeOfDayPatch.shouldRebirth); foreach (Moons modMoon in Nachito_LunarRework.ModMoons) { modMoon.Cap = modMoon.DefaultCap * (rebirthAmount + 1); modMoon.Mult = modMoon.DefaultMult * (rebirthAmount + 1); } List<Moons> list = Nachito_LunarRework.ModMoons.ToList(); foreach (Moons item in list) { ServerStuff.ClearMoonsAndSyncClientRpc(item.Name, item.Cap, item.Mult, item.Price, item.TimesNotVisited, item.DefaultCap, item.DefaultMult); } } TerminalApi.DeleteKeyword("yes"); } [HarmonyPatch("LoadNewNode")] [HarmonyPrefix] private static void LoadNewNodePatchBefore(ref TerminalNode node) { if ((Object)(object)node == (Object)(object)rebirthNodeConfirm && stop3) { node.displayText = og3; stop3 = false; } if ((Object)(object)node == (Object)(object)rebirthNode && stop2) { node.displayText = og2; stop2 = false; } if ((((Object)(object)node == (Object)(object)rebirthNodeConfirm && terminal.groupCredits < Nachito_LunarRework.rebirthMoney) || ((Object)(object)node == (Object)(object)rebirthNodeConfirm && !NetworkManager.Singleton.IsHost)) && !stop3) { og3 = node.displayText; node.displayText = node.displayText.Replace("CONTRACT RENEWED\n\n", "You Are Not Ready"); stop3 = true; } if ((Object)(object)node == (Object)(object)rebirthNode) { og2 = node.displayText; TerminalKeyword val = TerminalApi.CreateTerminalKeyword("yes", false, rebirthNodeConfirm); TerminalApi.AddTerminalKeyword(val); string text = Nachito_LunarRework.rebirthMoney + ")\n\n"; node.displayText = node.displayText.Replace("Cost: ", "Cost: " + text); stop2 = true; } } } [HarmonyPatch(typeof(GameNetworkManager))] internal class NetworkManagerPatch { [HarmonyPatch("Disconnect")] [HarmonyPostfix] private static void Clear() { Nachito_LunarRework.ModMoons.Clear(); Nachito_LunarRework.Logger.LogInfo((object)Nachito_LunarRework.ModMoons.Count); Nachito_LunarRework.rebirthMoney = MoonPricePatch.rebirthCost.Value; TimeOfDayPatch.shouldRebirth = false; MoonPricePatch.rebirthAmount = 0; } } [HarmonyPatch(typeof(TimeOfDay))] internal class TimeOfDayPatch { public static bool shouldRebirth; [HarmonyPatch("SetNewProfitQuota")] [HarmonyPostfix] private static void RebirthPatch(TimeOfDay __instance) { if (NetworkManager.Singleton.IsHost && shouldRebirth) { SaveLoadHandler.SaveData<int>(MoonPricePatch.rebirthAmount, "rebirths", (SaveLocation)0, true); SaveLoadHandler.SaveData<int>(Nachito_LunarRework.rebirthMoney, "rebirthCost", (SaveLocation)0, true); SaveLoadHandler.SaveData<bool>(shouldRebirth, "shouldRebirth", (SaveLocation)0, true); int num = __instance.quotaFulfilled - __instance.profitQuota; int num2 = num / 5 + 15 * __instance.daysUntilDeadline; __instance.SyncNewProfitQuotaClientRpc(130, num2, __instance.timesFulfilledQuota); SaveRebirth(MoonPricePatch.rebirthAmount, Nachito_LunarRework.rebirthMoney, sh: false); } } public static void SaveRebirth(int amo, int mon, bool sh) { SaveLoadHandler.SaveData<int>(amo, "rebirths", (SaveLocation)0, true); SaveLoadHandler.SaveData<int>(mon, "rebirthCost", (SaveLocation)0, true); SaveLoadHandler.SaveData<bool>(sh, "shouldRebirth", (SaveLocation)0, true); } public static void Save() { MoonPricePatch.rebirthAmount = SaveLoadHandler.LoadData<int>("rebirths", (SaveLocation)0, 0, true) + 1; Nachito_LunarRework.rebirthMoney = SaveLoadHandler.LoadData<int>("rebirthCost", (SaveLocation)0, MoonPricePatch.rebirthCost.Value, true) + 5000; shouldRebirth = true; SaveRebirth(MoonPricePatch.rebirthAmount, Nachito_LunarRework.rebirthMoney, shouldRebirth); } } }