Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LethalDirector 1v1 v1.0.0
LethalDirector_1v1.dll
Decompiled an hour 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalDirector_1v1")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalDirector_1v1")] [assembly: AssemblyTitle("LethalDirector_1v1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 LethalDirector { public static class ConfigManager { public readonly struct SyncedValue { public readonly string Section; public readonly string Key; public readonly string Value; public SyncedValue(string section, string key, string value) { Section = section; Key = key; Value = value; } } public const string SecControls = "Controls"; public const string SecVisuals = "Visuals"; public const string SecEconomy = "Economy"; public const string SecSpawning = "Spawning"; public const string SecVision = "Vision"; public const string SecMatch = "Match"; public const string SecOrders = "Orders"; public const string SecShop = "Shop"; public const string SecDirectorShop = "Director Shop"; public const string SecTricks = "Tricks"; public const string SecEnemyPrices = "Enemy Prices"; public static readonly HashSet<string> LocalSections = new HashSet<string> { "Controls", "Visuals" }; public static readonly string[] SectionOrder = new string[11] { "Controls", "Visuals", "Economy", "Spawning", "Vision", "Match", "Shop", "Director Shop", "Orders", "Tricks", "Enemy Prices" }; private static readonly Dictionary<string, int> DefaultBasePrices = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase) { { "Hoarding bug", 45 }, { "Centipede", 50 }, { "Puffer", 40 }, { "Bunker Spider", 75 }, { "Crawler", 95 }, { "Blob", 65 }, { "Flowerman", 130 }, { "Spring", 135 }, { "Nutcracker", 145 }, { "Masked", 120 }, { "Butler", 125 }, { "Barber", 130 }, { "Clay Surgeon", 130 }, { "Maneater", 140 }, { "Jester", 190 }, { "Girl", 180 }, { "Lasso", 90 }, { "Baboon hawk", 65 }, { "MouthDog", 110 }, { "ForestGiant", 155 }, { "SandWorm", 130 }, { "Earth Leviathan", 130 }, { "RadMech", 195 }, { "Bush Wolf", 115 }, { "GiantKiwi", 125 } }; private static readonly Dictionary<string, ConfigEntry<int>> _enemyPriceEntries = new Dictionary<string, ConfigEntry<int>>(StringComparer.OrdinalIgnoreCase); private static bool _hasHostSync; private static readonly Dictionary<ConfigDefinition, string> _hostValues = new Dictionary<ConfigDefinition, string>(); private static readonly Dictionary<ConfigDefinition, object> _parsedCache = new Dictionary<ConfigDefinition, object>(); private static readonly Dictionary<ConfigDefinition, float> _steps = new Dictionary<ConfigDefinition, float>(); public static ConfigFile File { get; private set; } public static ConfigEntry<KeyCode> MenuKey { get; private set; } public static ConfigEntry<KeyCode> NightVisionKey { get; private set; } public static ConfigEntry<KeyCode> TeleportPlayerKey { get; private set; } public static ConfigEntry<KeyCode> CommandKey { get; private set; } public static ConfigEntry<KeyCode> CancelCommandKey { get; private set; } public static ConfigEntry<KeyCode> SlowKey { get; private set; } public static ConfigEntry<bool> DisableRoomCulling { get; private set; } public static ConfigEntry<bool> ShowVentHighlight { get; private set; } public static ConfigEntry<bool> ShowESP { get; private set; } public static ConfigEntry<bool> ShowEnemyHighlights { get; private set; } public static ConfigEntry<float> PlayerPingIntervalSeconds { get; private set; } public static ConfigEntry<float> PlayerPingDurationSeconds { get; private set; } public static ConfigEntry<float> CreditMultiplier { get; private set; } public static ConfigEntry<float> MoonPowerDivisor { get; private set; } public static ConfigEntry<float> MinPriceMultiplier { get; private set; } public static ConfigEntry<float> MaxPriceMultiplier { get; private set; } public static ConfigEntry<float> OffMoonPriceMultiplier { get; private set; } public static ConfigEntry<float> VentSpawnDelaySeconds { get; private set; } public static ConfigEntry<float> GracePeriodSeconds { get; private set; } public static ConfigEntry<int> MaxAliveEnemies { get; private set; } public static ConfigEntry<int> QuotaTarget { get; private set; } public static ConfigEntry<int> DaysPerQuota { get; private set; } public static ConfigEntry<bool> RandomMoons { get; private set; } public static ConfigEntry<string> Quota1Moons { get; private set; } public static ConfigEntry<string> Quota2Moons { get; private set; } public static ConfigEntry<string> Quota3Moons { get; private set; } public static ConfigEntry<int> ShopItemCost { get; private set; } public static ConfigEntry<int> ShopPointsPerDay { get; private set; } public static ConfigEntry<float> ShopScrapValueBonus { get; private set; } public static ConfigEntry<float> ShopMoveSpeedBonus { get; private set; } public static ConfigEntry<float> ShopHealthBonus { get; private set; } public static ConfigEntry<int> ShopExtraScrap { get; private set; } public static ConfigEntry<float> ShopWeightReduction { get; private set; } public static ConfigEntry<float> DirCreditGainBonus { get; private set; } public static ConfigEntry<float> DirMonsterDamageBonus { get; private set; } public static ConfigEntry<int> DirStartCredits { get; private set; } public static ConfigEntry<float> DirTrickDiscount { get; private set; } public static ConfigEntry<float> DirMonsterDiscount { get; private set; } public static ConfigEntry<int> DirNoonSpawnCount { get; private set; } public static ConfigEntry<int> DirQuotaIncrease { get; private set; } public static ConfigEntry<float> DirSlowAmount { get; private set; } public static ConfigEntry<float> DirSlowDuration { get; private set; } public static ConfigEntry<float> DirExtraTraps { get; private set; } public static ConfigEntry<int> CommandCost { get; private set; } public static ConfigEntry<float> CommandCooldownSeconds { get; private set; } public static ConfigEntry<float> CommandDurationSeconds { get; private set; } public static ConfigEntry<int> TrickCutLightsCost { get; private set; } public static ConfigEntry<int> TrickSteamValvesCost { get; private set; } public static ConfigEntry<int> TrickAmbientSoundCost { get; private set; } public static ConfigEntry<int> TrickMeteorShowerCost { get; private set; } public static float EffectiveCreditMultiplier => Effective<float>(CreditMultiplier); public static float EffectiveMoonPowerDivisor => Effective<float>(MoonPowerDivisor); public static float EffectiveMinPriceMultiplier => Effective<float>(MinPriceMultiplier); public static float EffectiveMaxPriceMultiplier => Effective<float>(MaxPriceMultiplier); public static float EffectiveOffMoonPriceMultiplier => Effective<float>(OffMoonPriceMultiplier); public static float EffectiveVentSpawnDelay => Effective<float>(VentSpawnDelaySeconds); public static float EffectivePlayerPingInterval => Effective<float>(PlayerPingIntervalSeconds); public static float EffectivePlayerPingDuration => Effective<float>(PlayerPingDurationSeconds); public static float EffectiveGracePeriodSeconds => Effective<float>(GracePeriodSeconds); public static int EffectiveMaxAliveEnemies => Effective<int>(MaxAliveEnemies); public static int EffectiveCommandCost => Effective<int>(CommandCost); public static int EffectiveShopItemCost => Effective<int>(ShopItemCost); public static int EffectiveShopPointsPerDay => Effective<int>(ShopPointsPerDay); public static float EffectiveShopScrapValueBonus => Effective<float>(ShopScrapValueBonus); public static float EffectiveShopMoveSpeedBonus => Effective<float>(ShopMoveSpeedBonus); public static float EffectiveShopHealthBonus => Effective<float>(ShopHealthBonus); public static int EffectiveShopExtraScrap => Effective<int>(ShopExtraScrap); public static float EffectiveShopWeightReduction => Effective<float>(ShopWeightReduction); public static float EffectiveDirCreditGainBonus => Effective<float>(DirCreditGainBonus); public static float EffectiveDirMonsterDamageBonus => Effective<float>(DirMonsterDamageBonus); public static int EffectiveDirStartCredits => Effective<int>(DirStartCredits); public static float EffectiveDirTrickDiscount => Effective<float>(DirTrickDiscount); public static float EffectiveDirMonsterDiscount => Effective<float>(DirMonsterDiscount); public static int EffectiveDirNoonSpawnCount => Effective<int>(DirNoonSpawnCount); public static int EffectiveDirQuotaIncrease => Effective<int>(DirQuotaIncrease); public static float EffectiveDirSlowAmount => Effective<float>(DirSlowAmount); public static float EffectiveDirSlowDuration => Effective<float>(DirSlowDuration); public static float EffectiveDirExtraTraps => Effective<float>(DirExtraTraps); public static float EffectiveCommandCooldown => Effective<float>(CommandCooldownSeconds); public static int EffectiveTrickCutLightsCost => Effective<int>(TrickCutLightsCost); public static int EffectiveTrickSteamValvesCost => Effective<int>(TrickSteamValvesCost); public static int EffectiveTrickAmbientSoundCost => Effective<int>(TrickAmbientSoundCost); public static int EffectiveTrickMeteorShowerCost => Effective<int>(TrickMeteorShowerCost); public static void Init(ConfigFile config) { File = config; MenuKey = config.Bind<KeyCode>("Controls", "MenuKey", (KeyCode)102, "Open / close the Director menu."); NightVisionKey = config.Bind<KeyCode>("Controls", "NightVisionKey", (KeyCode)110, "Toggle Director night vision."); TeleportPlayerKey = config.Bind<KeyCode>("Controls", "TeleportPlayerKey", (KeyCode)116, "Teleport to the next survivor."); CommandKey = config.Bind<KeyCode>("Controls", "CommandKey", (KeyCode)103, "Aim at an enemy to select it, aim at a spot to send it there."); CancelCommandKey = config.Bind<KeyCode>("Controls", "CancelCommandKey", (KeyCode)104, "Cancel the selected enemy's order (or all orders)."); SlowKey = config.Bind<KeyCode>("Controls", "SlowKey", (KeyCode)106, "Director: slow down the survivors (needs the 'Molasses' upgrade)."); DisableRoomCulling = config.Bind<bool>("Visuals", "DisableRoomCulling", true, "Render the entire facility interior at once for the Director."); ShowVentHighlight = config.Bind<bool>("Visuals", "ShowVentHighlight", true, "Highlight vents through walls for the Director."); ShowESP = config.Bind<bool>("Visuals", "ShowESP", true, "Show vent labels, and player labels during pings, for the Director."); ShowEnemyHighlights = config.Bind<bool>("Visuals", "ShowEnemyHighlights", true, "Monsters glow through walls: green, yellow when selected, red when following an order."); PlayerPingIntervalSeconds = BindFloat("Vision", "PlayerPingIntervalSeconds", 20f, "Survivors glow white through walls every X seconds (ping).", 5f, 120f, 5f); PlayerPingDurationSeconds = BindFloat("Vision", "PlayerPingDurationSeconds", 3f, "How long survivors stay visible after a ping.", 0.5f, 15f, 0.5f); CreditMultiplier = BindFloat("Economy", "CreditMultiplier", 1f, "Global multiplier for Director credit gain.", 0.1f, 10f, 0.1f); MoonPowerDivisor = BindFloat("Economy", "MoonPowerDivisor", 50f, "Moon multiplier = (inside + outside power) / divisor.", 5f, 300f, 5f); MinPriceMultiplier = BindFloat("Economy", "MinPriceMultiplier", 0.7f, "Lowest price multiplier for common native enemies.", 0.1f, 5f, 0.05f); MaxPriceMultiplier = BindFloat("Economy", "MaxPriceMultiplier", 1.6f, "Highest price multiplier for rare native enemies.", 0.1f, 10f, 0.05f); OffMoonPriceMultiplier = BindFloat("Economy", "OffMoonPriceMultiplier", 5f, "Price multiplier for enemies not native to the current moon.", 1f, 20f, 0.5f); VentSpawnDelaySeconds = BindFloat("Spawning", "VentSpawnDelaySeconds", 4f, "Seconds before an enemy exits a vent after being bought.", 0.5f, 30f, 0.5f); GracePeriodSeconds = BindFloat("Match", "GracePeriodSeconds", 75f, "Seconds after landing during which the Director cannot spawn or use tricks.", 0f, 600f, 15f); MaxAliveEnemies = BindInt("Match", "MaxAliveEnemies", 6, "Max living enemies at once, vent spawns included (0 = unlimited).", 0, 40, 1); QuotaTarget = BindInt("Match", "QuotaTarget", 1000, "Quota the survivors must sell for each round of a match (does not increase between rounds).", 50, 50000, 50); DaysPerQuota = BindInt("Match", "DaysPerQuota", 3, "Days before the deadline of each quota during a match.", 1, 10, 1); RandomMoons = config.Bind<bool>("Match", "RandomMoons", true, "During a match, the moon of every day is picked at random from the current quota's list (manual routing is disabled)."); Quota1Moons = config.Bind<string>("Match", "Quota1Moons", "Experimentation, Assurance, Vow", "Moons for quota 1 (comma separated, edit in the config file)."); Quota2Moons = config.Bind<string>("Match", "Quota2Moons", "Offense, March, Adamance", "Moons for quota 2 (comma separated, edit in the config file)."); Quota3Moons = config.Bind<string>("Match", "Quota3Moons", "Rend, Titan, Artifice", "Moons for quota 3 (comma separated, edit in the config file)."); ShopItemCost = BindInt("Shop", "ItemCost", 1, "Point cost of every shop upgrade.", 0, 20, 1); ShopPointsPerDay = BindInt("Shop", "PointsPerDay", 1, "Points earned per day = this x quota number (1 per day at quota 1, 2 at quota 2...).", 0, 20, 1); ShopScrapValueBonus = BindFloat("Shop", "ScrapValueBonus", 0.2f, "Scrap value bonus per 'Appraiser' upgrade.", 0f, 2f, 0.05f); ShopMoveSpeedBonus = BindFloat("Shop", "SpeedBonus", 0.25f, "Movement speed bonus per 'Quick feet' upgrade.", 0f, 2f, 0.05f); ShopHealthBonus = BindFloat("Shop", "HealthBonus", 0.5f, "Health bonus per 'Tough' upgrade.", 0f, 5f, 0.1f); ShopExtraScrap = BindInt("Shop", "ExtraScrapPerMoon", 6, "Extra scrap spawns per 'Rich moons' upgrade.", 0, 50, 1); ShopWeightReduction = BindFloat("Shop", "ScrapWeightReduction", 0.6f, "Scrap weight reduction per 'Featherweight' upgrade (stacks multiplicatively).", 0f, 0.95f, 0.05f); DirCreditGainBonus = BindFloat("Director Shop", "CreditGainBonus", 0.2f, "Credit gain bonus per 'Funding' upgrade.", 0f, 3f, 0.05f); DirMonsterDamageBonus = BindFloat("Director Shop", "MonsterDamageBonus", 0.35f, "Monster damage bonus per 'Bloodlust' upgrade.", 0f, 3f, 0.05f); DirStartCredits = BindInt("Director Shop", "StartCredits", 50, "Credits at the start of every day per 'Head start' upgrade.", 0, 2000, 10); DirTrickDiscount = BindFloat("Director Shop", "TrickDiscount", 0.4f, "Trick price reduction per 'Saboteur' upgrade (stacks multiplicatively).", 0f, 0.95f, 0.05f); DirMonsterDiscount = BindFloat("Director Shop", "MonsterDiscount", 0.2f, "Monster price reduction per 'Wholesale' upgrade (stacks multiplicatively).", 0f, 0.95f, 0.05f); DirNoonSpawnCount = BindInt("Director Shop", "NoonSpawnCount", 1, "Free random monsters at 12 PM per 'High noon' upgrade.", 0, 10, 1); DirQuotaIncrease = BindInt("Director Shop", "QuotaIncrease", 150, "Added to the survivors' current quota per 'Greedy company' upgrade.", 0, 5000, 25); DirSlowAmount = BindFloat("Director Shop", "SlowAmount", 0.25f, "Survivor speed reduction of 'Molasses'.", 0.05f, 0.9f, 0.05f); DirSlowDuration = BindFloat("Director Shop", "SlowDuration", 3f, "Duration of 'Molasses' in seconds.", 0.5f, 20f, 0.5f); DirExtraTraps = BindFloat("Director Shop", "ExtraTraps", 0.25f, "Extra turrets / landmines / spike traps per 'Booby traps' upgrade.", 0f, 3f, 0.05f); CommandCost = BindInt("Orders", "CommandCost", 10, "Credit cost of each order given to an enemy.", 0, 500, 5); CommandCooldownSeconds = BindFloat("Orders", "CommandCooldownSeconds", 8f, "Seconds between two orders.", 0f, 120f, 1f); CommandDurationSeconds = BindFloat("Orders", "CommandDurationSeconds", 25f, "Max time an enemy follows an order before its normal AI takes over.", 5f, 120f, 5f); TrickCutLightsCost = BindInt("Tricks", "CutLightsCost", 75, "Cost to flip the breaker and cut facility lights.", 0, 2000, 5); TrickSteamValvesCost = BindInt("Tricks", "BurstSteamValvesCost", 45, "Cost to burst up to 3 steam valves.", 0, 2000, 5); TrickAmbientSoundCost = BindInt("Tricks", "AmbientSoundCost", 5, "Cost to play a random interior ambience for everyone.", 0, 2000, 5); TrickMeteorShowerCost = BindInt("Tricks", "MeteorShowerCost", 120, "Cost to trigger a meteor shower.", 0, 2000, 5); config.SettingChanged += delegate(object sender, SettingChangedEventArgs args) { if (((args != null) ? args.ChangedSetting : null) != null && IsHostSynced(args.ChangedSetting)) { _parsedCache.Remove(args.ChangedSetting.Definition); NetworkSync.MarkConfigDirty(); } }; } public static void Initialize(ConfigFile config) { Init(config); } public static void Bind(ConfigFile config) { Init(config); } private static ConfigEntry<float> BindFloat(string section, string key, float def, string desc, float min, float max, float step) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown ConfigEntry<float> val = File.Bind<float>(section, key, def, new ConfigDescription(desc, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>())); _steps[((ConfigEntryBase)val).Definition] = step; return val; } private static ConfigEntry<int> BindInt(string section, string key, int def, string desc, int min, int max, int step) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown ConfigEntry<int> val = File.Bind<int>(section, key, def, new ConfigDescription(desc, (AcceptableValueBase)(object)new AcceptableValueRange<int>(min, max), Array.Empty<object>())); _steps[((ConfigEntryBase)val).Definition] = step; return val; } public static float GetStep(ConfigEntryBase entry, float fallback) { if (entry == null || !_steps.TryGetValue(entry.Definition, out var value)) { return fallback; } return value; } public static bool IsHostSynced(ConfigEntryBase entry) { if (entry != null) { return !LocalSections.Contains(entry.Definition.Section); } return false; } public static T Effective<T>(ConfigEntry<T> entry) { if (entry == null) { return default(T); } if (NetworkSync.IsHost || !_hasHostSync || !IsHostSynced((ConfigEntryBase)(object)entry)) { return entry.Value; } if (_parsedCache.TryGetValue(((ConfigEntryBase)entry).Definition, out var value) && value is T) { return (T)value; } if (_hostValues.TryGetValue(((ConfigEntryBase)entry).Definition, out var value2)) { try { T val = TomlTypeConverter.ConvertToValue<T>(value2); _parsedCache[((ConfigEntryBase)entry).Definition] = val; return val; } catch { } } return entry.Value; } public static string GetDisplayValue(ConfigEntryBase entry) { if (entry == null) { return string.Empty; } if (!NetworkSync.IsHost && _hasHostSync && IsHostSynced(entry) && _hostValues.TryGetValue(entry.Definition, out var value)) { return value; } return entry.GetSerializedValue(); } public static List<SyncedValue> GetHostSyncPayload() { List<SyncedValue> list = new List<SyncedValue>(); if (File == null) { return list; } foreach (ConfigDefinition key in File.Keys) { ConfigEntryBase val = File[key]; if (IsHostSynced(val)) { list.Add(new SyncedValue(key.Section, key.Key, val.GetSerializedValue())); } } return list; } public static void ApplyHostValues(List<SyncedValue> values) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown _hostValues.Clear(); _parsedCache.Clear(); foreach (SyncedValue value in values) { if (!string.IsNullOrEmpty(value.Section) && !string.IsNullOrEmpty(value.Key)) { _hostValues[new ConfigDefinition(value.Section, value.Key)] = value.Value ?? string.Empty; } } _hasHostSync = true; } public static void ResetHostSync() { _hasHostSync = false; _hostValues.Clear(); _parsedCache.Clear(); } private static string SanitizeKey(string name) { if (string.IsNullOrEmpty(name)) { return "Unknown"; } char[] array = name.ToCharArray(); for (int i = 0; i < array.Length; i++) { char c = array[i]; if (c == '=' || c == '\n' || c == '\t' || c == '\\' || c == '"' || c == '\'' || c == '[' || c == ']') { array[i] = '_'; } } return new string(array).Trim(); } private static int GetDefaultPrice(string name, float powerLevel) { if (DefaultBasePrices.TryGetValue(name, out var value)) { return value; } foreach (KeyValuePair<string, int> defaultBasePrice in DefaultBasePrices) { if (name.IndexOf(defaultBasePrice.Key, StringComparison.OrdinalIgnoreCase) >= 0) { return defaultBasePrice.Value; } } return Mathf.Clamp(Mathf.RoundToInt(Mathf.Max(0.5f, powerLevel) * 50f), 35, 220); } public static ConfigEntry<int> GetEnemyPriceEntry(EnemyType enemyType) { if (File == null || (Object)(object)enemyType == (Object)null) { return null; } string text = enemyType.enemyName ?? "Unknown"; string key = SanitizeKey(text); if (_enemyPriceEntries.TryGetValue(key, out var value)) { return value; } int defaultPrice = GetDefaultPrice(text, enemyType.PowerLevel); ConfigEntry<int> val = BindInt("Enemy Prices", key, defaultPrice, "Base price of " + text + ", before rarity / off-moon multipliers.", 1, 5000, 5); _enemyPriceEntries[key] = val; return val; } public static void RegisterAllEnemyPrices() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.levels == null) { return; } SelectableLevel[] levels = instance.levels; foreach (SelectableLevel val in levels) { if (!((Object)(object)val == (Object)null)) { RegisterList(val.Enemies); RegisterList(val.OutsideEnemies); RegisterList(val.DaytimeEnemies); } } } private static void RegisterList(List<SpawnableEnemyWithRarity> list) { if (list == null) { return; } foreach (SpawnableEnemyWithRarity item in list) { if ((Object)(object)item?.enemyType != (Object)null) { GetEnemyPriceEntry(item.enemyType); } } } public static int GetBasePrice(EnemyType enemyType) { if ((Object)(object)enemyType == (Object)null) { return 60; } ConfigEntry<int> enemyPriceEntry = GetEnemyPriceEntry(enemyType); if (enemyPriceEntry == null) { return GetDefaultPrice(enemyType.enemyName ?? string.Empty, enemyType.PowerLevel); } return Effective<int>(enemyPriceEntry); } } public class DirectorController : MonoBehaviour { private const float MinFlySpeed = 2f; private const float MaxFlySpeed = 60f; private Light _nightVisionLight; private int _lastTeleportSurvivorIndex = -1; private readonly Dictionary<EnemyVent, List<MeshRenderer>> _ventHighlights = new Dictionary<EnemyVent, List<MeshRenderer>>(); private Material _matVentFree; private Material _matVentNearest; private Material _matVentOccupied; private float _ventHighlightTimer; private int _cachedNearestVentIndex = -1; public static DirectorController Instance { get; private set; } public bool IsInDirectorMode { get; private set; } public float FlySpeed { get; set; } = 12f; public bool NightVisionEnabled { get; private set; } public int NearestVentIndex => _cachedNearestVentIndex; public static void EnsureExists() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("LethalDirector_Controller"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<DirectorController>(); } } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); return; } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); InitHighlightMaterials(); } private void OnDestroy() { ClearVentHighlights(); DirectorHighlights.ClearAll(); DestroyNightVisionLight(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void InitHighlightMaterials() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) _matVentFree = XRayMaterials.Create(new Color(0.1f, 0.55f, 0.75f, 0.4f)); _matVentNearest = XRayMaterials.Create(new Color(0f, 0.85f, 1f, 0.65f)); _matVentOccupied = XRayMaterials.Create(new Color(1f, 0.55f, 0.1f, 0.65f)); } public void EnterDirectorMode() { PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { IsInDirectorMode = true; val.disableMoveInput = true; if ((Object)(object)val.thisController != (Object)null) { ((Collider)val.thisController).enabled = false; } SetNightVision(enabled: true); DirectorManager.ApplyRoomCullingForDirector(); RefreshVentHighlights(); } } public void ExitDirectorMode(bool teleportToShip = false) { IsInDirectorMode = false; SetNightVision(enabled: false); ClearVentHighlights(); DirectorHighlights.ClearAll(); DirectorManager.RestoreRoomCulling(); PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if ((Object)(object)val != (Object)null) { val.disableMoveInput = false; val.disableLookInput = false; if ((Object)(object)val.thisController != (Object)null) { ((Collider)val.thisController).enabled = true; } if (teleportToShip) { MovePlayerIntoShip(val); } } } private static void MovePlayerIntoShip(PlayerControllerB player) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && instance.playerSpawnPositions != null && instance.playerSpawnPositions.Length != 0) { int num = (int)player.playerClientId; if (num < 0 || num >= instance.playerSpawnPositions.Length) { num = 0; } player.TeleportPlayer(instance.playerSpawnPositions[num].position, false, 0f, false, true); player.isInsideFactory = false; player.isInElevator = true; player.isInHangarShipRoom = true; } } public void ToggleNightVision() { SetNightVision(!NightVisionEnabled); } public void SetNightVision(bool enabled) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) NightVisionEnabled = enabled; PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || (Object)(object)val.gameplayCamera == (Object)null) { return; } if (enabled) { if ((Object)(object)_nightVisionLight == (Object)null) { GameObject val2 = new GameObject("LethalDirector_NightVision"); val2.transform.SetParent(((Component)val.gameplayCamera).transform, false); val2.transform.localPosition = Vector3.zero; _nightVisionLight = val2.AddComponent<Light>(); _nightVisionLight.type = (LightType)2; _nightVisionLight.color = new Color(0.85f, 0.95f, 1f); _nightVisionLight.range = 120f; _nightVisionLight.intensity = 2.2f; _nightVisionLight.shadows = (LightShadows)0; } ((Behaviour)_nightVisionLight).enabled = true; } else if ((Object)(object)_nightVisionLight != (Object)null) { ((Behaviour)_nightVisionLight).enabled = false; } } private void DestroyNightVisionLight() { if ((Object)(object)_nightVisionLight != (Object)null) { Object.Destroy((Object)(object)((Component)_nightVisionLight).gameObject); _nightVisionLight = null; } } public static bool WasKeyPressedThisFrame(KeyCode code) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) Keyboard current = Keyboard.current; if (current == null) { return false; } Key val = KeyCodeToInputKey(code); if ((int)val != 0) { return ((ButtonControl)current[val]).wasPressedThisFrame; } return false; } private unsafe static Key KeyCodeToInputKey(KeyCode code) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected I4, but got Unknown //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_012d: Unknown result type (might be due to invalid IL or missing references) if ((int)code <= 96) { if ((int)code == 13) { return (Key)2; } switch (code - 48) { case 0: return (Key)50; case 1: return (Key)41; case 2: return (Key)42; case 3: return (Key)43; case 4: return (Key)44; case 5: return (Key)45; case 6: return (Key)46; case 7: return (Key)47; case 8: return (Key)48; case 9: return (Key)49; } if ((int)code == 96) { return (Key)4; } } else { switch (code - 256) { case 0: return (Key)84; case 1: return (Key)85; case 2: return (Key)86; case 3: return (Key)87; case 4: return (Key)88; case 5: return (Key)89; case 6: return (Key)90; case 7: return (Key)91; case 8: return (Key)92; case 9: return (Key)93; } if ((int)code == 305) { return (Key)56; } if ((int)code == 306) { return (Key)55; } } string text = ((object)(*(KeyCode*)(&code))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Keypad")) { text = "Numpad" + text.Substring(6); } else if (text.StartsWith("Alpha")) { text = "Digit" + text.Substring(5); } if (!Enum.TryParse<Key>(text, ignoreCase: true, out Key result)) { return (Key)0; } return result; } public unsafe static bool TryInputKeyToKeyCode(Key key, out KeyCode code) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Invalid comparison between Unknown and I4 code = (KeyCode)0; if ((int)key == 0) { return false; } string text; if ((int)key <= 4) { if ((int)key != 2) { if ((int)key != 4) { goto IL_0042; } text = "BackQuote"; } else { text = "Return"; } } else if ((int)key != 55) { if ((int)key != 56) { goto IL_0042; } text = "RightControl"; } else { text = "LeftControl"; } goto IL_0090; IL_0042: text = ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Digit")) { text = "Alpha" + text.Substring(5); } else if (text.StartsWith("Numpad")) { text = "Keypad" + text.Substring(6); } goto IL_0090; IL_0090: if (Enum.TryParse<KeyCode>(text, ignoreCase: true, out code) && code) { return (int)KeyCodeToInputKey(code) > 0; } return false; } private void Update() { //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) if (!IsInDirectorMode || !DirectorManager.IsDirectorActive || !DirectorManager.IsLocalPlayerDirector) { return; } PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { return; } val.health = 100; val.sprintMeter = 1f; val.isExhausted = false; val.insanityLevel = 0f; val.drunkness = 0f; val.fallValue = 0f; val.fallValueUncapped = 0f; val.takingFallDamage = false; val.isUnderwater = false; val.disableMoveInput = true; if ((Object)(object)val.thisController != (Object)null && ((Collider)val.thisController).enabled) { ((Collider)val.thisController).enabled = false; } if (!val.isTypingChat && (!((Object)(object)val.quickMenuManager != (Object)null) || !val.quickMenuManager.isMenuOpen) && !DirectorUI.IsMenuOpen) { Mouse current = Mouse.current; if (current != null) { float y = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y; if (Mathf.Abs(y) > 0.01f) { FlySpeed = Mathf.Clamp(FlySpeed + Mathf.Sign(y) * 2f, 2f, 60f); } } if (WasKeyPressedThisFrame(ConfigManager.NightVisionKey.Value)) { ToggleNightVision(); } if (WasKeyPressedThisFrame(ConfigManager.TeleportPlayerKey.Value)) { TeleportToNextSurvivor(); } if (WasKeyPressedThisFrame(ConfigManager.CommandKey.Value)) { EnemyCommandManager.HandleCommandKey(val); } if (WasKeyPressedThisFrame(ConfigManager.CancelCommandKey.Value)) { EnemyCommandManager.HandleCancelKey(); } if (WasKeyPressedThisFrame(ConfigManager.SlowKey.Value)) { UpgradeManager.RequestSlow(); } HandleFreeFly(val); } val.isInsideFactory = ((Component)val).transform.position.y < -80f; DirectorHighlights.Tick(Time.deltaTime); _ventHighlightTimer += Time.deltaTime; if (_ventHighlightTimer >= 0.15f) { _ventHighlightTimer = 0f; UpdateVentHighlights(((Component)val).transform.position); } } private void LateUpdate() { if (!IsInDirectorMode || !DirectorManager.IsDirectorActive || !DirectorManager.IsLocalPlayerDirector) { return; } PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { return; } try { Traverse obj = Traverse.Create((object)val); obj.Field("hoveringOverTrigger").SetValue((object)null); Behaviour value = obj.Field("cursorIcon").GetValue<Behaviour>(); if ((Object)(object)value != (Object)null && value.enabled) { value.enabled = false; } object value2 = obj.Field("cursorTip").GetValue(); if (value2 != null) { Traverse.Create(value2).Property("text", (object[])null).SetValue((object)string.Empty); } } catch { } } private void HandleFreeFly(PlayerControllerB player) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null) { Transform val = (((Object)(object)player.gameplayCamera != (Object)null) ? ((Component)player.gameplayCamera).transform : ((Component)player).transform); Vector3 val2 = Vector3.zero; if (((ButtonControl)current[(Key)37]).isPressed || ((ButtonControl)current[(Key)40]).isPressed || ((ButtonControl)current[(Key)63]).isPressed) { val2 += val.forward; } if (((ButtonControl)current[(Key)33]).isPressed || ((ButtonControl)current[(Key)64]).isPressed) { val2 -= val.forward; } if (((ButtonControl)current[(Key)18]).isPressed || ((ButtonControl)current[(Key)62]).isPressed) { val2 += val.right; } if (((ButtonControl)current[(Key)15]).isPressed || ((ButtonControl)current[(Key)31]).isPressed || ((ButtonControl)current[(Key)61]).isPressed) { val2 -= val.right; } if (((ButtonControl)current[(Key)1]).isPressed) { val2 += Vector3.up; } if (((ButtonControl)current[(Key)55]).isPressed || ((ButtonControl)current[(Key)17]).isPressed) { val2 += Vector3.down; } if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { float num = FlySpeed * (((ButtonControl)current[(Key)51]).isPressed ? 2.2f : 1f); Transform transform = ((Component)player).transform; transform.position += ((Vector3)(ref val2)).normalized * (num * Time.deltaTime); } } } public void TeleportToPosition(Vector3 position) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { ((Component)val).transform.position = position; val.isInsideFactory = position.y < -80f; _cachedNearestVentIndex = DirectorManager.FindNearestVentIndex(position); } } public void TeleportToPlayer(PlayerControllerB target) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { TeleportToPosition(((Component)target).transform.position + Vector3.up * 1.5f); } } public void TeleportToNextSurvivor() { if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead && val.actualClientId != DirectorManager.DirectorClientId) { list.Add(val); } } if (list.Count != 0) { _lastTeleportSurvivorIndex = (_lastTeleportSurvivorIndex + 1) % list.Count; TeleportToPlayer(list[_lastTeleportSurvivorIndex]); } } public void TeleportToFacilityInterior() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(); EntranceTeleport val = null; EntranceTeleport[] array2 = array; foreach (EntranceTeleport val2 in array2) { if (!((Object)(object)val2 == (Object)null) && !val2.isEntranceToBuilding) { if (val2.entranceId == 0) { val = val2; break; } if ((Object)(object)val == (Object)null) { val = val2; } } } if ((Object)(object)val != (Object)null) { Vector3 position = (((Object)(object)val.entrancePoint != (Object)null) ? (val.entrancePoint.position + Vector3.up * 1.2f) : (((Component)val).transform.position + Vector3.up * 1.2f)); TeleportToPosition(position); return; } EnemyVent[] allVents = DirectorManager.GetAllVents(); if (allVents != null && allVents.Length != 0 && (Object)(object)allVents[0] != (Object)null) { TeleportToPosition(((Component)allVents[0]).transform.position + Vector3.up * 1.5f); } } public void TeleportToShip() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)StartOfRound.Instance == (Object)null)) { if (StartOfRound.Instance.playerSpawnPositions != null && StartOfRound.Instance.playerSpawnPositions.Length != 0) { TeleportToPosition(StartOfRound.Instance.playerSpawnPositions[0].position + Vector3.up * 1f); } else if ((Object)(object)StartOfRound.Instance.shipBounds != (Object)null) { TeleportToPosition(((Component)StartOfRound.Instance.shipBounds).transform.position + Vector3.up * 1.5f); } } } public void RefreshVentHighlights() { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) ClearVentHighlights(); if (!IsInDirectorMode || !ConfigManager.ShowVentHighlight.Value || (Object)(object)_matVentFree == (Object)null) { return; } EnemyVent[] allVents = DirectorManager.GetAllVents(); if (allVents == null || allVents.Length == 0) { return; } EnemyVent[] array = allVents; foreach (EnemyVent val in array) { if ((Object)(object)val == (Object)null) { continue; } List<MeshRenderer> list = new List<MeshRenderer>(); MeshFilter[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshFilter>(true); if (componentsInChildren != null && componentsInChildren.Length != 0) { MeshFilter[] array2 = componentsInChildren; foreach (MeshFilter val2 in array2) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sharedMesh == (Object)null)) { GameObject val3 = new GameObject("LethalDirector_VentHighlight"); val3.transform.SetParent(((Component)val2).transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = Vector3.one * 1.03f; val3.AddComponent<MeshFilter>().sharedMesh = val2.sharedMesh; MeshRenderer val4 = val3.AddComponent<MeshRenderer>(); ((Renderer)val4).sharedMaterial = _matVentFree; ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val4).receiveShadows = false; ((Renderer)val4).allowOcclusionWhenDynamic = false; list.Add(val4); } } } else { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "LethalDirector_VentHighlight"; Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.transform.SetParent(((Component)val).transform, false); obj.transform.localPosition = Vector3.zero; obj.transform.localScale = new Vector3(1.1f, 0.9f, 0.35f); MeshRenderer component = obj.GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = _matVentFree; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; ((Renderer)component).allowOcclusionWhenDynamic = false; list.Add(component); } _ventHighlights[val] = list; } } private void UpdateVentHighlights(Vector3 directorPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) _cachedNearestVentIndex = DirectorManager.FindNearestVentIndex(directorPos); if (!ConfigManager.ShowVentHighlight.Value) { if (_ventHighlights.Count > 0) { ClearVentHighlights(); } return; } EnemyVent[] allVents = DirectorManager.GetAllVents(); if (allVents == null || allVents.Length == 0) { return; } if (_ventHighlights.Count == 0) { RefreshVentHighlights(); } for (int i = 0; i < allVents.Length; i++) { EnemyVent val = allVents[i]; if ((Object)(object)val == (Object)null || !_ventHighlights.TryGetValue(val, out var value)) { continue; } Material val2 = (val.occupied ? _matVentOccupied : ((i == _cachedNearestVentIndex) ? _matVentNearest : _matVentFree)); foreach (MeshRenderer item in value) { if ((Object)(object)item != (Object)null && (Object)(object)((Renderer)item).sharedMaterial != (Object)(object)val2) { ((Renderer)item).sharedMaterial = val2; } } } } public void ClearVentHighlights() { foreach (KeyValuePair<EnemyVent, List<MeshRenderer>> ventHighlight in _ventHighlights) { if (ventHighlight.Value == null) { continue; } foreach (MeshRenderer item in ventHighlight.Value) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)((Component)item).gameObject); } } } _ventHighlights.Clear(); } } public static class DirectorHighlights { private sealed class HighlightSet { public readonly List<Renderer> Sources = new List<Renderer>(); public readonly List<Renderer> Overlays = new List<Renderer>(); public int State = -1; } public static readonly Color ColEnemy = new Color(0.2f, 1f, 0.35f, 0.45f); public static readonly Color ColSelected = new Color(1f, 0.85f, 0.1f, 0.6f); public static readonly Color ColOrdered = new Color(1f, 0.2f, 0.15f, 0.6f); public static readonly Color ColPlayer = new Color(1f, 1f, 1f, 0.75f); private const string OverlayName = "LethalDirector_Highlight"; private static readonly Dictionary<EnemyAI, HighlightSet> _enemies = new Dictionary<EnemyAI, HighlightSet>(); private static readonly Dictionary<PlayerControllerB, HighlightSet> _players = new Dictionary<PlayerControllerB, HighlightSet>(); private static Material _matEnemy; private static Material _matSelected; private static Material _matOrdered; private static Material _matPlayer; private static bool _materialsTried; private static float _syncTimer; public static float LastPingTime { get; private set; } = -999f; public static float PingDuration => Mathf.Max(0.5f, ConfigManager.EffectivePlayerPingDuration); public static float PingInterval => Mathf.Max(PingDuration + 0.5f, ConfigManager.EffectivePlayerPingInterval); public static bool IsPingActive => Time.time - LastPingTime < PingDuration; public static float PingFade { get { if (!IsPingActive) { return 0f; } return 1f - (Time.time - LastPingTime) / PingDuration; } } public static float NextPingIn => Mathf.Max(0f, PingInterval - (Time.time - LastPingTime)); public static void Tick(float deltaTime) { EnsureMaterials(); if (!((Object)(object)_matEnemy == (Object)null)) { _syncTimer += deltaTime; if (_syncTimer >= 0.5f) { _syncTimer = 0f; SyncEnemies(); SyncPlayers(); } UpdateEnemies(); UpdatePing(); } } public static void ClearAll() { foreach (HighlightSet value in _enemies.Values) { DestroySet(value); } foreach (HighlightSet value2 in _players.Values) { DestroySet(value2); } _enemies.Clear(); _players.Clear(); LastPingTime = -999f; } private static void SyncEnemies() { if (!ConfigManager.ShowEnemyHighlights.Value) { foreach (HighlightSet value in _enemies.Values) { DestroySet(value); } _enemies.Clear(); return; } List<EnemyAI> list = new List<EnemyAI>(); foreach (KeyValuePair<EnemyAI, HighlightSet> enemy in _enemies) { if ((Object)(object)enemy.Key == (Object)null || enemy.Key.isEnemyDead) { DestroySet(enemy.Value); list.Add(enemy.Key); } } foreach (EnemyAI item in list) { _enemies.Remove(item); } foreach (EnemyAI aliveEnemy in EnemyCommandManager.GetAliveEnemies()) { if (!((Object)(object)aliveEnemy == (Object)null) && !_enemies.ContainsKey(aliveEnemy)) { _enemies[aliveEnemy] = BuildSet(((Component)aliveEnemy).GetComponentsInChildren<Renderer>(true), _matEnemy); } } } private static void UpdateEnemies() { foreach (KeyValuePair<EnemyAI, HighlightSet> enemy in _enemies) { EnemyAI key = enemy.Key; if (!((Object)(object)key == (Object)null)) { HighlightSet value = enemy.Value; ulong networkObjectId = ((NetworkBehaviour)key).NetworkObjectId; EnemyCommandManager.EnemyCommand command; bool num = EnemyCommandManager.TryGet(networkObjectId, out command); bool flag = EnemyCommandManager.HasSelection && EnemyCommandManager.SelectedEnemyId == networkObjectId; int num2 = (num ? 2 : (flag ? 1 : 0)); if (value.State != num2) { value.State = num2; SetMaterial(value, (Material)(num2 switch { 1 => _matSelected, 2 => _matOrdered, _ => _matEnemy, })); } SyncVisibility(value, visible: true); } } } private static void SyncPlayers() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } List<PlayerControllerB> list = new List<PlayerControllerB>(); foreach (KeyValuePair<PlayerControllerB, HighlightSet> player in _players) { PlayerControllerB key = player.Key; if ((Object)(object)key == (Object)null || !key.isPlayerControlled || key.actualClientId == DirectorManager.DirectorClientId) { DestroySet(player.Value); list.Add(key); } } foreach (PlayerControllerB item in list) { _players.Remove(item); } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && val.actualClientId != DirectorManager.DirectorClientId && !_players.ContainsKey(val)) { List<Renderer> list2 = new List<Renderer>(); if ((Object)(object)val.thisPlayerModel != (Object)null) { list2.Add((Renderer)(object)val.thisPlayerModel); } _players[val] = BuildSet(list2, _matPlayer); } } } private static void UpdatePing() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (Time.time - LastPingTime >= PingInterval) { LastPingTime = Time.time; PlayPingSound(); } bool isPingActive = IsPingActive; if (isPingActive) { Color colPlayer = ColPlayer; colPlayer.a *= PingFade; XRayMaterials.SetColor(_matPlayer, colPlayer); } foreach (KeyValuePair<PlayerControllerB, HighlightSet> player in _players) { if (!((Object)(object)player.Key == (Object)null)) { SyncVisibility(player.Value, isPingActive && !player.Key.isPlayerDead); } } } private static void PlayPingSound() { try { HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null)) { Traverse obj = Traverse.Create((object)instance); AudioClip value = obj.Field("scanSFX").GetValue<AudioClip>(); AudioSource value2 = obj.Field("UIAudio").GetValue<AudioSource>(); if ((Object)(object)value != (Object)null && (Object)(object)value2 != (Object)null) { value2.PlayOneShot(value, 0.7f); } } } catch { } } private static void EnsureMaterials() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!_materialsTried) { _materialsTried = true; _matEnemy = XRayMaterials.Create(ColEnemy); _matSelected = XRayMaterials.Create(ColSelected); _matOrdered = XRayMaterials.Create(ColOrdered); _matPlayer = XRayMaterials.Create(ColPlayer); } } private static HighlightSet BuildSet(IEnumerable<Renderer> sources, Material mat) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) HighlightSet highlightSet = new HighlightSet(); foreach (Renderer source in sources) { if ((Object)(object)source == (Object)null || ((Object)((Component)source).gameObject).name == "LethalDirector_Highlight") { continue; } Renderer val = null; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((source is SkinnedMeshRenderer) ? source : null); if (val2 != null) { if ((Object)(object)val2.sharedMesh == (Object)null) { continue; } SkinnedMeshRenderer obj = CreateOverlayObject(((Component)val2).transform, ((Component)val2).gameObject.layer).AddComponent<SkinnedMeshRenderer>(); obj.sharedMesh = val2.sharedMesh; obj.bones = val2.bones; obj.rootBone = val2.rootBone; ((Renderer)obj).localBounds = ((Renderer)val2).localBounds; obj.updateWhenOffscreen = true; ((Renderer)obj).sharedMaterials = FillMaterials(mat, val2.sharedMesh.subMeshCount); val = (Renderer)(object)obj; } else { MeshRenderer val3 = (MeshRenderer)(object)((source is MeshRenderer) ? source : null); if (val3 != null) { MeshFilter component = ((Component)val3).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { continue; } GameObject obj2 = CreateOverlayObject(((Component)val3).transform, ((Component)val3).gameObject.layer); obj2.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh; MeshRenderer obj3 = obj2.AddComponent<MeshRenderer>(); ((Renderer)obj3).sharedMaterials = FillMaterials(mat, component.sharedMesh.subMeshCount); val = (Renderer)(object)obj3; } } if (!((Object)(object)val == (Object)null)) { val.shadowCastingMode = (ShadowCastingMode)0; val.receiveShadows = false; val.allowOcclusionWhenDynamic = false; val.enabled = source.enabled; highlightSet.Sources.Add(source); highlightSet.Overlays.Add(val); } } return highlightSet; } private static GameObject CreateOverlayObject(Transform parent, int layer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown GameObject val = new GameObject("LethalDirector_Highlight") { layer = layer }; val.transform.SetParent(parent, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; return val; } private static Material[] FillMaterials(Material mat, int count) { Material[] array = (Material[])(object)new Material[Mathf.Max(1, count)]; for (int i = 0; i < array.Length; i++) { array[i] = mat; } return array; } private static void SetMaterial(HighlightSet set, Material mat) { foreach (Renderer overlay in set.Overlays) { if (!((Object)(object)overlay == (Object)null)) { Material[] sharedMaterials = overlay.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { sharedMaterials[i] = mat; } overlay.sharedMaterials = sharedMaterials; } } } private static void SyncVisibility(HighlightSet set, bool visible) { for (int i = 0; i < set.Overlays.Count; i++) { Renderer val = set.Overlays[i]; Renderer val2 = set.Sources[i]; if (!((Object)(object)val == (Object)null)) { bool flag = visible && (Object)(object)val2 != (Object)null && val2.enabled; if (val.enabled != flag) { val.enabled = flag; } } } } private static void DestroySet(HighlightSet set) { if (set == null) { return; } foreach (Renderer overlay in set.Overlays) { if ((Object)(object)overlay != (Object)null) { Object.Destroy((Object)(object)((Component)overlay).gameObject); } } set.Overlays.Clear(); set.Sources.Clear(); } } public struct SpawnEntryInfo { public int CatalogIndex; public int NativeLevelIndex; public EnemyType EnemyType; public string DisplayName; public float SpawnPercentage; public int BasePrice; public int FinalPrice; public bool IsOutside; public bool IsOffMoon; } public static class DirectorManager { public const ulong NoDirectorId = ulong.MaxValue; public const int TrickCutLights = 1; public const int TrickSteamValves = 2; public const int TrickAmbientSound = 3; public const int TrickMeteorShower = 4; private static bool _hadLivingSurvivorThisRound; private static float _creditSyncTimer; private static bool _cullingDisabledThisRound; private static float _originalFarClipPlane = -1f; private static readonly Dictionary<ulong, List<Renderer>> _hiddenRenderers = new Dictionary<ulong, List<Renderer>>(); private static int _pendingVentSpawns; private static int _enemyCountCache; private static float _enemyCountCacheTime = -10f; public static ulong DirectorClientId { get; private set; } = ulong.MaxValue; public static bool IsRoundActive { get; private set; } public static float Credits { get; set; } public static float CurrentCreditsPerSecond { get; private set; } public static int CurrentHour24 { get; private set; } = 8; public static float MoonMultiplier { get; private set; } = 1f; public static int CurrentMoonTotalPower { get; private set; } public static List<SpawnEntryInfo> InsideEnemies { get; } = new List<SpawnEntryInfo>(); public static List<SpawnEntryInfo> OutsideEnemies { get; } = new List<SpawnEntryInfo>(); public static float LandedAtTime { get; private set; } = -1f; public static int EnemiesSpawnedThisRound { get; private set; } public static int CreditsSpentThisRound { get; private set; } public static bool HasDirector => DirectorClientId != ulong.MaxValue; public static bool IsDirectorActive { get { if (HasDirector) { return IsRoundActive; } return false; } } public static bool IsLocalPlayerDirector { get { if (!HasDirector || (Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) { return false; } return StartOfRound.Instance.localPlayerController.actualClientId == DirectorClientId; } } public static float GraceRemaining { get { float effectiveGracePeriodSeconds = ConfigManager.EffectiveGracePeriodSeconds; if (effectiveGracePeriodSeconds <= 0f) { return 0f; } if (LandedAtTime < 0f) { return effectiveGracePeriodSeconds; } return Mathf.Max(0f, effectiveGracePeriodSeconds - (Time.time - LandedAtTime)); } } public static bool IsInGracePeriod => GraceRemaining > 0f; public static bool IsEnemyCapReached { get { int effectiveMaxAliveEnemies = ConfigManager.EffectiveMaxAliveEnemies; if (effectiveMaxAliveEnemies > 0) { return CountAliveEnemies() >= effectiveMaxAliveEnemies; } return false; } } public static bool IsActiveDirector(PlayerControllerB player) { if (!HasDirector || (Object)(object)player == (Object)null || player.actualClientId != DirectorClientId) { return false; } if (IsRoundActive) { return true; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null) { return !instance.inShipPhase; } return false; } public static PlayerControllerB GetDirectorPlayer() { if (!HasDirector || (Object)(object)StartOfRound.Instance == (Object)null) { return null; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.isPlayerControlled && val.actualClientId == DirectorClientId) { return val; } } return null; } public static string GetDirectorName() { PlayerControllerB directorPlayer = GetDirectorPlayer(); if (!((Object)(object)directorPlayer != (Object)null)) { return "None"; } return directorPlayer.playerUsername; } public static void SetDirectorClientId(ulong clientId) { if (DirectorClientId != ulong.MaxValue && DirectorClientId != clientId) { RestorePlayerVisuals(DirectorClientId); } DirectorClientId = clientId; Plugin.Log.LogInfo((object)$"[Director] Set to: {GetDirectorName()} (ClientId={clientId})"); } public static void OnRoundStarted() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) IsRoundActive = true; Credits = UpgradeManager.DirectorStartCredits; CurrentCreditsPerSecond = 0f; CurrentHour24 = 8; _hadLivingSurvivorThisRound = false; _creditSyncTimer = 0f; _cullingDisabledThisRound = false; LandedAtTime = -1f; EnemiesSpawnedThisRound = 0; CreditsSpentThisRound = 0; _pendingVentSpawns = 0; if (NetworkSync.IsHost) { NetworkSync.BroadcastConfig(); } CalculateMoonMultiplier(); RebuildEnemyCatalog(); if (!HasDirector) { return; } ApplyDirectorVisibilityToAll(); if (IsLocalPlayerDirector) { DirectorController.Instance?.EnterDirectorMode(); HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("DIRECTOR MODE ACTIVE", $"[{ConfigManager.MenuKey.Value}] Menu | [{ConfigManager.NightVisionKey.Value}] Night Vision | [{ConfigManager.TeleportPlayerKey.Value}] TP Player | Scroll: Speed", false, false, "LC_Tip1"); } } } public static void OnLevelGenerated() { CalculateMoonMultiplier(); RebuildEnemyCatalog(); if (IsDirectorActive && IsLocalPlayerDirector) { _cullingDisabledThisRound = false; ApplyRoomCullingForDirector(); DirectorController.Instance?.RefreshVentHighlights(); } } public static void OnReturnToOrbit(bool shipLeaving = false) { if (shipLeaving) { MatchManager.OnShipLeaving(); } LandedAtTime = -1f; EnemyCommandManager.ClearAll(); DirectorController instance = DirectorController.Instance; if ((Object)(object)instance != (Object)null && instance.IsInDirectorMode) { instance.ExitDirectorMode(shipLeaving && IsLocalPlayerDirector); } RestoreAllVisuals(); RestoreRoomCulling(); IsRoundActive = false; Credits = 0f; _hadLivingSurvivorThisRound = false; _cullingDisabledThisRound = false; InsideEnemies.Clear(); OutsideEnemies.Clear(); } public static void CalculateMoonMultiplier() { MoonMultiplier = 1f; CurrentMoonTotalPower = 0; if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.currentLevel != (Object)null) { SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; CurrentMoonTotalPower = Mathf.Max(1, currentLevel.maxEnemyPowerCount + currentLevel.maxOutsideEnemyPowerCount); float num = Mathf.Max(1f, ConfigManager.EffectiveMoonPowerDivisor); MoonMultiplier = Mathf.Max(0.05f, (float)CurrentMoonTotalPower / num); } } public static void RebuildEnemyCatalog() { InsideEnemies.Clear(); OutsideEnemies.Clear(); if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null) { return; } SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; SelectableLevel[] levels = StartOfRound.Instance.levels; Dictionary<EnemyType, (int, int)> dictionary = new Dictionary<EnemyType, (int, int)>(); Dictionary<EnemyType, (int, int)> dictionary2 = new Dictionary<EnemyType, (int, int)>(); if (currentLevel.Enemies != null) { for (int i = 0; i < currentLevel.Enemies.Count; i++) { SpawnableEnemyWithRarity val = currentLevel.Enemies[i]; if ((Object)(object)val?.enemyType?.enemyPrefab != (Object)null && val.rarity > 0 && !dictionary.ContainsKey(val.enemyType)) { dictionary[val.enemyType] = (val.rarity, i); } } } if (currentLevel.OutsideEnemies != null) { for (int j = 0; j < currentLevel.OutsideEnemies.Count; j++) { SpawnableEnemyWithRarity val2 = currentLevel.OutsideEnemies[j]; if ((Object)(object)val2?.enemyType?.enemyPrefab != (Object)null && val2.rarity > 0 && !dictionary2.ContainsKey(val2.enemyType)) { dictionary2[val2.enemyType] = (val2.rarity, j); } } } int count = dictionary.Count; int count2 = dictionary2.Count; if (levels != null) { SelectableLevel[] array = levels; foreach (SelectableLevel val3 in array) { if ((Object)(object)val3 == (Object)null) { continue; } if (val3.Enemies != null) { foreach (SpawnableEnemyWithRarity enemy in val3.Enemies) { if ((Object)(object)enemy?.enemyType?.enemyPrefab != (Object)null && !dictionary.ContainsKey(enemy.enemyType)) { dictionary[enemy.enemyType] = (-1, -1); } } } if (val3.OutsideEnemies == null) { continue; } foreach (SpawnableEnemyWithRarity outsideEnemy in val3.OutsideEnemies) { if ((Object)(object)outsideEnemy?.enemyType?.enemyPrefab != (Object)null && !dictionary2.ContainsKey(outsideEnemy.enemyType)) { dictionary2[outsideEnemy.enemyType] = (-1, -1); } } } } BuildCatalogList(dictionary, InsideEnemies, isOutside: false, count); BuildCatalogList(dictionary2, OutsideEnemies, isOutside: true, count2); } private static void BuildCatalogList(Dictionary<EnemyType, (int rarity, int nativeIndex)> source, List<SpawnEntryInfo> target, bool isOutside, int nativeCount) { float num = 0f; foreach (KeyValuePair<EnemyType, (int, int)> item3 in source) { if (item3.Value.Item1 > 0) { num += (float)item3.Value.Item1; } } if (num <= 0f) { num = 100f; } float num2 = 100f / (float)Mathf.Max(1, nativeCount); float effectiveMinPriceMultiplier = ConfigManager.EffectiveMinPriceMultiplier; float effectiveMaxPriceMultiplier = ConfigManager.EffectiveMaxPriceMultiplier; float num3 = Mathf.Max(1f, ConfigManager.EffectiveOffMoonPriceMultiplier); foreach (KeyValuePair<EnemyType, (int, int)> item4 in source) { EnemyType key = item4.Key; int item = item4.Value.Item1; int item2 = item4.Value.Item2; bool flag = item < 0; int basePrice = ConfigManager.GetBasePrice(key); float num4 = 0f; int finalPrice; if (flag) { finalPrice = Mathf.Max(1, Mathf.RoundToInt((float)basePrice * num3 * UpgradeManager.MonsterCostMultiplier)); } else { num4 = (float)item / num * 100f; float num5 = Mathf.Clamp(Mathf.Sqrt(num2 / Mathf.Max(0.01f, num4)), effectiveMinPriceMultiplier, effectiveMaxPriceMultiplier); finalPrice = Mathf.Max(1, Mathf.RoundToInt((float)basePrice * num5 * UpgradeManager.MonsterCostMultiplier)); } target.Add(new SpawnEntryInfo { CatalogIndex = 0, NativeLevelIndex = item2, EnemyType = key, DisplayName = key.enemyName, SpawnPercentage = num4, BasePrice = basePrice, FinalPrice = finalPrice, IsOutside = isOutside, IsOffMoon = flag }); } target.Sort(delegate(SpawnEntryInfo a, SpawnEntryInfo b) { int num7 = a.IsOffMoon.CompareTo(b.IsOffMoon); if (num7 != 0) { return num7; } num7 = a.FinalPrice.CompareTo(b.FinalPrice); return (num7 != 0) ? num7 : string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase); }); for (int num6 = 0; num6 < target.Count; num6++) { SpawnEntryInfo value = target[num6]; value.CatalogIndex = num6; target[num6] = value; } } public static void TickRound(float deltaTime) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } if (!IsRoundActive && instance.shipHasLanded && !instance.shipIsLeaving) { OnRoundStarted(); } if (!IsDirectorActive) { return; } if (LandedAtTime < 0f && instance.shipHasLanded && !instance.shipIsLeaving) { LandedAtTime = Time.time; } ApplyDirectorVisibilityToAll(); if (IsLocalPlayerDirector && !_cullingDisabledThisRound && StartOfRound.Instance.shipHasLanded) { ApplyRoomCullingForDirector(); } if (!((Object)(object)TimeOfDay.Instance != (Object)null) || !StartOfRound.Instance.shipHasLanded || StartOfRound.Instance.shipIsLeaving) { return; } CurrentHour24 = ((int)(TimeOfDay.Instance.normalizedTimeOfDay * (60f * (float)TimeOfDay.Instance.numberOfHours)) + 360) / 60; CurrentCreditsPerSecond = (float)Mathf.Max(1, CurrentHour24 - 7) * MoonMultiplier * ConfigManager.EffectiveCreditMultiplier * UpgradeManager.DirectorCreditMultiplier; Credits += CurrentCreditsPerSecond * deltaTime; if (NetworkSync.IsHost) { UpgradeManager.TickHostRound(); } if (NetworkSync.IsHost) { _creditSyncTimer += deltaTime; if (_creditSyncTimer >= 1f) { _creditSyncTimer = 0f; NetworkSync.BroadcastCredits(Credits); } } CheckSurvivorsWipe(); } private static void CheckSurvivorsWipe() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.inShipPhase || !instance.shipHasLanded || instance.shipIsLeaving || instance.allPlayersDead) { return; } int num = 0; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && val.actualClientId != DirectorClientId && !val.isPlayerDead) { num++; } } if (num > 0) { _hadLivingSurvivorThisRound = true; } else if (_hadLivingSurvivorThisRound) { Plugin.Log.LogInfo((object)"[Director] All survivors dead: triggering ship departure."); instance.livingPlayers = 0; instance.allPlayersDead = true; instance.ShipLeaveAutomatically(false); } } public static EnemyVent[] GetAllVents() { if ((Object)(object)RoundManager.Instance != (Object)null && RoundManager.Instance.allEnemyVents != null && RoundManager.Instance.allEnemyVents.Length != 0) { return RoundManager.Instance.allEnemyVents; } if (IsDirectorActive && (Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.shipHasLanded) { EnemyVent[] array = Object.FindObjectsOfType<EnemyVent>(); if (array != null && array.Length != 0 && (Object)(object)RoundManager.Instance != (Object)null) { RoundManager.Instance.allEnemyVents = array; } return array; } return Array.Empty<EnemyVent>(); } public static int FindNearestVentIndex(Vector3 fromPosition) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) EnemyVent[] allVents = GetAllVents(); if (allVents == null || allVents.Length == 0) { return -1; } int num = -1; float num2 = float.MaxValue; int result = -1; float num3 = float.MaxValue; for (int i = 0; i < allVents.Length; i++) { EnemyVent val = allVents[i]; if (!((Object)(object)val == (Object)null) && !val.occupied) { float num4 = Vector3.SqrMagnitude(((Component)val).transform.position - fromPosition); if (!IsVentOpen(val) && num4 < num2) { num2 = num4; num = i; } if (num4 < num3) { num3 = num4; result = i; } } } if (num == -1) { return result; } return num; } public static bool IsVentOpen(EnemyVent vent) { if ((Object)(object)vent == (Object)null) { return false; } return Traverse.Create((object)vent).Field("ventIsOpen").GetValue<bool>(); } public static void ResetVentStateLocal(int ventIndex) { EnemyVent[] allVents = GetAllVents(); if (allVents == null || ventIndex < 0 || ventIndex >= allVents.Length) { return; } EnemyVent val = allVents[ventIndex]; if (!((Object)(object)val == (Object)null)) { Traverse obj = Traverse.Create((object)val); obj.Field("ventIsOpen").SetValue((object)false); obj.Field("isPlayingAudio").SetValue((object)false); if ((Object)(object)val.ventAnimator != (Object)null) { val.ventAnimator.SetBool("openVent", false); } } } public static int FindVentIndexByPosition(Vector3 position, float maxDistance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) EnemyVent[] allVents = GetAllVents(); if (allVents == null) { return -1; } int result = -1; float num = maxDistance * maxDistance; for (int i = 0; i < allVents.Length; i++) { if (!((Object)(object)allVents[i] == (Object)null)) { Vector3 val = ((Component)allVents[i]).transform.position - position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; result = i; } } } return result; } public static void ServerSpawnRandomFree() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (!NetworkSync.IsHost || !IsDirectorActive) { return; } List<SpawnEntryInfo> list = InsideEnemies.FindAll((SpawnEntryInfo e) => !e.IsOffMoon && (Object)(object)e.EnemyType != (Object)null); EnemyVent[] allVents = GetAllVents(); List<EnemyVent> list2 = new List<EnemyVent>(); if (allVents != null) { EnemyVent[] array = allVents; foreach (EnemyVent val in array) { if ((Object)(object)val != (Object)null && !val.occupied) { list2.Add(val); } } } if (list.Count > 0 && list2.Count > 0) { SpawnEntryInfo spawnEntryInfo = list[Random.Range(0, list.Count)]; EnemyVent val2 = list2[Random.Range(0, list2.Count)]; ServerTrySpawnEnemy(isOutside: false, spawnEntryInfo.EnemyType.enemyName, ((Component)val2).transform.position, free: true); return; } List<SpawnEntryInfo> list3 = OutsideEnemies.FindAll((SpawnEntryInfo e) => !e.IsOffMoon && (Object)(object)e.EnemyType != (Object)null); if (list3.Count > 0) { ServerTrySpawnEnemy(isOutside: true, list3[Random.Range(0, list3.Count)].EnemyType.enemyName, Vector3.zero, free: true); } } public static bool ServerTrySpawnEnemy(bool isOutside, string enemyName, Vector3 requestedVentPos, bool free = false) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) if (!NetworkSync.IsHost || !IsDirectorActive) { return false; } if ((Object)(object)RoundManager.Instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { return false; } if (!free && (IsInGracePeriod || IsEnemyCapReached)) { return false; } List<SpawnEntryInfo> list = (isOutside ? OutsideEnemies : InsideEnemies); int num = list.FindIndex((SpawnEntryInfo e) => (Object)(object)e.EnemyType != (Object)null && string.Equals(e.EnemyType.enemyName, enemyName, StringComparison.Ordinal)); if (num < 0) { Plugin.Log.LogWarning((object)("[Director] Spawn refusé : ennemi '" + enemyName + "' introuvable dans le catalogue de l'hôte.")); return false; } SpawnEntryInfo entry = list[num]; if (!free && Credits < (float)entry.FinalPrice) { return false; } if (!isOutside) { EnemyVent[] allVents = GetAllVents(); if (allVents == null || allVents.Length == 0) { return false; } int num2 = FindVentIndexByPosition(requestedVentPos, 3f); if (num2 < 0 || (Object)(object)allVents[num2] == (Object)null || allVents[num2].occupied) { PlayerControllerB directorPlayer = GetDirectorPlayer(); num2 = FindNearestVentIndex(((Object)(object)directorPlayer != (Object)null) ? ((Component)directorPlayer).transform.position : Vector3.zero); } if (num2 < 0 || num2 >= allVents.Length) { return false; } EnemyVent val = allVents[num2]; if ((Object)(object)val == (Object)null || val.occupied) { return false; } if (IsVentOpen(val)) { NetworkSync.BroadcastResetVent(((Component)val).transform.position); } float num3 = Mathf.Max(0.5f, ConfigManager.VentSpawnDelaySeconds.Value); float num4 = (((Object)(object)TimeOfDay.Instance != (Object)null) ? TimeOfDay.Instance.globalTimeSpeedMultiplier : 1.4f); int num5 = Mathf.RoundToInt((((Object)(object)TimeOfDay.Instance != (Object)null) ? TimeOfDay.Instance.currentDayTime : 0f) + (num3 + 8f) * num4); int num6 = 0; List<SpawnableEnemyWithRarity> list2 = StartOfRound.Instance.currentLevel?.Enemies; if (list2 != null && list2.Count > 0) { if (!entry.IsOffMoon && entry.NativeLevelIndex >= 0 && entry.NativeLevelIndex < list2.Count) { num6 = entry.NativeLevelIndex; } val.SyncVentSpawnTimeClientRpc(num5, num6); } Traverse obj = Traverse.Create((object)val); obj.Field("enemyType").SetValue((object)entry.EnemyType); obj.Field("enemyTypeIndex").SetValue((object)num6); obj.Field("spawnTime").SetValue((object)(float)num5); obj.Field("ventIsOpen").SetValue((object)false); obj.Field("isPlayingAudio").SetValue((object)false); val.occupied = true; if (!free) { Credits -= entry.FinalPrice; EnemiesSpawnedThisRound++; CreditsSpentThisRound += entry.FinalPrice; NetworkSync.BroadcastCredits(Credits); } ((MonoBehaviour)(((Object)(object)DirectorController.Instance != (Object)null) ? DirectorController.Instance : ((DirectorController)(object)RoundManager.Instance))).StartCoroutine(CompleteVentSpawnRoutine(val, entry, num3)); Plugin.Log.LogInfo((object)$"[Director] Scheduled inside spawn: {entry.DisplayName} (OffMoon={entry.IsOffMoon}) at vent #{num2}."); return true; } GameObject[] array = RoundManager.Instance.outsideAINodes; if (array == null || array.Length == 0) { array = GameObject.FindGameObjectsWithTag("OutsideAINode"); } if (array == null || array.Length == 0) { return false; } Vector3 position = array[Random.Range(0, array.Length)].transform.position; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val2, 15f, -1)) { position = ((NavMeshHit)(ref val2)).position; } GameObject obj2 = Object.Instantiate<GameObject>(entry.EnemyType.enemyPrefab, position, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); NetworkObject componentInChildren = obj2.GetComponentInChildren<NetworkObject>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.Spawn(true); } EnemyAI componentInChildren2 = obj2.GetComponentInChildren<EnemyAI>(); if ((Object)(object)componentInChildren2 != (Object)null) { RoundManager.Instance.SpawnedEnemies.Add(componentInChildren2); } if (!free) { Credits -= entry.FinalPrice; EnemiesSpawnedThisRound++; CreditsSpentThisRound += entry.FinalPrice; NetworkSync.BroadcastCredits(Credits); } Plugin.Log.LogInfo((object)$"[Director] Spawned outside: {entry.DisplayName} at {position}."); return true; } private static IEnumerator CompleteVentSpawnRoutine(EnemyVent vent, SpawnEntryInfo entry, float delay) { _pendingVentSpawns++; try { yield return (object)new WaitForSeconds(delay); if (IsDirectorActive && NetworkSync.IsHost && !((Object)(object)vent == (Object)null) && !((Object)(object)StartOfRound.Instance == (Object)null) && !StartOfRound.Instance.inShipPhase && !StartOfRound.Instance.shipIsLeaving && vent.occupied) { Vector3 val = (((Object)(object)vent.floorNode != (Object)null) ? vent.floorNode.position : ((Component)vent).transform.position); Quaternion val2 = (((Object)(object)vent.floorNode != (Object)null) ? vent.floorNode.rotation : ((Component)vent).transform.rotation); NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val3, 5f, -1)) { val = ((NavMeshHit)(ref val3)).position; } GameObject obj = Object.Instantiate<GameObject>(entry.EnemyType.enemyPrefab, val, val2); NetworkObject componentInChildren = obj.GetComponentInChildren<NetworkObject>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.Spawn(true); } EnemyAI componentInChildren2 = obj.GetComponentInChildren<EnemyAI>(); if ((Object)(object)componentInChildren2 != (Object)null && (Object)(object)RoundManager.Instance != (Object)null) { RoundManager.Instance.SpawnedEnemies.Add(componentInChildren2); } vent.OpenVentClientRpc(); vent.occupied = false; } } finally { _pendingVentSpawns = Mathf.Max(0, _pendingVentSpawns - 1); _enemyCountCacheTime = -10f; } } public static int CountAliveEnemies() { if (Time.time - _enemyCountCacheTime >= 0.5f) { int num = 0; EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(); foreach (EnemyAI val in array) { if ((Object)(object)val != (Object)null && !val.isEnemyDead) { num++; } } _enemyCountCache = num; _enemyCountCacheTime = Time.time; } return _enemyCountCache + _pendingVentSpawns; } public static void SpendCredits(int amount) { if (NetworkSync.IsHost && amount > 0) { Credits = Mathf.Max(0f, Credits - (float)amount); CreditsSpentThisRound += amount; NetworkSync.BroadcastCredits(Credits); } } public static int GetTrickCost(int trickId) { return Mathf.Max(0, Mathf.RoundToInt((float)(trickId switch { 1 => ConfigManager.EffectiveTrickCutLightsCost, 2 => ConfigManager.EffectiveTrickSteamValvesCost, 3 => ConfigManager.EffectiveTrickAmbientSoundCost, 4 => ConfigManager.EffectiveTrickMeteorShowerCost, _ => 0, }) * UpgradeManager.TrickCostMultiplier)); } public static bool ServerTriggerTrick(int trickId) { if (!NetworkSync.IsHost || !IsDirectorActive) { return false; } if ((Object)(object)StartOfRound.Instance == (Object)null || !StartOfRound.Instance.shipHasLanded || StartOfRound.Instance.shipIsLeaving) { return false; } if (IsInGracePeriod) { return false; } int trickCost = GetTrickCost(trickId); if (Credits < (float)trickCost) { return false; } int num = trickId switch { 1 => ServerExecuteCutLights() ? 1 : 0, 2 => ServerExecuteSteamValves() ? 1 : 0, 3 => ServerExecuteAmbientSound() ? 1 : 0, 4 => ServerExecuteMeteorShower() ? 1 : 0, _ => 0, }; if (num != 0) { Credits -= trickCost; CreditsSpentThisRound += trickCost; NetworkSync.BroadcastCredits(Credits); } return (byte)num != 0; } private static bool ServerExecuteCutLights() { BreakerBox val = Object.FindObjectOfType<BreakerBox>(); if ((Object)(object)val == (Object)null || !val.isPowerOn) { return false; } NetworkSync.BroadcastTrickEffect(1); Plugin.Log.LogInfo((object)"[Director Trick] Cut facility lights via BreakerBox."); return true; } private static SteamValveHazard[] GetSortedSteamValves() { SteamValveHazard[] array = Object.FindObjectsOfType<SteamValveHazard>(); if (array == null || array.Length == 0) { return Array.Empty<SteamValveHazard>(); } Array.Sort(array, delegate(SteamValveHazard a, SteamValveHazard b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)a).transform.position; Vector3 position2 = ((Component)b).transform.position; int num = position.x.CompareTo(position2.x); if (num != 0) { return num; } num = position.y.CompareTo(position2.y); return (num != 0) ? num : position.z.CompareTo(position2.z); }); return array; } private static bool ServerExecuteSteamValves() { SteamValveHazard[] sortedSteamValves = GetSortedSteamValves(); if (sortedSteamValves.Length == 0) { return false; } List<int> list = new List<int>(); for (int i = 0; i < sortedSteamValves.Length; i++) { SteamValveHazard val = sortedSteamValves[i]; if (!((Object)(object)val == (Object)null)) { Traverse obj = Traverse.Create((object)val); bool value = obj.Field("valveHasBurst").GetValue<bool>(); bool value2 = obj.Field("valveHasBeenRepaired").GetValue<bool>(); if (!value && !value2) { list.Add(i); } } } if (list.Count == 0) { return false; } for (int num = list.Count - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); List<int> list2 = list; int index = num; int index2 = num2; int value3 = list[num2]; int value4 = list[num]; list2[index] = value3; list[index2] = value4; } int num3 = Mathf.Min(3, list.Count); List<int> range = list.GetRange(0, num3); string text = string.Join(",", range); NetworkSync.BroadcastTrickEffect(2, text); Plugin.Log.LogInfo((object)$"[Director Trick] Burst {num3} steam valve(s): [{text}]."); return true; } private static AudioClip[] GetInsideAmbientClips() { List<AudioClip> list = new List<AudioClip>(); object obj = null; if ((Object)(object)StartOfRound.Instance?.currentLevel != (Object)null) { obj = Traverse.Create((object)StartOfRound.Instance.currentLevel).Field("levelAmbienceClips").GetValue(); } if (obj == null && (Object)(object)SoundManager.Instance != (Object)null) { obj = Traverse.Create((object)SoundManager.Instance).Field("currentLevelAmbience").GetValue(); } if (obj != null) { Traverse val = Traverse.Create(obj); AudioClip[] value = val.Field("insideAmbience").GetValue<AudioClip[]>(); if (value != null) { AudioClip[] array = value; foreach (AudioClip val2 in array) { if ((Object)(object)val2 != (Object)null) { list.Add(val2); } } } if (val.Field("insideAmbienceInsanity").GetValue() is Array array2) { foreach (object item in array2) { if (item != null) { AudioClip value2 = Traverse.Create(item).Field("audioClip").GetValue<AudioClip>(); if ((Object)(object)value2 != (Object)null) { list.Add(value2); } } } } } return list.ToArray(); } private static bool ServerExecuteAmbientSound() { AudioClip[] insideAmbientClips = GetInsideAmbientClips(); if (insideAmbientClips.Length == 0) { return false; } int num = Random.Range(0, insideAmbientClips.Length); NetworkSync.BroadcastTrickEffect(3, num.ToString()); Plugin.Log.LogInfo((object)$"[Director Trick] Played ambient sound #{num} ({((Object)insideAmbientClips[num]).name})."); return true; } private static bool ServerExecuteMeteorShower() { TimeOfDay instance = TimeOfDay.Instance; if ((Object)(object)instance == (Object)null) { return false; } Type type = ((object)instance).GetType(); FieldInfo fieldInfo = type.GetField("meteorShowerActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetField("doingMeteorShower", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetField("activeMeteorShower", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo != null && fieldInfo.FieldType == typeof(bool) && (bool)fieldInfo.GetValue(instance)) { Plugin.Log.LogInfo((object)"[Director Trick] Meteor shower is already active."); return false; } FieldInfo field = type.GetField("meteorShowerAtTime", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(float)) { NetworkSync.BroadcastTrickEffect(4); Plugin.Log.LogInfo((object)"[Director Trick] Meteor shower triggered."); return true; } Plugin.Log.LogWarning((object)"[Director Trick] Meteor shower field not found in this Lethal Company version."); return false; } private static void ScheduleMeteorShowerLocal() { TimeOfDay instance = TimeOfDay.Instance; if ((Object)(object)instance == (Object)null) { return; } Type type = ((object)instance).GetType(); FieldInfo field = type.GetField("meteorShowerAtTime", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null) && !(field.FieldType != typeof(float))) { float num = Mathf.Clamp(instance.normalizedTimeOfDay - 0.001f, 0.001f, 0.98f); field.SetValue(instance, num); FieldInfo fieldInfo = type.GetField("meteorShowerOccurred", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetField("hasDoneMeteorShower", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo != null && fieldInfo.FieldType == typeof(bool)) { fieldInfo.SetValue(instance, false); } } } public static void ClientApplyTrickEffect(int trickId, string param) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) switch (trickId) { case 1: { BreakerBox val2 = Object.FindObjectOfType<BreakerBox>(); if ((Object)(object)val2 != (Object)null) { Traverse val3 = Traverse.Create((object)val2).Method("SetSwitchesOff", Array.Empty<object>()); if (val3.MethodExists()) { val3.GetValue(); } val2.isPowerOn = false; } if ((Object)(object)RoundManager.Instance != (Object)null) { RoundManager.Instance.SwitchPower(false); } break; } case 2: { if (string.IsNullOrEmpty(param)) { break; } SteamValveHazard[] sortedSteamValves = GetSortedSteamValves(); string[] array = param.Split(','); for (int i = 0; i < array.Length; i++) { if (int.TryParse(array[i], out var result) && result >= 0 && result < sortedSteamValves.Length) { SteamValveHazard val = sortedSteamValves[result]; if (!((Object)(object)val == (Object)null)) { Traverse obj = Traverse.Create((object)val); obj.Field("valveCrackTime").SetValue((object)0.0005f); obj.Field("valveBurstTime").Se