Decompiled source of Augmented Enhancer v0.6.0
com.github.lordfirespeed.augmented_enhancer.dll
Decompiled 11 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Enhancer.Config; using Enhancer.Config.AcceptableValues; using Enhancer.Extensions; using Enhancer.FeatureInfo; using Enhancer.Features; using GameNetcodeStuff; using HarmonyLib; using LC_API.GameInterfaceAPI.Events.EventArgs.Player; using LC_API.GameInterfaceAPI.Events.Handlers; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Steamworks.Data; using TMPro; using TerminalApi; using TerminalApi.Classes; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; using UnityEngine.UIElements.Collections; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("TerminalApi")] [assembly: AssemblyCompany("Crunchepillar, Lordfirespeed")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Tweaks plugin for Lethal Company")] [assembly: AssemblyFileVersion("0.6.0.0")] [assembly: AssemblyInformationalVersion("0.6.0+482db3cff81ad007a2b484c5ff5c63d81b81e570")] [assembly: AssemblyProduct("Augmented Enhancer")] [assembly: AssemblyTitle("com.github.lordfirespeed.augmented_enhancer")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Lordfirespeed/Lethal-Company-Augmented-Enhancer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.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 Enhancer { public class EnhancerPatcher : MonoBehaviour { private readonly IList<IFeatureInfo<IFeature>> _features = new List<IFeatureInfo<IFeature>>(19) { new FeatureInfo<AlwaysShowTerminal> { Name = "Always show terminal", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.KeepConsoleEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.KeepConsoleEnabled }, DelegateToModGuids = new string[1] { "mom.llama.enhancer" } }, new FeatureInfo<DaysPerQuota> { Name = "Days per quota", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.DaysPerQuotaAssignmentEnabled.Value && BoundConfig.QuotaFormulaEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[3] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.DaysPerQuotaAssignmentEnabled, (ConfigEntryBase)BoundConfig.QuotaFormulaEnabled }, DelegateToModGuids = new string[2] { "mom.llama.enhancer", "Haha.DynamicDeadline" } }, new FeatureInfo<DeathPenalty> { Name = "Death penalty", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.DeathPenaltyFormulaEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.DeathPenaltyFormulaEnabled } }, new FeatureInfo<HangarDoorCloseDuration> { Name = "Hangar door close duration", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.DoorPowerDurationEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.DoorPowerDurationEnabled }, DelegateToModGuids = new string[1] { "mom.llama.enhancer" } }, new FeatureInfo<HideClock> { Name = "Hide Clock", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.HideClockEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[5] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.HideClockEnabled, (ConfigEntryBase)BoundConfig.HideClockOutside, (ConfigEntryBase)BoundConfig.HideClockOnShip, (ConfigEntryBase)BoundConfig.HideClockInFacility }, DelegateToModGuids = new string[1] { "atk.lethalcompany.shipclock" } }, new FeatureInfo<ThreatScanCommand> { Name = "Threat scanner", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.ThreatScanner.Value != ThreatScannerMode.Disabled, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.ThreatScanner }, DelegateToModGuids = new string[1] { "mom.llama.enhancer" } }, new FeatureInfo<ItemProtection> { Name = "Item protection", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.ScrapProtectionEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.ScrapProtectionEnabled }, DelegateToModGuids = new string[1] { "mom.llama.enhancer" } }, new FeatureInfo<LeaderboardUsesBestAttempt> { Name = "Leaderboard Uses Best Attempt", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.LeaderboardUsesBestAttemptEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.LeaderboardUsesBestAttemptEnabled } }, new FeatureInfo<LightswitchCommand> { Name = "Lightswitch Command", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.LightswitchCommandEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.LightswitchCommandEnabled } }, new FeatureInfo<MilitaryTime> { Name = "24-hour clock", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.MilitaryTime.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.MilitaryTime }, DelegateToModGuids = new string[1] { "com.zduniusz.lethalcompany.24hourclock" } }, new FeatureInfo<CompanyBuyingFactorTweaks> { Name = "Company buying factor tweaks", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.CompanyBuyingFactorTweaksEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.CompanyBuyingFactorTweaksEnabled }, DelegateToModGuids = new string[1] { "mom.llama.enhancer" } }, new FeatureInfo<QuotaFormula> { Name = "Quota formula", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.QuotaFormulaEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.QuotaFormulaEnabled } }, new FeatureInfo<RemoveSavedItemCap> { Name = "Remove Saved Item Cap", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.RemoveSavedItemCapEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.RemoveSavedItemCapEnabled } }, new FeatureInfo<SavedItemCap> { Name = "Saved Item Cap", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.SavedItemCapEnabled.Value && !BoundConfig.RemoveSavedItemCapEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[3] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.SavedItemCapEnabled, (ConfigEntryBase)BoundConfig.RemoveSavedItemCapEnabled }, DelegateToModGuids = new string[1] { "MoreItems" } }, new FeatureInfo<ScrapTweaks> { Name = "Scrap Tweaks", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.ScrapTweaksEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[4] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.ScrapPlayercountScaling, (ConfigEntryBase)BoundConfig.ScrapQuantityScalar, (ConfigEntryBase)BoundConfig.ScrapValueScalar } }, new FeatureInfo<StartingCredits> { Name = "Starting credits", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.StartingCreditsEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.StartingCreditsEnabled } }, new FeatureInfo<PassiveIncome> { Name = "Passive income", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.PassiveIncomeEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.PassiveIncomeEnabled } }, new FeatureInfo<FreeUnlockables> { Name = "Suit unlock", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.FreeUnlockablesEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.FreeUnlockablesEnabled }, DelegateToModGuids = new string[1] { "mom.llama.enhancer" } }, new FeatureInfo<TimeSpeed> { Name = "Time speed", EnabledCondition = () => BoundConfig.Enabled.Value && BoundConfig.TimeSpeedEnabled.Value, ListenToConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[2] { (ConfigEntryBase)BoundConfig.Enabled, (ConfigEntryBase)BoundConfig.TimeSpeedEnabled }, DelegateToModGuids = new string[1] { "mom.llama.enhancer" } } }; internal static PluginInfo Info { get; set; } internal static ManualLogSource Logger { get; set; } internal static PluginConfig BoundConfig { get; set; } private void Start() { FeatureInfoInitializers.HarmonyFactory = (string harmonyName) => new Harmony("com.github.lordfirespeed.augmented_enhancer-" + harmonyName); FeatureInfoInitializers.LogSourceFactory = (string patchName) => Logger.CreateLogSource("Augmented Enhancer/" + patchName); Logger.LogInfo((object)"Initialising features..."); CollectionExtensions.Do<IFeatureInfo<IFeature>>((IEnumerable<IFeatureInfo<IFeature>>)_features, (Action<IFeatureInfo<IFeature>>)delegate(IFeatureInfo<IFeature> patch) { patch.Initialise(); }); Logger.LogInfo((object)"Done!"); } private void OnDestroy() { CollectionExtensions.Do<IFeatureInfo<IFeature>>((IEnumerable<IFeatureInfo<IFeature>>)_features, (Action<IFeatureInfo<IFeature>>)delegate(IFeatureInfo<IFeature> patch) { patch.Dispose(); }); } } [BepInPlugin("com.github.lordfirespeed.augmented_enhancer", "Augmented Enhancer", "0.6.0")] [BepInDependency("LC_API", "3.3.2")] [BepInDependency("atomic.terminalapi", "1.5.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(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger { get; private set; } internal static PluginConfig BoundConfig { get; private set; } private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Binding config..."); PluginConfig.RegisterTypeConverters(); BoundConfig = new PluginConfig((BaseUnityPlugin)(object)this); EnhancerPatcher.Info = ((BaseUnityPlugin)this).Info; EnhancerPatcher.Logger = Logger; EnhancerPatcher.BoundConfig = BoundConfig; GameObject val = new GameObject("Enhancer") { hideFlags = (HideFlags)61 }; val.AddComponent<EnhancerPatcher>(); Object.DontDestroyOnLoad((Object)(object)val); } } public class PluginConfig { public readonly ConfigEntry<bool> Enabled; public readonly ConfigEntry<bool> DelegationEnabled; public readonly ConfigEntry<bool> KeepConsoleEnabled; public readonly ConfigEntry<bool> FreeUnlockablesEnabled; public readonly ConfigEntry<List<string>> FreeUnlockablesList; public readonly ConfigEntry<bool> LightswitchCommandEnabled; public readonly ConfigEntry<bool> LeaderboardUsesBestAttemptEnabled; public readonly ConfigEntry<bool> SavedItemCapEnabled; public readonly ConfigEntry<int> SavedItemCap; public readonly ConfigEntry<bool> RemoveSavedItemCapEnabled; public readonly ConfigEntry<bool> MilitaryTime; public readonly ConfigEntry<bool> HideClockEnabled; public readonly ConfigEntry<bool> HideClockOnShip; public readonly ConfigEntry<bool> HideClockOutside; public readonly ConfigEntry<bool> HideClockInFacility; public readonly ConfigEntry<bool> CompanyBuyingFactorTweaksEnabled; public readonly ConfigEntry<bool> RandomiseCompanyBuyingFactor; public readonly ConfigEntry<float> MinimumCompanyBuyingFactor; public readonly ConfigEntry<bool> TimeSpeedEnabled; public readonly ConfigEntry<float> TimeSpeed; public readonly ConfigEntry<bool> DoorPowerDurationEnabled; public readonly ConfigEntry<float> DoorPowerDuration; public readonly ConfigEntry<bool> StartingCreditsEnabled; public readonly ConfigEntry<int> StartingCredits; public readonly ConfigEntry<bool> PassiveIncomeEnabled; public readonly ConfigEntry<int> PassiveIncomeQuantity; public readonly ConfigEntry<bool> DaysPerQuotaAssignmentEnabled; public readonly ConfigEntry<QuotaDurationBehaviour> DaysPerQuotaAssignmentBehaviour; public readonly ConfigEntry<int> DaysPerQuotaAssignment; public readonly ConfigEntry<Interval<int>> DaysPerQuotaAssignmentBounds; public readonly ConfigEntry<int> BaseTargetIncomePerDay; public readonly ConfigEntry<float> MaxTargetIncomePerDayScalar; public readonly ConfigEntry<int> AssignmentsToReachMaximumTargetIncomePerDay; public readonly ConfigEntry<float> TargetIncomePerDayScalarCurvature; public readonly ConfigEntry<float> TargetIncomePerDayRandomnessScalar; public readonly ConfigEntry<bool> QuotaFormulaEnabled; public readonly ConfigEntry<int> StartingQuota; public readonly ConfigEntry<float> QuotaIncreaseSteepnessCoefficient; public readonly ConfigEntry<float> QuotaIncreaseSteepnessExponent; public readonly ConfigEntry<float> QuotaBaseIncrease; public readonly ConfigEntry<float> QuotaIncreaseRandomFactor; public readonly ConfigEntry<bool> ScrapTweaksEnabled; public readonly ConfigEntry<float> ScrapValueScalar; public readonly ConfigEntry<float> ScrapQuantityScalar; public readonly ConfigEntry<float> ScrapPlayercountScaling; public readonly ConfigEntry<ThreatScannerMode> ThreatScanner; public readonly ConfigEntry<bool> ScrapProtectionEnabled; public readonly ConfigEntry<float> ScrapProtection; public readonly ConfigEntry<float> ScrapProtectionRandomness; public readonly ConfigEntry<bool> DeathPenaltyFormulaEnabled; public readonly ConfigEntry<float> MaximumDeathPenalty; public readonly ConfigEntry<float> MaximumDeathPenaltyPerPlayer; public readonly ConfigEntry<float> DeadBodyRecoveryDiscount; public readonly ConfigEntry<float> DeathPenaltyScalingCurvature; public static void RegisterTypeConverters() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_011c: Expected O, but got Unknown TomlTypeConverter.AddConverter(typeof(Interval<int>), new TypeConverter { ConvertToString = (object obj, Type type) => obj.ToString(), ConvertToObject = (string str, Type type) => Interval<int>.Parse(str) }); TomlTypeConverter.AddConverter(typeof(Interval<float>), new TypeConverter { ConvertToString = (object obj, Type type) => obj.ToString(), ConvertToObject = (string str, Type type) => Interval<float>.Parse(str) }); TomlTypeConverter.AddConverter(typeof(List<string>), new TypeConverter { ConvertToString = (object obj, Type type) => JsonConvert.SerializeObject(obj, type, new JsonSerializerSettings()), ConvertToObject = (string str, Type type) => JsonConvert.DeserializeObject(str, type) ?? throw new InvalidOperationException() }); } public PluginConfig(BaseUnityPlugin bindingPlugin) { //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Expected O, but got Unknown //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Expected O, but got Unknown //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Expected O, but got Unknown //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Expected O, but got Unknown //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Expected O, but got Unknown //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Expected O, but got Unknown //IL_0635: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Expected O, but got Unknown //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Expected O, but got Unknown //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Expected O, but got Unknown //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Expected O, but got Unknown //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Expected O, but got Unknown //IL_077a: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Expected O, but got Unknown //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07c2: Expected O, but got Unknown //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_0821: Expected O, but got Unknown //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Expected O, but got Unknown //IL_0893: Unknown result type (might be due to invalid IL or missing references) //IL_089d: Expected O, but got Unknown Enabled = bindingPlugin.Config.Bind<bool>("Global", "Enabled", true, "Globally enable/disable the plugin"); DelegationEnabled = bindingPlugin.Config.Bind<bool>("Global", "Delegation Enabled", true, "Globally enables/disables delegation for the plugin. When this is true, features will be disabled automatically (delegated to other mods) depending on the mods you have installed."); KeepConsoleEnabled = bindingPlugin.Config.Bind<bool>("Misc Tweaks", "Always Show Terminal", false, "Whether to keep the terminal enabled after a player stops using it\nHost Required: No"); FreeUnlockablesEnabled = bindingPlugin.Config.Bind<bool>("Misc Tweaks", "Free Unlockables Enabled", false, "Unlocks unlockables (such as suits, furniture) by name at the start of round.\nHost Required: Yes"); FreeUnlockablesList = bindingPlugin.Config.Bind<List<string>>("Misc Tweaks", "Free Unlockables List", new List<string>(3) { "Green suit", "Hazard suit", "Purple Suit" }, "The unlockable item names to unlock when 'Free Unlockables' are enabled"); LightswitchCommandEnabled = bindingPlugin.Config.Bind<bool>("Misc Tweaks", "Lightswitch Commands Enabled", false, "Enabling this adds a 'lights' command to the terminal to control the interior ship lights, in case a trickster hides the switch.\nHost Required: No"); LeaderboardUsesBestAttemptEnabled = bindingPlugin.Config.Bind<bool>("Misc Tweaks", "Leaderboard uses Best Attempt", false, "Enabling this prevents you from overwriting better challenge moon attempts with a worse one.\nHost Required: Unknown"); SavedItemCapEnabled = bindingPlugin.Config.Bind<bool>("Saved Item Cap", "Saved Item Cap Enabled", false, "Feature flag for the 'saved item cap' option.\nHost Required: Yes"); SavedItemCap = bindingPlugin.Config.Bind<int>("Saved Item Cap", "Saved Item Cap", 45, "Increases the cap on the number of items that can be saved.\n +Can help to prevent items despawning when you have too many and re-load your lobby.\nHost Required: Yes"); RemoveSavedItemCapEnabled = bindingPlugin.Config.Bind<bool>("Saved Item Cap", "Remove Saved Item Cap", false, "Remove the cap on the number of items that can be saved entirely.\nHost Required: Yes"); MilitaryTime = bindingPlugin.Config.Bind<bool>("Clock Tweaks", "24-hour Clock", false, "Whether the time should display in 24-hour (military) format.\nHost Required: No"); HideClockEnabled = bindingPlugin.Config.Bind<bool>("Clock Tweaks", "Hide Clock Enabled", false, "Feature flag for the 'hide clock on x' options.\nHost Required: No"); HideClockOnShip = bindingPlugin.Config.Bind<bool>("Clock Tweaks", "Hide Clock on Ship", true, "Whether the HUD clock should be hidden on the ship.\nHost Required: No"); HideClockOutside = bindingPlugin.Config.Bind<bool>("Clock Tweaks", "Hide Clock Outside", false, "Whether the HUD clock should be hidden outside.\nHost Required: No"); HideClockInFacility = bindingPlugin.Config.Bind<bool>("Clock Tweaks", "Hide Clock in Facility", true, "Whether the HUD clock should be hidden in the facility.\nHost Required: No"); CompanyBuyingFactorTweaksEnabled = bindingPlugin.Config.Bind<bool>("Company Buying Prices", "Company Buying Factor Tweaks Enabled", false, "Whether or not the company buying price tweaks are enabled.\nHost required: Yes"); RandomiseCompanyBuyingFactor = bindingPlugin.Config.Bind<bool>("Company Buying Prices", "Company Buying Factor Randomizer Enabled", false, "Randomises the company buying % when enabled. Great if you're using longer quota deadlines.\nThis uses a variety of things to randomize prices such as the company mood, time passed in the quota, etc.\nRespects the minimum sale value, too.\nHost Required: Yes"); MinimumCompanyBuyingFactor = bindingPlugin.Config.Bind<float>("Company Buying Prices", "Minimum Company Buying Factor", 0f, "The default formula for selling items to the company isn't designed to handle more than 3 days remaining.\nThe Company will be prevented from offering a factor lower than this configured value.\nRecommended values for games above 3 days: 0.3 - 0.5\nHost Required: Yes"); TimeSpeedEnabled = bindingPlugin.Config.Bind<bool>("Time Speed", "Time Speed Enabled", false, "Feature flag for the 'time speed' variable.\nHost Required: Yes"); TimeSpeed = bindingPlugin.Config.Bind<float>("Time Speed", "Time Speed", 1f, "How fast time passes on moons. Lower values mean time passes more slowly.\nRecommended value for single play: 0.75\nHost Required: Yes"); DoorPowerDurationEnabled = bindingPlugin.Config.Bind<bool>("Door Power", "Door Power Duration Enabled", false, "Feature flag for the 'door power duration' variable.\nHost Required: Yes"); DoorPowerDuration = bindingPlugin.Config.Bind<float>("Door Power", "Door Power Duration", 30f, "How long the hangar door can be kept shut at a time (in seconds)\nRecommended values: 60.0 - 180.0\nHost Required: All players should use the same value."); StartingCreditsEnabled = bindingPlugin.Config.Bind<bool>("Starting Credits & Passive Income", "Starting Credits Enabled", false, "Feature flag for the 'starting credits' variable.\nHost Required: Yes"); StartingCredits = bindingPlugin.Config.Bind<int>("Starting Credits & Passive Income", "Starting Credits", 60, "How many credits the group starts with on a new run.\nHost Required: Yes"); PassiveIncomeEnabled = bindingPlugin.Config.Bind<bool>("Starting Credits & Passive Income", "Passive Income Enabled", false, "Feature flag for the 'passive income' variable.\nHost Required: Yes"); PassiveIncomeQuantity = bindingPlugin.Config.Bind<int>("Starting Credits & Passive Income", "Passive Income Amount", 0, "The number of credits you will be given at the end of each level.\nHost Required: Yes"); DaysPerQuotaAssignmentEnabled = bindingPlugin.Config.Bind<bool>("Quota Assignment Duration", "Quota Assignment Duration Enabled", false, "Feature flag for the 'days per quota' feature. 'Quota Formula' feature must also be enabled for this to take effect.\nHost Required: Yes"); DaysPerQuotaAssignmentBehaviour = bindingPlugin.Config.Bind<QuotaDurationBehaviour>("Quota Assignment Duration", "Quota Assignment Behaviour", QuotaDurationBehaviour.Constant, "The behaviour of the quota duration.\n- Constant: Quota duration remains constant throughout play.\n- Variable: Quota duration varies based upon 'target income per day' (configured below)\n- DynamicVariable: Quota duration varies upon your lifetime average income per day .\nHost Required: Yes"); DaysPerQuotaAssignment = bindingPlugin.Config.Bind<int>("Quota Assignment Duration", "Quota Assignment Days", 3, "How long you have to meet each quota (in days)\nRecommended values: 3 - 7\nHost Required: Yes"); DaysPerQuotaAssignmentBounds = bindingPlugin.Config.Bind<Interval<int>>("Quota Assignment Duration", "Quota Assignment Days Bounds", new Interval<int>(3, 10), new ConfigDescription("Bounds for the quota assignment duration when using variable quota duration behaviour.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableInterval<int>(new Interval<int>(1, int.MaxValue)), Array.Empty<object>())); BaseTargetIncomePerDay = bindingPlugin.Config.Bind<int>("Quota Assignment Duration", "Base Target Income per Day", 200, new ConfigDescription("Base target income per day. Used when calculating the quota duration with Variable behaviour.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, int.MaxValue), Array.Empty<object>())); MaxTargetIncomePerDayScalar = bindingPlugin.Config.Bind<float>("Quota Assignment Duration", "Maximum Target Income Per Day Scalar", 1.5f, new ConfigDescription("Upper bound for target income per day multiplier when using variable quota duration behaviour.\nHost Required: Yes", (AcceptableValueBase)null, Array.Empty<object>())); AssignmentsToReachMaximumTargetIncomePerDay = bindingPlugin.Config.Bind<int>("Quota Assignment Duration", "Assignment Count to Reach Maximum Target Income per Day", 10, new ConfigDescription("Number of assignments you must complete to reach the maximum target income per day multiplier.\nHost Required: Yes", (AcceptableValueBase)null, Array.Empty<object>())); TargetIncomePerDayScalarCurvature = bindingPlugin.Config.Bind<float>("Quota Assignment Duration", "Target Income Scalar Curvature", 0f, new ConfigDescription("How curved the graph of target income per day against quota assignments completed is.\n- 0: Target income per day increases linearly.\n- 1: ", (AcceptableValueBase)null, Array.Empty<object>())); TargetIncomePerDayRandomnessScalar = bindingPlugin.Config.Bind<float>("Quota Assignment Duration", "Target Income Scalar Randomness", 0.4f, new ConfigDescription("Randomness of target income per day value used to calculate the quota duration.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, float.MaxValue), Array.Empty<object>())); QuotaFormulaEnabled = bindingPlugin.Config.Bind<bool>("Quota Calculation", "Quota Formula Enabled", false, "Feature flag for the 'quota formula' variables, which include:\n - 'starting quota'\n - 'quota increase steepness'\n - 'quota base increase'\n - 'quota increase randomness'\nHost Required: Yes"); StartingQuota = bindingPlugin.Config.Bind<int>("Quota Calculation", "Starting Quota", 130, "The starting quota on a new run.\nHost Required: Yes"); QuotaIncreaseSteepnessCoefficient = bindingPlugin.Config.Bind<float>("Quota Calculation", "Quota Increase Steepness", 0.0625f, "Used in calculating quota increase. Coefficient for the increase factor dependent on the number of completed quota assignments.\nHost Required: Yes"); QuotaIncreaseSteepnessExponent = bindingPlugin.Config.Bind<float>("Quota Calculation", "Quota Increase Steepness Exponent", 2f, "Used in calculating quota increase. Exponent for the increase factor dependent on the number of completed quota assignments.\nHost Required: Yes"); QuotaBaseIncrease = bindingPlugin.Config.Bind<float>("Quota Calculation", "fQuotaBaseIncrease", 100f, "Used in calculating quota increase. Multiplier for the constant increase factor.\nHost Required: Yes"); QuotaIncreaseRandomFactor = bindingPlugin.Config.Bind<float>("Quota Calculation", "Quota Increase Random Factor", 0.5f, "Used in calculating quota increase. Multiplier for the random increase factor.\nHost Required: Yes"); ScrapTweaksEnabled = bindingPlugin.Config.Bind<bool>("Scrap Value, Quantity & Playercount Scaling", "Scrap Tweaks Enabled", false, new ConfigDescription("Whether or not to enable scrap tweaks.\nHost required: Yes", (AcceptableValueBase)null, Array.Empty<object>())); ScrapValueScalar = bindingPlugin.Config.Bind<float>("Scrap Value, Quantity & Playercount Scaling", "Scrap Value Scalar", 1f, new ConfigDescription("Multiplier for value of spawned scrap items. Should be a positive float.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, float.MaxValue), Array.Empty<object>())); ScrapQuantityScalar = bindingPlugin.Config.Bind<float>("Scrap Value, Quantity & Playercount Scaling", "Scrap Quantity Scalar", 1f, new ConfigDescription("Multiplier for quantity of spawned scrap items. Should be a positive float.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, float.MaxValue), Array.Empty<object>())); ScrapPlayercountScaling = bindingPlugin.Config.Bind<float>("Scrap Value, Quantity & Playercount Scaling", "Scrap Playercount Scaling", 0f, new ConfigDescription("Multiplier for 'playercount scaling' - Higher values increase scrap spawn quantity but decrease scrap value.\nHas no effect when 4 or fewer players are present.\nA value of 0 disables playercount scaling.\nA value of 1.0 means that each additional player will cause 25% more scrap items to spawn (linear, not compounding) and reduce scrap value by an equal factor.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, float.MaxValue), Array.Empty<object>())); ThreatScanner = bindingPlugin.Config.Bind<ThreatScannerMode>("Threat Scanner", "Threat Scanner Mode", ThreatScannerMode.Disabled, "How the threat scanner functions. Valid types:\n - Disabled\n - Contacts: Number of Enemies on level\n - ThreatLevelPercentage: Percentage of max enemies on level\n - ThreatLevelName: Vague Text description (In order of threat level) [Clear -> Green -> Yellow -> Orange - Red]\nHost Required: No"); ScrapProtectionEnabled = bindingPlugin.Config.Bind<bool>("Scrap Protection", "Scrap Protection Enabled", false, new ConfigDescription("Sets whether or not the scrap protection feature is enabled. \nHost Required: Yes", (AcceptableValueBase)null, Array.Empty<object>())); ScrapProtection = bindingPlugin.Config.Bind<float>("Scrap Protection", "Scrap Protection Probability", 0f, new ConfigDescription("Sets the average probability that each scrap item is kept in the event that that no players survive a mission.\nThat is, this is the approximate average fraction of secured scrap items kept.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); ScrapProtectionRandomness = bindingPlugin.Config.Bind<float>("Scrap Protection", "Scrap Protection Randomness Scalar", 0f, new ConfigDescription("Sets the randomness of the probability that each scrap item is kept in the event that that no players survive a mission.\n 0 -> no randomness, 0.5 -> ±0.5, 1 -> ±1\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); DeathPenaltyFormulaEnabled = bindingPlugin.Config.Bind<bool>("Death Penalty", "Death Penalty Formula Enabled", false, "Feature flag for the 'death penalty formula' variables, which includes\n - 'max death penalty'\n - 'max death penalty per player'\n - 'body recovery discount'\n - 'death penalty scaling curvature'\nHost Required: Yes"); MaximumDeathPenalty = bindingPlugin.Config.Bind<float>("Death Penalty", "Maximum Death Penalty", 0.8f, new ConfigDescription("The maximum fraction of your money that you can lose per round.\nValue should be in [0,1], e.g.\n0 - No money can be lost.\n0.5 - Half your money can be lost in one run.\n1 - All money can be lost in one run.\nUse 0.8 for vanilla behaviour.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); MaximumDeathPenaltyPerPlayer = bindingPlugin.Config.Bind<float>("Death Penalty", "Maximum Death Penalty per Player", 0.2f, new ConfigDescription("The maximum fraction of your money that you can lose per round, per dead player.\nValue should be in [0,1].\nUse 0.2 for vanilla behaviour.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); DeadBodyRecoveryDiscount = bindingPlugin.Config.Bind<float>("Death Penalty", "Dead Body Recovery Discount", 0.6f, new ConfigDescription("How much recovering dead bodies reduces the penalty for that death by.\nValue should be in [0,1], e.g.\n0 - Recovering a body does not reduce the fine.\n1 - Recovering a body completely removes the fine for that death.\nUse 0.6 for vanilla behaviour.\nHost Required: Yes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); DeathPenaltyScalingCurvature = bindingPlugin.Config.Bind<float>("Death Penalty", "Death Penalty Curve Degree", 0f, "How curved the death penalty scaling is. Positive -> less fine for fewer deaths. Negative -> more fine for fewer deaths.\ne.g. with a 4-player lobby:\n0 - The fine scales linearly: 25%, 50%, 75%, 100%.\n1 - The fine scales quadratically: 6.3%, 25%, 56.3%, 100%\n-1 - The fine scales anti-quadratically: 50%, 70.1%, 86.6%, 100%\nHost Required: Yes"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.lordfirespeed.augmented_enhancer"; public const string PLUGIN_NAME = "Augmented Enhancer"; public const string PLUGIN_VERSION = "0.6.0"; } } namespace Enhancer.Features { public class AlwaysShowTerminal : IFeature { private static readonly MethodInfo WaitUntilFrameEndToSetActiveMethod = AccessTools.Method(typeof(Terminal), "waitUntilFrameEndToSetActive", (Type[])null, (Type[])null); private static readonly MethodInfo StartCoroutineMethod = AccessTools.Method(typeof(MonoBehaviour), "StartCoroutine", new Type[1] { typeof(IEnumerator) }, (Type[])null); private static readonly FieldInfo TerminalScrollBarVertical = AccessTools.Field(typeof(Terminal), "scrollBarVertical"); private static readonly PropertyInfo ScrollbarValue = AccessTools.Property(typeof(Scrollbar), "value"); [HarmonyPatch(typeof(Terminal), "QuitTerminal")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> TerminalQuitTranspile(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Call, (object)WaitUntilFrameEndToSetActiveMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)StartCoroutineMethod, (string)null) }).MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null) }) .SetOpcodeAndAdvance(OpCodes.Ldc_I4_1) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)TerminalScrollBarVertical, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0f, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)ScrollbarValue.GetSetMethod(), (string)null) }) .SetOpcodeAndAdvance(OpCodes.Nop) .RemoveInstructions(3); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> TerminalOpenTranspile(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(instr, (object)13)), (string)null) }).Advance(-4) .SetAndAdvance(OpCodes.Nop, (object)null) .RemoveInstructions(6); return val.InstructionEnumeration(); } } public class CompanyBuyingFactorTweaks : IFeature { protected static ManualLogSource Logger { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } private static float GetRandomPriceFactor() { if (TimeOfDay.Instance.daysUntilDeadline < 1) { return 1f; } Logger.LogInfo((object)"Choosing random buying factor..."); float moodFactor = GetMoodFactor(); float num = 1f + 0.05f * (float)(Plugin.BoundConfig.DaysPerQuotaAssignment.Value - TimeOfDay.Instance.daysUntilDeadline); num = Mathf.Clamp(num, 1f, 2f); Random random = new Random(StartOfRound.Instance.randomMapSeed + 77); float num2 = (float)random.NextDouble() * (1f - moodFactor * num) + moodFactor; Logger.LogInfo((object)$"New buying % set at {num2}"); Logger.LogDebug((object)$" factors {moodFactor} : {num} : {StartOfRound.Instance.randomMapSeed + 77}"); return num2; } private static string? GetCompanyMoodName() { if (TimeOfDay.Instance == null) { return null; } if (TimeOfDay.Instance.currentCompanyMood == null) { return null; } return ((Object)TimeOfDay.Instance.currentCompanyMood).name; } private static float GetMoodFactor() { Logger.LogDebug((object)"Getting mood factor"); try { return GetCompanyMoodName() switch { "SilentCalm" => 0.35f, "SnoringGiant" => 0.45f, "Agitated" => 0.25f, _ => 0.4f, }; } finally { Logger.LogDebug((object)"Got mood factor"); } } [HarmonyPatch(typeof(TimeOfDay), "SetBuyingRateForDay")] [HarmonyPostfix] public static void BuyingRatePost(TimeOfDay __instance) { Logger.LogInfo((object)"Setting company buying rate ..."); if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { if (Plugin.BoundConfig.RandomiseCompanyBuyingFactor.Value) { StartOfRound.Instance.companyBuyingRate = GetRandomPriceFactor(); } if (StartOfRound.Instance.companyBuyingRate < Plugin.BoundConfig.MinimumCompanyBuyingFactor.Value) { StartOfRound.Instance.companyBuyingRate = Plugin.BoundConfig.MinimumCompanyBuyingFactor.Value; } StartOfRound.Instance.SyncCompanyBuyingRateServerRpc(); } } } public class DaysPerQuota : IFeature { protected static ManualLogSource Logger { get; set; } private static float DifficultyScalar { get { int timesFulfilledQuota = TimeOfDay.Instance.timesFulfilledQuota; int value = Plugin.BoundConfig.AssignmentsToReachMaximumTargetIncomePerDay.Value; if (timesFulfilledQuota >= value) { return Plugin.BoundConfig.MaxTargetIncomePerDayScalar.Value; } if (timesFulfilledQuota == 0) { return 1f; } float num = Mathf.Pow(2f, Plugin.BoundConfig.TargetIncomePerDayScalarCurvature.Value); float num2 = 1f + Mathf.Pow((float)timesFulfilledQuota / (float)value, num) * (Plugin.BoundConfig.MaxTargetIncomePerDayScalar.Value - 1f); Logger.LogInfo((object)$"Difficulty scalar calculated to be {num2:f1}"); return num2; } } private static float RandomnessScalar { get { float value = Plugin.BoundConfig.TargetIncomePerDayRandomnessScalar.Value; if (value == 0f) { return 0f; } float num = 1f + value * 2f * TimeOfDay.Instance.quotaVariables.randomizerCurve.Evaluate(Random.Range(0f, 1f)); Logger.LogInfo((object)$"Randomness scalar selected to be {num:f1}"); return num; } } private static float BaseTargetDailyIncome { get { switch (Plugin.BoundConfig.DaysPerQuotaAssignmentBehaviour.Value) { case QuotaDurationBehaviour.Constant: throw new InvalidOperationException(); case QuotaDurationBehaviour.Variable: return Plugin.BoundConfig.BaseTargetIncomePerDay.Value; case QuotaDurationBehaviour.DynamicVariable: try { float num = QuotaFormula.Instance.PastAssignments.Average((QuotaAssignmentInfo info) => (float)info.Income / (float)info.Duration); Logger.LogInfo((object)$"Average income is currently {num:f1}"); return num; } catch (InvalidOperationException) { return Plugin.BoundConfig.BaseTargetIncomePerDay.Value; } default: throw new ArgumentOutOfRangeException(); } } } private static float TargetDailyIncome => BaseTargetDailyIncome * DifficultyScalar * RandomnessScalar; private static float QuotaMagnitude { get { QuotaFormula instance = QuotaFormula.Instance; float num = instance.PastAssignments.Sum((QuotaAssignmentInfo info) => info.BaseIncreaseCoefficient * info.PolynomialIncreaseCoefficient); return (float)instance.RunQuotaVariables.StartingQuota + num; } } private static int AssignmentDuration { get { if (Plugin.BoundConfig.DaysPerQuotaAssignmentBehaviour.Value == QuotaDurationBehaviour.Constant) { return Plugin.BoundConfig.DaysPerQuotaAssignment.Value; } int value = Mathf.CeilToInt(QuotaMagnitude / TargetDailyIncome); return Plugin.BoundConfig.DaysPerQuotaAssignmentBounds.Value.Clamp(value); } } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } private static void SetQuotaDuration() { int assignmentDuration = AssignmentDuration; Logger.LogInfo((object)$"Setting quota duration to {assignmentDuration}..."); QuotaSettings quotaVariables = TimeOfDay.Instance.quotaVariables; quotaVariables.deadlineDaysAmount = assignmentDuration; } private static void TrySetQuotaDuration() { try { SetQuotaDuration(); } catch (Exception ex) { Logger.LogError((object)"Failed to set new quota duration."); Logger.LogError((object)ex); } } [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPrefix] public static void StartOfRoundShipStartPre() { TrySetQuotaDuration(); } [HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")] [HarmonyPostfix] [HarmonyAfter(new string[] { "com.github.lordfirespeed.augmented_enhancer-QuotaFormula" })] private static void SetDeadline() { TrySetQuotaDuration(); } } public enum QuotaDurationBehaviour { Constant, Variable, DynamicVariable } public class DeathPenalty : IFeature { protected static ManualLogSource Logger { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } private static int CountTotalPlayersInSession() { return StartOfRound.Instance.connectedPlayersAmount + 1; } private static float DetermineMaximumPenaltyFactor() { return Mathf.Clamp(Mathf.Min(Plugin.BoundConfig.MaximumDeathPenalty.Value, (float)CountTotalPlayersInSession() * Plugin.BoundConfig.MaximumDeathPenaltyPerPlayer.Value), 0f, 1f); } private static float ComputePenaltyFactor(float deathCoefficient, float maximumPenaltyFactor) { float num = Mathf.Pow(2f, Plugin.BoundConfig.DeathPenaltyScalingCurvature.Value); float num2 = Mathf.Pow(deathCoefficient, num) * Mathf.Pow((float)CountTotalPlayersInSession(), 0f - num) * maximumPenaltyFactor; return Mathf.Clamp(num2, 0f, 1f); } private static float ComputeDeathCoefficient(int playersDead, int bodiesInsured) { return (float)(playersDead - bodiesInsured) + (1f - Mathf.Max(0f, Plugin.BoundConfig.DeadBodyRecoveryDiscount.Value)) * (float)bodiesInsured; } [HarmonyPatch(typeof(HUDManager), "ApplyPenalty")] [HarmonyPrefix] public static bool ApplyPenaltyPrefix(ref int playersDead, ref int bodiesInsured, HUDManager __instance) { playersDead = Mathf.Max(playersDead, 0); bodiesInsured = Mathf.Max(bodiesInsured, 0); float deathCoefficient = ComputeDeathCoefficient(playersDead, bodiesInsured); float maximumPenaltyFactor = DetermineMaximumPenaltyFactor(); float num = ComputePenaltyFactor(deathCoefficient, maximumPenaltyFactor); Terminal val = Object.FindObjectOfType<Terminal>(); int num2 = (int)((float)val.groupCredits * num); Logger.LogInfo((object)$"Death Penalty is {num:p1} of {val.groupCredits} = {num2} credits."); val.groupCredits = Mathf.Max(0, val.groupCredits - num2); ((TMP_Text)__instance.statsUIElements.penaltyAddition).text = $"{playersDead} casualties: -{num:p0}\n({bodiesInsured} bodies recovered)"; ((TMP_Text)__instance.statsUIElements.penaltyTotal).text = $"DUE: {num2}"; Logger.LogInfo((object)$"Death penalty has been applied. New group credits: {val.groupCredits}."); return false; } } public class FreeUnlockables : IFeature { protected static ManualLogSource Logger { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] public static void StartOfRoundSuitPatch(StartOfRound __instance) { StartOfRound __instance2 = __instance; Logger.LogInfo((object)"Unlocking items..."); CollectionExtensions.Do(from item in __instance2.unlockablesList.unlockables.Select((UnlockableItem unlockable, int index) => new { unlockable, index }).Tap(item => { Logger.LogDebug((object)$"Unlockable item {item.index}: '{item.unlockable.unlockableName}'"); }) where Plugin.BoundConfig.FreeUnlockablesList.Value.Contains(item.unlockable.unlockableName) select item, item => { __instance2.SpawnUnlockable(item.index); }); } } public class HangarDoorCloseDuration : IFeature { protected static ManualLogSource Logger { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } [HarmonyPatch(typeof(HangarShipDoor), "Start")] [HarmonyPostfix] public static void HangarShipDoorPost(HangarShipDoor __instance) { Logger.LogInfo((object)$"Setting Hangar door power to last for {Plugin.BoundConfig.DoorPowerDuration.Value} seconds..."); __instance.doorPowerDuration = Plugin.BoundConfig.DoorPowerDuration.Value; } } public class HideClock : IFeature { [Flags] private enum Environment { None = 0, Outside = 1, Ship = 2, Facility = 4, Terminal = 8 } protected static ManualLogSource Logger { get; set; } private static PlayerControllerB? Player { get { if (!((Object)(object)HUDManager.Instance != (Object)null)) { return null; } return HUDManager.Instance.localPlayer; } } private static bool PlayerIsInFactory => Player?.isInsideFactory ?? false; private static bool PlayerIsInShip => Player?.isInHangarShipRoom ?? false; private static bool PlayerIsInTerminal => Player?.inTerminalMenu ?? false; private static HUDElement? Clock { get { if (!((Object)(object)HUDManager.Instance != (Object)null)) { return null; } return HUDManager.Instance.Clock; } } private static bool CurrentClockVisibility { get { HUDElement clock = Clock; if (clock != null) { return clock.targetAlpha > 0f; } return false; } } private static Environment CurrentPlayerLocationEnvironment { get { if (PlayerIsInShip) { return Environment.Ship; } if (PlayerIsInFactory) { return Environment.Facility; } return Environment.Outside; } } private static Environment CurrentPlayerEnvironment { get { Environment environment = CurrentPlayerLocationEnvironment; if (PlayerIsInTerminal) { environment |= Environment.Terminal; } return environment; } } private static Environment ClockVisibleEnvironments { get { Environment environment = Environment.None; if (!Plugin.BoundConfig.HideClockOutside.Value) { environment |= Environment.Outside; } if (!Plugin.BoundConfig.HideClockOnShip.Value) { environment |= Environment.Ship; } if (!Plugin.BoundConfig.HideClockInFacility.Value) { environment |= Environment.Facility; } return environment; } } private static Environment ClockInvisibleEnvironments => Environment.Terminal; private static bool DesiredClockVisibility { get { if (Convert.ToBoolean(CurrentPlayerEnvironment & ClockInvisibleEnvironments)) { return false; } return Convert.ToBoolean(CurrentPlayerEnvironment & ClockVisibleEnvironments); } } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } public static void SetDesiredClockVisibility() { if (HUDManager.Instance != null) { bool desiredClockVisibility = DesiredClockVisibility; if (CurrentClockVisibility != desiredClockVisibility) { Logger.LogDebug((object)((desiredClockVisibility ? "Showing" : "Hiding") + " clock")); HUDManager.Instance.SetClockVisible(desiredClockVisibility); } } } [HarmonyPatch(typeof(TimeOfDay), "SetInsideLightingDimness")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> RedirectSetClockVisible(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(HUDManager), "Instance"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "insideLighting"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ceq, (object)null, (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Callvirt), (string)null) }).SetAndAdvance(OpCodes.Nop, (object)null) .RemoveInstructions(5) .Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HideClock), "SetDesiredClockVisibility", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } } public interface IFeature { void SetLogger(ManualLogSource logger) { } void SetHarmony(Harmony harmony) { } void OnEnable() { } void OnDisable() { } void OnConfigChange() { } } [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] public class ItemProtection : IFeature { private static readonly FieldInfo ItemIsScrapField = AccessTools.Field(typeof(Item), "isScrap"); private static readonly MethodInfo ItemIsUnprotectedScrapMethod = AccessTools.Method(typeof(ItemProtection), "IsUnprotectedScrap", (Type[])null, (Type[])null); protected static ManualLogSource Logger { get; set; } = null; private static Random? RandomGenerator { get; set; } private static float? ThisPassProtectionProbability { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } public static bool IsUnprotectedScrap(Item item) { Logger.LogDebug((object)$"Considering item {item} for destruction..."); if (item.isScrap) { return !ShouldSaveScrap(); } return false; } [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return Transpilers.Manipulator(instructions, (Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldfld && CodeInstructionExtensions.OperandIs(instruction, (MemberInfo)ItemIsScrapField)), (Action<CodeInstruction>)delegate(CodeInstruction instruction) { instruction.opcode = OpCodes.Call; instruction.operand = ItemIsUnprotectedScrapMethod; }); } [HarmonyPrefix] private static void Prefix(RoundManager __instance, bool despawnAllItems) { Logger.LogInfo((object)"Getting ready to consider items for destruction"); if (despawnAllItems || !StartOfRound.Instance.allPlayersDead) { return; } ThisPassProtectionProbability = Plugin.BoundConfig.ScrapProtection.Value; if (!(Plugin.BoundConfig.ScrapProtectionRandomness.Value <= 0f) || (!(Plugin.BoundConfig.ScrapProtection.Value <= 0f) && !(Plugin.BoundConfig.ScrapProtection.Value >= 1f))) { RandomGenerator = new Random(StartOfRound.Instance.randomMapSeed + 83); if (!(Plugin.BoundConfig.ScrapProtectionRandomness.Value <= 0f)) { ThisPassProtectionProbability += Plugin.BoundConfig.ScrapProtectionRandomness.Value * 2f * TimeOfDay.Instance.quotaVariables.randomizerCurve.Evaluate((float)RandomGenerator.NextDouble()); ThisPassProtectionProbability = Mathf.Clamp(ThisPassProtectionProbability.Value, 0f, 1f); } } } [HarmonyPostfix] private static void Postfix() { Logger.LogInfo((object)"Finished considering items for destruction"); RandomGenerator = null; ThisPassProtectionProbability = null; } public static bool ShouldSaveScrap() { float value = Plugin.BoundConfig.ScrapProtection.Value; if (value != 0f) { if (value == 1f) { return true; } return (double?)ThisPassProtectionProbability > RandomGenerator?.NextDouble(); } return false; } } public class LeaderboardUsesBestAttempt : IFeature { protected static ManualLogSource Logger { get; set; } protected static Harmony Harmony { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } public void SetHarmony(Harmony harmony) { Logger.LogDebug((object)"Harmony assigned."); Harmony = harmony; } public void OnEnable() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown MethodInfo method = AccessTools.Method(typeof(MenuManager), "GetLeaderboardForChallenge", (Type[])null, (Type[])null).GetCustomAttribute<AsyncStateMachineAttribute>().StateMachineType.GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(LeaderboardUsesBestAttempt), "DoNotOverwriteBetterChallengeAttempts", (Type[])null, (Type[])null)); Harmony.Patch((MethodBase)method, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } public static IEnumerable<CodeInstruction> DoNotOverwriteBetterChallengeAttempts(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Leaderboard), "ReplaceScore", (Type[])null, (Type[])null), (string)null) }).SetAndAdvance(OpCodes.Call, (object)AccessTools.Method(typeof(Leaderboard), "SubmitScoreAsync", (Type[])null, (Type[])null)); return val.InstructionEnumeration(); } } public class LightswitchCommand : IFeature { private bool _initialized; private TerminalKeyword? _lightsVerbKeyword; private TerminalKeyword? _helpNounKeyword; private TerminalKeyword? _onNounKeyword; private TerminalKeyword? _offNounKeyword; private TerminalKeyword? _toggleNounKeyword; private CommandInfo? _onCommandInfo; private CommandInfo? _offCommandInfo; private CommandInfo? _toggleCommandInfo; private static ShipLights? _shipLightsInstance = null; private static readonly string LightsHelpText = new StringBuilder().AppendLine(">LIGHTS HELP").AppendLine("Display this information.").AppendLine() .AppendLine(">LIGHTS ON") .AppendLine("Turns the ship interior lights on.") .AppendLine() .AppendLine(">LIGHTS OFF") .AppendLine("Turns the ship interior lights off.") .AppendLine() .AppendLine(">LIGHTS TOGGLE") .AppendLine("Toggles the ship interior lights on/off.") .AppendLine() .ToString(); protected static ManualLogSource Logger { get; set; } = null; protected static LightswitchCommand? Instance { get; set; } = null; private static ShipLights? ShipLightsInstance { get { if (_shipLightsInstance != null) { return _shipLightsInstance; } if (_shipLightsInstance == null) { _shipLightsInstance = Object.FindObjectOfType<ShipLights>(); } return _shipLightsInstance; } } private static bool ShipLightsAreOn { get { if (ShipLightsInstance != null) { return ShipLightsInstance.areLightsOn; } return false; } } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } private static void SetShipLights(bool lightsOn) { if (_shipLightsInstance != null) { _shipLightsInstance.SetShipLightsBoolean(lightsOn); } } public static string ToggleLightsTextSupplier() { return SetLightsTextSupplier(!ShipLightsAreOn); } public static string SetLightsTextSupplier(bool lightsOn) { SetShipLights(lightsOn); return "Lights " + (lightsOn ? "on" : "out") + "!\n\n"; } public void Initialize() { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown if (!_initialized) { _initialized = true; TerminalNode val = TerminalApi.CreateTerminalNode(LightsHelpText, true, ""); TerminalNode val2 = TerminalApi.CreateTerminalNode("Lights on\n", true, ""); TerminalNode val3 = TerminalApi.CreateTerminalNode("Lights out\n", true, ""); TerminalNode val4 = TerminalApi.CreateTerminalNode("Lights toggle\n", true, ""); _lightsVerbKeyword = TerminalApi.CreateTerminalKeyword("lights", true, val4); _helpNounKeyword = TerminalApi.GetKeyword("help"); _onNounKeyword = TerminalApi.CreateTerminalKeyword("on", false, (TerminalNode)null); _offNounKeyword = TerminalApi.CreateTerminalKeyword("off", false, (TerminalNode)null); _toggleNounKeyword = TerminalApi.CreateTerminalKeyword("toggle", false, (TerminalNode)null); TerminalExtenstionMethods.AddCompatibleNoun(_lightsVerbKeyword, _helpNounKeyword, val); TerminalExtenstionMethods.AddCompatibleNoun(_lightsVerbKeyword, _onNounKeyword, val2); TerminalExtenstionMethods.AddCompatibleNoun(_lightsVerbKeyword, _offNounKeyword, val3); TerminalExtenstionMethods.AddCompatibleNoun(_lightsVerbKeyword, _toggleNounKeyword, val4); TerminalApi.AddTerminalKeyword(_lightsVerbKeyword, new CommandInfo { Title = "Lights", Category = "Other", Description = "Lightswitch-related commands. Run 'lights help' for info." }); TerminalApi.AddTerminalKeyword(_helpNounKeyword, (CommandInfo)null); _onCommandInfo = new CommandInfo { TriggerNode = val2, DisplayTextSupplier = () => SetLightsTextSupplier(lightsOn: true) }; TerminalApi.AddTerminalKeyword(_onNounKeyword, (CommandInfo)null); TerminalApi.CommandInfos.Add(_onCommandInfo); _offCommandInfo = new CommandInfo { TriggerNode = val3, DisplayTextSupplier = () => SetLightsTextSupplier(lightsOn: false) }; TerminalApi.AddTerminalKeyword(_offNounKeyword, (CommandInfo)null); TerminalApi.CommandInfos.Add(_offCommandInfo); CommandInfo val5 = new CommandInfo(); val5.TriggerNode = val4; val5.DisplayTextSupplier = ToggleLightsTextSupplier; _toggleCommandInfo = val5; TerminalApi.AddTerminalKeyword(_toggleNounKeyword, (CommandInfo)null); TerminalApi.CommandInfos.Add(_toggleCommandInfo); } } public void OnEnable() { Instance = this; if (NetworkManager.Singleton != null && NetworkManager.Singleton.IsConnectedClient && Object.FindObjectOfType<Terminal>() != null) { Initialize(); } } public void OnDisable() { if (Instance == this) { Instance = null; } if (_initialized) { if (_lightsVerbKeyword != null) { TerminalApi.DeleteKeyword(_lightsVerbKeyword.word); } if (_onNounKeyword != null) { TerminalApi.DeleteKeyword(_onNounKeyword.word); } if (_offNounKeyword != null) { TerminalApi.DeleteKeyword(_offNounKeyword.word); } if (_toggleNounKeyword != null) { TerminalApi.DeleteKeyword(_toggleNounKeyword.word); } TerminalApi.CommandInfos.Remove(_onCommandInfo); TerminalApi.CommandInfos.Remove(_offCommandInfo); TerminalApi.CommandInfos.Remove(_toggleCommandInfo); } } [HarmonyPatch(typeof(Terminal), "Awake")] [HarmonyPostfix] public static void OnTerminalAwake() { Instance?.Initialize(); } } public class MilitaryTime : IFeature { protected static ManualLogSource Logger { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } [HarmonyPatch(typeof(HUDManager), "SetClock")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpile24HourClock(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null) }); int pos = val.Pos; val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(instr, (object)12)), (string)null), new CodeMatch((OpCode?)OpCodes.Rem, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).RemoveInstructionsInRange(pos, val.Pos); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(instr, (object)48)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Callvirt), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(HUDManager), "amPM"), (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(string), "Concat", new Type[2] { typeof(string), typeof(string) }, (Type[])null), (string)null) }).RemoveInstructions(5); return val.InstructionEnumeration(); } } public class PassiveIncome : IFeature { protected static ManualLogSource Logger { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } [HarmonyPatch(typeof(TimeOfDay), "OnDayChanged")] [HarmonyPostfix] public static void AddPassiveIncome(TimeOfDay __instance) { if (((NetworkBehaviour)__instance).IsServer) { Logger.LogInfo((object)$"Adding {Plugin.BoundConfig.PassiveIncomeQuantity.Value} passive income credits..."); Terminal val = Object.FindObjectOfType<Terminal>(); val.groupCredits += Plugin.BoundConfig.PassiveIncomeQuantity.Value; val.SyncGroupCreditsServerRpc(val.groupCredits, val.numberOfItemsInDropship); } } } public class QuotaFormula : IFeature { [HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")] private class SetNewProfitQuotaPatches { [HarmonyPrefix] public static void Prefix(TimeOfDay __instance) { if (Instance != null) { Instance._currentAssignmentInfo = new QuotaAssignmentInfo { Quota = __instance.profitQuota, Income = __instance.quotaFulfilled, Duration = __instance.quotaVariables.deadlineDaysAmount, BaseIncreaseCoefficient = Instance.RunQuotaVariables.BaseIncrease }; } } [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Expected O, but got Unknown //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Expected O, but got Unknown //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Expected O, but got Unknown //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Expected O, but got Unknown //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Expected O, but got Unknown //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Expected O, but got Unknown //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Expected O, but got Unknown //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Expected O, but got Unknown //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Expected O, but got Unknown //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Expected O, but got Unknown //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Expected O, but got Unknown //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Expected O, but got Unknown //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Expected O, but got Unknown //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[13] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)1f, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "timesFulfilledQuota"), (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "timesFulfilledQuota"), (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "quotaVariables"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(QuotaSettings), "increaseSteepness"), (string)null), new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null) }).RemoveInstructions(13) .Insert((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "timesFulfilledQuota")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(QuotaFormula), "ComputePolynomialCoefficient", (Type[])null, (Type[])null)) }) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "quotaVariables"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(QuotaSettings), "baseIncrease"), (string)null) }) .RemoveInstructions(3) .Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "RunQuotaVariables")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(AugmentedQuotaVariables), "BaseIncrease")) }) .MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null) }) .Advance(1) .Insert((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "CurrentAssignmentInfo")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "CurrentAssignmentInfo")) }) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "quotaVariables"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(QuotaSettings), "randomizerMultiplier"), (string)null) }) .RemoveInstructions(3) .Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "RunQuotaVariables")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(AugmentedQuotaVariables), "RandomizerMultiplier")) }) .MatchForward(true, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)1f, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null) }) .Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(QuotaAssignmentInfo), "RandomizedIncreaseCoefficient")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(QuotaAssignmentInfo), "RandomizedIncreaseCoefficient")) }); return val.InstructionEnumeration(); } [HarmonyPostfix] public static void Postfix(TimeOfDay __instance) { if (Instance?.CurrentAssignmentInfo != null) { Instance.CurrentAssignmentInfo.NextQuota = __instance.profitQuota; Instance.CurrentAssignmentInfo.CombinedIncrease = __instance.profitQuota - Instance.CurrentAssignmentInfo.Quota; Logger.LogDebug((object)Instance.CurrentAssignmentInfo); Instance.PastAssignments.Add(Instance.CurrentAssignmentInfo); Instance._currentAssignmentInfo = null; } } } protected static readonly string QuotaVariablesKey = "com.github.lordfirespeed.augmented_enhancer-QuotaVariables"; protected static readonly string PastAssignmentsKey = "com.github.lordfirespeed.augmented_enhancer-PastAssignments"; private static readonly MethodInfo FindObjectOfTypeTimeOfDayMethodInfo = AccessTools.Method(typeof(Object), "FindObjectOfType", (Type[])null, new Type[1] { typeof(TimeOfDay) }); private AugmentedQuotaVariables? _runQuotaVariables; private QuotaAssignmentInfo? _currentAssignmentInfo; private List<QuotaAssignmentInfo>? _pastAssignments; protected static ManualLogSource Logger { get; set; } = null; public static QuotaFormula? Instance { get; private set; } public AugmentedQuotaVariables RunQuotaVariables { get { if (!NetworkManager.Singleton.IsConnectedClient) { throw new InvalidOperationException("Not currently in-game!"); } if (_runQuotaVariables == null) { _runQuotaVariables = ES3.Load<AugmentedQuotaVariables>(QuotaVariablesKey, GameNetworkManager.Instance.currentSaveFileName, (AugmentedQuotaVariables)null); } if (_runQuotaVariables == null) { _runQuotaVariables = ConfiguredQuotaVariables; } return _runQuotaVariables; } } private QuotaAssignmentInfo? CurrentAssignmentInfo { get { if (!NetworkManager.Singleton.IsConnectedClient) { throw new InvalidOperationException("Not currently in-game!"); } return _currentAssignmentInfo; } } public List<QuotaAssignmentInfo> PastAssignments { get { if (!NetworkManager.Singleton.IsConnectedClient) { throw new InvalidOperationException("Not currently in-game!"); } if (_pastAssignments == null) { _pastAssignments = ES3.Load<List<QuotaAssignmentInfo>>(PastAssignmentsKey, GameNetworkManager.Instance.currentSaveFileName, (List<QuotaAssignmentInfo>)null); } if (_pastAssignments == null) { _pastAssignments = new List<QuotaAssignmentInfo>(); } return _pastAssignments; } } public static AugmentedQuotaVariables ConfiguredQuotaVariables => new AugmentedQuotaVariables { StartingQuota = Plugin.BoundConfig.StartingQuota.Value, IncreaseSteepness = Plugin.BoundConfig.QuotaIncreaseSteepnessCoefficient.Value, IncreaseExponent = Plugin.BoundConfig.QuotaIncreaseSteepnessExponent.Value, BaseIncrease = Plugin.BoundConfig.QuotaBaseIncrease.Value, RandomizerMultiplier = Plugin.BoundConfig.QuotaIncreaseRandomFactor.Value * 2f }; public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } public void OnEnable() { Instance = this; } public void OnDisable() { if (Instance == this) { Instance = null; } } public static void ResetQuotaVariables() { AugmentedQuotaVariables configuredQuotaVariables = ConfiguredQuotaVariables; Instance._runQuotaVariables = configuredQuotaVariables; ES3.Save<AugmentedQuotaVariables>(QuotaVariablesKey, configuredQuotaVariables, GameNetworkManager.Instance.currentSaveFileName); Logger.LogDebug((object)"Saved quota variables to current save file."); } public static void ResetPastAssignments() { List<QuotaAssignmentInfo> list = new List<QuotaAssignmentInfo>(); Instance._pastAssignments = list; ES3.Save<List<QuotaAssignmentInfo>>(PastAssignmentsKey, list, GameNetworkManager.Instance.currentSaveFileName); Logger.LogDebug((object)"Saved past assignments to current save file."); } public static void ResetValues() { ResetQuotaVariables(); ResetPastAssignments(); } public static void SaveQuotaVariables() { if (!ES3.KeyExists(QuotaVariablesKey, GameNetworkManager.Instance.currentSaveFileName)) { ResetValues(); } } public static void SavePastAssignments() { ES3.Save<List<QuotaAssignmentInfo>>(PastAssignmentsKey, Instance.PastAssignments, GameNetworkManager.Instance.currentSaveFileName); } public static void SaveValues() { SaveQuotaVariables(); SavePastAssignments(); } public float ComputePolynomialCoefficient(int timesFulfilledQuota) { float num = 1f + Mathf.Pow((float)timesFulfilledQuota, RunQuotaVariables.IncreaseExponent) * RunQuotaVariables.IncreaseSteepness; Logger.LogDebug((object)$"Computed polynomial coefficient: {num}"); Instance._currentAssignmentInfo.PolynomialIncreaseCoefficient = num; return num; } [HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> TranspileResetSavedGameValues(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(true, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Call, (object)FindObjectOfTypeTimeOfDayMethodInfo, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldnull, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)null, (object)null, (string)null) { labels = new List<Label>(1) { (Label)val.Operand } } }) .MatchBack(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"ProfitQuota", (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "quotaVariables"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(QuotaSettings), "startingQuota"), (string)null) }) .Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(QuotaFormula), "ResetValues", (Type[])null, (Type[])null)) }) .Advance(2) .RemoveInstructions(3) .Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "RunQuotaVariables")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(AugmentedQuotaVariables), "StartingQuota")) }); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> TranspileSaveGameValues(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(true, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Call, (object)FindObjectOfTypeTimeOfDayMethodInfo, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldnull, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)null, (object)null, (string)null) { labels = new List<Label>(1) { (Label)val.Operand } } }) .MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null) }) .Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(QuotaFormula), "SaveValues", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(StartOfRound), "SetTimeAndPlanetToSavedSettings")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> TranspileSetTimeAndPlanetToSavedSettings(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(TimeOfDay), "Instance"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "quotaVariables"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(QuotaSettings), "startingQuota"), (string)null) }).RemoveInstructions(3) .Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "RunQuotaVariables")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(AugmentedQuotaVariables), "StartingQuota")) }); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(StartOfRound), "ResetShip")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> TranspileResetShip(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(TimeOfDay), "Instance"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "quotaVariables"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(QuotaSettings), "startingQuota"), (string)null) }).RemoveInstructions(3) .Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "Instance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(QuotaFormula), "RunQuotaVariables")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(AugmentedQuotaVariables), "StartingQuota")) }); return val.InstructionEnumeration(); } } public class QuotaAssignmentInfo { public int Quota; public int Income; public int Duration; public float BaseIncreaseCoefficient; public float PolynomialIncreaseCoefficient; public float RandomizedIncreaseCoefficient; public int CombinedIncrease; public int NextQuota; public override string ToString() { return new StringBuilder("\n").AppendLine("QuotaAssignmentInfo {").AppendLine($" Quota: {Quota}").AppendLine($" Income: {Income}") .AppendLine($" Duration: {Duration}") .AppendLine($" BaseIncreaseCoefficient: {BaseIncreaseCoefficient}") .AppendLine($" PolynomialIncreaseCoefficient: {PolynomialIncreaseCoefficient}") .AppendLine($" RandomizedIncreaseCoefficient: {RandomizedIncreaseCoefficient}") .AppendLine($" CombinedIncrease: {CombinedIncrease}") .AppendLine($" NextQuota: {NextQuota}") .AppendLine("}") .ToString(); } } public class AugmentedQuotaVariables { public int StartingQuota; public float IncreaseSteepness; public float IncreaseExponent; public float BaseIncrease; public float RandomizerMultiplier; } public class RemoveSavedItemCap : IFeature { protected static ManualLogSource Logger { get; set; } public void SetLogger(ManualLogSource logger) { logger.LogDebug((object)"Logger assigned."); Logger = logger; } [HarmonyPatch(typeof(GameNetworkManager), "SaveItemsInShip")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> RemoveSavedItemCapTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)n