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 ZetasMoonTweaks v1.0.0
ZetasMoonTweaks.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using Dawn; using Dusk; using GameNetcodeStuff; using HarmonyLib; using LethalLevelLoader; using LethalModDataLib.Attributes; using LethalModDataLib.Features; using LethalModDataLib.Helpers; using LethalNetworkAPI; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using WeatherRegistry; using WeatherTweaks.Definitions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ZetasMoonDiscounts")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ZetasMoonDiscounts")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("051aec3d-698c-48a7-b7ba-2445de4e8117")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } [HarmonyPatch(typeof(NetworkManager))] internal static class NetworkPrefabPatch2 { [HarmonyPostfix] [HarmonyPatch("SetSingleton")] private static void RegisterPrefab() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ZetaArcade.ZetasMoonTweaks Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent<NetworkObject>(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash("ZetaArcade.ZetasMoonTweaks")); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } namespace ZetasMoonTweaks { public class ConfigHandler : SyncedConfig2<ConfigHandler> { public enum OxydeLockModes { None, OddOnly, EvenOnly, Threshold, Rng } [SyncedEntryField] public SyncedEntry<bool> ApplyBuyingChanges; [SyncedEntryField] public SyncedEntry<float> NormalSellRate; [SyncedEntryField] public SyncedEntry<float> ZeroDaysSellRate; [SyncedEntryField] public SyncedEntry<bool> AutoCompanyBuilding; [SyncedEntryField] public SyncedEntry<bool> ApplyDiscountChanges; [SyncedEntryField] public SyncedEntry<int> FreeThreshold; [SyncedEntryField] public SyncedEntry<int> FreeThresholdCap; [SyncedEntryField] public SyncedEntry<int> DowngradeCost; [SyncedEntryField] public SyncedEntry<int> UpgradeThreshold; [SyncedEntryField] public SyncedEntry<string> IronmanMoons; [SyncedEntryField] public SyncedEntry<bool> IronmanMode; [SyncedEntryField] public SyncedEntry<bool> IronmanRestrictRouting; [SyncedEntryField] public SyncedEntry<bool> IronmanAutoRoute; [SyncedEntryField] public SyncedEntry<bool> ApplyRiskLevelChanges; [SyncedEntryField] public SyncedEntry<float> DefaultWeatherRiskLevelIncrease; [SyncedEntryField] public SyncedEntry<string> WeathersAndRiskLevels; [SyncedEntryField] public SyncedEntry<bool> RelockOxydeOnEject; [SyncedEntryField] public SyncedEntry<OxydeLockModes> OxydeLockMode; [SyncedEntryField] public SyncedEntry<int> OxydeUnlockThreshold; [SyncedEntryField] public SyncedEntry<int> OxydeUnlockChance; [SyncedEntryField] public SyncedEntry<int> ZeroDaysOxydeCost; [SyncedEntryField] public SyncedEntry<int> OneDayOxydeCost; [SyncedEntryField] public SyncedEntry<int> TwoDayOxydeCost; [SyncedEntryField] public SyncedEntry<int> ThreeDayOxydeCost; [SyncedEntryField] public SyncedEntry<bool> DestroyOxydeSellScrapsInOrbit; public ConfigHandler(ConfigFile cfg) : base("ZetaArcade.ZetasMoonTweaks") { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown AutoCompanyBuilding = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "General", "Auto Company Building", true, "If true, when there are 0 days left to the Deadline, automatically route the ship back to the Company."); ApplyBuyingChanges = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Buying Rate Changes", "Toggle Buying Rate Changes", true, "If true, the below 2 configs will be applied to the Company Buying Rate (How many credits you get for selling things)"); NormalSellRate = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Buying Rate Changes", "Normal Selling Rate", 1f, new ConfigDescription("The selling rate at the company on all days except the final day, where 1f = 100%, 0.5f = 50% etc.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); ZeroDaysSellRate = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Buying Rate Changes", "Zero Days Selling Rate", 1f, new ConfigDescription("The selling rate at the company on the final day, where 1f = 100%, 0.5f = 50% etc.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); ApplyDiscountChanges = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Discount Settings", "Toggle Moon Discounts", true, "If true, the below configs will be applied to moons"); FreeThreshold = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Discount Settings", "Free Threshold", 300, "When at Moon A, if Moon B is this amount cheaper (or even cheaper!) it becomes free to route to. E.g. with the default value of 300, if Moon A costs 800 and you route to it, then any moons that cost 500 or less are free to route to."); FreeThresholdCap = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Discount Settings", "Free Threshold Cap", 1000, "A Cap for the above config, where if a moon costs this amount or more, then other moons cannot route down to it for free. Note moons that are $3500 cheaper than the current moon or more are set to free anyways, bypassing this config"); DowngradeCost = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Discount Settings", "Downgrade Cost", 50, "When at Moon A, if Moon B is cheaper but isn't cheap enough to become free with the above config (or costs the same amount as Moon A), then it will be this route price instead."); UpgradeThreshold = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Discount Settings", "Upgrade Threshold", 500, "When at Moon A, if Moon B is more expensive, then if it's within the range of this config then you can route 'up' to it, only paying the difference in cost to route. E.g. (with default config at 500) if Moon A costs 400, Moon B costs 800, and Moon C costs 1200, then you can route from Moon A to B for 400 (Since its less than 500 in difference), but Moon C will cost the full 1200."); IronmanMode = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Ironman Settings", "Ironman Mode", false, "When true, will just use the Ironman section of the config instead for moon prices. See mod desc. for how Ironman mode works."); IronmanRestrictRouting = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Ironman Settings", "Restrict Routing", false, "When true, you can only route to the current pair of moons, based on the current Quota No. rather than route to any pairing you like."); IronmanAutoRoute = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Ironman Settings", "Auto Routing", false, "When true, if Restrict Routing is enabled too, the ship will automatically route to the next pair of moons upon Quota completion. It will also route to the Company on Deadline day."); IronmanMoons = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, "Ironman Settings", "Ironman Moon List", "", "List of groups of moons, starting with a price for that group of moons, in the format of: Price@[email protected]. ; e.g. 0@Exp@Vow;300@Assurance@Solace; Only works if Ironman Mode is enabled."); ApplyRiskLevelChanges = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Dynamic Risk Level Settings", "Toggle Risk Level Changes", false, "If true, a moon's risk level will change depending on the current weather and below settings."); DefaultWeatherRiskLevelIncrease = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Dynamic Risk Level Settings", "Default Weather Risk Level Increase", 1f, "The default difficulty increase for a weather where unspecified below."); WeathersAndRiskLevels = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, "Dynamic Risk Level Settings", "Weathers and Risk Levels", "", "A list of weathers paired with how much they should increase the difficulty rating, in the format WeatherName@DifficultyIncreaseAmount; e.g. None@0;[email protected]; Be careful to not include any whitespace unless it's a part of the weather name!"); RelockOxydeOnEject = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Oxyde Settings", "Relock Oxyde on Eject", true, "If true, then when an ejection occurs, Oxyde will be Locked again for the save file. This is a bug fix for CodeRebirth."); DestroyOxydeSellScrapsInOrbit = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Oxyde Settings", "Destroy Selling Scraps when leaving", true, "If true, then when the ship is leaving Oxyde, any Shredded Scraps / Compacted Cubes will be destroyed to prevent bringing them into orbit, which prevents cheesing the sell process by amassing these scraps early."); OxydeLockMode = SyncedBindingExtensions.BindSyncedEntry<OxydeLockModes>(cfg, "Oxyde Settings", "Oxyde Lock Mode", OxydeLockModes.None, "Different ways to control when Oxyde is 'Locked' by setting the Route cost to 99999. 'None' = No changes, 'OddOnly' / 'EvenOnly' = Oxyde will only be available on Odd/Even numbered Quotas respectively, 'Threshold' = The quota must reach a certain threshold for Oxyde to become available, 'Rng' = Oxyde has a random chance to be available each Quota."); OxydeUnlockThreshold = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Oxyde Settings", "Oxyde Unlock Threshold", 3000, "How high the Quota should be before Oxyde becomes available, if 'Oxyde Lock Mode' is set to 'Threshold'"); OxydeUnlockChance = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Oxyde Settings", "Oxyde Unlock Chance", 75, new ConfigDescription("How likely Oxyde will be available for that Quota, if 'Oxyde Lock Mode' is set to 'Rng'. 100 = 100 % chance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ZeroDaysOxydeCost = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Oxyde Settings", "0 Days Oxyde Cost", -1, "How much Oxyde should cost when there are 0 days left for the Quota. Leave as -1 to not change it."); OneDayOxydeCost = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Oxyde Settings", "1 Days Oxyde Cost", -1, "How much Oxyde should cost when there are 1 days left for the Quota. Leave as -1 to not change it."); TwoDayOxydeCost = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Oxyde Settings", "2 Days Oxyde Cost", -1, "How much Oxyde should cost when there are 2 days left for the Quota. Leave as -1 to not change it."); ThreeDayOxydeCost = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Oxyde Settings", "3 Days Oxyde Cost", -1, "How much Oxyde should cost when there are 3 days (or more!) left for the Quota. Leave as -1 to not change it."); ConfigManager.Register<ConfigHandler>((SyncedConfig2<ConfigHandler>)this); } } [BepInPlugin("ZetaArcade.ZetasMoonTweaks", "ZetasMoonTweaks", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency("com.sigurd.csync", "5.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ZMTBase : BaseUnityPlugin { internal class LevelPairedWithPrice { public ExtendedLevel Level; public int OriginalPrice; } internal class LevelPairedWithRisk { public ExtendedLevel Level; public string OriginalRiskLevel; } private readonly Harmony harmony = new Harmony("ZetaArcade.ZetasMoonTweaks"); public static ManualLogSource Logger; public static ZMTBase Instance; internal static ConfigHandler Config; internal static ModData ModDataInstance; public int groupCredits; public bool displayedOxydeAlertForQuota; private List<LevelPairedWithPrice> MoonDefaultCosts = new List<LevelPairedWithPrice>(); private List<LevelPairedWithRisk> MoonDefaultRiskLevels = new List<LevelPairedWithRisk>(); private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Logger = ((BaseUnityPlugin)this).Logger; Config = new ConfigHandler(((BaseUnityPlugin)this).Config); ModDataInstance = new ModData(); ModDataHandler.RegisterInstance((object)ModDataInstance, "ZMTModDataInstance"); ZMTNetwork.Init(); try { harmony.PatchAll(); } catch (Exception arg) { Logger.LogError((object)$"Harmony patching failed: {arg}"); } Logger.LogInfo((object)"Plugin is loaded!"); } public void RollNewSeed() { if (NetworkManager.Singleton.IsHost) { if (!ModDataInstance.seedSetForQuota) { int num = Random.Range(0, 100); SetNewSeed(num); ZMTNetwork.SendNewSeed(num); } else { Logger.LogDebug((object)("Seed already set as: " + ModDataInstance.currentQuotaRoll)); } } } public void SetNewSeed(int newQuotaRoll) { Logger.LogDebug((object)("New seed set as: " + newQuotaRoll)); ModDataInstance.currentQuotaRoll = newQuotaRoll; ModDataInstance.seedSetForQuota = true; ModDataInstance.ZMTSaveData(); } public void CheckForScrapsToDestroy() { if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { List<GrabbableObject> list = (from o in Object.FindObjectsOfType<GrabbableObject>() where !o.isHeld && o.isInShipRoom && Object.op_Implicit((Object)(object)o.itemProperties) && (o.itemProperties.itemName == "Normal Shredded Scraps" || o.itemProperties.itemName == "Sally Cube") select o).ToList(); Logger.LogInfo((object)("Destroying " + list.Count + " scraps when in the ship when Orbiting")); for (int num = 0; num < list.Count; num++) { ((NetworkBehaviour)list[num]).NetworkObject.Despawn(true); } } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; Dictionary<int, GrabbableObject> dictionary = new Dictionary<int, GrabbableObject>(); if ((Object)(object)localPlayerController != (Object)null) { for (int num2 = 0; num2 < localPlayerController.ItemSlots.Length; num2++) { dictionary[num2] = localPlayerController.ItemSlots[num2]; } } foreach (int key in dictionary.Keys) { if (!((Object)(object)dictionary[key] == (Object)null) && (dictionary[key].itemProperties.itemName == "Normal Shredded Scraps" || dictionary[key].itemProperties.itemName == "Sally Cube")) { Logger.LogInfo((object)("Destroying banned scrap in slot " + key + " scraps when Orbiting")); ZMTNetwork.SendItemDestroy(StartOfRound.Instance.localPlayerController.playerClientId, key); } } } public void DestroyScrapInSlot(ulong playerClientID, int slot) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => p.playerClientId == playerClientID)); if ((Object)(object)val == (Object)null) { return; } GrabbableObject val2 = val.ItemSlots[slot]; if (!((Object)(object)val2 == (Object)null)) { val.carryWeight = Mathf.Clamp(val.carryWeight - (val2.itemProperties.weight - 1f), 1f, 10f); val.DestroyItemInSlot(slot); if ((Object)(object)HUDManager.Instance != (Object)null) { ((Behaviour)HUDManager.Instance.itemSlotIcons[slot]).enabled = false; } } } public void ModifyBuyingRate() { if (Config.ApplyBuyingChanges.Value && Object.op_Implicit((Object)(object)TimeOfDay.Instance) && Object.op_Implicit((Object)(object)StartOfRound.Instance)) { if (TimeOfDay.Instance.daysUntilDeadline != 0) { StartOfRound.Instance.companyBuyingRate = Config.NormalSellRate.Value; } else { StartOfRound.Instance.companyBuyingRate = Config.ZeroDaysSellRate.Value; } } } public void rerouteShip(GameNetworkManager networkManager, bool toCompany) { if (!Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel) || !networkManager.isHostingGame) { return; } int num = 0; if (toCompany) { num = 3; if (StartOfRound.Instance.currentLevelID == 3) { ModDataInstance.hasReroutedCompany = true; } } else { num = GetNextQuotaMoonID(); if (StartOfRound.Instance.currentLevelID == num) { ModDataInstance.hasReroutedMoonPair = true; } } if (num == -1) { return; } if (toCompany) { if (StartOfRound.Instance.CanChangeLevels() && !ModDataInstance.hasReroutedCompany && TimeOfDay.Instance.daysUntilDeadline == 0 && Config.AutoCompanyBuilding.Value && TimeOfDay.Instance.quotaFulfilled < TimeOfDay.Instance.profitQuota) { StartOfRound.Instance.ChangeLevelServerRpc(num, groupCredits); StartOfRound.Instance.ChangeLevel(num); ModDataInstance.hasReroutedCompany = true; } else { ModDataInstance.hasReroutedCompany = false; } } else if (StartOfRound.Instance.CanChangeLevels() && !ModDataInstance.hasReroutedMoonPair && Config.IronmanAutoRoute.Value && TimeOfDay.Instance.quotaFulfilled < TimeOfDay.Instance.profitQuota) { StartOfRound.Instance.ChangeLevelServerRpc(num, groupCredits); StartOfRound.Instance.ChangeLevel(num); ModDataInstance.hasReroutedMoonPair = true; } else { ModDataInstance.hasReroutedMoonPair = false; } ModDataInstance.ZMTSaveData(); } public int GetNextQuotaMoonID() { int result = -1; if (!Object.op_Implicit((Object)(object)StartOfRound.Instance)) { return -1; } if (!Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel)) { return -1; } int num = TimeOfDay.Instance.timesFulfilledQuota + 1; string[] array = Config.IronmanMoons.Value.ToString().Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); int num2 = 0; if ((Object)(object)TimeOfDay.Instance != (Object)null) { num = TimeOfDay.Instance.timesFulfilledQuota + 1; Logger.LogDebug((object)("Current quota number is: " + num)); } string[] array2 = array; foreach (string text in array2) { num2++; string[] array3 = text.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries); int num3 = 0; bool flag = false; string[] array4 = array3; foreach (string pair in array4) { if (num3 != 0) { bool flag2 = false; try { ExtendedLevel val = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pair)[0]); flag2 = true; } catch (Exception) { Logger.LogError((object)("Error when trying to parse " + pair + " in the ExtendedLevels list")); } if (flag2 && !flag) { ExtendedLevel val2 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pair)[0]); if ((Object)(object)val2 != (Object)null && int.TryParse(array3[0].ToString(), out var _) && num == num2) { result = val2.SelectableLevel.levelID; flag = true; } } } num3++; } } return result; } public void SetOxydeCostFromConfigs() { int num = TimeOfDay.Instance.quotaFulfilled + 1; ExtendedLevel val = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => x.NumberlessPlanetName == "Oxyde"); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"Couldnt find Oxyde, no changes will be made to the price"); return; } bool flag = num % 2 == 0; switch (Config.OxydeLockMode.Value) { case ConfigHandler.OxydeLockModes.None: SetOxydeCostFromDeadline(val); break; case ConfigHandler.OxydeLockModes.EvenOnly: if (flag) { SetOxydeCostFromDeadline(val); OxydeHUDAlert(denied: true, "Oxyde has been unlocked for this Quota, since the Quota # is an Even Number!"); } else { val.RoutePrice = 9999; OxydeHUDAlert(denied: true, "Oxyde has been locked for this Quota, since the Quota # isn't an Even Number!"); } break; case ConfigHandler.OxydeLockModes.OddOnly: if (!flag) { SetOxydeCostFromDeadline(val); OxydeHUDAlert(denied: true, "Oxyde has been unlocked for this Quota, since the Quota # is an Odd Number!"); } else { val.RoutePrice = 9999; OxydeHUDAlert(denied: true, "Oxyde has been locked for this Quota, since the Quota # isn't an Odd Number!"); } break; case ConfigHandler.OxydeLockModes.Threshold: if (TimeOfDay.Instance.profitQuota >= Config.OxydeUnlockThreshold.Value) { SetOxydeCostFromDeadline(val); OxydeHUDAlert(denied: false, "Oxyde has been unlocked for this Quota, since the Quota is above $" + Config.OxydeUnlockThreshold.Value + "!"); } else { val.RoutePrice = 9999; OxydeHUDAlert(denied: true, "Oxyde has been locked for this Quota, since the Quota isn't at $" + Config.OxydeUnlockThreshold.Value + " yet!"); } break; case ConfigHandler.OxydeLockModes.Rng: if (!ModDataInstance.seedSetForQuota) { val.RoutePrice = 9999; RollNewSeed(); } else if (ModDataInstance.currentQuotaRoll <= Config.OxydeUnlockChance.Value) { SetOxydeCostFromDeadline(val); OxydeHUDAlert(denied: false, "Oxyde has been unlocked due to good luck for this Quota! (A " + Config.OxydeUnlockChance.Value + "% chance of happening!)"); } else { val.RoutePrice = 9999; OxydeHUDAlert(denied: true, "Oxyde has been locked due to bad luck for this Quota! (A " + (100 - Config.OxydeUnlockChance.Value) + "% chance of happening!)"); } break; } } public void OxydeHUDAlert(bool denied, string reason) { if ((Object)(object)HUDManager.Instance != (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && !displayedOxydeAlertForQuota && StartOfRound.Instance.localPlayerController.isPlayerControlled && StartOfRound.Instance.inShipPhase) { displayedOxydeAlertForQuota = true; HUDManager.Instance.DisplayTip("Oxyde Update", reason, denied, false, "LC_Tip1"); } } public void SetOxydeCostFromDeadline(ExtendedLevel OxydeRef) { int num = -1; num = TimeOfDay.Instance.daysUntilDeadline switch { 0 => SyncedEntry<int>.op_Implicit(Config.ZeroDaysOxydeCost), 1 => SyncedEntry<int>.op_Implicit(Config.OneDayOxydeCost), 2 => SyncedEntry<int>.op_Implicit(Config.TwoDayOxydeCost), 3 => SyncedEntry<int>.op_Implicit(Config.ThreeDayOxydeCost), _ => SyncedEntry<int>.op_Implicit(Config.ThreeDayOxydeCost), }; if (num > -1) { OxydeRef.RoutePrice = num; return; } OxydeRef.RoutePrice = MoonDefaultCosts.Find((LevelPairedWithPrice x) => (Object)(object)x.Level == (Object)(object)OxydeRef).OriginalPrice; } public void CalculateMoonPrices() { if (!Config.ApplyDiscountChanges.Value && !Config.IronmanMode.Value) { return; } Logger.LogDebug((object)"Attempting CalculateMoonPrices"); if (MoonDefaultCosts.Count < 1 && !Config.IronmanMode.Value) { Logger.LogDebug((object)"Default moon prices have not been set, skipping Calculation of moon prices"); return; } Logger.LogDebug((object)"Default moon prices been set, continuing"); if (!Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel)) { return; } SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; Logger.LogDebug((object)"Got current level ref"); ExtendedLevel val = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)currentLevel); if (!Config.IronmanMode.Value) { foreach (ExtendedLevel level in PatchedContent.ExtendedLevels) { level.RoutePrice = MoonDefaultCosts.Find((LevelPairedWithPrice x) => (Object)(object)x.Level == (Object)(object)level).OriginalPrice; } if (val.NumberlessPlanetName == "Gordion" || val.NumberlessPlanetName == "Galetry" || val.NumberlessPlanetName == "Oxyde" || val.RoutePrice == 0) { Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + " is free/company/oxyde, so no discounts will be applied except for Oxyde Route Cost changes")); return; } Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + " is not free/company/oxyde, so discounts will be applied")); { foreach (ExtendedLevel level2 in PatchedContent.ExtendedLevels) { if (level2.NumberlessPlanetName == "Gordion" || level2.NumberlessPlanetName == "Oxyde" || level2.NumberlessPlanetName == "Galetry" || level2.NumberlessPlanetName == val.NumberlessPlanetName || level2.RoutePrice == 0) { level2.RoutePrice = MoonDefaultCosts.Find((LevelPairedWithPrice x) => (Object)(object)x.Level == (Object)(object)level2).OriginalPrice; continue; } int num = val.RoutePrice - level2.RoutePrice; if ((num >= Config.FreeThreshold.Value && level2.RoutePrice < Config.FreeThresholdCap.Value) || num >= 3500) { level2.RoutePrice = 0; Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level2.NumberlessPlanetName + "(" + level2.RoutePrice + ") Meets the free discount criteria")); continue; } if (level2.RoutePrice <= Config.DowngradeCost.Value) { Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level2.NumberlessPlanetName + "(" + level2.RoutePrice + ") Meets the downgrade discount criteria but is so cheap it will stay the same price")); continue; } if (level2.RoutePrice <= val.RoutePrice) { level2.RoutePrice = Config.DowngradeCost.Value; Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level2.NumberlessPlanetName + "(" + level2.RoutePrice + ") Meets the downgrade discount criteria")); continue; } num = level2.RoutePrice - val.RoutePrice; if (num <= Config.UpgradeThreshold.Value) { level2.RoutePrice = num; Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level2.NumberlessPlanetName + "(" + level2.RoutePrice + ") Meets the upgrade discount criteria")); continue; } level2.RoutePrice = MoonDefaultCosts.Find((LevelPairedWithPrice x) => (Object)(object)x.Level == (Object)(object)level2).OriginalPrice; Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level2.NumberlessPlanetName + "(" + level2.RoutePrice + ") Does not meet any discount criteria")); } return; } } Logger.LogDebug((object)"Ironman Mode Detected"); if (val.NumberlessPlanetName == "Gordion" || val.NumberlessPlanetName == "Galetry" || val.NumberlessPlanetName == "Oxyde") { Logger.LogDebug((object)"Ironman Is Company"); string[] array = Config.IronmanMoons.Value.ToString().Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); int num2 = 0; int num3 = 0; if ((Object)(object)TimeOfDay.Instance != (Object)null) { num3 = TimeOfDay.Instance.timesFulfilledQuota + 1; Logger.LogDebug((object)("Current quota number is: " + num3)); } string[] array2 = array; foreach (string text in array2) { num2++; Logger.LogDebug((object)("Ironman currently on entry " + text)); string[] array3 = text.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries); int num5 = 0; string[] array4 = array3; foreach (string pair in array4) { Logger.LogDebug((object)("Ironman currently on pair " + pair)); if (num5 != 0) { bool flag = false; try { ExtendedLevel val2 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pair)[0]); flag = true; } catch (Exception) { Logger.LogError((object)("Error when trying to parse " + pair + " in the ExtendedLevels list")); } if (flag) { ExtendedLevel val3 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pair)[0]); if ((Object)(object)val3 != (Object)null) { if (int.TryParse(array3[0].ToString(), out var result)) { Logger.LogDebug((object)("Setting " + val3.NumberlessPlanetName + " route price to " + result)); if (Config.IronmanRestrictRouting.Value) { if (num3 == num2) { val3.IsRouteLocked = false; val3.IsRouteHidden = false; Logger.LogDebug((object)("Moon " + val3.NumberlessPlanetName + " is not locked because it is from pair " + num2 + " and the current quota is " + num3)); if (Config.IronmanAutoRoute.Value) { val3.RoutePrice = 0; } else { val3.RoutePrice = result; } } else { val3.IsRouteLocked = true; val3.IsRouteHidden = true; val3.RoutePrice = 9999; Logger.LogDebug((object)("Moon " + val3.NumberlessPlanetName + " is locked because it is from pair " + num2 + " and the current quota is " + num3)); } } else { val3.RoutePrice = result; val3.IsRouteLocked = false; val3.IsRouteHidden = false; } } } else { Logger.LogError((object)("Ironman could not find a matching level for " + pair + " in the ExtendedLevels list")); } } } num5++; } } return; } Logger.LogDebug((object)"Ironman is a normal moon"); bool flag2 = false; List<string> list = new List<string>(); string[] array5 = Config.IronmanMoons.Value.ToString().Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); string[] array6 = array5; foreach (string text2 in array6) { string[] pairs = text2.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries); int index = 0; string[] array7 = pairs; foreach (string pair2 in array7) { if (index != 0) { bool flag3 = false; try { ExtendedLevel val4 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pair2)[0]); flag3 = true; } catch (Exception) { Logger.LogError((object)("Error when trying to parse " + pair2 + " in the ExtendedLevels list")); } if (flag3) { ExtendedLevel val5 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pairs[index])[0]); Logger.LogDebug((object)("Current level is: " + val.NumberlessPlanetName + " and Current config level is " + val5.NumberlessPlanetName)); if (val.NumberlessPlanetName == val5.NumberlessPlanetName) { flag2 = true; int index2 = 0; string[] array8 = pairs; foreach (string text3 in array8) { if (index2 != 0) { bool flag4 = false; try { ExtendedLevel val6 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pairs[index2])[0]); flag4 = true; } catch (Exception) { Logger.LogError((object)("Error when trying to parse " + pairs?.ToString() + " in the ExtendedLevels list")); } if (flag4) { ExtendedLevel val7 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pairs[index2])[0]); Logger.LogDebug((object)("Trying to add " + pairs[index2] + " passed as " + (object)val7)); list.Add(val7.NumberlessPlanetName); } } index2++; } } } } int num10 = index; index = num10 + 1; } } foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (!(extendedLevel.NumberlessPlanetName != "Gordion") || !(extendedLevel.NumberlessPlanetName != "Galetry") || !(extendedLevel.NumberlessPlanetName != "Oxyde") || !(extendedLevel.NumberlessPlanetName != val.NumberlessPlanetName)) { continue; } bool flag5 = false; foreach (string item in list) { Logger.LogDebug((object)("Ironman current level checked is " + extendedLevel.NumberlessPlanetName + " vs. " + item)); if (extendedLevel.NumberlessPlanetName == item) { Logger.LogDebug((object)"Ironman they are a match"); flag5 = true; } else { Logger.LogDebug((object)"Ironman they are not a match"); } } if (!flag5) { extendedLevel.RoutePrice = 9999; extendedLevel.IsRouteLocked = true; extendedLevel.IsRouteHidden = false; } else { extendedLevel.RoutePrice = 0; extendedLevel.IsRouteLocked = false; extendedLevel.IsRouteHidden = false; } } } public void CalculateMoonRiskLevels() { Logger.LogDebug((object)"Attempting CalculateMoonRiskLevels"); if (MoonDefaultRiskLevels.Count < 1 || !Config.ApplyRiskLevelChanges.Value) { Logger.LogDebug((object)"Default moon risk levels have not been set or the option is disabled, skipping Calculation of moon risk levels"); return; } Logger.LogDebug((object)"Default moon risk levels have been set, continuing"); if (!Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel)) { return; } Logger.LogDebug((object)"Got current level ref"); if (!Config.ApplyRiskLevelChanges.Value) { return; } foreach (ExtendedLevel level in PatchedContent.ExtendedLevels) { level.SelectableLevel.riskLevel = MoonDefaultRiskLevels.Find((LevelPairedWithRisk x) => (Object)(object)x.Level == (Object)(object)level).OriginalRiskLevel; if (level.NumberlessPlanetName == "Gordion" || level.NumberlessPlanetName == "Galetry" || level.NumberlessPlanetName == "Oxyde") { Logger.LogDebug((object)("Current moon " + level.NumberlessPlanetName + " is free/company/oxyde, so no risk level changes will be applied")); continue; } Logger.LogDebug((object)("Current moon " + level.NumberlessPlanetName + " is not free/company/oxyde, so risk level changes will be applied")); bool isCombined; float floatRiskLevel = Utils.ConvertRiskLevelToFloat(level.SelectableLevel.riskLevel) + GetWeatherRiskLevelFloat(WeatherManager.GetCurrentWeather(level.SelectableLevel), out isCombined); level.SelectableLevel.riskLevel = Utils.ConvertFloatToRiskLevel(floatRiskLevel); if (isCombined) { SelectableLevel selectableLevel = level.SelectableLevel; selectableLevel.riskLevel += "?"; } } } public float GetWeatherRiskLevelFloat(Weather weather, out bool isCombined) { isCombined = false; float num = 0f; WeatherTweaksWeather val = (WeatherTweaksWeather)(object)((weather is WeatherTweaksWeather) ? weather : null); if (val != null) { float num2 = 0f; float num3 = 0f; float num4 = 0f; float num5 = 0f; float num6 = 0f; List<string> list = new List<string>(); for (int i = 0; i < val.WeatherTypes.Count; i++) { float num7 = ConvertWeatherNameToRiskFloat(val.WeatherTypes[i].WeatherName); num3 += num7; if (!list.Contains(val.WeatherTypes[i].WeatherName)) { list.Add(val.WeatherTypes[i].WeatherName); if (val.WeatherTypes[i].WeatherName != "None" || val.WeatherTypes[i].WeatherName != "Clear" || val.WeatherTypes[i].WeatherName != "Cloudy" || val.WeatherTypes[i].WeatherName != "NightShift") { num5 += 0.15f; } } if (num2 < num7) { num2 = num7; } } num4 = num3 / (float)val.WeatherTypes.Count; num4 += num5; num6 = num2 + num5; num = num6; isCombined = true; } else { num = ConvertWeatherNameToRiskFloat(weather.Name); } return num; } public float ConvertWeatherNameToRiskFloat(string weatherName) { Logger.LogDebug((object)"Started converting weather name to risk"); float num = 0f; Dictionary<string, float> dictionary = new Dictionary<string, float>(); string[] array = Config.WeathersAndRiskLevels.Value.ToString().Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries); float num2 = 0f; if (float.TryParse(array3[1], out var result)) { Logger.LogDebug((object)("Succesfully parsed " + text + "'s second part as a float (" + result + ")")); num2 = result; } else { Logger.LogDebug((object)("Couldn't parse " + text + "'s second part as a float, so setting to default value instead")); num2 = Config.DefaultWeatherRiskLevelIncrease.Value; } Logger.LogDebug((object)("Now trying to parse weather " + array3[0] + " in the ConfigHelper")); List<Weather> list = new List<Weather>(); try { list = ConfigHelper.ResolveStringToWeathers(array3[0]); } catch (Exception) { Logger.LogDebug((object)("Exception caught, Could not resolve weather " + text + " in the ConfigHelper")); } bool flag = false; string text2 = ""; foreach (Weather weather in list) { try { WeatherManager.Weathers.Find((Weather x) => x.Name == weather.name); Logger.LogDebug((object)("Found weather " + text + " in the WeatherManager")); flag = true; text2 = weather.Name; } catch (Exception) { Logger.LogDebug((object)("Exception caught, could not find " + text + " in the WeatherManager")); } } if (flag) { try { dictionary.Add(text2, num2); Logger.LogDebug((object)("Added " + text2 + " to the Config Dictionary, with a value of " + num2)); } catch (ArgumentException) { Logger.LogDebug((object)("Couldn't add weather " + array3[0] + " to Config Dictionary as it is already in there")); } } else { Logger.LogDebug((object)("Couldn't find weather " + array3[0] + ", so it will not be added to the Config Dictionary")); } } float value = Config.DefaultWeatherRiskLevelIncrease.Value; if (dictionary.TryGetValue(ConfigHelper.ResolveStringToWeather(weatherName).Name, out value)) { Logger.LogDebug((object)("Found weather " + weatherName + " in Dictionary of weathers from config, outputting it's risk level")); return value; } Logger.LogDebug((object)("Could not find weather " + weatherName + " in Dictionary of weathers from config, risk level will be default")); return Config.DefaultWeatherRiskLevelIncrease.Value; } public void SaveDefaultMoonRiskLevels() { Logger.LogDebug((object)"Attempting to save moon default difficulty ratings"); if (MoonDefaultRiskLevels.Count > 1) { Logger.LogDebug((object)"Default difficulty levels have already have been set, skipping"); return; } int num = 0; foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { LevelPairedWithRisk levelPairedWithRisk = new LevelPairedWithRisk(); levelPairedWithRisk.Level = extendedLevel; levelPairedWithRisk.OriginalRiskLevel = extendedLevel.SelectableLevel.riskLevel; MoonDefaultRiskLevels.Add(levelPairedWithRisk); Logger.LogDebug((object)("Saved " + extendedLevel.NumberlessPlanetName + " default difficulty level as " + extendedLevel.SelectableLevel.riskLevel)); num++; } Logger.LogDebug((object)"Finished setting moon default risk levels"); } public void SaveDefaultMoonPrices() { Logger.LogDebug((object)"Attempting to save moon default prices"); Logger.LogDebug((object)("ExtendedLevels Count is: " + PatchedContent.ExtendedLevels.Count)); if (MoonDefaultCosts.Count > 1) { Logger.LogDebug((object)"Default prices already have been set, skipping"); return; } int num = 0; foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { Logger.LogDebug((object)"In loop"); Logger.LogDebug((object)("Looping through level, current is: " + extendedLevel.NumberlessPlanetName)); LevelPairedWithPrice levelPairedWithPrice = new LevelPairedWithPrice(); levelPairedWithPrice.Level = extendedLevel; levelPairedWithPrice.OriginalPrice = extendedLevel.RoutePrice; MoonDefaultCosts.Add(levelPairedWithPrice); Logger.LogDebug((object)("Saved " + extendedLevel.NumberlessPlanetName + " default price as " + extendedLevel.RoutePrice)); num++; } Logger.LogDebug((object)"Finished setting moon default prices"); } } public class ModData { [ModData(/*Could not decode attribute arguments.*/)] public bool hasReroutedCompany; [ModData(/*Could not decode attribute arguments.*/)] public bool hasReroutedMoonPair; [ModData(/*Could not decode attribute arguments.*/)] public int currentQuotaRoll; [ModData(/*Could not decode attribute arguments.*/)] public bool seedSetForQuota; public void ZMTSaveData() { SaveLoadHandler.SaveData(ModDataHelper.GetModDataKey((object)this, "currentQuotaRoll")); SaveLoadHandler.SaveData(ModDataHelper.GetModDataKey((object)this, "seedSetForQuota")); SaveLoadHandler.SaveData(ModDataHelper.GetModDataKey((object)this, "hasReroutedCompany")); SaveLoadHandler.SaveData(ModDataHelper.GetModDataKey((object)this, "hasReroutedMoonPair")); } public void ZMTLoadData() { SaveLoadHandler.LoadData(ModDataHelper.GetModDataKey((object)this, "currentQuotaRoll")); SaveLoadHandler.LoadData(ModDataHelper.GetModDataKey((object)this, "seedSetForQuota")); SaveLoadHandler.LoadData(ModDataHelper.GetModDataKey((object)this, "hasReroutedCompany")); SaveLoadHandler.LoadData(ModDataHelper.GetModDataKey((object)this, "hasReroutedMoonPair")); } } internal class Patches { [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void TerminalStartPatch(ref Terminal __instance) { Logger.LogDebug((object)"Terminal patch detected"); ZMTBase.Instance.displayedOxydeAlertForQuota = false; ZMTBase.Instance.SaveDefaultMoonPrices(); ZMTBase.Instance.SaveDefaultMoonRiskLevels(); ZMTBase.Instance.CalculateMoonPrices(); ZMTBase.Instance.CalculateMoonRiskLevels(); ZMTBase.Instance.SetOxydeCostFromConfigs(); } [HarmonyPatch("BeginUsingTerminal")] [HarmonyPostfix] private static void TerminalBeginUsePatch(ref Terminal __instance) { Logger.LogDebug((object)"Terminal begin use patch detected"); ZMTBase.Instance.CalculateMoonPrices(); ZMTBase.Instance.CalculateMoonRiskLevels(); ZMTBase.Instance.SetOxydeCostFromConfigs(); } [HarmonyPatch("Update")] [HarmonyPostfix] private static void gatherGroupCreditsValue(ref int ___groupCredits) { ZMTBase.Instance.groupCredits = ___groupCredits; } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("EndPlayersFiredSequenceClientRpc")] [HarmonyPostfix] private static void ResetHasRerouted() { ZMTBase.Instance.displayedOxydeAlertForQuota = false; ZMTBase.ModDataInstance.hasReroutedCompany = false; ZMTBase.ModDataInstance.hasReroutedMoonPair = false; ZMTBase.ModDataInstance.seedSetForQuota = false; ZMTBase.ModDataInstance.ZMTSaveData(); if (ZMTBase.Config.RelockOxydeOnEject.Value) { ExtendedLevel val = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => x.NumberlessPlanetName == "Oxyde"); if (!((Object)(object)val == (Object)null)) { LockMoon(val.SelectableLevel); Logger.LogInfo((object)"Oxyde is now re-locked!"); } } } [HarmonyPatch("PassTimeToNextDay")] [HarmonyPostfix] private static void PassTimeToNextDay() { Logger.LogDebug((object)"PassTimeToNextDay patch detected"); ZMTBase.Instance.CalculateMoonPrices(); ZMTBase.Instance.CalculateMoonRiskLevels(); ZMTBase.Instance.SetOxydeCostFromConfigs(); } [HarmonyPatch("ArriveAtLevel")] [HarmonyPostfix] private static void ArriveAtLevelPatch() { Logger.LogDebug((object)"ArriveAtLevel patch detected"); ZMTBase.Instance.CalculateMoonPrices(); ZMTBase.Instance.CalculateMoonRiskLevels(); ZMTBase.Instance.SetOxydeCostFromConfigs(); } [HarmonyPatch("Update")] [HarmonyPostfix] private static void AutoShipToCompanyBuilding(StartOfRound __instance) { if (ZMTBase.Config.AutoCompanyBuilding.Value) { Logger.LogDebug((object)"Trying to reroute ship"); ZMTBase.Instance.rerouteShip(GameNetworkManager.Instance, toCompany: true); } } [HarmonyPatch("ShipHasLeft")] [HarmonyPostfix] private static void ShipHasLeftPatch() { if (ZMTBase.Config.DestroyOxydeSellScrapsInOrbit.Value) { ZMTBase.Instance.CheckForScrapsToDestroy(); } } } [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { [HarmonyPatch("StartHost")] [HarmonyPostfix] private static void StartsHostPatch() { if (!ZMTBase.ModDataInstance.seedSetForQuota) { ZMTBase.Instance?.RollNewSeed(); } ZMTBase.Instance.displayedOxydeAlertForQuota = false; } [HarmonyPatch("SaveGame")] [HarmonyPostfix] private static void SaveGameValuesPatch() { ZMTBase.Instance.CalculateMoonPrices(); ZMTBase.Instance.CalculateMoonRiskLevels(); ZMTBase.Instance.SetOxydeCostFromConfigs(); } [HarmonyPatch("ResetSavedGameValues")] [HarmonyPostfix] private static void ResetSavedGameValuesPatch() { ZMTBase.Instance.CalculateMoonPrices(); ZMTBase.Instance.CalculateMoonRiskLevels(); ZMTBase.Instance.SetOxydeCostFromConfigs(); } } public static ManualLogSource Logger = ZMTBase.Logger; private static readonly MethodInfo? SetFromServerMethod = typeof(ProgressivePredicate).GetMethod("SetFromServer", BindingFlags.Instance | BindingFlags.NonPublic); private static void LockMoon(SelectableLevel level) { DawnMoonInfo dawnInfo = SelectableLevelExtensions.GetDawnInfo(level); ITerminalPurchasePredicate obj = ((dawnInfo != null) ? dawnInfo.DawnPurchaseInfo.PurchasePredicate : null); ProgressivePredicate val = (ProgressivePredicate)(object)((obj is ProgressivePredicate) ? obj : null); if (val != null) { SetFromServerMethod?.Invoke(val, new object[2] { false, val.ProgressiveStates.IsHidden }); Logger.LogWarning((object)("Locked Dawn moon: " + level.PlanetName)); } } } [HarmonyPatch(typeof(TimeOfDay))] internal class TimeOfDayPatch { [HarmonyPatch("SetNewProfitQuota")] [HarmonyPrefix] private static void SetNewProfitQuotaPatchPre() { ZMTBase.Instance.displayedOxydeAlertForQuota = false; ZMTBase.ModDataInstance.seedSetForQuota = false; ZMTBase.ModDataInstance.ZMTSaveData(); ZMTBase.Instance.RollNewSeed(); ZMTBase.Instance.CalculateMoonPrices(); ZMTBase.Instance.CalculateMoonRiskLevels(); ZMTBase.Instance.SetOxydeCostFromConfigs(); } [HarmonyPostfix] [HarmonyPatch("SetBuyingRateForDay")] private static void SetBuyingRateForDayPatch() { ZMTBase.Instance.ModifyBuyingRate(); } [HarmonyPostfix] [HarmonyPatch("SetNewProfitQuota")] private static void SetNewProfitQuotaPatchPost() { ZMTBase.Instance.ModifyBuyingRate(); } [HarmonyPostfix] [HarmonyPatch("UpdateProfitQuotaCurrentTime")] private static void UpdateProfitQuotaCurrentTimePatch() { if (ZMTBase.Config.IronmanAutoRoute.Value && ZMTBase.Config.IronmanMode.Value) { ZMTBase.Instance.rerouteShip(GameNetworkManager.Instance, toCompany: false); } } } internal static class PluginInfo { public const string modGUID = "ZetaArcade.ZetasMoonTweaks"; public const string modName = "ZetasMoonTweaks"; public const string modVersion = "1.0.0"; } internal static class Utils { public static float SwapLetterForRiskFloat(char target) { float num = 0f; return target switch { 'X' => 10f, 'S' => 6f, 'A' => 5f, 'B' => 4f, 'C' => 3f, 'D' => 2f, 'E' => 1f, 'F' => 0f, _ => 0f, }; } public static float SwapSymbolsForRiskFloat(string target) { float num = 0f; return target switch { "-" => 0.31f, "+" => 0.66f, "++" => 0.76f, "*" => 0.86f, _ => 0.5f, }; } public static string SwapIntForRiskLetter(int riskInt) { string text = ""; if (riskInt > 10) { return "X"; } if (riskInt > 6) { return "S"; } return riskInt switch { 0 => "F", 1 => "E", 2 => "D", 3 => "C", 4 => "B", 5 => "A", 6 => "S", 10 => "X", _ => "?", }; } public static string SwapFloatDecimalsForRiskSymbol(float riskFloat) { string text = ""; float num = riskFloat - (float)(int)riskFloat; double num2 = Math.Round(num, 2); if (num2 >= 0.85) { return "*"; } if (num2 >= 0.75) { return "++"; } if (num2 >= 0.65) { return "+"; } if (num2 >= 0.3) { return ""; } return "-"; } public static float ConvertRiskLevelToFloat(string riskLevel) { float num = 0f; float num2 = 0f; float num3 = 0f; char[] array = riskLevel.ToCharArray(); num2 = SwapLetterForRiskFloat(array[0]); string text = riskLevel.TrimStart(new char[1] { array[0] }); num3 = ((text.Length <= 0) ? 0.5f : SwapSymbolsForRiskFloat(text)); ZMTBase.Logger.LogDebug((object)("Converted " + riskLevel + " to " + num2 + " + " + num3)); return num2 + num3; } public static string ConvertFloatToRiskLevel(float floatRiskLevel) { string text = ""; string text2 = SwapIntForRiskLetter((int)floatRiskLevel); string text3 = SwapFloatDecimalsForRiskSymbol(floatRiskLevel); return text2 + text3; } } internal class ZMTNetwork { public class SeedMessage { public int seed; } public class ItemPickup { public ulong playerID; public int slot; } public static LNetworkMessage<SeedMessage> NewSeedMessage; public static LNetworkMessage<ItemPickup> ItemDestroyMessage; public static void Init() { NewSeedMessage = LNetworkMessage<SeedMessage>.Create("SeedSent", (Action<SeedMessage, ulong>)null, (Action<SeedMessage>)OnNewSeed, (Action<SeedMessage, ulong>)null); ItemDestroyMessage = LNetworkMessage<ItemPickup>.Create("ItemDestroy", (Action<ItemPickup, ulong>)OnItemDestroy, (Action<ItemPickup>)null, (Action<ItemPickup, ulong>)null); } private static void OnNewSeed(SeedMessage message) { if (!((Object)(object)ZMTBase.Instance == (Object)null)) { ZMTBase.Instance.SetNewSeed(message.seed); } } public static void SendNewSeed(int seed) { if (NetworkManager.Singleton.IsListening && NetworkManager.Singleton.IsHost) { NewSeedMessage.SendClients(new SeedMessage { seed = seed }); } } private static void OnItemDestroy(ItemPickup message, ulong senderClientId) { if (NetworkManager.Singleton.IsHost && !((Object)(object)ZMTBase.Instance == (Object)null)) { ZMTBase.Instance.DestroyScrapInSlot(message.playerID, message.slot); } } public static void SendItemDestroy(ulong playerID, int slot) { if (NetworkManager.Singleton.IsListening) { ItemDestroyMessage.SendServer(new ItemPickup { playerID = playerID, slot = slot }); } } } }