using System;
using System.Collections;
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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BinaryMoonsOverhaul.Components;
using BinaryMoonsOverhaul.Models;
using BinaryMoonsOverhaul.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using Unity.Netcode;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyCompany("Skit")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("BinaryMoonsOverhaul")]
[assembly: AssemblyFileVersion("5.1.0.0")]
[assembly: AssemblyInformationalVersion("5.1.0")]
[assembly: AssemblyProduct("BinaryMoonsOverhaul")]
[assembly: AssemblyTitle("BinaryMoonsOverhaul")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("5.1.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace BinaryMoonsOverhaul
{
public static class FlavorText
{
public const string TerminalMoonsCatalogueHeader = "\n\nWelcome to the exomoons catalogue.\nTo route the autopilot to a moon, use the word ROUTE.\nTo learn about any moon, use the word INFO.\n\n* The Company building // Buying at [companyBuyingRate].\n\nAvailable moons:\n";
public const string TerminalRerollRerouteText = "\nRerolling Moons...\n\n";
public const string TerminalNoRerollsText = "\nNo rerolls remaining! You earn 1 reroll at the start of each quota.\n\n";
public const string TerminalAccessDeniedHeader = "\n[ ACCESS DENIED ]\n\nThis celestial body is currently outside the authorized routing protocols for this quota.\n\nAvailable Destinations:\n";
public const string TerminalRerollRemainingText = "\n\nYou have {0} moon REROLL remaining.\nUse RE-ROLL to refresh the choices!\nType FIXMOON if your moon list does not match the host's.\n\n";
public const string HUDQuotaRewardHeader = "QUOTA REWARD";
public const string HUDQuotaRewardBody = "You've earned 1 extra moon REROLL!";
public const string HUDModifierActiveHeader = "MODIFIER ACTIVE";
public const string HUDModifierActiveBodySuffix = " is currently affecting the moon.";
public const string HUDExpressEntryChat = "EXPRESS ENTRY: Crew deployed directly to facility entrance.";
public const string ModExpressEntryHeader = "Rapid Deployment Initiated";
public const string ModExpressEntryBody = "Crew deployed directly to facility.";
public const string HUDExpressEntryTipHeader = "EXPRESS ENTRY";
public const string HUDExpressEntryTipBody = "Crew relocated to the main entrance.";
public const string HUDHighUVExposureHeader = "High UV Exposure";
public const string HUDHighUVExposureBody = "Higher than recommended levels of UV detected!";
public const string HUDInteriorLoadedHeader = "INTERIOR LOADED";
public const string HUDOrientationDayHeader = "ORIENTATION DAY";
public const string HUDOrientationDayBody = "New recruit has arrived for orientation and requires supervision";
public const string HUDStatusErrorHeader = "S\u0337T\u0334A\u0334T\u0338U\u0335S\u0335 E\u0337R\u0338R\u0335O\u0335R\u0335";
public const string HUDTipID = "LC_Tip1";
public const string ModWatchDogHeader = "ACTIVE GUARD DOGS";
public const string ModWatchDogBody = "Guard dogs detected in area. Please avoid and do not interere with their patrol.";
public const string ModToxicAtmosphereHeader = "TOXIC ATMOSPHERE";
public const string ModToxicAtmosphereBody = "Toxic gases detected. Involuntary motor disruption and hallucinations possible. Inhalors recommended.";
public const string ModLowGravityHeader = "LOW GRAVITY";
public const string ModLowGravityBody = "Gravitational limitations mitigated; quota adjusted accordingly.";
public const string ModRadioactiveSunlightHeader = "UV RADIATION WARNING";
public const string ModRadioactiveSunlightBody = "UV exposure may result in dermal compromise. Seek shelter and avoid prolonged exposure during daylight hours.";
public const string ModHauntedHeader = "PARANORMAL ACTIVITY DETECTED";
public const string ModHauntedBody = "Error: Unidentified UNKNOWABLE U\u0335\u035d\u0346\u0344\u031b\u031f\u0359\u0355N\u0335\u035d\u034b\u0312\u0320K\u0338\u0313\u0341\u0357\u0360\u032d\u033aI\u0337\u033e\u035d\u0300\u0320\u032e\u0319\u0333L\u0334\u033e\u0360\u0312\u0330L\u0334\u0341\u033f\u031a\u0343\u0316A\u0334\u035d\u0309\u035c\u0323B\u0336\u030b\u0309\u030a\u0352\u0326L\u0337\u0306\u035d\u0310\u035d\u0324E\u0338\u034b\u034b\u0342\u0315\u035c.";
public const string ModOxygenRichHeader = "OXYGEN RICH";
public const string ModOxygenRichBody = "Recovery thresholds recalibrated for increased productivity.";
public const string ModEquipmentCacheHeader = "EQUIPMENT CACHE";
public const string ModEquipmentCacheBody = "Locate dropship for additional tools and ship upgrades.";
public const string ModNewHireHeader = "EMPLOYEE ORIENTATION";
public const string ModNewHireBody = "New employee en route. Please rendezvous and assist in on site orientation.";
public const string ModWeaponDeliveryHeader = "WEAPON DROP";
public const string ModWeaponDeliveryBody = "Look down. Pick it up.";
public const string ModGroovyHeader = "GROOVY MOON";
public const string ModGroovyBody = "Rare cosmic frequencies detected! Scrap may contain enhanced value.";
public const string ModNameLowGravity = "Low Gravity";
public const string ModNameOxygenRich = "Oxygen Rich";
public const string ModNameEquipmentCache = "Equipment Cache";
public const string ModNameExpressEntry = "Express Entry";
public const string ModNameGroovy = "Groovy";
public const string ModNameWatchDog = "Guard Dog";
public const string ModNameRadioactiveSunlight = "High UV";
public const string ModNameHaunted = "Paranormal Activity";
public const string ModNameToxicAtmosphere = "Toxic Atmosphere";
public const string ModNameNewHire = "New Hire";
public const string ModNameWeaponDelivery = "Weapon Delivery";
public const string ModNameStandard = "Standard";
public const string ModNameUnknown = "Unknown";
public const string CompanySearchGordion = "gordion";
public const string CompanySearchCompany = "company";
public const string RainbowGroovy = "Groovy";
public const string ColorRed = "#FF0000";
public const string ColorGreen = "#00FF00";
public const string ColorWhite = "#FFFFFF";
public const string NetTagAskSync = "";
public const string NetTagRerollReq = "";
public const string NetTagRerollSyncPrefix = ":";
public const string NetTagSyncCfg = ":";
public const string NetTagSyncMoon = ":";
public const string NetTagSyncDone = "";
public const string NetTagRerollDeny = "";
public const string ItemNameTZP = "tzp";
public const string TerminalSellSuccess = "SHIP SCRAP LIQUIDATED. \n\nTotal: {0} credits for {1} items. \n\nThe Company appreciates your productivity.";
public const string TerminalSellNoScrap = "NO SCRAP DETECTED ON SHIP.";
public const string TerminalSellNotAtCompany = "RE ROUTE TO COMPANY BUILDING TO LIQUIDATE ASSETS.";
public const string ManifestDescription = "2 random FREE moons per day. Custom Moon compatible (LLL). Includes terminal sell command and reroll mechanics.";
public const string ReadmeTitle = "Binary Moons Overhaul (Restored)";
public const string ReadmeBody = "A roguelike experience for Lethal Company that restricts the autopilot to a choice of 2 random moons per day, each potentially having unique global modifiers.";
public const string ReadmeFeatures = "### Features\n* **Daily Random Selection**: Only 2 moons are available for routing each day.\n* **100% Free Travel**: All selected moons are **FREE** to visit, regardless of their standard cost.\n* **Custom Moon Compatible**: Fully compatible with all custom moons via **Lethal Level Loader**.\n* **Unique Modifiers**: Paranormal Activity, Weapon Delivery, Equipment Cache, Guard Dog and more coming soon. These modifiers are in addition to weather.\n* **Economy Modifiers**: Positive modifiers increase the quota; negative modifiers provide bonus credits.\n* **Moon Rerolls**: Spend your earned rerolls to refresh the daily choices!\n\n(not currently v.80 compatible, and prefered LethalLevelLoader v1.6.8 prefered. Sorry.)";
public const string ReadmeCommands = "### Commands\n* `moons` - Open the custom catalogue.\n* `reroll` / `re-roll` / `rr` - Refresh the daily moon options (uses 1 Reroll).\n* `sell` / `sell all` - **[WIP]** Sells all scrap on ship at Company Desk (Note: Currently only adds to credits, not quota requirement).\n* `fixmoon` - Force-sync your moon list with the Host.";
public static readonly string[] HauntedMessages = new string[9] { "I\u0337\u0352\u034a \u0336\u0352\u033eC\u0336\u0352\u034aA\u0336\u0352\u034aN\u0336\u0352\u034a \u0336\u0352\u033eF\u0336\u0352\u034aE\u0336\u0352\u034aE\u0336\u0352\u034aL\u0336\u0352\u034a \u0336\u0352\u033eY\u0336\u0352\u034aO\u0336\u0352\u034aU\u0336\u0352\u034a \u0336\u0352\u033eS\u0336\u0352\u034aH\u0336\u0352\u034aI\u0336\u0352\u034aV\u0336\u0352\u034aE\u0336\u0352\u034aR\u0336\u0352\u034a \u0336\u0352\u033eI\u0336\u0352\u034aN\u0336\u0352\u034a \u0336\u0352\u033eT\u0336\u0352\u034aH\u0336\u0352\u034aE\u0336\u0352\u034aR\u0336\u0352\u034aE\u0336\u0352\u034a .", "Y\u0334O\u0334U\u0337R\u0335 \u0335L\u0338U\u0338N\u0337G\u0337S\u0335 \u0337F\u0335E\u0334E\u0338L\u0334 \u0337S\u0338O\u0335 \u0338F\u0336U\u0338L\u0336L\u0337 \u0338O\u0337F\u0336 \u0337M\u0336Y\u0338 \u0335B\u0338R\u0336E\u0335A\u0335T\u0337H\u0335 .", "W\u0338H\u0336Y\u0336 \u0335A\u0334R\u0338E\u0335 \u0335Y\u0334O\u0334U\u0337 \u0334S\u0334T\u0337I\u0336L\u0336L\u0338 \u0335L\u0336O\u0335O\u0336K\u0338I\u0335N\u0337G\u0338?\u0334", "T\u0337H\u0335E\u0337Y\u0335 \u0335C\u0338A\u0338N\u0335'\u0337T\u0338 \u0335H\u0336E\u0337L\u0337P\u0336 \u0335Y\u0334O\u0334U\u0334 .", "S\u0338O\u0334O\u0336N\u0337 \u0338W\u0335E\u0336 \u0338W\u0338I\u0335L\u0336L\u0335 \u0337B\u0336E\u0335 \u0335O\u0337O\u0337N\u0337E\u0337 .", "D\u0338O\u0338N\u0336'\u0336T\u0336 \u0334T\u0337U\u0337R\u0338N\u0336 \u0337A\u0338R\u0338O\u0334U\u0335N\u0335D\u0334 .", "T\u0338H\u0338E\u0336 \u0334D\u0336A\u0336R\u0336K\u0337N\u0334E\u0337S\u0336S\u0334 \u0336H\u0334A\u0335S\u0336 \u0336T\u0335E\u0337E\u0337T\u0338H\u0338 .", "I\u0335S\u0336 \u0338T\u0335H\u0338A\u0336T\u0337 \u0334Y\u0337O\u0338U\u0336R\u0335 \u0335H\u0336E\u0338A\u0338R\u0338T\u0335B\u0335E\u0337A\u0336T\u0336?\u0336 \u0338I\u0335T\u0338'\u0338S\u0337 \u0334S\u0337O\u0337 \u0336F\u0334A\u0337S\u0336T\u0334 .", "Y\u0334O\u0334U\u0335 \u0335L\u0335O\u0336O\u0338K\u0335 \u0338L\u0338O\u0335V\u0337E\u0334L\u0338Y\u0335 \u0334I\u0337N\u0338 \u0335T\u0334H\u0338E\u0337 \u0335V\u0334O\u0334I\u0336D\u0338 ." };
}
[BepInPlugin("BinaryMoonsOverhaul", "BinaryMoonsOverhaul", "7.0.55")]
public class BinaryMoons : BaseUnityPlugin
{
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
public class NetworkingPatch
{
[HarmonyPostfix]
public static void StartPostfix()
{
BMO_Networking.Initialize();
}
}
public static ConfigEntry BlacklistedMoons;
public static ConfigEntry BonusPayMin;
public static ConfigEntry BonusPayMax;
public static ConfigEntry QuotaPenaltyMin;
public static ConfigEntry QuotaPenaltyMax;
public static ConfigEntry EnableOxygenRich;
public static ConfigEntry EnableLowGravity;
public static ConfigEntry EnableEquipmentCache;
public static ConfigEntry EnableWatchDog;
public static ConfigEntry EnableRadioactiveSunlight;
public static ConfigEntry EnableHaunted;
public static ConfigEntry EnableToxicAtmosphere;
public static ConfigEntry EnableExpressEntry;
public static ConfigEntry EnableGroovy;
public static ConfigEntry EnableStandardMoons;
public static ConfigEntry EnableNewHire;
public static ConfigEntry EnableWeaponDelivery;
public static ConfigEntry NewHireSpawnTime;
public static ConfigEntry GroovyLootMultiplier;
public static ConfigEntry GroovySpeedMultiplier;
public static ConfigEntry StartingRerolls;
public static ConfigEntry LowGravityStrength;
public static ConfigEntry OxygenStaminaMultiplier;
public static ConfigEntry HauntedGhostSpawnTime;
public static ConfigEntry WatchDogWakeTime;
public static ConfigEntry RadioactiveSunlightEndTime;
public static ConfigEntry EnableLogSpam;
public static ConfigEntry EquipmentCacheWhitelist;
public static ConfigEntry EquipmentCacheBlacklist;
public static HashSet MasterEquipmentPool;
public static BinaryMoons Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
ReflectionCache.Initialize();
BlacklistedMoons = ((BaseUnityPlugin)this).Config.Bind("General", "BlacklistedMoons", "Gordion, end, liquidation", "Comma-separated list of moons to NEVER include in the rotation.");
StartingRerolls = ((BaseUnityPlugin)this).Config.Bind("General", "StartingRerolls", 1, "Number of rerolls granted at the start of a new save.");
EnableLogSpam = ((BaseUnityPlugin)this).Config.Bind("General", "EnableLogSpam", false, "Enable detailed diagnostic logging in the console.");
BonusPayMin = ((BaseUnityPlugin)this).Config.Bind("Settings", "BonusPayMin", 50, "Minimum base reward for negative modifiers");
BonusPayMax = ((BaseUnityPlugin)this).Config.Bind("Settings", "BonusPayMax", 100, "Maximum base reward for negative modifiers");
QuotaPenaltyMin = ((BaseUnityPlugin)this).Config.Bind("Settings", "QuotaPenaltyMin", 25, "Minimum base penalty for positive modifiers");
QuotaPenaltyMax = ((BaseUnityPlugin)this).Config.Bind("Settings", "QuotaPenaltyMax", 50, "Maximum base penalty for positive modifiers");
GroovyLootMultiplier = ((BaseUnityPlugin)this).Config.Bind("Settings", "GroovyLootMultiplier", 1.15f, "Value multiplier for scrap on Groovy moons.");
GroovySpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("Settings", "GroovySpeedMultiplier", 1.15f, "Movement speed multiplier on Groovy moons.");
NewHireSpawnTime = ((BaseUnityPlugin)this).Config.Bind("Settings", "NewHireSpawnTime", 12f, "Time when the New Hire dropship arrives (12.0 = Noon).");
LowGravityStrength = ((BaseUnityPlugin)this).Config.Bind("Settings", "LowGravityStrength", 18f, "Gravity force for Low Gravity (13 is normal).");
OxygenStaminaMultiplier = ((BaseUnityPlugin)this).Config.Bind("Settings", "OxygenStaminaMultiplier", 1.5f, "Stamina efficiency for Oxygen Rich.");
HauntedGhostSpawnTime = ((BaseUnityPlugin)this).Config.Bind("Settings", "HauntedGhostSpawnTime", 17f, "Time when Ghost Girl spawns (17.0 = 5 PM).");
WatchDogWakeTime = ((BaseUnityPlugin)this).Config.Bind("Settings", "WatchDogWakeTime", 12f, "Time when Watch Dog wakes up.");
RadioactiveSunlightEndTime = ((BaseUnityPlugin)this).Config.Bind("Settings", "RadioactiveSunlightEndTime", 18f, "Time when Radiation stops.");
EquipmentCacheWhitelist = ((BaseUnityPlugin)this).Config.Bind("Settings", "EquipmentCacheWhitelist", "", "Comma-separated list of additional unlockable names to ADD to the Equipment Cache pool (e.g., 'Model Ship, Fancy Table').");
EquipmentCacheBlacklist = ((BaseUnityPlugin)this).Config.Bind("Settings", "EquipmentCacheBlacklist", "", "Comma-separated list of unlockable names to REMOVE from the pool.");
EnableOxygenRich = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableOxygenRich", false, "[WIP] Enable Oxygen Rich.");
EnableLowGravity = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableLowGravity", false, "[WIP] Enable Low Gravity.");
EnableEquipmentCache = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableEquipmentCache", true, "Enable Equipment Cache.");
EnableWatchDog = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableWatchDog", true, "Enable Guard Dog.");
EnableRadioactiveSunlight = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableRadioactiveSunlight", false, "[WIP] Enable High UV.");
EnableHaunted = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableHaunted", true, "Enable Paranormal Activity.");
EnableToxicAtmosphere = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableToxicAtmosphere", false, "[WIP] Enable Toxic Atmosphere.");
EnableExpressEntry = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableExpressEntry", false, "[WIP] Enable Express Entry.");
EnableGroovy = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableGroovy", false, "[WIP] Enable Groovy.");
EnableNewHire = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableNewHire", false, "[WIP] Enable New Hire.");
EnableWeaponDelivery = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableWeaponDelivery", true, "Enable Weapon Delivery.");
EnableStandardMoons = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "EnableStandardMoons", true, "Enable Standard moons in the rotation.");
InitializeMasterEquipmentPool();
Patch();
RegisterHotReloading();
Logger.LogInfo((object)"BinaryMoonsOverhaul v7.0.55 has loaded!");
}
private void RegisterHotReloading()
{
Action onCfgChanged = delegate
{
if ((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsServer)
{
Logger.LogInfo((object)"[BMO] Config Hot-Reload detected. Broadcasting update...");
BMO_Networking.BroadcastSync();
}
};
BonusPayMin.SettingChanged += delegate
{
onCfgChanged();
};
BonusPayMax.SettingChanged += delegate
{
onCfgChanged();
};
QuotaPenaltyMin.SettingChanged += delegate
{
onCfgChanged();
};
QuotaPenaltyMax.SettingChanged += delegate
{
onCfgChanged();
};
GroovyLootMultiplier.SettingChanged += delegate
{
onCfgChanged();
};
GroovySpeedMultiplier.SettingChanged += delegate
{
onCfgChanged();
};
NewHireSpawnTime.SettingChanged += delegate
{
onCfgChanged();
};
LowGravityStrength.SettingChanged += delegate
{
onCfgChanged();
};
OxygenStaminaMultiplier.SettingChanged += delegate
{
onCfgChanged();
};
HauntedGhostSpawnTime.SettingChanged += delegate
{
onCfgChanged();
};
WatchDogWakeTime.SettingChanged += delegate
{
onCfgChanged();
};
RadioactiveSunlightEndTime.SettingChanged += delegate
{
onCfgChanged();
};
StartingRerolls.SettingChanged += delegate
{
onCfgChanged();
};
}
internal static void Patch()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("BinaryMoonsOverhaul");
}
Logger.LogDebug((object)"Patching core components...");
try
{
Harmony.PatchAll();
ReflectionCache.Initialize();
if (ReflectionCache.HUDManager_UpdateProfitQuota != null)
{
Logger.LogInfo((object)("[BMO] Manual Patching: " + ReflectionCache.HUDManager_UpdateProfitQuota.DeclaringType.Name + "." + ReflectionCache.HUDManager_UpdateProfitQuota.Name + "..."));
Harmony.Patch((MethodBase)ReflectionCache.HUDManager_UpdateProfitQuota, (HarmonyMethod)null, new HarmonyMethod(typeof(ModifierLogicPatch), "QuotaVisualPatch", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
Logger.LogWarning((object)"[BMO] Could not find a stable Profit Quota Sync method. Quota fallback active.");
}
}
catch (Exception ex)
{
Logger.LogError((object)("[BMO] Harmony Patching Failed: " + ex.Message));
}
TerminalPatch.ApplyLLLHijack(Harmony);
BMO_Networking.Initialize();
Logger.LogInfo((object)"Binary Moons Overhaul Restored (v7.0.55) Loaded!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
private void InitializeMasterEquipmentPool()
{
string[] collection = new string[15]
{
"Teleporter", "Inverse Teleporter", "Loud horn", "Signal translator", "Television", "Toilet", "Shower", "Record player", "Romantic table", "Table",
"Company Cruiser", "Plushie mummy", "Pajama plushie", "Jack-o-lantern", "Cupboard"
};
MasterEquipmentPool = new HashSet(collection, StringComparer.OrdinalIgnoreCase);
IEnumerable enumerable = from s in EquipmentCacheWhitelist.Value.Split(',')
select s.Trim() into s
where !string.IsNullOrEmpty(s)
select s;
IEnumerable enumerable2 = from s in EquipmentCacheBlacklist.Value.Split(',')
select s.Trim() into s
where !string.IsNullOrEmpty(s)
select s;
foreach (string item in enumerable)
{
MasterEquipmentPool.Add(item);
}
foreach (string item2 in enumerable2)
{
MasterEquipmentPool.Remove(item2);
}
Logger.LogInfo((object)$"[LM] Equipment Cache Pool initialized with {MasterEquipmentPool.Count} valid items.");
}
}
public static class ReflectionCache
{
public static FieldInfo Terminal_buyItemSFX;
public static FieldInfo Terminal_shipIsComing;
public static FieldInfo TerminalNode_isLocked;
public static FieldInfo SelectableLevel_itemCost;
public static MethodInfo TimeOfDay_SyncStats_ClientRpc;
public static MethodInfo HUDManager_UpdateProfitQuota;
public static MethodInfo Terminal_TriggerDropshipServerRpc;
public static bool IsLethalLevelLoaderLoaded;
public static Terminal CachedTerminal;
public static EnemyType[] CachedEnemies;
public static TerminalNode[] CachedTerminalNodes;
public static Item CachedKnife;
public static Item CachedShotgun;
public static void Initialize()
{
try
{
IsLethalLevelLoaderLoaded = Chainloader.PluginInfos.ContainsKey("com.iamabatman.lethallevelloader");
Terminal_buyItemSFX = typeof(Terminal).GetField("buyItemSFX", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeof(Terminal).GetField("itemBoughtSound", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeof(Terminal).GetField("buyItemAudio", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
Terminal_shipIsComing = typeof(Terminal).GetField("shipIsComing", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
Terminal_TriggerDropshipServerRpc = typeof(Terminal).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name.Contains("Trigger") && m.Name.Contains("Dropship") && m.Name.Contains("ServerRpc"));
TerminalNode_isLocked = typeof(TerminalNode).GetField("isLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
SelectableLevel_itemCost = typeof(SelectableLevel).GetField("itemCost", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
TimeOfDay_SyncStats_ClientRpc = typeof(TimeOfDay).GetMethod("SyncStats_ClientRpc", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
HUDManager_UpdateProfitQuota = typeof(HUDManager).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name.Contains("UpdateProfitQuota") || m.Name.Contains("SetProfitQuota") || m.Name.Contains("SyncQuotaHUD"));
BinaryMoons.Logger.LogInfo((object)"Reflection Cache Initialized Successfully.");
}
catch (Exception ex)
{
BinaryMoons.Logger.LogError((object)("Failed to initialize Reflection Cache: " + ex.Message));
}
}
public static void InitializeAssets(Terminal terminal)
{
if ((Object)(object)CachedTerminal != (Object)null)
{
return;
}
CachedTerminal = terminal;
try
{
CachedEnemies = Resources.FindObjectsOfTypeAll();
CachedTerminalNodes = Resources.FindObjectsOfTypeAll();
if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.allItemsList != (Object)null)
{
CachedKnife = ((IEnumerable- )StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func
- )((Item i) => i.itemName.ToLower().Contains("kitchen knife") || i.itemName.ToLower().Contains("knife")));
CachedShotgun = ((IEnumerable
- )StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func
- )((Item i) => i.itemName.ToLower().Contains("shotgun")));
}
BinaryMoons.Logger.LogInfo((object)"[LM] Asset Cache Initialized Successfully (Terminal, Enemies, Nodes, Items).");
}
catch (Exception ex)
{
BinaryMoons.Logger.LogError((object)("[LM] Failed to initialize Asset Cache: " + ex.Message));
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "BinaryMoonsOverhaul";
public const string PLUGIN_NAME = "BinaryMoonsOverhaul";
public const string PLUGIN_VERSION = "7.0.55";
}
}
namespace BinaryMoonsOverhaul.Patches
{
[HarmonyPatch(typeof(ItemDropship), "Update")]
public class DropShipNewHirePatch
{
private static bool landingMessagePlayed;
[HarmonyPostfix]
private static void Postfix(ItemDropship __instance)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)StartOfRound.Instance).IsServer)
{
return;
}
if (__instance.shipLanded)
{
if (!landingMessagePlayed)
{
landingMessagePlayed = true;
if (TerminalPatch.IsModifierActive("New Hire"))
{
BMO_Networking.SendTip("ORIENTATION DAY", "New recruit has arrived for orientation and requires supervision", isPositive: true);
if (ModifierLogicPatch.isNewHireDropshipActive)
{
ModifierLogicPatch.isNewHireDropshipActive = false;
Terminal cachedTerminal = ReflectionCache.CachedTerminal;
if ((Object)(object)cachedTerminal != (Object)null && cachedTerminal.numberOfItemsInDropship > 0)
{
cachedTerminal.numberOfItemsInDropship--;
BinaryMoons.Logger.LogInfo((object)"New Hire: Cleaned up phantom dropship item count.");
}
}
SpawnMaskedAtDropship(((Component)__instance).transform.position);
}
}
if (!TerminalPatch.IsModifierActive("Equipment Cache") || !ModifierLogicPatch.waitingForDropshipArrival || ModifierLogicPatch.pendingVoucherUpgradeIndex == -1)
{
return;
}
bool flag = false;
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead && Vector3.Distance(((Component)val).transform.position, ((Component)__instance).transform.position) < 4.5f)
{
flag = true;
break;
}
}
if (flag)
{
ModifierLogicPatch.waitingForDropshipArrival = false;
int pendingVoucherUpgradeIndex = ModifierLogicPatch.pendingVoucherUpgradeIndex;
string pendingVoucherUpgradeName = ModifierLogicPatch.pendingVoucherUpgradeName;
ModifierLogicPatch.pendingVoucherUpgradeIndex = -1;
ModifierLogicPatch.pendingVoucherUpgradeName = "";
Terminal cachedTerminal2 = ReflectionCache.CachedTerminal;
int num = (((Object)(object)cachedTerminal2 != (Object)null) ? cachedTerminal2.groupCredits : 0);
StartOfRound.Instance.BuyShipUnlockableServerRpc(pendingVoucherUpgradeIndex, num);
HUDManager instance = HUDManager.Instance;
if (instance != null)
{
instance.AddTextToChatOnServer("EQUIPMENT CACHE: " + pendingVoucherUpgradeName + " voucher secured.", -1);
}
BMO_Networking.SendTip("EQUIPMENT CACHE", "Recovered: " + pendingVoucherUpgradeName + " voucher.", isPositive: false);
BinaryMoons.Logger.LogInfo((object)("[LM] Equipment Cache reward COLLECTED via proximity interaction: " + pendingVoucherUpgradeName));
}
}
else
{
landingMessagePlayed = false;
}
}
private static void SpawnMaskedAtDropship(Vector3 position)
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)RoundManager.Instance == (Object)null || (Object)(object)RoundManager.Instance.currentLevel == (Object)null || RoundManager.Instance.currentLevel.Enemies == null)
{
return;
}
EnemyType val = ModifierLogicPatch.CachedMasked;
if ((Object)(object)val == (Object)null)
{
val = ((IEnumerable)RoundManager.Instance.currentLevel.Enemies).FirstOrDefault((Func)((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType != (Object)null && e.enemyType.enemyName.ToLower().Contains("masked")))?.enemyType;
}
if ((Object)(object)val != (Object)null)
{
RoundManager.Instance.SpawnEnemyGameObject(position, 0f, -1, val);
BinaryMoons.Logger.LogInfo((object)"New Hire: Masked spawned at dropship!");
}
}
}
[HarmonyPatch]
public class ModifierLogicPatch
{
[CompilerGenerated]
private sealed class d__19 : IEnumerator