using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using IL;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WeekdayBonuses")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+baaaf857c0735304674c482da63858371e1a85fb")]
[assembly: AssemblyProduct("WeekdayBonuses")]
[assembly: AssemblyTitle("WeekdayBonuses")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace WeekdayBonuses
{
public class Config : SyncedConfig2<Config>
{
public ConfigEntry<bool> AllowDayChange;
public Dictionary<DayOfWeek, ConfigEntry<EventType>> EventForDay = new Dictionary<DayOfWeek, ConfigEntry<EventType>>();
public Dictionary<DayOfWeek, ConfigEntry<string>> EventListForDay = new Dictionary<DayOfWeek, ConfigEntry<string>>();
public ConfigEntry<bool> DoubleMonsterAlwaysSpawnOldBird;
public ConfigEntry<int> DoubleMonsterOldBirdActivationTime;
public ConfigEntry<float> DoubleMonsterPerEnemyCapMultiplier;
public ConfigEntry<float> DoubleMonsterIndoorPowerMultiplier;
public ConfigEntry<float> DoubleMonsterIndoorRateMultiplier;
public ConfigEntry<float> DoubleMonsterOutdoorPowerMultiplier;
public ConfigEntry<float> DoubleMonsterOutdoorRateMultiplier;
public ConfigEntry<float> DoubleTrapMultiplier;
public ConfigEntry<float> DoubleTrapRollBaseline;
[SyncedEntryField]
public SyncedEntry<float> DoubleTrapBuffLandmineDelay;
[SyncedEntryField]
public SyncedEntry<int> DoubleTrapBuffLandmineNonLethalDamage;
public ConfigEntry<bool> DoubleTrapEnableTurrets;
public ConfigEntry<bool> DoubleTrapEnableLandmines;
public ConfigEntry<bool> DoubleTrapEnableSpikeTraps;
public ConfigEntry<bool> DoubleTrapEnableOther;
public ConfigEntry<float> DoubleLootMultiplier;
[SyncedEntryField]
public SyncedEntry<bool> SmallFacilityUseFixedSize;
[SyncedEntryField]
public SyncedEntry<float> SmallFacilityFixedMapSize;
[SyncedEntryField]
public SyncedEntry<float> SmallFacilityMapSizeMultiplier;
[SyncedEntryField]
public SyncedEntry<SaleMode> BlackFridaySaleMode;
[SyncedEntryField]
public SyncedEntry<int> BlackFridayRandomSaleMinimum;
[SyncedEntryField]
public SyncedEntry<int> BlackFridayCustomSale;
public ConfigEntry<float> EasterEggSpawnRate;
[SyncedEntryField]
public SyncedEntry<string> NightmareEventList;
public Config(ConfigFile cfg)
: base("moe.sylvi.WeekdayBonuses")
{
AllowDayChange = cfg.Bind<bool>("GeneralSettings", "AllowDayChange", true, "Whether the day of the week checked for the current bonus event changes in realtime. If disabled, the game will keep the same bonus event from when you launched the game.");
EventForDay.Clear();
BindEvent(cfg, DayOfWeek.Monday, EventType.DoubleMonster);
BindEvent(cfg, DayOfWeek.Tuesday, EventType.DoubleTrap);
BindEvent(cfg, DayOfWeek.Wednesday, EventType.DoubleLoot);
BindEvent(cfg, DayOfWeek.Thursday, EventType.SmallFacility);
BindEvent(cfg, DayOfWeek.Friday, EventType.Black);
BindEvent(cfg, DayOfWeek.Saturday, EventType.Nightmare);
BindEvent(cfg, DayOfWeek.Sunday, EventType.Easter);
EventListForDay.Clear();
BindEventList(cfg, DayOfWeek.Monday);
BindEventList(cfg, DayOfWeek.Tuesday);
BindEventList(cfg, DayOfWeek.Wednesday);
BindEventList(cfg, DayOfWeek.Thursday);
BindEventList(cfg, DayOfWeek.Friday);
BindEventList(cfg, DayOfWeek.Saturday);
BindEventList(cfg, DayOfWeek.Sunday);
DoubleMonsterAlwaysSpawnOldBird = cfg.Bind<bool>("TweakDoubleMonster", "AlwaysSpawnOldBird", true, "Ensures an Old Bird spawns outside on Double Monster days.");
DoubleMonsterOldBirdActivationTime = cfg.Bind<int>("TweakDoubleMonster", "OldBirdActivationTime", 18, "If the Old Bird spawn is enabled, this is the time the guaranteed Old Bird awakens (24 hour time). Default is ~6pm.");
DoubleMonsterPerEnemyCapMultiplier = cfg.Bind<float>("TweakDoubleMonster", "PerEnemyCapMultiplier", 2f, "Multiplies the max spawn count for each individual enemy (unless its max is 1) on Double Monster days.");
DoubleMonsterIndoorPowerMultiplier = cfg.Bind<float>("TweakDoubleMonster", "IndoorPowerMultiplier", 2f, "Multiplies the max power level indoors on Double Monster days.");
DoubleMonsterIndoorRateMultiplier = cfg.Bind<float>("TweakDoubleMonster", "IndoorRateMultiplier", 2f, "Multiplies how many indoor enemies spawn per hour on Double Monster days.");
DoubleMonsterOutdoorPowerMultiplier = cfg.Bind<float>("TweakDoubleMonster", "OutdoorPowerMultiplier", 2f, "Multiplies the max power level outdoors on Double Monster days.");
DoubleMonsterOutdoorRateMultiplier = cfg.Bind<float>("TweakDoubleMonster", "OutdoorRateMultiplier", 2f, "Multiplies how many outdoor enemies spawn per hour on Double Monster days.");
DoubleMonsterPerEnemyCapMultiplier.SettingChanged += OnDoubleMonsterVariableSettingChanged;
DoubleMonsterIndoorPowerMultiplier.SettingChanged += OnDoubleMonsterVariableSettingChanged;
DoubleMonsterOutdoorPowerMultiplier.SettingChanged += OnDoubleMonsterVariableSettingChanged;
DoubleTrapMultiplier = cfg.Bind<float>("TweakDoubleTrap", "TrapMultiplier", 2f, "Overall multiplier of the number of traps spawned on Double Trap days.");
DoubleTrapRollBaseline = cfg.Bind<float>("TweakDoubleTrap", "RollBaseline", 0.5f, "The minimum roll (between 0 and 1) for trap counts during Double Trap days.\nTrap spawn rates are on a curve, and the game rolls a point between 0 - 1 on the curve each day. If this is set to 0.5, it will be between 0.5 - 1, making every day a relatively high roll.");
DoubleTrapBuffLandmineDelay = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "TweakDoubleTrap", "BuffLandmineDelay", 0.15f, "Additional delay in seconds between stepping on a landmine and it exploding on Double Trap days.");
DoubleTrapBuffLandmineNonLethalDamage = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "TweakDoubleTrap", "BuffLandmineNonLethalDamage", 30, "Modified damage the non-lethal (outside) radius of landmine explosions deal on Double Trap days.\nVanilla value is 50 damage.");
DoubleTrapEnableTurrets = cfg.Bind<bool>("TweakDoubleTrap", "EnableTurrets", true, "Whether turret amounts will be affected on Double Trap days.");
DoubleTrapEnableLandmines = cfg.Bind<bool>("TweakDoubleTrap", "EnableLandmines", true, "Whether landmine amounts will be affected on Double Trap days.");
DoubleTrapEnableSpikeTraps = cfg.Bind<bool>("TweakDoubleTrap", "EnableSpikeTraps", true, "Whether spike trap amounts will be affected on Double Trap days.");
DoubleTrapEnableOther = cfg.Bind<bool>("TweakDoubleTrap", "EnableOther", true, "Whether the amounts of any hazards not mentioned here (likely modded ones) will be affected on Double Trap days.");
DoubleLootMultiplier = cfg.Bind<float>("TweakDoubleLoot", "ScrapMultiplier", 2f, "Multiplier for the amount of scrap to be spawned on Double Loot days.");
SmallFacilityUseFixedSize = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "TweakSmallFacility", "UseFixedSize", true, "Whether Small Facility days should set the facility size the same on every moon using the Fixed Size option, or use the Size Multiplier option.");
SmallFacilityFixedMapSize = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "TweakSmallFacility", "FixedMapSize", 0.8f, "Static map size multiplier that should be used on every moon on Small Facility days when using fixed size.");
SmallFacilityMapSizeMultiplier = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "TweakSmallFacility", "MapSizeMultiplier", 0.5f, "Map size multiplier that should be applied on Small Facility days when not using fixed size.");
BlackFridaySaleMode = SyncedBindingExtensions.BindSyncedEntry<SaleMode>(cfg, "TweakBlackFriday", "SaleMode", SaleMode.Random, "Configures how Black Friday sales should work.\n- Random: Sales are random between the specified minimum, and the maximum possible sale for each item.\n- Highest: All items are on sale for their highest possible amount.\n- Custom: All items are on sale for the specified amount.");
BlackFridayRandomSaleMinimum = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "TweakBlackFriday", "RandomSaleMinimum", 10, "The minimum sale value of each item using Random sale mode. May be overridden if the item's highest sale percentage is lower.");
BlackFridayCustomSale = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "TweakBlackFriday", "CustomSale", 50, "The sale percentage of each item using Custom sale mode. Overrides items' individual maximum sale values.");
BlackFridaySaleMode.Changed += OnBlackFridaySettingChanged<SaleMode>;
BlackFridayRandomSaleMinimum.Changed += OnBlackFridaySettingChanged<int>;
BlackFridayCustomSale.Changed += OnBlackFridaySettingChanged<int>;
EasterEggSpawnRate = cfg.Bind<float>("TweakEaster", "EggSpawnRate", 0.25f, "Easter days spawn an additional number of eggs based on this multiplier applied to the amount of scrap spawned in the facility, e.g. 0.25 means there will be 1.25x the total amount of scrap (and 1/5 will be eggs).");
NightmareEventList = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, "TweakNightmare", "EventList", "", "Comma-separated list of other event names used on Nightmare days. If empty, uses all events.\nEvent names should be formatted like they are in the multiple-choice settings (e.g. \"DoubleLoot,DoubleMonster,Easter\")");
ConfigManager.Register<Config>((SyncedConfig2<Config>)this);
}
private void BindEvent(ConfigFile cfg, DayOfWeek dayOfWeek, EventType defaultEvent)
{
ConfigEntry<EventType> val = cfg.Bind<EventType>("GeneralEvents", $"{dayOfWeek}Event", defaultEvent, $"Which bonus event should occur on {dayOfWeek}.");
val.SettingChanged += OnScheduleSettingChanged;
EventForDay.Add(dayOfWeek, val);
}
private void BindEventList(ConfigFile cfg, DayOfWeek dayOfWeek)
{
ConfigEntry<string> val = cfg.Bind<string>("GeneralEventLists", $"{dayOfWeek}EventList", "", $"Comma-separated list of names of bonus events that should occur on {dayOfWeek}. Overrides the basic settings.\nEvent names should be formatted like they are in the multiple-choice settings (e.g. \"DoubleLoot,DoubleMonster,Easter\")");
val.SettingChanged += OnScheduleSettingChanged;
EventListForDay.Add(dayOfWeek, val);
}
private void OnScheduleSettingChanged(object sender, EventArgs e)
{
DayOfWeek value = Plugin.CurrentDay.Value;
Plugin.CurrentEvents.Value = WeekdayUtils.GetEventsForDay(value);
}
private void OnDoubleMonsterVariableSettingChanged(object sender, EventArgs e)
{
if ((Object)(object)StartOfRound.Instance != (Object)null && ((Behaviour)StartOfRound.Instance).enabled && WeekdayUtils.HasEvent(EventType.DoubleMonster))
{
EventCallbacks.DoubleMonsterDisabled();
EventCallbacks.DoubleMonsterEnabled();
}
}
private void OnBlackFridaySettingChanged<T>(object sender, SyncedSettingChangedEventArgs<T> e)
{
EventCallbacks.BlackFridaySettingChanged();
}
}
public static class EventCallbacks
{
private static Dictionary<SelectableLevel, int> OriginalLevelEnemyPower = new Dictionary<SelectableLevel, int>();
private static Dictionary<SelectableLevel, int> OriginalLevelOutsideEnemyPower = new Dictionary<SelectableLevel, int>();
private static Dictionary<EnemyType, int> OriginalEnemyMaxCounts = new Dictionary<EnemyType, int>();
public static void DoubleMonsterEnabled()
{
OriginalEnemyMaxCounts.Clear();
OriginalLevelEnemyPower.Clear();
OriginalLevelOutsideEnemyPower.Clear();
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val in levels)
{
if (OriginalLevelEnemyPower.ContainsKey(val))
{
continue;
}
OriginalLevelEnemyPower.Add(val, val.maxEnemyPowerCount);
OriginalLevelOutsideEnemyPower.Add(val, val.maxOutsideEnemyPowerCount);
Plugin.Logger.LogInfo((object)$"Max power for {val.PlanetName}: {val.maxEnemyPowerCount}");
val.maxEnemyPowerCount = (int)((float)val.maxEnemyPowerCount * Plugin.Config.DoubleMonsterIndoorPowerMultiplier.Value);
val.maxOutsideEnemyPowerCount = (int)((float)val.maxOutsideEnemyPowerCount * Plugin.Config.DoubleMonsterOutdoorPowerMultiplier.Value);
foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
{
DoubleMonsterApplyEnabledToEnemy(enemy.enemyType);
}
foreach (SpawnableEnemyWithRarity outsideEnemy in val.OutsideEnemies)
{
DoubleMonsterApplyEnabledToEnemy(outsideEnemy.enemyType);
}
}
}
public static void DoubleMonsterDisabled()
{
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val in levels)
{
val.maxEnemyPowerCount = OriginalLevelEnemyPower[val];
val.maxOutsideEnemyPowerCount = OriginalLevelOutsideEnemyPower[val];
Plugin.Logger.LogInfo((object)$"Max power for {val.PlanetName}: {val.maxEnemyPowerCount}");
OriginalLevelEnemyPower.Remove(val);
OriginalLevelOutsideEnemyPower.Remove(val);
foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
{
DoubleMonsterApplyDisabledToEnemy(enemy.enemyType);
}
foreach (SpawnableEnemyWithRarity outsideEnemy in val.OutsideEnemies)
{
DoubleMonsterApplyDisabledToEnemy(outsideEnemy.enemyType);
}
}
OriginalEnemyMaxCounts.Clear();
OriginalLevelEnemyPower.Clear();
OriginalLevelOutsideEnemyPower.Clear();
}
private static void DoubleMonsterApplyEnabledToEnemy(EnemyType enemyType)
{
if (enemyType.MaxCount > 1 && !OriginalEnemyMaxCounts.ContainsKey(enemyType))
{
Plugin.Logger.LogInfo((object)$"Max count for {enemyType.enemyName}: {enemyType.MaxCount}");
OriginalEnemyMaxCounts.Add(enemyType, enemyType.MaxCount);
enemyType.MaxCount = (int)((float)enemyType.MaxCount * Plugin.Config.DoubleMonsterPerEnemyCapMultiplier.Value);
}
}
private static void DoubleMonsterApplyDisabledToEnemy(EnemyType enemyType)
{
if (enemyType.MaxCount > 1 && OriginalEnemyMaxCounts.ContainsKey(enemyType))
{
enemyType.MaxCount = OriginalEnemyMaxCounts[enemyType];
OriginalEnemyMaxCounts.Remove(enemyType);
Plugin.Logger.LogInfo((object)$"Max count for {enemyType.enemyName}: {enemyType.MaxCount}");
}
}
public static void BlackFridaySettingChanged()
{
if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
{
return;
}
Terminal val = Object.FindObjectOfType<Terminal>();
if ((Object)(object)val != (Object)null)
{
Patches.ForceTerminalSalesChange = true;
if (val != null)
{
val.SetItemSales();
}
Patches.ForceTerminalSalesChange = false;
}
}
}
public enum EventType
{
None,
DoubleMonster,
DoubleTrap,
DoubleLoot,
SmallFacility,
Black,
Easter,
Nightmare
}
public class ModLandmine : MonoBehaviour
{
private Landmine landmine;
public bool DelayExplosion;
private void Awake()
{
landmine = ((Component)this).gameObject.GetComponent<Landmine>();
}
public void TryDetonate()
{
if (DelayExplosion && Plugin.Config.DoubleTrapBuffLandmineDelay.Value > 0f)
{
((MonoBehaviour)this).StartCoroutine(ExplodeWithDelay());
return;
}
DelayExplosion = false;
landmine.Detonate();
}
public IEnumerator ExplodeWithDelay()
{
yield return (object)new WaitForSeconds(Plugin.Config.DoubleTrapBuffLandmineDelay.Value);
DelayExplosion = false;
landmine.Detonate();
}
}
public static class Patches
{
[CompilerGenerated]
private static class <>O
{
public static hook_OnEnable <0>__StartOfRound_OnEnable;
public static hook_OnDisable <1>__StartOfRound_OnDisable;
public static hook_Start <2>__StartOfRound_Start;
public static hook_Update <3>__StartOfRound_Update;
public static Manipulator <4>__Terminal_TextPostProcess_IL;
public static Manipulator <5>__Terminal_SetItemSales_IL;
public static hook_SetItemSales <6>__Terminal_SetItemSales;
public static hook_TriggerMineOnLocalClientByExiting <7>__Landmine_TriggerMineOnLocalClientByExiting;
public static Manipulator <8>__Landmine_ExplodeMineClientRpc_IL;
public static hook_Detonate <9>__Landmine_Detonate;
public static Manipulator <10>__Landmine_Detonate_IL;
public static hook_SpawnScrapInLevel <11>__RoundManager_SpawnScrapInLevel;
public static hook_GenerateNewFloor <12>__RoundManager_GenerateNewFloor;
public static Manipulator <13>__RoundManager_SpawnScrapInLevel_IL;
public static Manipulator <14>__RoundManager_SpawnMapObjects_IL;
public static Manipulator <15>__RoundManager_SpawnEnemiesOutside_IL;
public static Manipulator <16>__RoundManager_PredictAllOutsideEnemies_IL;
public static Manipulator <17>__RoundManager_PlotOutEnemiesForNextHour_IL;
}
public static bool ForceTerminalSalesChange;
private static bool DoubleMonsterSpawnRobot;
private static float DoubleMonsterRobotSpawnTime;
public static void Initialize()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Expected O, but got Unknown
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Expected O, but got Unknown
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Expected O, but got Unknown
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Expected O, but got Unknown
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Expected O, but got Unknown
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Expected O, but got Unknown
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Expected O, but got Unknown
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Expected O, but got Unknown
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Expected O, but got Unknown
object obj = <>O.<0>__StartOfRound_OnEnable;
if (obj == null)
{
hook_OnEnable val = StartOfRound_OnEnable;
<>O.<0>__StartOfRound_OnEnable = val;
obj = (object)val;
}
StartOfRound.OnEnable += (hook_OnEnable)obj;
object obj2 = <>O.<1>__StartOfRound_OnDisable;
if (obj2 == null)
{
hook_OnDisable val2 = StartOfRound_OnDisable;
<>O.<1>__StartOfRound_OnDisable = val2;
obj2 = (object)val2;
}
StartOfRound.OnDisable += (hook_OnDisable)obj2;
object obj3 = <>O.<2>__StartOfRound_Start;
if (obj3 == null)
{
hook_Start val3 = StartOfRound_Start;
<>O.<2>__StartOfRound_Start = val3;
obj3 = (object)val3;
}
StartOfRound.Start += (hook_Start)obj3;
object obj4 = <>O.<3>__StartOfRound_Update;
if (obj4 == null)
{
hook_Update val4 = StartOfRound_Update;
<>O.<3>__StartOfRound_Update = val4;
obj4 = (object)val4;
}
StartOfRound.Update += (hook_Update)obj4;
object obj5 = <>O.<4>__Terminal_TextPostProcess_IL;
if (obj5 == null)
{
Manipulator val5 = Terminal_TextPostProcess_IL;
<>O.<4>__Terminal_TextPostProcess_IL = val5;
obj5 = (object)val5;
}
Terminal.TextPostProcess += (Manipulator)obj5;
object obj6 = <>O.<5>__Terminal_SetItemSales_IL;
if (obj6 == null)
{
Manipulator val6 = Terminal_SetItemSales_IL;
<>O.<5>__Terminal_SetItemSales_IL = val6;
obj6 = (object)val6;
}
Terminal.SetItemSales += (Manipulator)obj6;
object obj7 = <>O.<6>__Terminal_SetItemSales;
if (obj7 == null)
{
hook_SetItemSales val7 = Terminal_SetItemSales;
<>O.<6>__Terminal_SetItemSales = val7;
obj7 = (object)val7;
}
Terminal.SetItemSales += (hook_SetItemSales)obj7;
object obj8 = <>O.<7>__Landmine_TriggerMineOnLocalClientByExiting;
if (obj8 == null)
{
hook_TriggerMineOnLocalClientByExiting val8 = Landmine_TriggerMineOnLocalClientByExiting;
<>O.<7>__Landmine_TriggerMineOnLocalClientByExiting = val8;
obj8 = (object)val8;
}
Landmine.TriggerMineOnLocalClientByExiting += (hook_TriggerMineOnLocalClientByExiting)obj8;
object obj9 = <>O.<8>__Landmine_ExplodeMineClientRpc_IL;
if (obj9 == null)
{
Manipulator val9 = Landmine_ExplodeMineClientRpc_IL;
<>O.<8>__Landmine_ExplodeMineClientRpc_IL = val9;
obj9 = (object)val9;
}
Landmine.ExplodeMineClientRpc += (Manipulator)obj9;
object obj10 = <>O.<9>__Landmine_Detonate;
if (obj10 == null)
{
hook_Detonate val10 = Landmine_Detonate;
<>O.<9>__Landmine_Detonate = val10;
obj10 = (object)val10;
}
Landmine.Detonate += (hook_Detonate)obj10;
object obj11 = <>O.<10>__Landmine_Detonate_IL;
if (obj11 == null)
{
Manipulator val11 = Landmine_Detonate_IL;
<>O.<10>__Landmine_Detonate_IL = val11;
obj11 = (object)val11;
}
Landmine.Detonate += (Manipulator)obj11;
object obj12 = <>O.<11>__RoundManager_SpawnScrapInLevel;
if (obj12 == null)
{
hook_SpawnScrapInLevel val12 = RoundManager_SpawnScrapInLevel;
<>O.<11>__RoundManager_SpawnScrapInLevel = val12;
obj12 = (object)val12;
}
RoundManager.SpawnScrapInLevel += (hook_SpawnScrapInLevel)obj12;
object obj13 = <>O.<12>__RoundManager_GenerateNewFloor;
if (obj13 == null)
{
hook_GenerateNewFloor val13 = RoundManager_GenerateNewFloor;
<>O.<12>__RoundManager_GenerateNewFloor = val13;
obj13 = (object)val13;
}
RoundManager.GenerateNewFloor += (hook_GenerateNewFloor)obj13;
object obj14 = <>O.<13>__RoundManager_SpawnScrapInLevel_IL;
if (obj14 == null)
{
Manipulator val14 = RoundManager_SpawnScrapInLevel_IL;
<>O.<13>__RoundManager_SpawnScrapInLevel_IL = val14;
obj14 = (object)val14;
}
RoundManager.SpawnScrapInLevel += (Manipulator)obj14;
object obj15 = <>O.<14>__RoundManager_SpawnMapObjects_IL;
if (obj15 == null)
{
Manipulator val15 = RoundManager_SpawnMapObjects_IL;
<>O.<14>__RoundManager_SpawnMapObjects_IL = val15;
obj15 = (object)val15;
}
RoundManager.SpawnMapObjects += (Manipulator)obj15;
object obj16 = <>O.<15>__RoundManager_SpawnEnemiesOutside_IL;
if (obj16 == null)
{
Manipulator val16 = RoundManager_SpawnEnemiesOutside_IL;
<>O.<15>__RoundManager_SpawnEnemiesOutside_IL = val16;
obj16 = (object)val16;
}
RoundManager.SpawnEnemiesOutside += (Manipulator)obj16;
object obj17 = <>O.<16>__RoundManager_PredictAllOutsideEnemies_IL;
if (obj17 == null)
{
Manipulator val17 = RoundManager_PredictAllOutsideEnemies_IL;
<>O.<16>__RoundManager_PredictAllOutsideEnemies_IL = val17;
obj17 = (object)val17;
}
RoundManager.PredictAllOutsideEnemies += (Manipulator)obj17;
object obj18 = <>O.<17>__RoundManager_PlotOutEnemiesForNextHour_IL;
if (obj18 == null)
{
Manipulator val18 = RoundManager_PlotOutEnemiesForNextHour_IL;
<>O.<17>__RoundManager_PlotOutEnemiesForNextHour_IL = val18;
obj18 = (object)val18;
}
RoundManager.PlotOutEnemiesForNextHour += (Manipulator)obj18;
}
private static void Terminal_SetItemSales_IL(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
ILLabel gotoLabel = null;
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchBgt(instr, ref gotoLabel)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for Terminal.SetItemSales @ Randomly don't change sales");
return;
}
val.EmitDelegate<Func<bool>>((Func<bool>)(() => ForceTerminalSalesChange));
val.Emit(OpCodes.Brtrue, (object)gotoLabel);
}
private static void Landmine_Detonate_IL(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 50)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for Landmine.Detonate @ Set non-lethal damage to 50");
return;
}
val.EmitDelegate<Func<int, int>>((Func<int, int>)delegate(int damage)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleTrap))
{
return damage;
}
int value = Plugin.Config.DoubleTrapBuffLandmineNonLethalDamage.Value;
return (value >= 0) ? value : damage;
});
}
private static void Landmine_Detonate(orig_Detonate orig, Landmine self)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleTrap))
{
orig.Invoke(self);
return;
}
ModLandmine component = ((Component)self).GetComponent<ModLandmine>();
if ((Object)(object)component == (Object)null || !component.DelayExplosion)
{
orig.Invoke(self);
}
else
{
component.TryDetonate();
}
}
private static void Landmine_TriggerMineOnLocalClientByExiting(orig_TriggerMineOnLocalClientByExiting orig, Landmine self)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleTrap))
{
orig.Invoke(self);
return;
}
DelayLandmineDetonation(self);
orig.Invoke(self);
}
private static void Landmine_ExplodeMineClientRpc_IL(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[2]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0),
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt<Landmine>(instr, "SetOffMineAnimation")
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for Landmine.ExplodeMineClientRpc @ SetOffMineAnimation");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<Landmine>>((Action<Landmine>)delegate(Landmine self)
{
if (!StartOfRound.Instance.isChallengeFile && WeekdayUtils.HasEvent(EventType.DoubleTrap))
{
DelayLandmineDetonation(self);
}
});
}
private static void DelayLandmineDetonation(Landmine landmine)
{
ModLandmine modLandmine = ((Component)landmine).GetComponent<ModLandmine>() ?? ((Component)landmine).gameObject.AddComponent<ModLandmine>();
modLandmine.DelayExplosion = true;
}
private static void Terminal_SetItemSales(orig_SetItemSales orig, Terminal self)
{
orig.Invoke(self);
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.Black))
{
return;
}
Random random = new Random(StartOfRound.Instance.randomMapSeed + 90);
for (int i = 0; i < self.itemSalesPercentages.Length; i++)
{
int num = 80;
if (i < self.buyableItemsList.Length)
{
num = self.buyableItemsList[i].highestSalePercentage;
}
switch (Plugin.Config.BlackFridaySaleMode.Value)
{
case SaleMode.Random:
{
int minValue = Mathf.Clamp(Plugin.Config.BlackFridayRandomSaleMinimum.Value, 0, num);
int num6 = Mathf.Clamp(num, 0, 90);
int num7 = self.RoundToNearestTen(100 - random.Next(minValue, num6 + 1));
self.itemSalesPercentages[i] = num7;
break;
}
case SaleMode.Highest:
{
int num4 = Mathf.Clamp(num, 0, 90);
int num5 = self.RoundToNearestTen(100 - num4);
self.itemSalesPercentages[i] = num5;
break;
}
case SaleMode.Custom:
{
int num2 = Mathf.Clamp(Plugin.Config.BlackFridayCustomSale.Value, 0, 100);
int num3 = 100 - num2;
self.itemSalesPercentages[i] = num3;
break;
}
}
}
}
private static void RoundManager_SpawnMapObjects_IL(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int num = 0;
int num2 = 6;
int spawnedObjectCountLoc = 4;
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchStloc(instr, spawnedObjectCountLoc)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for RoundManager.SpawnMapObjects @ Calculate number of hazards");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc, num2);
val.Emit(OpCodes.Ldloc, num);
val.EmitDelegate<Func<int, RoundManager, int, Random, int>>((Func<int, RoundManager, int, Random, int>)delegate(int amount, RoundManager self, int i, Random random)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleTrap))
{
return amount;
}
SpawnableMapObject val2 = self.currentLevel.spawnableMapObjects[i];
bool flag = false;
if (((Object)val2.prefabToSpawn).name switch
{
"TurretContainer" => Plugin.Config.DoubleTrapEnableTurrets.Value ? 1 : 0,
"Landmine" => Plugin.Config.DoubleTrapEnableLandmines.Value ? 1 : 0,
"SpikeRoofTrapHazard" => Plugin.Config.DoubleTrapEnableSpikeTraps.Value ? 1 : 0,
_ => Plugin.Config.DoubleTrapEnableOther.Value ? 1 : 0,
} == 0)
{
return amount;
}
if (Plugin.Config.DoubleTrapRollBaseline.Value > 0f)
{
float num3 = 1f - Plugin.Config.DoubleTrapRollBaseline.Value;
float num4 = (float)random.NextDouble() * num3 + Plugin.Config.DoubleTrapRollBaseline.Value;
amount = (int)val2.numberToSpawn.Evaluate(num4);
}
return (int)((float)amount * Plugin.Config.DoubleTrapMultiplier.Value);
});
}
private static void RoundManager_PlotOutEnemiesForNextHour_IL(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
int spawnedEnemyCountLoc = 1;
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchStloc(instr, spawnedEnemyCountLoc)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for RoundManager.PlotOutEnemiesForNextHour @ Evaluate enemy curve");
return;
}
val.EmitDelegate<Func<float, float>>((Func<float, float>)delegate(float orig)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleMonster))
{
return orig;
}
return (orig < 0f) ? orig : (orig * Plugin.Config.DoubleMonsterIndoorRateMultiplier.Value);
});
}
private static void StartOfRound_OnEnable(orig_OnEnable orig, StartOfRound self)
{
orig.Invoke(self);
Plugin.CallEventsEnabled(Plugin.CurrentEvents.Value);
}
private static void StartOfRound_OnDisable(orig_OnDisable orig, StartOfRound self)
{
Plugin.CallEventsDisabled(Plugin.CurrentEvents.Value);
orig.Invoke(self);
}
private static void RoundManager_PredictAllOutsideEnemies_IL(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int num = 9;
int spawnedEnemyCountLoc = 4;
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchStloc(instr, spawnedEnemyCountLoc)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for RoundManager.PredictAllOutsideEnemies @ Evaluate enemy curve");
return;
}
val.EmitDelegate<Func<float, float>>((Func<float, float>)delegate(float orig)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleMonster))
{
return orig;
}
return (orig < 0f) ? orig : (orig * Plugin.Config.DoubleMonsterOutdoorRateMultiplier.Value);
});
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdfld<RoundManager>(instr, "enemyNestSpawnObjects")
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for RoundManager.PredictAllOutsideEnemies @ After spawn prediction loop");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc, num);
val.EmitDelegate<Action<RoundManager, Random>>((Action<RoundManager, Random>)delegate(RoundManager self, Random anomalyRandom)
{
DoubleMonsterSpawnRobot = false;
DoubleMonsterRobotSpawnTime = 0f;
if (!StartOfRound.Instance.isChallengeFile && WeekdayUtils.HasEvent(EventType.DoubleMonster) && Plugin.Config.DoubleMonsterAlwaysSpawnOldBird.Value)
{
DoubleMonsterSpawnRobot = true;
DoubleMonsterRobotSpawnTime = self.timeScript.lengthOfHours * (float)(Plugin.Config.DoubleMonsterOldBirdActivationTime.Value - 6);
EnemyType enemyType = WeekdayUtils.GetEnemyType("RadMech");
self.SpawnNestObjectForOutsideEnemy(enemyType, anomalyRandom);
}
});
}
private static void RoundManager_SpawnEnemiesOutside_IL(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int spawnedEnemyCountLoc = 1;
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchStloc(instr, spawnedEnemyCountLoc)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for RoundManager.SpawnEnemiesOutside @ Evaluate enemy curve");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<float, RoundManager, float>>((Func<float, RoundManager, float>)delegate(float orig, RoundManager self)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleMonster))
{
return orig;
}
float num = self.timeScript.lengthOfHours * (float)self.currentHour;
if (DoubleMonsterSpawnRobot && num >= DoubleMonsterRobotSpawnTime)
{
SpawnRobot();
DoubleMonsterSpawnRobot = false;
DoubleMonsterRobotSpawnTime = 0f;
}
return (orig < 0f) ? orig : (orig * Plugin.Config.DoubleMonsterOutdoorRateMultiplier.Value);
});
}
private static void SpawnRobot()
{
//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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
RoundManager instance = RoundManager.Instance;
GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
EnemyType enemyType = WeekdayUtils.GetEnemyType("RadMech");
if (enemyType.requireNestObjectsToSpawn)
{
bool flag = false;
EnemyAINestSpawnObject[] array2 = Object.FindObjectsByType<EnemyAINestSpawnObject>((FindObjectsSortMode)0);
for (int i = 0; i < array2.Length; i++)
{
if ((Object)(object)array2[i].enemyType == (Object)(object)enemyType)
{
flag = true;
break;
}
}
if (!flag)
{
return;
}
}
int num = Mathf.Max(enemyType.spawnInGroupsOf, 1);
for (int j = 0; j < num; j++)
{
Vector3 position = array[instance.AnomalyRandom.Next(0, array.Length)].transform.position;
position = instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), instance.AnomalyRandom, instance.GetLayermaskForEnemySizeLimit(enemyType));
position = instance.PositionWithDenialPointsChecked(position, array, enemyType);
GameObject val = Object.Instantiate<GameObject>(enemyType.enemyPrefab, position, Quaternion.Euler(Vector3.zero));
val.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
instance.SpawnedEnemies.Add(val.GetComponent<EnemyAI>());
}
}
private static void StartOfRound_Start(orig_Start orig, StartOfRound self)
{
if (((NetworkBehaviour)self).IsServer)
{
DayOfWeek dayOfWeek = (Plugin.Config.AllowDayChange.Value ? DateTime.Now.DayOfWeek : Plugin.DayAtStartup);
Plugin.CurrentDay.Value = dayOfWeek;
Plugin.CurrentEvents.Value = WeekdayUtils.GetEventsForDay(dayOfWeek);
}
orig.Invoke(self);
}
private static void StartOfRound_Update(orig_Update orig, StartOfRound self)
{
orig.Invoke(self);
if (((NetworkBehaviour)self).IsServer && Plugin.Config.AllowDayChange.Value)
{
DayOfWeek dayOfWeek = DateTime.Now.DayOfWeek;
if (Plugin.CurrentDay.Value != DateTime.Now.DayOfWeek)
{
Plugin.CurrentDay.Value = dayOfWeek;
Plugin.CurrentEvents.Value = WeekdayUtils.GetEventsForDay(dayOfWeek);
}
}
}
private static void Terminal_TextPostProcess_IL(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdstr(instr, "[currentDay]")
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for Terminal.TextPostProcess @ [currentDay]");
return;
}
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt<string>(instr, "Replace")
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for Terminal.TextPostProcess @ String replace");
return;
}
val.EmitDelegate<Func<string, string>>((Func<string, string>)delegate(string orig)
{
if (StartOfRound.Instance.isChallengeFile)
{
return orig;
}
string text = Plugin.CurrentDay.Value.ToString();
if (Plugin.CurrentEvents.Value.Length != 0)
{
switch (Plugin.CurrentEvents.Value[0])
{
case EventType.DoubleMonster:
text = "Double Monster " + text;
break;
case EventType.DoubleTrap:
text = "Double Trap " + text;
break;
case EventType.DoubleLoot:
text = "Double Loot " + text;
break;
case EventType.SmallFacility:
text = "Small Facility " + text;
break;
case EventType.Black:
text = "Black " + text;
break;
case EventType.Nightmare:
text = "Nightmare " + text;
break;
case EventType.Easter:
text = "Easter " + text;
break;
}
}
return text;
});
}
private static void RoundManager_SpawnScrapInLevel(orig_SpawnScrapInLevel orig, RoundManager self)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.DoubleLoot))
{
orig.Invoke(self);
return;
}
Plugin.Logger.LogInfo((object)"Applying Double Loot");
float scrapAmountMultiplier = self.scrapAmountMultiplier;
self.scrapAmountMultiplier *= Plugin.Config.DoubleLootMultiplier.Value;
orig.Invoke(self);
self.scrapAmountMultiplier = scrapAmountMultiplier;
}
private static void RoundManager_SpawnScrapInLevel_IL(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int containerLoc = -1;
FieldReference scrapToSpawnField = null;
if (!val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, ref containerLoc),
(Instruction instr) => ILPatternMatchingExt.MatchNewobj<List<Item>>(instr),
(Instruction instr) => ILPatternMatchingExt.MatchStfld(instr, ref scrapToSpawnField)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for RoundManager.SpawnScrapInLevel @ Init ScrapToSpawn list");
return;
}
int num2 = default(int);
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[2]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdnull(instr),
(Instruction instr) => ILPatternMatchingExt.MatchStloc(instr, ref num2)
}))
{
Plugin.Logger.LogError((object)"Failed IL hook for RoundManager.SpawnScrapInLevel @ After populate ScrapToSpawn");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc, containerLoc);
val.Emit(OpCodes.Ldfld, scrapToSpawnField);
val.EmitDelegate<Action<RoundManager, List<Item>>>((Action<RoundManager, List<Item>>)delegate(RoundManager self, List<Item> scrapToSpawn)
{
if (!StartOfRound.Instance.isChallengeFile && WeekdayUtils.HasEvent(EventType.Easter))
{
Plugin.Logger.LogInfo((object)"Applying Easter");
Random random = new Random(self.playersManager.randomMapSeed);
Item item2 = StartOfRound.Instance.allItemsList.itemsList.First((Item item) => item.itemName == "Easter egg");
int num = (int)((float)scrapToSpawn.Count * Plugin.Config.EasterEggSpawnRate.Value);
for (int i = 0; i < num; i++)
{
scrapToSpawn.Insert(random.Next(0, scrapToSpawn.Count), item2);
}
}
});
}
private static void RoundManager_GenerateNewFloor(orig_GenerateNewFloor orig, RoundManager self)
{
if (StartOfRound.Instance.isChallengeFile || !WeekdayUtils.HasEvent(EventType.SmallFacility))
{
orig.Invoke(self);
return;
}
Plugin.Logger.LogInfo((object)"Applying Small Facility");
if (SyncedEntry<bool>.op_Implicit(Plugin.Config.SmallFacilityUseFixedSize))
{
float factorySizeMultiplier = self.currentLevel.factorySizeMultiplier;
self.currentLevel.factorySizeMultiplier = Plugin.Config.SmallFacilityFixedMapSize.Value;
orig.Invoke(self);
self.currentLevel.factorySizeMultiplier = factorySizeMultiplier;
}
else
{
float mapSizeMultiplier = self.mapSizeMultiplier;
self.mapSizeMultiplier *= Plugin.Config.SmallFacilityMapSizeMultiplier.Value;
orig.Invoke(self);
self.mapSizeMultiplier = mapSizeMultiplier;
}
}
}
[BepInPlugin("moe.sylvi.WeekdayBonuses", "WeekdayBonuses", "1.1.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("com.sigurd.csync", "5.0.0")]
public class Plugin : BaseUnityPlugin
{
public static LethalNetworkVariable<DayOfWeek> CurrentDay = new LethalNetworkVariable<DayOfWeek>("currentDay");
public static LethalNetworkVariable<EventType[]> CurrentEvents = new LethalNetworkVariable<EventType[]>("currentEvents");
public static DayOfWeek DayAtStartup;
public static EventType[] LastEvents = Array.Empty<EventType>();
public static Plugin Instance { get; private set; }
public static ManualLogSource Logger { get; private set; }
public static Config Config { get; private set; }
private void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
Config = new Config(((BaseUnityPlugin)this).Config);
CurrentEvents.OnValueChanged += CurrentEvents_OnValueChanged;
DayAtStartup = DateTime.Now.DayOfWeek;
CurrentDay.Value = DayAtStartup;
CurrentEvents.Value = WeekdayUtils.GetEventsForDay(DayAtStartup);
Patches.Initialize();
Logger.LogInfo((object)"Plugin moe.sylvi.WeekdayBonuses is loaded!");
}
private void CurrentEvents_OnValueChanged(EventType[] eventTypes)
{
List<EventType> list = new List<EventType>();
List<EventType> list2 = new List<EventType>();
foreach (EventType value in Enum.GetValues(typeof(EventType)))
{
bool flag = eventTypes.Contains(value);
bool flag2 = LastEvents.Contains(value);
if (flag && !flag2)
{
list.Add(value);
}
else if (flag2 && !flag)
{
list2.Add(value);
}
}
LastEvents = eventTypes;
if (!((Object)(object)StartOfRound.Instance == (Object)null) && ((Behaviour)StartOfRound.Instance).enabled)
{
CallEventsDisabled(list2.ToArray());
CallEventsEnabled(list.ToArray());
}
}
public static void CallEventsEnabled(EventType[] events)
{
if (events.Contains(EventType.DoubleMonster))
{
EventCallbacks.DoubleMonsterEnabled();
}
if (events.Contains(EventType.Black))
{
EventCallbacks.BlackFridaySettingChanged();
}
}
public static void CallEventsDisabled(EventType[] events)
{
if (events.Contains(EventType.DoubleMonster))
{
EventCallbacks.DoubleMonsterDisabled();
}
if (events.Contains(EventType.Black))
{
EventCallbacks.BlackFridaySettingChanged();
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "moe.sylvi.WeekdayBonuses";
public const string PLUGIN_NAME = "WeekdayBonuses";
public const string PLUGIN_VERSION = "1.1.4";
}
public enum SaleMode
{
Random,
Highest,
Custom
}
public static class WeekdayUtils
{
private static EventType[] nightmareEventList = Array.Empty<EventType>();
private static string lastNightmareEventListValue = null;
public static EnemyType GetEnemyType(string enemyName)
{
QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>();
if ((Object)(object)val == (Object)null)
{
return null;
}
foreach (SpawnableEnemyWithRarity enemy in val.testAllEnemiesLevel.Enemies)
{
if (enemy.enemyType.enemyName == enemyName)
{
return enemy.enemyType;
}
}
foreach (SpawnableEnemyWithRarity outsideEnemy in val.testAllEnemiesLevel.OutsideEnemies)
{
if (outsideEnemy.enemyType.enemyName == enemyName)
{
return outsideEnemy.enemyType;
}
}
foreach (SpawnableEnemyWithRarity daytimeEnemy in val.testAllEnemiesLevel.DaytimeEnemies)
{
if (daytimeEnemy.enemyType.enemyName == enemyName)
{
return daytimeEnemy.enemyType;
}
}
return null;
}
public static EventType[] GetEventsForDay(DayOfWeek day)
{
string value = Plugin.Config.EventListForDay[day].Value;
if (!string.IsNullOrEmpty(value.Trim()))
{
return ParseEventList(value);
}
EventType value2 = Plugin.Config.EventForDay[day].Value;
return (value2 == EventType.None) ? Array.Empty<EventType>() : new EventType[1] { value2 };
}
public static EventType[] ParseEventList(string eventListString)
{
string[] array = eventListString.Split(',', StringSplitOptions.RemoveEmptyEntries);
List<EventType> list = new List<EventType>();
string[] array2 = array;
foreach (string text in array2)
{
string value = new string(text.Where((char c) => !char.IsWhiteSpace(c)).ToArray());
if (Enum.TryParse<EventType>(value, ignoreCase: true, out var result))
{
list.Add(result);
}
else
{
Plugin.Logger.LogError((object)("Unknown event in config: " + text));
}
}
return list.ToArray();
}
public static bool HasEvent(EventType eventType)
{
if (Plugin.CurrentEvents.Value.Contains(eventType))
{
return true;
}
if (Plugin.CurrentEvents.Value.Contains(EventType.Nightmare))
{
UpdateNightmareEventList();
if (nightmareEventList.Contains(eventType))
{
return true;
}
}
return false;
}
private static void UpdateNightmareEventList()
{
if (lastNightmareEventListValue != Plugin.Config.NightmareEventList.Value)
{
if (string.IsNullOrEmpty(Plugin.Config.NightmareEventList.Value.Trim()))
{
nightmareEventList = (EventType[])Enum.GetValues(typeof(EventType));
}
else
{
nightmareEventList = ParseEventList(Plugin.Config.NightmareEventList.Value);
}
lastNightmareEventListValue = Plugin.Config.NightmareEventList.Value;
}
}
}
}