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 FacilityMeltdownFork v2.7.501
plugins/FacilityMeltdown/FacilityMeltdown.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.Globalization; using System.IO; using System.Linq; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Biodiversity.Util.Assetloading; using Dawn; using Diomedes.Client; using Diomedes.Client.API; using Diomedes.Client.GameMode.Bingo; using FacilityMeltdown.API; using FacilityMeltdown.Behaviours; using FacilityMeltdown.Config; using FacilityMeltdown.Integrations; using FacilityMeltdown.Integrations.SoundAPI; using FacilityMeltdown.Lang; using FacilityMeltdown.MeltdownSequence.Behaviours; using FacilityMeltdown.NetcodePatcher; using FacilityMeltdown.Patches; using FacilityMeltdown.Util; using FacilityMeltdown.Util.Attributes; using FacilityMeltdown.Util.Config; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Rendering.HighDefinition; using UnityEngine.UI; using WeatherRegistry; using loaforcsSoundAPI; using loaforcsSoundAPI.Core.Data; using loaforcsSoundAPI.SoundPacks.Data.Conditions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("WeatherRegistry")] [assembly: AssemblyCompany("FacilityMeltdown")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+393d76663855abc04213e7390adf082916838ff2")] [assembly: AssemblyProduct("FacilityMeltdown")] [assembly: AssemblyTitle("FacilityMeltdown")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 Biodiversity.Util.Assetloading { [AttributeUsage(AttributeTargets.Property)] internal class LoadFromBundleAttribute(string bundleFile) : Attribute() { public string BundleFile { get; private set; } = bundleFile; } } namespace FacilityMeltdown { public static class MeltdownKeys { public static readonly NamespacedKey<DawnItemInfo> GeigerCounter = NamespacedKey<DawnItemInfo>.From("facility_meltdown", "geiger_counter"); } public static class MeltdownTags { public static readonly NamespacedKey NotSpawnable = NamespacedKey.From("facility_meltdown", "meltdown_not_spawnable"); } [BepInPlugin("me.loaforc.facilitymeltdown", "FacilityMeltdown", "2.7.501")] [CompatibleDependency("ainavt.lc.lethalconfig", typeof(LethalConfigIntergration))] [CompatibleDependency("BMX.LobbyCompatibility", typeof(LobbyCompatibilityIntegration))] [CompatibleDependency("mrov.WeatherRegistry", typeof(WeatherRegistryIntegration))] [CompatibleDependency("me.loaforc.soundapi", typeof(SoundAPIIntegration))] [CompatibleDependency("me.loaforc.diomedes", typeof(DiomedesIntergration))] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MeltdownPlugin : BaseUnityPlugin { internal const string modGUID = "me.loaforc.facilitymeltdown"; internal const string modName = "FacilityMeltdown"; internal const string modVersion = "2.7.501"; internal static MeltdownPlugin instance; internal static ManualLogSource logger; internal static Harmony harmony = new Harmony("me.loaforc.facilitymeltdown"); private static ConfigEntry<bool> verboseLogging; internal static MeltdownAssets assets { get; private set; } internal static CompanionAssets companion { get; private set; } public static bool loadedFully { get; private set; } = false; internal static MeltdownConfig config { get; set; } internal static void LogVerbose(string message) { ConfigEntry<bool> obj = verboseLogging; if (obj != null && obj.Value) { logger.LogInfo((object)("[Verbose] " + message)); } } private void Awake() { if (!((Object)(object)instance == (Object)null)) { return; } instance = this; logger = Logger.CreateLogSource("me.loaforc.facilitymeltdown"); verboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "VerboseLogging", false, "Write local asset, multiplayer config, countdown audio, and detonation details to the BepInEx log."); LogVerbose("Initializing FacilityMeltdown 2.7.501 on Unity " + Application.unityVersion + "."); if (!RunLoadStep("Assets.Init", "Getting assets", delegate { assets = new MeltdownAssets(); LogVerbose($"Loaded facilitymeltdown bundle: {((Object)assets.facilityExplosionPrefab).name}, {assets.warnings.Length} warning clips, Geiger item {assets.geigerCounterItemDef.itemName}."); })) { return; } companion = CompanionAssets.TryLoad(); if (companion != null) { AudioSource[] componentsInChildren = assets.meltdownHandlerPrefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { val.playOnAwake = false; } } if (RunLoadStep("LangParser.Init", "Getting possible languages", LangParser.Init) && RunLoadStep("new MeltdownConfig()", "Setting up config", delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown bool migrateLegacyApparatusValue = !((BaseUnityPlugin)this).Config.ContainsKey(new ConfigDefinition("GameBalance", "ApparatusValueMin")) && !((BaseUnityPlugin)this).Config.ContainsKey(new ConfigDefinition("GameBalance", "ApparatusValueMax")); bool flag = !((BaseUnityPlugin)this).Config.ContainsKey(new ConfigDefinition("Audio", "MusicVolume")); config = new MeltdownConfig(((BaseUnityPlugin)this).Config, migrateLegacyApparatusValue); if (flag) { config.ImportLegacyClientSettings(Utility.CombinePaths(new string[2] { Paths.ConfigPath, "me.loaforc.facilitymeltdown.Client.cfg" })); } logger.LogDebug((object)$"Apparatus value range: {config.ApparatusValueMin}-{config.ApparatusValueMax}"); ((BaseUnityPlugin)this).Config.ClearOrphans(); }) && RunLoadStep("LangParser.SetLanguage", "Setting language", delegate { LangParser.SetLanguage(config.Language); }) && RunLoadStep("RegisterPatches", "Integrating into LethalCompany", RegisterPatches)) { if (!RunLoadStep("RegisterItems", "Adding the Geiger Counter", RegisterItems)) { logger.LogWarning((object)"Failed to register the geiger counter."); } if (!RunLoadStep("CompatibleDependency.Init", "Checking for any soft dependencies", delegate { CompatibleDependencyAttribute.Init((BaseUnityPlugin)(object)this); })) { logger.LogWarning((object)"Doing something with soft dependencies broke, meltdown itself should be fine."); } loadedFully = true; logger.LogInfo((object)"FacilityMeltdown:2.7.501 by loaforc has loaded! have fun :3"); logger.LogInfo((object)" .-_; ;_-. "); logger.LogInfo((object)" / / \\ \\ "); logger.LogInfo((object)" | | | | "); logger.LogInfo((object)" \\ \\.---./ / "); logger.LogInfo((object)" .-\\\"\"~ .---. ~\"\"-."); logger.LogInfo((object)" ,`.-~// .'`---`'. \\\\~-.`,"); logger.LogInfo((object)" ' ` | | \\(_)/ | | `' "); logger.LogInfo((object)" , \\ \\ | | / / , "); logger.LogInfo((object)" ;`'.,_\\ `-'-' /_,.'`; "); logger.LogInfo((object)" '-._ _.-'^'-._ _.-' "); } } private bool RunLoadStep(string stepName, string descrption, Action callback) { try { callback(); } catch (Exception ex) { logger.LogError((object)("`" + stepName + "` caused an exception to be thrown, meltdown may or may not work, look for more errors.")); logger.LogError((object)ex); return false; } logger.LogInfo((object)(stepName.PadRight(25) + " == " + descrption)); return true; } private void RegisterItems() { logger.LogInfo((object)"Registering Items"); DawnLib.DefineItem(MeltdownKeys.GeigerCounter, assets.geigerCounterItemDef, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder item) { item.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shop) { shop.OverrideCost(90).OverrideInfoNode(assets.geigerCounterNode); }); }); ((Registry<DawnItemInfo>)(object)LethalContent.Items).OnFreeze += delegate { if (config.OverrideApparatusValue) { ((Registry<DawnItemInfo>)(object)LethalContent.Items)[ItemKeys.Apparatus].Item.minValue = Mathf.Min(config.ApparatusValueMin, config.ApparatusValueMax); ((Registry<DawnItemInfo>)(object)LethalContent.Items)[ItemKeys.Apparatus].Item.maxValue = Mathf.Max(config.ApparatusValueMin, config.ApparatusValueMax); } }; } private void OnDisable() { if (!loadedFully) { Harmony.UnpatchID("me.loaforc.facilitymeltdown"); logger.LogInfo((object)"Unpatching as something failed while loading."); } else if (Chainloader.PluginInfos.ContainsKey("den.meltdownchance") || Chainloader.PluginInfos.ContainsKey("PizzaProbability")) { logger.LogInfo((object)"You are using a mod that makes meltdown have a random chance of occuring."); logger.LogInfo((object)"Keep in mind this goes against meltdown's core design, but your choice."); logger.LogWarning((object)"However; BY DESIGN these mods need to mess with the internals of meltdown"); logger.LogWarning((object)"so I personally will be offering low to no support with these mods installed."); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void RegisterPatches() { foreach (Type item in from t in Assembly.GetExecutingAssembly().GetLoadableTypes() where t.IsClass && t.Namespace == "FacilityMeltdown.Patches" select t) { logger.LogDebug((object)("Registering Patch handler: " + item.Name)); harmony.PatchAll(item); } } } internal sealed class CompanionAssets { internal const int Inside = 0; internal const int Outside = 1; internal const int Ship = 2; private const string Root = "assets/nuclearexplosion/companion/"; internal readonly AudioClip[] Countdown = (AudioClip[])(object)new AudioClip[3]; internal readonly AudioClip[] Blast = (AudioClip[])(object)new AudioClip[3]; internal readonly AudioClip Warning; internal readonly GameObject Visual; private CompanionAssets(AssetBundle bundle) { AssetBundle bundle2 = bundle; base..ctor(); Visual = Load<GameObject>("MeltdownExplosion.prefab"); Warning = LoadClip("Warning"); string[] array = new string[3] { "Inside", "Outside", "Ship" }; for (int i = 0; i < array.Length; i++) { string text = "V2Adjusted_" + array[i] + "Meltdown"; Countdown[i] = LoadClip(text); Blast[i] = LoadClip(text + "_Explosion"); } T Load<T>(string name) where T : Object { return bundle2.LoadAsset<T>("assets/nuclearexplosion/companion/" + name.ToLowerInvariant()) ?? throw new InvalidDataException("Missing " + name); } AudioClip LoadClip(string name) { AudioClip val = Load<AudioClip>("Audio/" + name + ".ogg"); if (!val.LoadAudioData()) { throw new InvalidDataException("Cannot load audio data for " + name); } return val; } } internal static CompanionAssets TryLoad() { string text = Path.Combine(Path.GetDirectoryName(typeof(MeltdownPlugin).Assembly.Location), "facilitymeltdownfork"); AssetBundle val = null; try { if (!File.Exists(text)) { throw new FileNotFoundException("Bundle file is absent."); } val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { throw new InvalidDataException("Unity could not open the bundle."); } CompanionAssets result = new CompanionAssets(val); val.Unload(false); MeltdownPlugin.logger.LogInfo((object)"Loaded facilitymeltdownfork: one explosion prefab and seven audio clips."); return result; } catch (Exception ex) { if ((Object)(object)val != (Object)null) { val.Unload(true); } MeltdownPlugin.logger.LogWarning((object)("Using original meltdown assets. Failed to load " + text + ": " + ex.Message)); return null; } } } internal static class ExtensionMethods { private static Random rng = new Random(); public static void Shuffle<T>(this IList<T> list) { int num = list.Count; while (num > 1) { num--; int index = rng.Next(num + 1); T value = list[index]; list[index] = list[num]; list[num] = value; } } public static float Remap(this float value, float from1, float to1, float from2, float to2) { return (value - from1) / (to1 - from1) * (to2 - from2) + from2; } public static List<PlayerControllerB> GetConnectedPlayers(this StartOfRound startOfRound) { return startOfRound.allPlayerScripts.Where((PlayerControllerB player) => player.isPlayerControlled).ToList(); } public static void SpawnEnemy(this EnemyVent vent, SpawnableEnemyWithRarity enemy) { //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_0028: 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) Vector3 position = vent.floorNode.position; float y = vent.floorNode.eulerAngles.y; GameObject val = Object.Instantiate<GameObject>(enemy.enemyType.enemyPrefab, position, Quaternion.Euler(new Vector3(0f, y, 0f))); EnemyAI component = val.GetComponent<EnemyAI>(); ((NetworkBehaviour)component).NetworkObject.Spawn(true); RoundManager.Instance.SpawnedEnemies.Add(component); vent.OpenVentClientRpc(); vent.occupied = false; } internal static string Translate(this string text) { return LangParser.GetTranslation(text); } internal static void ClearOrphans(this ConfigFile config) { PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null); dictionary.Clear(); config.Save(); } internal static IEnumerable<Type> GetLoadableTypes(this Assembly assembly) { if (assembly == null) { throw new ArgumentNullException("assembly"); } try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type t) => t != null); } } internal static (int hours, int minutes) GetCurrentTime(this TimeOfDay timeOfDay) { int num = Mathf.FloorToInt(timeOfDay.normalizedTimeOfDay * 60f * (float)timeOfDay.numberOfHours + 360f); int item = Mathf.FloorToInt((float)(num / 60)); return (hours: item, minutes: num % 60); } } internal class MeltdownAssets : AssetBundleLoader<MeltdownAssets> { [LoadFromBundle("meltdownmusic.mp3")] public AudioClip defaultMusic { get; private set; } [LoadFromBundle("shockwave.mp3")] public AudioClip shockwave { get; private set; } [LoadFromBundle("medium radiation.ogg")] public AudioClip mediumRadiation { get; private set; } [LoadFromBundle("high radiation.ogg")] public AudioClip highRadiation { get; private set; } [LoadFromBundle("FacilityExplosion.prefab")] public GameObject facilityExplosionPrefab { get; private set; } [LoadFromBundle("MeltdownHandler.prefab")] public GameObject meltdownHandlerPrefab { get; private set; } [LoadFromBundle("Shockwave.prefab")] public GameObject shockwavePrefab { get; private set; } [LoadFromBundle("GeigerCounterItemDef.asset")] public Item geigerCounterItemDef { get; private set; } [LoadFromBundle("GeigerCounterNode.asset")] public TerminalNode geigerCounterNode { get; private set; } [LoadFromBundle("HealthKeyword.asset")] public TerminalKeyword healthKeyword { get; private set; } [LoadFromBundle("ReactorKeyword.asset")] public TerminalKeyword reactorKeyword { get; private set; } [LoadFromBundle("ReactorHealthReport.asset")] public TerminalNode reactorHealthNode { get; private set; } public GameObject[] facilityEffects { get; private set; } public AudioClip[] warnings { get; private set; } public MeltdownAssets() : base("facilitymeltdown") { } protected override void FinishLoadingAssets(AssetBundle bundle) { warnings = (AudioClip[])(object)new AudioClip[4] { LoadAsset<AudioClip>(bundle, "warning1.mp3"), LoadAsset<AudioClip>(bundle, "warning2.mp3"), LoadAsset<AudioClip>(bundle, "warning3.mp3"), LoadAsset<AudioClip>(bundle, "warning4.mp3") }; facilityEffects = (GameObject[])(object)new GameObject[2] { LoadAsset<GameObject>(bundle, "Dust.prefab"), LoadAsset<GameObject>(bundle, "Waterstream.prefab") }; TerminalPatch.terminalKeywordsToRegister.Add(healthKeyword); TerminalPatch.terminalKeywordsToRegister.Add(reactorKeyword); TerminalPatch.terminalNodesToRegister.Add(reactorHealthNode); } } } namespace FacilityMeltdown.Util { internal abstract class AssetBundleLoader<T> where T : AssetBundleLoader<T> { public AssetBundleLoader(string filePath) { AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filePath)); MeltdownPlugin.logger.LogDebug((object)("[Assets] AssetBundle `" + filePath + "` contains these objects: \n" + string.Join("\n", val.GetAllAssetNames()))); Type typeFromHandle = typeof(T); PropertyInfo[] properties = typeFromHandle.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { LoadFromBundleAttribute loadFromBundleAttribute = (LoadFromBundleAttribute)propertyInfo.GetCustomAttribute(typeof(LoadFromBundleAttribute)); if (loadFromBundleAttribute != null) { MeltdownPlugin.logger.LogDebug((object)("[Assets] Got LoadFromBundle attribute on `" + propertyInfo.Name + "`. Loading asset: `" + loadFromBundleAttribute.BundleFile + "` into the [roperty.")); propertyInfo.SetValue(this, LoadAsset<Object>(val, loadFromBundleAttribute.BundleFile.ToLower(CultureInfo.GetCultureInfo("en-GB")))); } } GameObject[] array = val.LoadAllAssets<GameObject>(); foreach (GameObject val2 in array) { if (!((Object)(object)val2.GetComponent<NetworkObject>() == (Object)null) && !GameNetworkManagerPatch.networkPrefabsToRegister.Contains(val2)) { GameNetworkManagerPatch.networkPrefabsToRegister.Add(val2); } } FinishLoadingAssets(val); } protected virtual void FinishLoadingAssets(AssetBundle bundle) { } protected AssetType LoadAsset<AssetType>(AssetBundle bundle, string path) where AssetType : Object { AssetType val = bundle.LoadAsset<AssetType>(path); if ((Object)(object)val == (Object)null) { throw new ArgumentException(path + " is not valid in the assetbundle!"); } return val; } } } namespace FacilityMeltdown.Util.Config { [AttributeUsage(AttributeTargets.Property)] internal class ConfigDescAttribute(string desc) : Attribute() { public string Description { get; private set; } = desc; } [AttributeUsage(AttributeTargets.Property)] internal class ConfigGroupAttribute(string Group) : Attribute() { public string Group { get; private set; } = Group; } [AttributeUsage(AttributeTargets.Property)] internal class ConfigIgnoreAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property)] internal class ConfigRangeAttribute : Attribute { internal float Min { get; private set; } internal float Max { get; private set; } internal ConfigRangeAttribute(float min, float max) { Min = min; Max = max; } } [Serializable] internal abstract class LoafConfig<T> where T : LoafConfig<T> { internal List<(PropertyInfo, object)> configEntries = new List<(PropertyInfo, object)>(); internal ConfigFile configFile { get; private set; } public LoafConfig(ConfigFile configFile) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown if (configFile == null) { return; } this.configFile = configFile; string header = "Misc"; Type typeFromHandle = typeof(T); PropertyInfo[] properties = typeFromHandle.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.GetCustomAttribute(typeof(ConfigIgnoreAttribute)) == null) { ConfigGroupAttribute configGroupAttribute = (ConfigGroupAttribute)propertyInfo.GetCustomAttribute(typeof(ConfigGroupAttribute)); if (configGroupAttribute != null) { header = configGroupAttribute.Group.Replace(" ", ""); } string text = "no description here :pensive:"; ConfigDescAttribute configDescAttribute = (ConfigDescAttribute)propertyInfo.GetCustomAttribute(typeof(ConfigDescAttribute)); if (configDescAttribute != null) { text = configDescAttribute.Description; } ConfigDescription val = new ConfigDescription(text, (AcceptableValueBase)null, Array.Empty<object>()); ConfigRangeAttribute configRangeAttribute = (ConfigRangeAttribute)propertyInfo.GetCustomAttribute(typeof(ConfigRangeAttribute)); val = ((configRangeAttribute == null) ? new ConfigDescription(text, (AcceptableValueBase)null, Array.Empty<object>()) : ((!(propertyInfo.PropertyType == typeof(int))) ? new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<float>(configRangeAttribute.Min, configRangeAttribute.Max), Array.Empty<object>()) : new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>((int)configRangeAttribute.Min, (int)configRangeAttribute.Max), Array.Empty<object>()))); if (propertyInfo.PropertyType == typeof(float)) { BindProperty<float>(propertyInfo, header, val); } if (propertyInfo.PropertyType == typeof(int)) { BindProperty<int>(propertyInfo, header, val); } if (propertyInfo.PropertyType == typeof(string)) { BindProperty<string>(propertyInfo, header, val); } if (propertyInfo.PropertyType == typeof(bool)) { BindProperty<bool>(propertyInfo, header, val); } } } } protected void BindProperty<V>(PropertyInfo property, string header, ConfigDescription description) { ConfigEntry<V> val = configFile.Bind<V>(header, property.Name, (V)property.GetValue(this), description); configEntries.Add((property, val)); property.SetValue(this, val.Value); } } internal abstract class LoafSyncedConfig<T> : LoafConfig<T> where T : LoafSyncedConfig<T> { internal static T Default { get; private set; } internal LoafSyncedConfig(ConfigFile file) : base(file) { if (Default == null) { Default = (T)this; } } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)] internal class RequiresRestartAttribute(bool requiresRestart = true) : Attribute() { public bool RequiresRestart { get; private set; } = requiresRestart; } } namespace FacilityMeltdown.Util.Attributes { internal class CompatibleDependencyAttribute : BepInDependency { public Type Handler; public CompatibleDependencyAttribute(string guid, Type handlerType) : base(guid, (DependencyFlags)2) { Handler = handlerType; } public static void Init(BaseUnityPlugin source) { IEnumerable<CompatibleDependencyAttribute> customAttributes = ((MemberInfo)((object)source).GetType()).GetCustomAttributes<CompatibleDependencyAttribute>(); foreach (CompatibleDependencyAttribute item in customAttributes) { if (Chainloader.PluginInfos.ContainsKey(((BepInDependency)item).DependencyGUID)) { item.Handler.GetMethod("Initialize", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, null); item.Handler = null; } } } } } namespace FacilityMeltdown.Patches { [HarmonyPatch(typeof(LungProp))] internal static class ApparaticePatch { [HarmonyPrefix] [HarmonyPatch("EquipItem")] [HarmonyWrapSafe] internal static void BeginMeltdownSequence(LungProp __instance, ref bool ___isLungDocked) { if (((NetworkBehaviour)__instance).IsHost && ___isLungDocked && !MeltdownAPI.MeltdownStarted) { GameObject val = Object.Instantiate<GameObject>(MeltdownPlugin.assets.meltdownHandlerPrefab); val.GetComponent<MeltdownHandler>().causingLungProp = __instance; val.GetComponent<NetworkObject>().Spawn(false); } } [HarmonyFinalizer] [HarmonyPatch("EquipItem")] [HarmonyWrapSafe] private static void RecoverDockedApparatus(LungProp __instance) { if (!((Object)(object)__instance == (Object)null) && ((NetworkBehaviour)__instance).IsHost && __instance.isLungDocked) { MeltdownPlugin.logger.LogError((object)"Another mod prevented the apparatus from being removed. Clearing its docked state to prevent the round from becoming stuck."); __instance.isLungDocked = false; } } [HarmonyPrefix] [HarmonyPatch("Start")] [HarmonyWrapSafe] internal static void AddRadiationSource(LungProp __instance) { if (!StartOfRound.Instance.inShipPhase) { MeltdownMoonMapper.EnsureMeltdownMoonMapper(); MeltdownInteriorMapper.EnsureMeltdownInteriorMapper(); } RadiationSource radiationSource = ((Component)__instance).gameObject.AddComponent<RadiationSource>(); radiationSource.radiationAmount = 80f; radiationSource.radiationDistance = 60f; if (MeltdownPlugin.config.OverrideApparatusValue) { int minValue = Mathf.Min(MeltdownPlugin.config.ApparatusValueMin, MeltdownPlugin.config.ApparatusValueMax); int num = Mathf.Max(MeltdownPlugin.config.ApparatusValueMin, MeltdownPlugin.config.ApparatusValueMax); int seed = (StartOfRound.Instance.randomMapSeed * 397) ^ (int)((NetworkBehaviour)__instance).NetworkObjectId; int num2 = new Random(seed).Next(minValue, num + 1); if (WeatherRegistryIntegration.Enabled) { try { num2 = Mathf.RoundToInt((float)num2 * WeatherRegistryIntegration.GetWeatherMultiplier()); } catch (Exception ex) { MeltdownPlugin.logger.LogWarning((object)ex.ToString()); } } ((GrabbableObject)__instance).SetScrapValue(num2); } MeltdownPlugin.logger.LogDebug((object)((GrabbableObject)__instance).scrapValue); } } [HarmonyPatch(typeof(BlobAI))] internal class BlobAIPatch { [HarmonyPrefix] [HarmonyPatch("Start")] internal static void AddRadiationSource(BlobAI __instance) { RadiationSource radiationSource = ((Component)__instance).gameObject.AddComponent<RadiationSource>(); radiationSource.radiationAmount = 30f; radiationSource.radiationDistance = 25f; } } [HarmonyPatch(typeof(EntranceTeleport))] internal static class EntranceTeleportPatch { [HarmonyPrefix] [HarmonyPatch("FindExitPoint")] private static bool dontAllowReneter(ref bool __result) { if ((Object)(object)MeltdownHandler.Instance != (Object)null && MeltdownHandler.Instance.HasExplosionOccured()) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { internal static List<GameObject> networkPrefabsToRegister = new List<GameObject>(); [HarmonyPatch("Start")] [HarmonyPrefix] private static void AddNetworkPrefabs() { foreach (GameObject item in networkPrefabsToRegister) { NetworkManager.Singleton.AddNetworkPrefab(item); MeltdownPlugin.logger.LogDebug((object)("Registered " + ((Object)item).name + " as a network prefab.")); } MeltdownPlugin.logger.LogInfo((object)$"Succesfully registered {networkPrefabsToRegister.Count} network prefabs."); } [HarmonyPostfix] [HarmonyPatch("StartDisconnect")] public static void PlayerLeave() { MeltdownPlugin.config = LoafSyncedConfig<MeltdownConfig>.Default; } } [HarmonyPatch(typeof(GrabbableObject))] public class GrabbableObjectPatch { [HarmonyPrefix] [HarmonyPatch("Update")] internal static void ApplyMinPeople(GrabbableObject __instance) { LungProp apparatus = (LungProp)(object)((__instance is LungProp) ? __instance : null); if (apparatus == null) { return; } if (!apparatus.isLungDocked) { if (!((GrabbableObject)apparatus).grabbable) { ((GrabbableObject)apparatus).customGrabTooltip = ""; ((GrabbableObject)apparatus).grabbable = true; } return; } int num = StartOfRound.Instance.GetConnectedPlayers().Count((PlayerControllerB player) => Vector3.Distance(((Component)player).transform.position, ((Component)apparatus).transform.position) < 15f); int num2 = Mathf.Min(MeltdownPlugin.config.MinPeopleToPullApparatus, StartOfRound.Instance.livingPlayers); if (num < num2 && TimeOfDay.Instance.GetCurrentTime().hours < 21) { ((GrabbableObject)apparatus).customGrabTooltip = $"[ NEEDS {num2} PEOPLE ]"; ((GrabbableObject)apparatus).grabbable = false; } else { ((GrabbableObject)apparatus).customGrabTooltip = ""; ((GrabbableObject)apparatus).grabbable = true; } } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerPatch { [HarmonyPostfix] [HarmonyPatch("ConnectClientToPlayerObject")] private static void SyncConfig() { MeltdownConfigSync.RegisterHandlers(); } } internal static class MeltdownConfigSync { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequestSync; public static HandleNamedMessageDelegate <1>__OnReceiveSync; } private const string MESSAGE_REQUEST = "meltdown_OnRequestConfigSync"; private const string MESSAGE_RECIEVE = "meltdown_OnRecieveConfigSync"; private const int IntSize = 4; internal static void RegisterHandlers() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (NetworkManager.Singleton.IsHost) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>O.<0>__OnRequestSync; if (obj == null) { HandleNamedMessageDelegate val = OnRequestSync; <>O.<0>__OnRequestSync = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("meltdown_OnRequestConfigSync", (HandleNamedMessageDelegate)obj); return; } CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager; object obj2 = <>O.<1>__OnReceiveSync; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnReceiveSync; <>O.<1>__OnReceiveSync = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("meltdown_OnRecieveConfigSync", (HandleNamedMessageDelegate)obj2); RequestSync(); } public unsafe static void RequestSync() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsHost) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); try { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("meltdown_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } public unsafe static void OnRequestSync(ulong clientId, FastBufferReader _) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsHost) { return; } MeltdownPlugin.logger.LogInfo((object)$"Config sync request received from client: {clientId}"); byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject((object)MeltdownPlugin.config)); int num = bytes.Length; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num + 4, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(bytes, -1, 0); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("meltdown_OnRecieveConfigSync", clientId, val, (NetworkDelivery)3); } catch (Exception arg) { MeltdownPlugin.logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}"); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnReceiveSync(ulong _, FastBufferReader reader) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown if (!((FastBufferReader)(ref reader)).TryBeginRead(4)) { MeltdownPlugin.logger.LogError((object)"Config sync error: Could not begin reading buffer."); return; } int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (!((FastBufferReader)(ref reader)).TryBeginRead(num)) { MeltdownPlugin.logger.LogError((object)"Config sync error: Host could not sync."); return; } byte[] bytes = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref bytes, num, 0); MeltdownPlugin.logger.LogDebug((object)Encoding.UTF8.GetString(bytes)); MeltdownPlugin.config = JsonConvert.DeserializeObject<MeltdownConfig>(Encoding.UTF8.GetString(bytes), new JsonSerializerSettings { ContractResolver = (IContractResolver)(object)new IncludePrivateSetterContractResolver() }); MeltdownPlugin.logger.LogDebug((object)"Deserialized values are: "); PropertyInfo[] properties = MeltdownPlugin.config.GetType().GetProperties(); foreach (PropertyInfo propertyInfo in properties) { MeltdownPlugin.logger.LogDebug((object)$"{propertyInfo.Name} => {propertyInfo.GetValue(MeltdownPlugin.config)}"); } MeltdownPlugin.LogVerbose($"Applied {num} bytes of host config. Meltdown duration: {MeltdownPlugin.config.MeltdownTime}s."); MeltdownPlugin.logger.LogInfo((object)"Successfully synced config with host."); } } internal class IncludePrivateSetterContractResolver : DefaultContractResolver { protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) JsonProperty val = ((DefaultContractResolver)this).CreateProperty(member, memberSerialization); if (!val.Writable && member is PropertyInfo propertyInfo) { val.Writable = propertyInfo.GetSetMethod(nonPublic: true) != null; } return val; } } [HarmonyPatch(typeof(StartMatchLever))] internal static class StartMatchLeverPatch { [HarmonyPostfix] [HarmonyPatch("EndGame")] private static void ShortenMeltdownTimer() { if ((Object)(object)MeltdownHandler.Instance != (Object)null && MeltdownPlugin.config.ShortenMeltdownTimerOnShipLeave) { MeltdownHandler instance = MeltdownHandler.Instance; instance.meltdownTimer = Mathf.Min(instance.meltdownTimer, 5f); } } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRoundPatches { [HarmonyPrefix] [HarmonyPatch("EndOfGame")] internal static void UnloadMeltdownHandler() { if (Object.op_Implicit((Object)(object)MeltdownHandler.Instance)) { Object.Destroy((Object)(object)((Component)MeltdownHandler.Instance).gameObject); } if (Object.op_Implicit((Object)(object)MeltdownMoonMapper.Instance)) { Object.Destroy((Object)(object)((Component)MeltdownMoonMapper.Instance).gameObject); } if (Object.op_Implicit((Object)(object)MeltdownInteriorMapper.Instance)) { Object.Destroy((Object)(object)((Component)MeltdownInteriorMapper.Instance).gameObject); } } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { internal class ReactorHealthReport { public float reactorInstability; public float timeRemaining; public float generatedAt = Time.time; public string GetFlavourText() { if (timeRemaining / MeltdownHandler.Instance.Duration > 0.75f) { return "reactorscan.result.flavour.start"; } if (timeRemaining / MeltdownHandler.Instance.Duration > 0.5f) { return "reactorscan.result.flavour.low"; } if (timeRemaining / MeltdownHandler.Instance.Duration > 0.33f) { return "reactorscan.result.flavour.medium"; } if (timeRemaining / MeltdownHandler.Instance.Duration > 0.15f) { return "reactorscan.result.flavour.high"; } return ""; } public string GetTeminalOutput() { string text = "reactorscan.result.unstable".Translate(); text = SubstituteVariables(text); return text + "\n\n" + SubstituteVariables(GetFlavourText().Translate()) + "\n\n"; } } internal static float lastHealthCheck = 0f; internal static ReactorHealthReport lastReport = null; internal static List<TerminalKeyword> terminalKeywordsToRegister = new List<TerminalKeyword>(); internal static List<TerminalNode> terminalNodesToRegister = new List<TerminalNode>(); internal static string SubstituteVariables(string text) { StringBuilder stringBuilder = new StringBuilder(text); stringBuilder.Replace("<cooldown>", MeltdownPlugin.config.ShipScanCooldown.ToString()); stringBuilder.Replace("<instability>", lastReport.reactorInstability.ToString()); stringBuilder.Replace("<time_left>", lastReport.timeRemaining.ToString()); return stringBuilder.ToString(); } internal static string GetTextForNode() { if (Object.op_Implicit((Object)(object)MeltdownHandler.Instance)) { string text = "reactorscan.error.overheat"; if (ReactorHealthCheckReady()) { lastHealthCheck = Time.time; lastReport = GetNewReactorHealthReport(); text = "reactorscan.success"; } return SubstituteVariables(text.Translate()) + lastReport.GetTeminalOutput(); } return "reactorscan.result.stable".Translate(); } internal static bool ReactorHealthCheckReady() { return Time.time >= lastHealthCheck + MeltdownPlugin.config.ShipScanCooldown; } internal static ReactorHealthReport GetNewReactorHealthReport() { float duration = MeltdownHandler.Instance.Duration; float num = (duration - MeltdownHandler.Instance.meltdownTimer) / duration * 100f; float num2 = Mathf.Max(1f, MeltdownPlugin.config.ShipScanAccuracy); num = Mathf.Round(num / num2) * num2; float timeRemaining = (1f - num / 100f) * duration; return new ReactorHealthReport { reactorInstability = num, timeRemaining = timeRemaining }; } [HarmonyPostfix] [HarmonyPatch("Awake")] internal static void RegisterNodes(Terminal __instance) { __instance.terminalNodes.allKeywords = CollectionExtensions.AddRangeToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, terminalKeywordsToRegister.ToArray()); __instance.terminalNodes.terminalNodes.AddRange(terminalNodesToRegister); } [HarmonyPostfix] [HarmonyPatch("TextPostProcess")] internal static void ProcessReactorText(TerminalNode node, ref string __result) { if ((Object)(object)node == (Object)(object)MeltdownPlugin.assets.reactorHealthNode) { __result = "\n\n\n" + GetTextForNode(); } } [HarmonyPostfix] [HarmonyPatch(typeof(StormyWeather), "GetMetalObjectsAfterDelay")] internal static void CancelCoroutine(StormyWeather __instance, ref IEnumerator __result) { ((MonoBehaviour)__instance).StopCoroutine(__result); } } [HarmonyPatch(typeof(TimeOfDay), "MoveTimeOfDay")] internal static class TimeOfDayPatch { [HarmonyPostfix] private static void ApplyMeltdownEvening(TimeOfDay __instance) { Animator sunAnimator = __instance.sunAnimator; MeltdownEveningLighting meltdownEveningLighting = default(MeltdownEveningLighting); if (Object.op_Implicit((Object)(object)sunAnimator) && ((Component)sunAnimator).TryGetComponent<MeltdownEveningLighting>(ref meltdownEveningLighting)) { meltdownEveningLighting.ApplyEveningLighting(); } } } } namespace FacilityMeltdown.MeltdownSequence { public static class MeltdownEffects { public static List<(Light light, Color originalColour)> SetupEmergencyLights() { //IL_0019: 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) for (int i = 0; i < RoundManager.Instance.allPoweredLights.Count; i++) { RoundManager.Instance.allPoweredLights[i].color = MeltdownInteriorMapper.Instance.outsideEmergencyLightColour; } List<(Light, Color)> list = new List<(Light, Color)>(); for (int j = 0; j < MeltdownMoonMapper.Instance.outsideEmergencyLights.Count; j++) { list.Add((MeltdownMoonMapper.Instance.outsideEmergencyLights[j], MeltdownMoonMapper.Instance.outsideEmergencyLights[j].color)); } return list; } public static IEnumerator RepeatUntilEndOfMeltdown(Func<IEnumerator> enumerator) { yield return (object)new WaitForSeconds(Random.Range(0f, 1f)); while ((Object)(object)MeltdownHandler.Instance != (Object)null && !MeltdownHandler.Instance.HasExplosionOccured()) { MeltdownPlugin.logger.LogDebug((object)"looping effect"); yield return enumerator(); } } public static IEnumerator WithDelay(IEnumerator enumerator, float delay) { yield return (object)new WaitForSeconds(delay); yield return enumerator; } public static IEnumerator WithDelay(Action callback, float delay) { yield return (object)new WaitForSeconds(delay); callback(); } public static IEnumerator WithRandomDelay(Func<IEnumerator> enumerator, float min, float max) { yield return WithDelay(enumerator(), Random.Range(min, max)); } public static IEnumerator WithRandomDelay(Action callback, float min, float max) { yield return WithDelay(callback, Random.Range(min, max)); } public static IEnumerator AtProgress(IEnumerator enumerator, float progress) { while (MeltdownAPI.MeltdownStarted && MeltdownHandler.Instance.Progress > progress) { yield return null; } yield return enumerator; } public static IEnumerator AtProgress(Action callback, float progress) { while (MeltdownAPI.MeltdownStarted && MeltdownHandler.Instance.Progress > progress) { yield return null; } callback(); } public static IEnumerator EmergencyLights(float onTime, float offTime, List<(Light light, Color originalColour)> originalLightColours) { MeltdownPlugin.logger.LogDebug((object)"Switching lights ON"); for (int i = 0; i < RoundManager.Instance.allPoweredLightsAnimators.Count; i++) { RoundManager.Instance.allPoweredLightsAnimators[i].SetBool("on", true); } for (int j = 0; j < MeltdownMoonMapper.Instance.outsideEmergencyLights.Count; j++) { MeltdownMoonMapper.Instance.outsideEmergencyLights[j].color = MeltdownMoonMapper.Instance.outsideEmergencyLightColour; } yield return (object)new WaitForSeconds(onTime); MeltdownPlugin.logger.LogDebug((object)"Switching lights OFF"); for (int k = 0; k < RoundManager.Instance.allPoweredLightsAnimators.Count; k++) { RoundManager.Instance.allPoweredLightsAnimators[k].SetBool("on", false); } foreach (var (val, color) in originalLightColours) { val.color = color; } yield return (object)new WaitForSeconds(offTime); } public static void InsideParticleEffects() { //IL_00c5: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0073: Unknown result type (might be due to invalid IL or missing references) if (MeltdownPlugin.config.ParticleEffects) { RaycastHit val2 = default(RaycastHit); for (int i = 0; i < Random.Range(5, 15); i++) { Vector3 val = GetRandomPositionInsideFacility() + Vector3.up; if (Physics.Raycast(new Ray(val, Vector3.up), ref val2, 20f, 256)) { GameObject val3 = MeltdownPlugin.assets.facilityEffects[Random.Range(0, MeltdownPlugin.assets.facilityEffects.Length)]; GameObject val4 = Object.Instantiate<GameObject>(val3); val4.transform.position = ((RaycastHit)(ref val2)).point; val4.transform.parent = ((Component)MeltdownHandler.Instance).transform; } } } if (GameNetworkManager.Instance.localPlayerController.isInsideFactory) { Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, GetRandomPositionNearPlayer(), Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform); } if (MeltdownPlugin.config.ScreenShake) { if (MeltdownHandler.Instance.Progress > 0.5f) { HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } else { HUDManager.Instance.ShakeCamera((ScreenShakeType)3); } } } public static IEnumerator WarningAnnouncer(AudioSource source) { source.volume = (float)MeltdownPlugin.config.MusicVolume / 100f; AudioClip clip = MeltdownPlugin.companion?.Warning ?? MeltdownPlugin.assets.warnings[Random.Range(0, MeltdownPlugin.assets.warnings.Length)]; source.clip = clip; source.Play(); yield return (object)new WaitForSeconds(source.clip.length); } private static Vector3 PlacePositionInsideFacility(Vector3 position, float radius = 10f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return RoundManager.Instance.GetRandomNavMeshPositionInRadius(position, radius, default(NavMeshHit)); } private static Vector3 GetRandomPositionNearPlayer(float radius = 15f) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0029: Unknown result type (might be due to invalid IL or missing references) return PlacePositionInsideFacility(((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Random.insideUnitSphere * radius); } private static Vector3 GetRandomPositionInsideFacility() { //IL_0022: 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) return PlacePositionInsideFacility(RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position); } } } namespace FacilityMeltdown.MeltdownSequence.Behaviours { internal class FacilityExplosionHandler : MonoBehaviour { private PlayerControllerB player; private float size; private float time; private readonly HashSet<EnemyAI> enemiesHit = new HashSet<EnemyAI>(); private LocalVolumetricFog internalFog; private void Awake() { player = GameNetworkManager.Instance.localPlayerController; internalFog = ((Component)this).GetComponentInChildren<LocalVolumetricFog>(true); if ((Object)(object)internalFog == (Object)null && MeltdownPlugin.companion == null) { MeltdownPlugin.logger.LogWarning((object)"Explosion prefab has no volumetric fog; continuing without the expanding fog effect."); } if (MeltdownPlugin.config.ScreenShake) { ((MonoBehaviour)this).StartCoroutine(ShakeDuringDetonation()); } ApplyBlastToEnemies(outside: false); if (!player.isPlayerDead && player.isInsideFactory) { if (player.isInElevator) { MeltdownPlugin.logger.LogWarning((object)"Player is inside ship and facility at the same time!! Did you teleport out? Aborting kill"); } else { KillPlayer(); } } } private void ApplyBlastToEnemies(bool outside) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) RoundManager instance = RoundManager.Instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } List<EnemyAI> spawnedEnemies = instance.SpawnedEnemies; for (int num = spawnedEnemies.Count - 1; num >= 0; num--) { EnemyAI val = spawnedEnemies[num]; if (Object.op_Implicit((Object)(object)val) && ((NetworkBehaviour)val).IsSpawned && ((NetworkBehaviour)val).IsOwner && !val.isEnemyDead && val.isOutside == outside && Object.op_Implicit((Object)(object)val.enemyType) && (!outside || !(Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) >= size))) { bool flag = !val.enemyType.canDie; if ((!flag || val.enemyType.canBeDestroyed) && enemiesHit.Add(val)) { val.KillEnemyOnOwnerClient(flag); } } } } private IEnumerator ShakeDuringDetonation() { WaitForSeconds interval = new WaitForSeconds(1f); HUDManager.Instance.ShakeCamera((ScreenShakeType)3); for (int repeat = 0; repeat < 5; repeat++) { yield return interval; HUDManager.Instance.ShakeCamera((ScreenShakeType)3); } } private void Update() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) time += Time.deltaTime * 10f; size = TimeToSize(time); ApplyBlastToEnemies(outside: true); ((Component)this).transform.localScale = Vector3.one * size; if ((Object)(object)internalFog != (Object)null) { internalFog.parameters.size = Vector3.one * size * 1.25f; } if (!ShouldIgnorePlayer() && PlayerIsInsideFireball()) { player.KillPlayer(Vector3.zero, false, (CauseOfDeath)3, 0, default(Vector3), false); } } private void KillPlayer() { //IL_0006: 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_0016: Unknown result type (might be due to invalid IL or missing references) player.KillPlayer(Vector3.zero, false, (CauseOfDeath)3, 0, default(Vector3), false); } private bool PlayerIsInsideFireball() { //IL_0006: 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) return Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) < size; } private bool ShouldIgnorePlayer() { if (!player.isPlayerDead) { if (player.isInElevator) { return StartOfRound.Instance.shipIsLeaving; } return false; } return true; } private float TimeToSize(float time) { return Mathf.Log(time) + 3f + 2f * time; } } internal sealed class MeltdownCountdownTimer : MonoBehaviour { private GameObject timerObject; private TextMeshProUGUI timerText; private void Update() { MeltdownHandler instance = MeltdownHandler.Instance; if ((Object)(object)instance == (Object)null || instance.HasExplosionOccured()) { HideTimer(); } else if (!((Object)(object)timerText == (Object)null) || TryCreateTimer()) { int num = Mathf.Max(0, Mathf.CeilToInt(instance.TimeLeftUntilMeltdown)); ((TMP_Text)timerText).text = $"MELTDOWN: {num / 60:00}:{num % 60:00}"; } } private bool TryCreateTimer() { //IL_0110: 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_00a0: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null || instance.controlTipLines == null || instance.controlTipLines.Length == 0 || (Object)(object)instance.controlTipLines[0] == (Object)null) { return false; } TextMeshProUGUI val = instance.controlTipLines[0]; timerObject = Object.Instantiate<GameObject>(((Component)val).gameObject, ((TMP_Text)val).transform.parent, false); ((Object)timerObject).name = "FacilityMeltdownCountdown"; if (instance.controlTipLines.Length > 1 && (Object)(object)instance.controlTipLines[1] != (Object)null) { float num = ((TMP_Text)val).transform.position.y - ((TMP_Text)instance.controlTipLines[1]).transform.position.y; timerObject.transform.Translate(0f, num, 0f); } timerText = timerObject.GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)timerText == (Object)null) { MeltdownPlugin.logger.LogWarning((object)"Unable to create the meltdown countdown HUD text."); Object.Destroy((Object)(object)timerObject); timerObject = null; return false; } ((Graphic)timerText).color = Color.red; return true; } private void OnDisable() { HideTimer(); } private void OnDestroy() { HideTimer(); } private void HideTimer() { if ((Object)(object)timerObject != (Object)null) { Object.Destroy((Object)(object)timerObject); timerObject = null; timerText = null; } } } public class MeltdownHandler : NetworkBehaviour { [CompilerGenerated] private static class <>O { public static Action <0>__InsideParticleEffects; public static RpcReceiveHandler <1>____rpc_handler_3631067672; } internal float meltdownTimer; private bool meltdownStarted; private bool detonated; private bool eveningLightingChecked; internal LungProp causingLungProp; private GameObject explosion; private GameObject legacyShockwave; private readonly List<GameObject> countdownWaves = new List<GameObject>(); private GameObject companionVisual; private AudioSource[] locationMusic; private readonly float[] mixWeights = new float[3]; private readonly bool[] musicStarted = new bool[3]; private float previousTimeLeft; private float seekGain = 1f; private bool pendingMusicSeek; [SerializeField] private AudioSource meltdownMusic; [SerializeField] private AudioSource warningSource; public float TimeLeftUntilMeltdown => meltdownTimer; internal float Duration { get; private set; } public float Progress { get { if (!(Duration <= 0f)) { return Mathf.Clamp01(1f - TimeLeftUntilMeltdown / Duration); } return 0f; } } private static PlayerControllerB Player => GameNetworkManager.Instance.localPlayerController; internal static MeltdownHandler Instance { get; private set; } private Vector3 effectOrigin => MeltdownMoonMapper.Instance.EffectOrigin; private static int ListenerZone { get { if (!Player.isInHangarShipRoom) { return (!Player.isInsideFactory) ? 1 : 0; } return 2; } } private void SendStartMeltdownRpc(int duration) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3631067672u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref duration, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3631067672u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; StartMeltdown(duration); } } } private void StartMeltdown(int duration) { //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance != (Object)null) { return; } Instance = this; Stopwatch stopwatch = new Stopwatch(); MeltdownPlugin.logger.LogInfo((object)$"Beginning Meltdown Sequence! Countdown: {duration} seconds. I'd run if I were you!"); stopwatch.Start(); MeltdownMoonMapper.EnsureMeltdownMoonMapper(); MeltdownInteriorMapper.EnsureMeltdownInteriorMapper(); if ((Object)(object)MeltdownInteriorMapper.Instance == (Object)null) { MeltdownPlugin.logger.LogError((object)"WHAT. Just ensured that the interior mapper exists and it doesnt?!?"); } if ((Object)(object)MeltdownMoonMapper.Instance == (Object)null) { MeltdownPlugin.logger.LogError((object)"WHAT. Just ensured that the moon mapper exists and it doesnt?!?"); } stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"Ensuring data objects exist: {stopwatch.ElapsedMilliseconds}ms"); Duration = duration; meltdownTimer = Duration; if (MeltdownPlugin.companion != null) { StartLocationMusic(); } MeltdownPlugin.LogVerbose(string.Format("Countdown: {0}s, audio {1}, volume {2}%.", duration, (locationMusic == null) ? "original" : "companion", MeltdownPlugin.config.MusicVolume)); MeltdownCountdownTimer meltdownCountdownTimer = default(MeltdownCountdownTimer); if (MeltdownPlugin.config.ShowCountdownTimer && !((Component)this).TryGetComponent<MeltdownCountdownTimer>(ref meltdownCountdownTimer)) { ((Component)this).gameObject.AddComponent<MeltdownCountdownTimer>(); } stopwatch.Restart(); stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"Creating audio: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Restart(); ((MonoBehaviour)this).StartCoroutine(MeltdownEffects.WithDelay(delegate { HUDManager.Instance.ReadDialogue(GetDialogue("meltdown.dialogue.start")); }, 5f)); ((MonoBehaviour)this).StartCoroutine(MeltdownEffects.WithDelay(MeltdownEffects.RepeatUntilEndOfMeltdown(() => MeltdownEffects.WithRandomDelay(() => MeltdownEffects.WarningAnnouncer(warningSource), 10f, 15f)), 10f)); ((MonoBehaviour)this).StartCoroutine(MeltdownEffects.RepeatUntilEndOfMeltdown(() => MeltdownEffects.WithRandomDelay((Action)MeltdownEffects.InsideParticleEffects, 10f, 15f))); if (MeltdownPlugin.config.EmergencyLights) { try { List<(Light, Color)> originalLightColours = MeltdownEffects.SetupEmergencyLights(); ((MonoBehaviour)this).StartCoroutine(MeltdownEffects.RepeatUntilEndOfMeltdown(() => MeltdownEffects.EmergencyLights(2f, 5f, originalLightColours))); } catch (Exception arg) { MeltdownPlugin.logger.LogError((object)$"Failed to set the emergency light colour: {arg}"); } } ((MonoBehaviour)this).StartCoroutine(MeltdownEffects.RepeatUntilEndOfMeltdown(() => MeltdownEffects.WithRandomDelay(delegate { SpawnCountdownShockwave(); }, 5f, 10f))); ((MonoBehaviour)this).StartCoroutine(MeltdownEffects.AtProgress((Action)HUDManager.Instance.RadiationWarningHUD, 0.5f)); stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"Starting effects: {stopwatch.ElapsedMilliseconds}ms"); if (((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsServer) { SpawnEnemies(); } stopwatch.Restart(); if (effectOrigin == Vector3.zero) { MeltdownPlugin.logger.LogError((object)"Effect Origin is Vector3.Zero! We couldn't find the effect origin"); HUDManager.Instance.DisplayGlobalNotification("Failed to find effect origin... Things will look broken."); } if (MeltdownPlugin.config.ScreenShake) { HUDManager.Instance.ShakeCamera((ScreenShakeType)3); HUDManager.Instance.ShakeCamera((ScreenShakeType)2); } stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"Getting effect origin: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Restart(); MeltdownAPI.OnMeltdownStart(); stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"MeltdownAPI.OnMeltdownStart(): {stopwatch.ElapsedMilliseconds}ms"); meltdownStarted = true; } private void SpawnEnemies() { //IL_0216: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); List<string> disallowed = MeltdownPlugin.config.GetDisallowedEnemies(); List<SpawnableEnemyWithRarity> list = RoundManager.Instance.currentLevel.Enemies.Where(delegate(SpawnableEnemyWithRarity enemy) { if (enemy == null || (Object)(object)enemy.enemyType == (Object)null) { MeltdownPlugin.logger.LogWarning((object)"Ignoring an invalid enemy entry in the meltdown spawn pool."); return false; } return enemy.rarity > 0 && !EnemyCannotBeSpawned(enemy.enemyType) && !disallowed.Contains(enemy.enemyType.enemyName) && IsEnemyEligibleForMeltdown(enemy.enemyType); }).ToList(); stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"Filtering enemies: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Restart(); List<EnemyVent> list2 = RoundManager.Instance.allEnemyVents.Where(delegate(EnemyVent vent) { if ((Object)(object)vent == (Object)null) { MeltdownPlugin.logger.LogWarning((object)"Ignoring a null enemy vent during the meltdown sequence."); return false; } return !vent.occupied; }).ToList(); stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"Filtering vents: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Restart(); if (list.Count == 0) { MeltdownPlugin.logger.LogWarning((object)"No eligible enemies are available to spawn during the meltdown sequence."); return; } int num = Mathf.Min(MeltdownPlugin.config.MonsterSpawnAmount, list2.Count); Random random = new Random(StartOfRound.Instance.randomMapSeed + 1923847); for (int num2 = 0; num2 < num; num2++) { EnemyVent val = list2[random.Next(list2.Count)]; list2.Remove(val); SpawnableEnemyWithRarity val2 = list[random.Next(list.Count)]; RoundManager instance = RoundManager.Instance; instance.currentEnemyPower += val2.enemyType.PowerLevel; MeltdownPlugin.logger.LogInfo((object)("Spawning a " + val2.enemyType.enemyName + " during the meltdown sequence")); val.SpawnEnemy(val2); } stopwatch.Stop(); MeltdownPlugin.logger.LogDebug((object)$"Spawning enemies: {stopwatch.ElapsedMilliseconds}ms"); if (!MeltdownPlugin.config.ScareBabyManeaters || !((Object)(object)causingLungProp != (Object)null)) { return; } CaveDwellerAI[] array = Object.FindObjectsOfType<CaveDwellerAI>(); foreach (CaveDwellerAI val3 in array) { if (((EnemyAI)val3).currentBehaviourStateIndex == 0) { val3.ScareBaby(((Component)causingLungProp).transform.position); } } } private bool IsEnemyEligibleForMeltdown(EnemyType enemyType) { DawnEnemyInfo dawnInfo = EnemyTypeExtensions.GetDawnInfo(enemyType); if (dawnInfo == null) { MeltdownPlugin.logger.LogWarning((object)(((Object)enemyType).name + " has no DawnEnemyInfo and will not spawn during the meltdown sequence.")); return false; } if (!((DawnBaseInfo<DawnEnemyInfo>)(object)dawnInfo).HasTag(MeltdownTags.NotSpawnable)) { return !((DawnBaseInfo<DawnEnemyInfo>)(object)dawnInfo).HasTag(Tags.Unimplemented); } return false; } public override void OnNetworkSpawn() { //IL_001b: 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) if (MeltdownPlugin.loadedFully && ((NetworkBehaviour)this).IsServer) { MeltdownMoonMapper.EnsureMeltdownMoonMapper(); MeltdownInteriorMapper.EnsureMeltdownInteriorMapper(); if (effectOrigin == Vector3.zero) { MeltdownPlugin.logger.LogError((object)"Effect origin is Vector3.zero; the meltdown will not start on this moon."); return; } int meltdownTime = MeltdownPlugin.config.MeltdownTime; MeltdownPlugin.logger.LogInfo((object)$"Starting meltdown with host-configured duration: {meltdownTime} seconds."); SendStartMeltdownRpc(meltdownTime); } } protected override void __initializeRpcs() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown object obj = <>O.<1>____rpc_handler_3631067672; if (obj == null) { RpcReceiveHandler val = __rpc_handler_3631067672; <>O.<1>____rpc_handler_3631067672 = val; obj = (object)val; } ((NetworkBehaviour)this).__registerRpc(3631067672u, (RpcReceiveHandler)obj, "StartMeltdownClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_3631067672(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0044: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (!(target is MeltdownHandler meltdownHandler)) { return; } NetworkManager networkManager = ((NetworkBehaviour)meltdownHandler).NetworkManager; if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening) { if (!((FastBufferReader)(ref reader)).TryBeginRead(4)) { MeltdownPlugin.logger.LogError((object)"Meltdown start RPC was missing its duration."); return; } int duration = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref duration, default(ForPrimitives)); ((NetworkBehaviour)meltdownHandler).__rpc_exec_stage = (__RpcExecStage)1; meltdownHandler.SendStartMeltdownRpc(duration); ((NetworkBehaviour)meltdownHandler).__rpc_exec_stage = (__RpcExecStage)0; } } internal bool EnemyCannotBeSpawned(EnemyType type) { if (!type.spawningDisabled) { return type.numberSpawned >= type.MaxCount; } return true; } internal static DialogueSegment[] GetDialogue(string translation) { //IL_0019: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown JArray translationSet = LangParser.GetTranslationSet(translation); DialogueSegment[] array = (DialogueSegment[])(object)new DialogueSegment[((JContainer)translationSet).Count]; for (int i = 0; i < ((JContainer)translationSet).Count; i++) { array[i] = new DialogueSegment { bodyText = ((string)translationSet[i]).Replace("<meltdown_time>", ((Instance?.Duration ?? ((float)MeltdownPlugin.config.MeltdownTime)) / 60f).ToString("0.#", CultureInfo.InvariantCulture)), speakerText = "meltdown.dialogue.speaker".Translate() }; } return array; } private void SpawnCountdownShockwave() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = effectOrigin; GameObject val2 = MeltdownPlugin.companion?.Visual; Transform val3 = (((Object)(object)val2 != (Object)null) ? val2.transform.Find("BigShockWave") : null); ParticleSystemRenderer val4 = default(ParticleSystemRenderer); if ((Object)(object)val3 == (Object)null || !((Component)val3).TryGetComponent<ParticleSystemRenderer>(ref val4)) { GameObject shockwavePrefab = MeltdownPlugin.assets.shockwavePrefab; if ((Object)(object)legacyShockwave != (Object)null) { Object.Destroy((Object)(object)legacyShockwave); } legacyShockwave = Object.Instantiate<GameObject>(shockwavePrefab, val, shockwavePrefab.transform.rotation); } else { GameObject val5 = new GameObject("FacilityMeltdownCountdownShockwave"); val5.transform.position = val; Transform val6 = Object.Instantiate<Transform>(val3, val5.transform, false); ParticleSystem component = ((Component)val6).GetComponent<ParticleSystem>(); val5.AddComponent<Shockwave>(); countdownWaves.Add(val5); ((MonoBehaviour)this).StartCoroutine(CleanUpCountdownWave(val5, component)); } } private IEnumerator CleanUpCountdownWave(GameObject wave, ParticleSystem particles) { yield return null; while (Object.op_Implicit((Object)(object)particles) && particles.IsAlive(true)) { yield return null; } countdownWaves.Remove(wave); if (Object.op_Implicit((Object)(object)wave)) { Object.Destroy((Object)(object)wave); } } private void OnDisable() { if ((Object)(object)Instance != (Object)(object)this) { return; } MeltdownPlugin.logger.LogInfo((object)"Cleaning up MeltdownHandler."); Instance = null; if ((Object)(object)explosion != (Object)null) { Object.Destroy((Object)(object)explosion); } if ((Object)(object)companionVisual != (Object)null) { Object.Destroy((Object)(object)companionVisual); } StopLocationMusic(); if ((Object)(object)legacyShockwave != (Object)null) { Object.Destroy((Object)(object)legacyShockwave); } foreach (GameObject countdownWave in countdownWaves) { if (Object.op_Implicit((Object)(object)countdownWave)) { Object.Destroy((Object)(object)countdownWave); } } countdownWaves.Clear(); if (!meltdownStarted) { MeltdownPlugin.logger.LogError((object)"MeltdownHandler was disabled without starting a meltdown, a client most likely failed the MeltdownReadyCheck. If you are going to report this make sure to provide ALL client logs."); } } private void Update() { //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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) if (!meltdownStarted || HasExplosionOccured()) { return; } StartOfRound instance = StartOfRound.Instance; meltdownTimer -= Time.deltaTime; if (!eveningLightingChecked && meltdownTimer <= 3f) { eveningLightingChecked = true; MeltdownEveningLighting.Begin(TimeOfDay.Instance, meltdownTimer); } float num = (float)MeltdownPlugin.config.MusicVolume / 100f; bool flag = Player.isInsideFactory || MeltdownPlugin.config.MusicPlaysOutside; if (locationMusic != null) { UpdateLocationMusic(flag ? num : 0f); } else { meltdownMusic.volume = (flag ? num : 0f); } if (meltdownTimer <= 3f && !instance.shipIsLeaving) { ((MonoBehaviour)this).StartCoroutine(ShipTakeOff()); } if (!(meltdownTimer <= 0f)) { return; } meltdownMusic.Stop(); StopLocationMusic(); if (locationMusic != null) { warningSource.Stop(); } GameObject val = MeltdownMoonMapper.Instance.explosionPrefab; detonated = true; if ((Object)(object)val == (Object)null && MeltdownPlugin.companion != null) { explosion = new GameObject("FacilityMeltdownBlast"); explosion.transform.position = effectOrigin; explosion.AddComponent<FacilityExplosionHandler>(); GameObject visual = MeltdownPlugin.companion.Visual; companionVisual = Object.Instantiate<GameObject>(visual, effectOrigin, visual.transform.rotation); ((MonoBehaviour)this).StartCoroutine(CleanUpVisual(companionVisual)); PlayBlast(); PlayPrefabDetonationAudio(companionVisual); return; } if ((Object)(object)val == (Object)null) { val = MeltdownPlugin.assets.facilityExplosionPrefab; } MeltdownPlugin.LogVerbose($"Detonation at {effectOrigin}, prefab {((Object)val).name}, camera shake {MeltdownPlugin.config.ScreenShake}."); explosion = Object.Instantiate<GameObject>(val, effectOrigin, val.transform.rotation); FacilityExplosionHandler facilityExplosionHandler = default(FacilityExplosionHandler); if (!explosion.TryGetComponent<FacilityExplosionHandler>(ref facilityExplosionHandler)) { explosion.AddComponent<FacilityExplosionHandler>(); } if (MeltdownPlugin.companion != null && !explosion.GetComponentsInChildren<AudioSource>().Any((AudioSource source) => ((Behaviour)source).enabled && Object.op_Implicit((Object)(object)source.clip) && (source.playOnAwake || source.isPlaying))) { PlayBlast(); } } private void StartLocationMusic() { AudioClip[] countdown = MeltdownPlugin.companion.Countdown; locationMusic = (AudioSource[])(object)new AudioSource[countdown.Length]; mixWeights[ListenerZone] = 1f; previousTimeLeft = meltdownTimer; for (int i = 0; i < countdown.Length; i++) { AudioSource val = ((i == 0) ? meltdownMusic : ((Component)meltdownMusic).gameObject.AddComponent<AudioSource>()); val.Stop(); val.playOnAwake = false; val.loop = false; val.spatialBlend = 0f; val.volume = 0f; val.outputAudioMixerGroup = meltdownMusic.outputAudioMixerGroup; val.clip = countdown[i]; locationMusic[i] = val; } } private void UpdateLocationMusic(float volume) { if (Mathf.Abs(previousTimeLeft - Time.deltaTime - meltdownTimer) > 0.1f) { pendingMusicSeek = true; } previousTimeLeft = meltdownTimer; float num = (pendingMusicSeek ? 0.18f : 0.3f); seekGain = Mathf.MoveTowards(seekGain, pendingMusicSeek ? 0f : 1f, Time.deltaTime / num); bool flag = pendingMusicSeek && seekGain == 0f; if (flag) { pendingMusicSeek = false; } int listenerZone = ListenerZone; for (int i = 0; i < locationMusic.Length; i++) { AudioSource val = locationMusic[i]; mixWeights[i] = Mathf.MoveTowards(mixWeights[i], (i == listenerZone) ? 1f : 0f, Time.deltaTime / 0.3f); val.volume = mixWeights[i] * volume * seekGain; float num2 = MeltdownPlugin.companion.Countdown[i].length - meltdownTimer; if (!(num2 < 0f) && !(meltdownTimer <= 0f) && (!musicStarted[i] || flag)) { if (!musicStarted[i]) { val.Play(); musicStarted[i] = true; } if (Object.op_Implicit((Object)(object)val.clip) && num2 < val.clip.length) { val.time = num2; } } } } private void StopLocationMusic() { if (locationMusic == null) { return; } AudioSource[] array = locationMusic; foreach (AudioSource val in array) { if (Object.op_Implicit((Object)(object)val)) { val.Stop(); } } } private void PlayPrefabDetonationAudio(GameObject visual) { Transform val = visual.transform.Find("DetonationAudio"); if (!((Object)(object)val == (Object)null)) { Transform obj = val.Find("Explosion"); AudioSource val2 = ((obj != null) ? ((Component)obj).GetComponent<AudioSource>() : null); Transform obj2 = val.Find("Distant"); AudioSource val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<AudioSource>() : null); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.clip) || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.clip)) { MeltdownPlugin.logger.LogWarning((object)"DetonationAudio needs an Explosion and a Distant AudioSource with clips assigned."); return; } val.SetParent((Transform)null, true); float num = (float)MeltdownPlugin.config.MusicVolume / 100f; AudioMixerGroup outputAudioMixerGroup = meltdownMusic.outputAudioMixerGroup; val2.volume *= num; val3.volume *= num; ((Component)val3).gameObject.AddComponent<DistantGain>(); val2.outputAudioMixerGroup = outputAudioMixerGroup; val3.outputAudioMixerGroup = outputAudioMixerGroup; double dspTime = AudioSettings.dspTime; double num2 = dspTime + 5.0; val2.Play(); val3.PlayScheduled(num2); ShipGeigerAudio shipGeigerAudio = ((Component)val).gameObject.AddComponent<ShipGeigerAudio>(); shipGeigerAudio.Begin(outputAudioMixerGroup, num, dspTime); float num3 = Mathf.Max(val2.clip.length, 5f + val3.clip.length); num3 = Mathf.Max(num3, 20f); Object.Destroy((Object)(object)((Component)val).gameObject, num3 + 0.1f); } } private void PlayBlast() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("MeltdownDetonation"); AudioSource val2 = val.AddComponent<AudioSource>(); val2.outputAudioMixerGroup = meltdownMusic.outputAudioMixerGroup; val2.spatialBlend = 0f; val2.volume = (float)MeltdownPlugin.config.MusicVolume / 100f; val2.clip = MeltdownPlugin.companion.Blast[ListenerZone]; val2.Play(); Object.Destroy((Object)(object)val, val2.clip.length + 0.1f); } private static IEnumerator CleanUpVisual(GameObject visual) { ParticleSystem particles = visual.GetComponent<ParticleSystem>(); yield return null; while (Object.op_Implicit((Object)(object)visual) && Object.op_Implicit((Object)(object)particles) && particles.IsAlive(true)) { yield return null; } if (Object.op_Implicit((Object)(object)visual)) { Object.Destroy((Object)(object)visual); } } private IEnumerator ShipTakeOff() { StartOfRound shipManager = StartOfRound.Instance; shipManager.shipLeftAutomatically = true; shipManager.shipIsLeaving = true; HUDManager.Instance.ReadDialogue(GetDialogue("meltdown.dialogue.shiptakeoff")); yield return (object)new WaitForSeconds(3f); yield return (object)new WaitForSeconds(3f); ((Behaviour)HUDManager.Instance.shipLeavingEarlyIcon).enabled = false; StartMatchLever val = Object.FindObjectOfType<StartMatchLever>(); val.triggerScript.animationString = "SA_PushLeverBack"; val.leverHasBeenPulled = false; val.triggerScript.interactable = false; val.leverAnimatorObject.SetBool("pullLever", false); shipManager.ShipLeave(); yield return (object)new WaitForSeconds(1.5f); if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { shipManager.SetSpectateCameraToGameOverMode(true, (PlayerControllerB)null); GameNetworkManager.Instance.localPlayerController.SetSpectatedPlayerEffects(true); } yield return (object)new WaitForSeconds(1f); yield return (object)new WaitForSeconds(9.5f); } public bool HasExplosionOccured() { return detonated; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected internal override string __getTypeName() { return "MeltdownHandler"; } } internal sealed class ShipGeigerAudio : MonoBehaviour { private const float HoldSeconds = 10f; private const float FadeSeconds = 10f; internal const float Duration = 20f; internal void Begin(AudioMixerGroup mixer, float volume, double detonationTime) { AudioSource first = CreateSource(mixer, volume); AudioSource second = CreateSource(mixer, volume); double endTime = detonationTime + 20.0; ((MonoBehaviour)this).StartCoroutine(PlayGeiger(first, second, volume, detonationTime, endTime, 10.0)); } private AudioSource CreateSource(AudioMixerGroup mixer, float volume) { AudioSource val = ((Component)this).gameObject.AddComponent<AudioSource>(); val.playOnAwake = false; val.loop = false; val.outputAudioMixerGroup = mixer; val.volume = volume; val.spatialBlend = 0f; return val; } private static AudioClip PickClip() { if (!(Random.value < 0.5f)) { return MeltdownPlugin.assets.highRadiation; } return MeltdownPlugin.assets.mediumRadiation; } private static IEnumerator PlayGeiger(AudioSource first, AudioSource second, float volume, double detonationTime, double endTime, double fadeSeconds) { first.clip = PickClip(); first.Play(); AudioSource nextSource = second; double nextStart = detonationTime + (double)first.clip.length; double queueAfter = detonationTime; while (AudioSettings.dspTime < endTime) { double dspTime = AudioSettings.dspTime; if (dspTime >= queueAfter && nextStart < endTime) { AudioClip val = (nextSource.clip = PickClip()); nextSource.PlayScheduled(nextStart); if (nextStart + (double)val.length > endTime) { nextSource.SetScheduledEndTime(endTime); } queueAfter = nextStart; nextStart += (double)val.length; nextSource = (((Object)(object)nextSource == (Object)(object)first) ? second : first); } float num = Mathf.Clamp01((float)((endTime - dspTime) / fadeSeconds)); first.volume = volume * num; second.volume = volume * num; yield return null; } first.Stop(); second.Stop(); } } internal sealed class DistantGain : MonoBehaviour { private const float Gain = 2f; private void OnAudioFilterRead(float[] data, int channels) { for (int i = 0; i < data.Length; i++) { data[i] *= 2f; } } } public class Shockwave : MonoBehaviour { private bool localPlayerCameraShake; private float size; private AudioSource sound; private Renderer waveRenderer; private bool scaleLegacyMesh; private void Awake() { sound = ((Component)this).gameObject.AddComponent<AudioSource>(); sound.clip = MeltdownPlugin.assets.shockwave; sound.spatialBlend = 0f; sound.loop = false; waveRenderer = ((Component)this).GetComponent<Renderer>(); scaleLegacyMesh = (Object)(object)waveRenderer != (Object)null; if (!scaleLegacyMesh) { waveRenderer = (Renderer)(object)((Component)this).GetComponentInChildren<ParticleSystemRenderer>(); } } private void Update() { //IL_0031: 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 localPlayerController = GameNetworkManager.Instance.localPlayerController; size += Time.deltaTime * 50f; if (scaleLegacyMesh) { ((Component)this).transform.localScale = Vector3.one * size; } if (localPlayerController.isInsideFactory) { waveRenderer.enabled = false; return; } waveRenderer.enabled = true; if (PlayerIsInsideShockwave() && !localPlayerCameraShake && MeltdownPlugin.config.ScreenShake) { ScreenShake(); localPlayerCameraShake = true; sound.Play(); } } private void ScreenShake() { HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } internal bool PlayerIsInsideShockwave() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) <= size; } } internal sealed class MeltdownEveningLighting : MonoBehaviour { private static readonly int TimeOfDayParameter = Animator.StringToHash("timeOfDay"); private TimeOfDay clock; private Animator sun; private float startingValue; private float targetValue; private float startTime; private float fadeSeconds; internal static void Begin(TimeOfDay clock, float secondsUntilDetonation) { if (!Object.op_Implicit((Object)(object)clock) || !Object.op_Implicit((Object)(object)clock.sunAnimator) || clock.numberOfHours <= 0) { return; } float num = 17f / (float)clock.numberOfHours; if (!(clock.normalizedTimeOfDay >= num)) { Animator sunAnimator = clock.sunAnimator; if (!Object.op_Implicit((Object)(object)((Component)sunAnimator).GetComponent<MeltdownEveningLighting>())) { MeltdownEveningLighting meltdownEveningLighting = ((Component)sunAnimator).gameObject.AddComponent<MeltdownEveningLighting>(); meltdownEveningLighting.clock = clock; meltdownEveningLighting.sun = sunAnimator; meltdownEveningLighting.startingValue = sunAnimator.GetFloat(TimeOfDayParameter); meltdownEveningLighting.targetValue = Mathf.Clamp(num, 0f, 0.99f); meltdownEveningLighting.startTime = Time.time; meltdownEveningLighting.fadeSeconds = Mathf.Max(0f, secondsUntilDetonation); } } } private void LateUpdate() { StartOfRound instance = StartOfRound.Instance; if (!Object.op_Implicit((Object)(object)instance) || instance.inShipPhase || !Object.op_Implicit((Object)(object)clock) || !Object.op_Implicit((Object)(object)sun) || (Object)(object)clock.sunAnimator != (Object)(object)sun) { Object.Destroy((Object)(object)this); } else if (clock.normalizedTimeOfDay >= targetValue) { Object.Destroy((Object)(object)this); } else { ApplyEveningLighting(); } } internal void ApplyEveningLighting() { float num = ((fadeSeconds > 0f) ? Mathf.Clamp01((Time.time - startTime) / fadeSeconds) : 1f); sun.SetFloat(TimeOfDayParameter, Mathf.SmoothStep(startingValue, targetValue, num)); } private void OnDisable() { if (Object.op_Implicit((Object)(object)clock) && Object.op_Implicit((Object)(object)sun) && (Object)(object)clock.sunAnimator == (Object)(object)sun) { sun.SetFloat(TimeOfDayParameter, Mathf.Clamp(clock.normalizedTimeOfDay, 0f, 0.99f)); } } } } namespace FacilityMeltdown.Lang { internal static class LangParser { internal static Dictionary<string, string> languages { get; private set; } internal static Dictionary<string, object> loadedLanguage { get; private set; } internal static Dictionary<string, object> defaultLanguage { get; private set; } internal static void Init() { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FacilityMeltdown.Lang.defs.json"); using StreamReader streamReader = new StreamReader(stream); string text = streamReader.ReadToEnd(); languages = JsonConvert.DeserializeObject<Dictionary<string, string>>(text); defaultLanguage = LoadLanguage("en"); } internal static Dictionary<string, object> LoadLanguage(string id) { using Stream stream = File.Open(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lang", id + ".json"), FileMode.Open); using StreamReader streamReader = new StreamReader(stream); string text = streamReader.ReadToEnd(); return JsonConvert.DeserializeObject<Dictionary<string, object>>(text); } internal static void SetLanguage(string id) { MeltdownPlugin.logger.LogInfo((object)("Loading language: " + languages[id] + " (" + id + ")")); loadedLanguage = LoadLanguage(id); MeltdownPlugin.logger.LogInfo((object)("Loaded " + languages[id])); } internal static string GetTranslation(string translation) { if (loadedLanguage.TryGetValue(translation, out var value)) { return (string)value; } if (defaultLanguage.TryGetValue(translation, out value)) { MeltdownPlugin.logger.LogError((object)("Falling back to english. for translation: " + translation)); return (string)value; } if (translation == "lang.missing") { MeltdownPlugin.logger.LogError((object)"LANG.MISSING IS MISSING!!!!! THIS IS BAD!! VERY BAD!!"); return "lang.missing; <translation_id>"; } return GetTranslation("lang.missing").Replace("<translation_id>", translation); } internal static JArray GetTranslationSet(string translation) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown if (loadedLanguage.TryGetValue(translation, out var value)) { return (JArray)((value is JArray) ? value : null); } if (defaultLanguage.TryGetValue(translation, out value)) { MeltdownPlugin.logger.LogError((object)("Falling back to english. for translation (dialogue): " + translation)); return (JArray)((value is JArray) ? value : null); } JArray val = new JArray(); val.Add(JToken.op_Implicit(GetTranslation("lang.missing").Replace("<translation_id>", translation))); return val; } } } namespace FacilityMeltdown.Integrations { internal static class DiomedesIntergration { private sealed class TriggerMeltdownChallenge : BingoChallenge { public NamespacedKey<DawnMoonInfo> MoonKey; private readonly string moonName; public TriggerMeltdownChallenge(string moonName) { this.moonName = moonName; MeltdownAPI.OnMeltdownStart = (Action)Delegate.Combine(MeltdownAPI.OnMeltdownStart, new Action(OnMeltdownStart)); } private void OnMeltdownStart() { DawnMoonInfo dawnInfo = SelectableLevelExtensions.GetDawnInfo(StartOfRound.Instance.currentLevel); if (MoonKey == null || (dawnInfo != null && (object)((DawnBaseInfo<DawnMoonInfo>)(object)dawnInfo).Key == MoonKey)) { ((BingoChallenge)this).Complete(); } } protected override void Cleanup() { ((BingoChallenge)this).Cleanup(); MeltdownAPI.OnMeltdownStart = (Action)Delegate.Remove(MeltdownAPI.OnMeltdownStart, new Action(OnMeltdownStart)); } public override BingoUIState CreateUI() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown return new BingoUIState { Name = "Trigger Meltdown on " + moonName }; } } public static readonly NamespacedKey<ChallengeInfo> TriggerMeltdown = NamespacedKey<ChallengeInfo>.From("facility_meltdown", "trigger_meltdown"); public static readonly NamespacedKey<ChallengeGroup> MeltdownGroup = NamespacedKey<ChallengeGroup>.From("facility_meltdown", "meltdown_bingo"); public static bool Enabled { get; private set; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void Initialize() { Enabled = true; DiomedesClientAPI.DefineBingoChallengeGroup(MeltdownGroup, (Action<ChallengeGroupBuilder>)delegate(ChallengeGroupBuilder builder) { builder.WithMaxAmount(1); }); List<(NamespacedKey<DawnMoonInfo>, string)> list = new List<(NamespacedKey<DawnMoonInfo>, string)> { (null, "any moon"), (MoonKeys.Embrion, "Embrion"), (MoonKeys.Artifice, "Artifice"), (MoonKeys.Titan, "Titan") }; foreach (var item in list) { var (moonKey, moonName) = item; DiomedesClientAPI.DefineBingoChallenge(TriggerMeltdown, (Func<BingoChallenge>)(() => (BingoChallenge)(object)new TriggerMeltdownChallenge(moonName) { MoonKey = moonKey }), (Action<ChallengeInfoBuilder>)delegate(ChallengeInfoBuilder builder) { builder.AddToGroup(MeltdownGroup).AddToGroup(DiomedesKeys.ApparatusGroup); }); } } } internal class LethalConfigIntergration { public static bool Enabled { get; private set; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void Initialize() { Enabled = true; LethalConfigManager.SetModDescription("Maybe taking the appartus isn't such a great idea..."); HandleConfig(MeltdownPlugin.config); } private static void HandleConfig<T>(LoafConfig<T> config) where T : LoafConfig<T> { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown bool flag = true; if (config.GetType().GetCustomAttribute<RequiresRestartAttribute>() != null) { flag = config.GetType().GetCustomAttribute<RequiresRestartAttribute>().RequiresRestart; } foreach (var configEntry in config.configEntries) { PropertyInfo property = configEntry.Item1; object uncastedEntry = configEntry.Item2; bool flag2 = flag; RequiresRestartAttribute customAttribute = property.GetCustomAttribute<RequiresRestartAttribute>(); if (customAttribute != null) { flag2 = customAttribute.RequiresRestart; } ConfigRangeAttribute customAttribute2 = property.GetCustomAttribute<ConfigRangeAttribute>(); if (property.PropertyType == typeof(int)) { if (customAttribute2 == null) { throw new NotImplementedException(property.Name + ": config entry of type: int, must have a range attribute, because i was too lazy lmao"); } ConfigEntry<int> obj = (ConfigEntry<int>)uncastedEntry; IntSliderOptions val = new IntSliderOptions(); ((BaseRangeOptions<int>)val).Min = (int)customAttribute2.Min; ((BaseRangeOptions<int>)val).Max = (int)customAttribute2.Max; ((BaseOptions)val).RequiresRestart = flag2; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj, val)); if (!flag2) { ((ConfigEntry<int>)uncastedEntry).SettingChanged += delegate { property.SetValue(config, ((ConfigEntry<int>)uncastedEntry).Value); }; } } if (property.PropertyType == typeof(float)) { if (customAttribute2 == null) { throw new NotImplementedException(property.Name + ": config entry of type: float, must have a range attribute, because i was too lazy lmao"); } ConfigEntry<float> obj2 = (ConfigEntry<float>)uncastedEntry; FloatSliderOptions val2 = new FloatSliderOptions(); ((BaseRangeOptions<float>)val2).Min = customAttribute2.Min; ((BaseRangeOptions<float>)val2).Max = customAttribute2.Max; ((BaseOptions)val2).RequiresRestart = flag2; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(obj2, val2)); if (!flag2) { ((ConfigEntry<float>)uncastedEntry).SettingChanged += delegate { property.SetValue(config, ((ConfigEntry<float>)uncastedEntry).Value); }; } } if (property.PropertyType == typeof(bool)) { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem((ConfigEntry<bool>)uncastedEntry, flag2)); if (!flag2) { ((ConfigEntry<bool>)uncastedEntry).SettingChanged += delegate { property.SetV