Decompiled source of Heat v1.5.10
plugins/Heat/net6/CustomRundownLabels.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.Json; using BepInEx; using BepInEx.Unity.IL2CPP; using GameData; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("CustomRundownLabels")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CustomRundownLabels")] [assembly: AssemblyTitle("CustomRundownLabels")] [assembly: AssemblyVersion("1.0.0.0")] namespace CustomRundownLabels; public class ConfigSerializer<T> where T : new() { private string JsonPath; private T JsonSettings; private FileStream JsonFile; private JsonSerializerOptions JsonOptions; public T Settings => JsonSettings; public ConfigSerializer(string jsonName) { JsonPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), jsonName + ".json"); JsonSettings = new T(); JsonOptions = new JsonSerializerOptions { AllowTrailingCommas = true, WriteIndented = true }; if (File.Exists(JsonPath)) { JsonFile = File.OpenRead(JsonPath); JsonSettings = JsonSerializer.Deserialize<T>(JsonFile, JsonOptions); } else { JsonFile = File.OpenWrite(JsonPath); JsonSerializer.Serialize(JsonFile, JsonSettings, JsonOptions); } JsonFile.Close(); } } [BepInPlugin("me.bro.customrundownlabels", "CustomRundownLabels", "1.0.0")] public class EntryPoint : BasePlugin { public ConfigSerializer<fucking> Fucking; public override void Load() { PlayFabManager.OnTitleDataUpdated += Action.op_Implicit((Action)Setup); } public void Setup() { Fucking = new ConfigSerializer<fucking>("CustomRundownName"); int num = 0; Enumerator<CM_RundownSelection> enumerator = MainMenuGuiLayer.Current.PageRundownNew.m_rundownSelections.GetEnumerator(); while (enumerator.MoveNext()) { CM_RundownSelection current = enumerator.Current; if ((Object)(object)current.m_altText != (Object)null) { Object.Destroy((Object)(object)((Component)current.m_altText).gameObject); } ((TMP_Text)current.m_rundownText).text = Fucking.Settings.Labels[num]; num++; } } } public class fucking { public bool UseCustomNames { get; set; } public List<string> Labels { get; set; } public fucking() { Labels = new List<string> { "R1", "R7", "R2", "R3", "R4", "R5", "R6", "R8" }; } private void nextfucking() { Enumerator<CM_RundownSelection> enumerator = MainMenuGuiLayer.Current.PageRundownNew.m_rundownSelections.GetEnumerator(); while (enumerator.MoveNext()) { CM_RundownSelection current = enumerator.Current; uint num = uint.Parse(current.RundownKey.Substring("Local_".Length)); if (GameDataBlockBase<RundownDataBlock>.s_blockByID != null && GameDataBlockBase<RundownDataBlock>.s_blockByID.ContainsKey(num)) { RundownDataBlock val = GameDataBlockBase<RundownDataBlock>.s_blockByID[num]; string untranslatedText = val.StorytellingData.Title.UntranslatedText; Labels.Add(untranslatedText); } } } }
plugins/Heat/net6/ExtraEnemyCustomization_Revised.dll
Decompiled 5 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using System.Text.RegularExpressions; using System.Threading.Tasks; using AIGraph; using AK; using Agents; using AssetShards; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using CellMenu; using CullingSystem; using EEC.API; using EEC.Configs; using EEC.Configs.Customizations; using EEC.CustomAbilities.Bleed; using EEC.CustomAbilities.Bleed.Handlers; using EEC.CustomAbilities.Bleed.Inject; using EEC.CustomAbilities.DrainStamina; using EEC.CustomAbilities.EMP; using EEC.CustomAbilities.EMP.Handlers; using EEC.CustomAbilities.EMP.Inject; using EEC.CustomAbilities.Explosion; using EEC.CustomAbilities.Explosion.Handlers; using EEC.CustomSettings.CustomProjectiles; using EEC.CustomSettings.CustomScoutWaves; using EEC.CustomSettings.CustomTentacles; using EEC.EnemyCustomizations; using EEC.EnemyCustomizations.Abilities; using EEC.EnemyCustomizations.Abilities.Handlers; using EEC.EnemyCustomizations.Abilities.Inject; using EEC.EnemyCustomizations.Detections; using EEC.EnemyCustomizations.EnemyAbilities; using EEC.EnemyCustomizations.EnemyAbilities.Abilities; using EEC.EnemyCustomizations.EnemyAbilities.Events; using EEC.EnemyCustomizations.EnemyAbilities.Handlers; using EEC.EnemyCustomizations.Models; using EEC.EnemyCustomizations.Models.Handlers; using EEC.EnemyCustomizations.Properties; using EEC.EnemyCustomizations.Shared; using EEC.EnemyCustomizations.Shared.Handlers; using EEC.EnemyCustomizations.Shooters; using EEC.EnemyCustomizations.Shooters.Handlers; using EEC.EnemyCustomizations.Strikers; using EEC.Events; using EEC.Managers; using EEC.Managers.Assets; using EEC.Managers.Properties; using EEC.Networking; using EEC.Networking.Events; using EEC.Networking.Replicators; using EEC.Patches.Handlers; using EEC.Utils; using EEC.Utils.Integrations; using EEC.Utils.Json; using EEC.Utils.Json.Converters; using EEC.Utils.Json.Elements; using EEC.Utils.Unity; using Enemies; using GTFO.API; using GTFO.API.Utilities; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppInterop.Runtime.InteropTypes.Fields; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Localization; using Microsoft.CodeAnalysis; using Player; using SNetwork; using SemanticVersioning; using StateMachines; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ExtraEnemyCustomization")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ExtraEnemyCustomization")] [assembly: AssemblyTitle("ExtraEnemyCustomization")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EEC { [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] internal sealed class CallConstructorOnLoadAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] internal sealed class InjectToIl2CppAttribute : Attribute { } public static class Configuration { public const string SECTION_USER = "1. User-End"; public const string SECTION_RUNDEVS = "2. Rundown Developer"; public const string SECTION_LOGGING = "3. Logging"; public const string SECTION_DEV = "4. DEBUG"; public const int CONFIG_VERSION = 1; private static ConfigEntry<bool> _showMarkerText; private static ConfigEntry<bool> _showMarkerDistance; private static ConfigEntry<bool> _showExplosionEffect; private static ConfigEntry<ShitpostType> _shitpostType; private static ConfigEntry<bool> _useLiveEdit; private static ConfigEntry<bool> _linkMTFOHotReload; private static ConfigEntry<bool> _useDebugLog; private static ConfigEntry<bool> _useVerboseLog; private static ConfigEntry<AssetCacheManager.OutputType> _assetCacheBehaviour; private static ConfigEntry<bool> _dumpConfig; private static ConfigEntry<bool> _profiler; private static ConfigFile _currentContext; public static bool ShowMarkerText { get; private set; } public static bool ShowMarkerDistance { get; private set; } public static bool ShowExplosionEffect { get; private set; } public static ShitpostType ShitpostType { get; private set; } public static bool UseLiveEdit { get; private set; } public static bool LinkMTFOHotReload { get; private set; } public static bool UseDebugLog { get; private set; } public static bool UseVerboseLog { get; private set; } public static AssetCacheManager.OutputType AssetCacheBehaviour { get; private set; } public static bool DumpConfig { get; private set; } public static bool Profiler { get; private set; } public static bool CanShitpostOf(ShitpostType type) { switch (ShitpostType) { case ShitpostType.ForceOff: return false; case ShitpostType.Enable: { DateTime now = DateTime.Now; if (now.Month == 4) { return now.Day == 1; } return false; } default: return ShitpostType.HasFlag(type); } } public static void CreateAndBindAll() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, "EEC.cfg"); ConfigFile context = new ConfigFile(text, true); if (BindConfigVersion(context).Value < 1) { File.Delete(text); context = new ConfigFile(text, true); BindConfigVersion(context); } BindAll(context); } public static void BindAll(ConfigFile context) { _currentContext = context; _showMarkerText = BindUserConfig("Marker Text", "Display Enemy Marker Texts? (if set by rundown devs)", defaultValue: true); _showMarkerDistance = BindUserConfig("Marker Distance", "Display Enemy Marker Distance? (if set by rundown devs)", defaultValue: true); _showExplosionEffect = BindUserConfig("Explosion Flash", "(Accessibility) Display Light flash effect for explosion abilities?", defaultValue: true); _shitpostType = BindUserConfig("Shitposting", "Shitpost mode use comma to enable multiple stuffs", ShitpostType.ForceOff); ShowMarkerText = _showMarkerText.Value; ShowMarkerDistance = _showMarkerDistance.Value; ShowExplosionEffect = _showExplosionEffect.Value; ShitpostType = _shitpostType.Value; _useLiveEdit = BindRdwDevConfig("Live Edit", "Reload Config when they are edited while in-game", defaultValue: false); _linkMTFOHotReload = BindRdwDevConfig("Reload on MTFO HotReload", "Reload Configs when MTFO's HotReload button has pressed?", defaultValue: true); UseLiveEdit = _useLiveEdit.Value; LinkMTFOHotReload = _linkMTFOHotReload.Value; _useDebugLog = BindLoggingConfig("UseDevMessage", "Using Dev Message for Debugging your config?", defaultValue: false); _useVerboseLog = BindLoggingConfig("Verbose", "Using Much more detailed Message for Debugging?", defaultValue: false); _assetCacheBehaviour = BindLoggingConfig("Cached Asset Result Output", "How does your cached material/texture result be returned?", AssetCacheManager.OutputType.None); UseDebugLog = _useDebugLog.Value; UseVerboseLog = _useVerboseLog.Value; AssetCacheBehaviour = _assetCacheBehaviour.Value; _dumpConfig = BindDevConfig("DumpConfig", "Dump Empty Config file?", defaultValue: false); _profiler = BindDevConfig("Profiler", "Show Profiler Info for Spawned Event", defaultValue: false); DumpConfig = _dumpConfig.Value; Profiler = _profiler.Value; } private static ConfigEntry<int> BindConfigVersion(ConfigFile context) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown return context.Bind<int>(new ConfigDefinition("Version", "Config Version"), 1, (ConfigDescription)null); } private static ConfigEntry<T> BindUserConfig<T>(string name, string description, T defaultValue) { return BindItem(_currentContext, "1. User-End", name, description, defaultValue); } private static ConfigEntry<T> BindRdwDevConfig<T>(string name, string description, T defaultValue) { return BindItem(_currentContext, "2. Rundown Developer", name, description, defaultValue); } private static ConfigEntry<T> BindLoggingConfig<T>(string name, string description, T defaultValue) { return BindItem(_currentContext, "3. Logging", name, description, defaultValue); } private static ConfigEntry<T> BindDevConfig<T>(string name, string description, T defaultValue) { return BindItem(_currentContext, "4. DEBUG", name, description, defaultValue); } private static ConfigEntry<T> BindItem<T>(ConfigFile context, string section, string name, string description, T defaultValue) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001b: Expected O, but got Unknown return context.Bind<T>(new ConfigDefinition(section, name), defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } } [BepInPlugin("GTFO.EECustomization", "EECustom", "1.7.7")] [BepInProcess("GTFO.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class EntryPoint : BasePlugin { public static Harmony HarmonyInstance { get; private set; } public static string BasePath { get; private set; } public override void Load() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown Configuration.CreateAndBindAll(); Logger.Initialize(); InjectAllIl2CppType(); CallAllAutoConstructor(); BasePath = Path.Combine(MTFOUtil.CustomPath, "ExtraEnemyCustomization"); HarmonyInstance = new Harmony("EEC.Harmony"); HarmonyInstance.PatchAll(); NetworkManager.Initialize(); ConfigManager.Initialize(); if (Configuration.DumpConfig) { ConfigManager.DumpDefault(); } AssetEvents.AllAssetLoaded += AllAssetLoaded; AssetCacheManager.OutputMethod = Configuration.AssetCacheBehaviour; } private void AllAssetLoaded() { SpriteManager.Initialize(); AssetCacheManager.AssetLoaded(); ConfigManager.FireAssetLoaded(); ConfigManager.FirePrefabBuildEventAll(rebuildPrefabs: false); } public override bool Unload() { UninjectAllIl2CppType(); HarmonyInstance.UnpatchSelf(); ConfigManager.UnloadAllConfig(doClear: true); return ((BasePlugin)this).Unload(); } private void InjectAllIl2CppType() { Logger.Debug("Injecting IL2CPP Types"); IEnumerable<Type> allHandlers = GetAllHandlers(); Logger.Debug($" - Count: {allHandlers.Count()}"); foreach (Type item in allHandlers) { if (!ClassInjector.IsTypeRegisteredInIl2Cpp(item)) { ClassInjector.RegisterTypeInIl2Cpp(item); } } } private void CallAllAutoConstructor() { Logger.Debug("Calling Necessary Static .ctors"); IEnumerable<Type> allAutoConstructor = GetAllAutoConstructor(); Logger.Debug($" - Count: {allAutoConstructor.Count()}"); foreach (Type item in allAutoConstructor) { Logger.Debug("calling ctor of: " + item.Name); RuntimeHelpers.RunClassConstructor(item.TypeHandle); } } private void UninjectAllIl2CppType() { Logger.Debug("Uninjecting IL2CPP Types"); IEnumerable<Type> allHandlers = GetAllHandlers(); Logger.Debug($" - Count: {allHandlers.Count()}"); foreach (Type item in allHandlers) { ClassInjector.IsTypeRegisteredInIl2Cpp(item); } } private IEnumerable<Type> GetAllAutoConstructor() { return from type in ((object)this).GetType().Assembly.GetTypes() where type != null && Attribute.IsDefined(type, typeof(CallConstructorOnLoadAttribute)) select type; } private IEnumerable<Type> GetAllHandlers() { return from type in ((object)this).GetType().Assembly.GetTypes() where type != null && Attribute.IsDefined(type, typeof(InjectToIl2CppAttribute)) select type; } } public static class AgentExtension { public static bool TryCastToEnemyAgent(this Agent agent, out EnemyAgent enemyAgent) { return TryCast<EnemyAgent>(agent, (AgentType)1, out enemyAgent); } public static bool TryCastToPlayerAgent(this Agent agent, out PlayerAgent playerAgent) { return TryCast<PlayerAgent>(agent, (AgentType)0, out playerAgent); } private static bool TryCast<T>(Agent agent, AgentType type, out T result) where T : Agent { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)agent == (Object)null) && !((Il2CppObjectBase)agent).WasCollected && agent.Type == type) { T val = ((Il2CppObjectBase)agent).TryCast<T>(); if (!((Object)(object)val == (Object)null)) { result = val; return true; } } result = default(T); return false; } } public static class EasingExtension { public static float Evaluate(this eEasingType easeType, float progress, bool backward = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Easing.GetEasingValue(easeType, progress, backward); } public static Func<float, float, float, float, float> GetEaseFunction(this eEasingType easeType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected I4, but got Unknown return (easeType - 1) switch { 0 => Easing.EaseInQuad, 1 => Easing.EaseOutQuad, 2 => Easing.EaseInOutQuad, 3 => Easing.EaseInCubic, 4 => Easing.EaseOutCubic, 5 => Easing.EaseInOutCubic, 6 => Easing.EaseInQuart, 7 => Easing.EaseOutQuart, 8 => Easing.EaseInOutQuart, 9 => Easing.EaseInQuint, 10 => Easing.EaseOutQuint, 11 => Easing.EaseInOutQuint, 12 => Easing.EaseInSine, 13 => Easing.EaseOutSine, 14 => Easing.EaseInOutSine, 15 => Easing.EaseInExpo, 16 => Easing.EaseOutExpo, 17 => Easing.EaseInOutExpo, 18 => Easing.EaseInCirc, 19 => Easing.EaseOutCirc, 20 => Easing.EaseInOutCirc, _ => Easing.LinearTween, }; } } public static class EnemyAgentExtension { public static void AddOnDeadOnce(this EnemyAgent agent, Action onDead) { bool called = false; agent.OnDeadCallback += Action.op_Implicit((Action)delegate { if (!called) { onDead?.Invoke(); called = true; } }); } public static T RegisterOrGetProperty<T>(this EnemyAgent agent) where T : class, new() { return EnemyProperty<T>.RegisterOrGet(agent); } public static bool TryGetProperty<T>(this EnemyAgent agent, out T property) where T : class, new() { return EnemyProperty<T>.TryGet(agent, out property); } public static bool TryGetSpawnData(this EnemyAgent agent, out pEnemySpawnData spawnData) { return EnemySpawnDataManager.TryGet(((Agent)agent).GlobalID, out spawnData); } public static bool TryGetEnemyGroup(this EnemyAgent agent, out EnemyGroup group) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!agent.TryGetSpawnData(out var spawnData)) { group = null; return false; } if (spawnData.groupReplicatorKey == 0) { group = null; return false; } IReplicator val = default(IReplicator); if (SNet_Replication.TryGetReplicator(spawnData.groupReplicatorKey, ref val)) { group = null; return false; } if (val.ReplicatorSupplier == null) { group = null; return false; } group = ((Il2CppObjectBase)val.ReplicatorSupplier).TryCast<EnemyGroup>(); return (Object)(object)group != (Object)null; } public static AIG_CourseNode GetSpawnedNode(this EnemyAgent agent) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) pEnemySpawnData spawnData = ((SNet_DynamicReplicator<pEnemySpawnData>)(object)((Il2CppObjectBase)agent.Sync.Replicator).Cast<EnemyReplicator>()).GetSpawnData(); AIG_CourseNode result = default(AIG_CourseNode); if (!((pCourseNode)(ref spawnData.courseNode)).TryGet(ref result)) { return null; } return result; } } public static class EnemyDataBlockExtension { public static bool TryGetBehaviourBlock(this EnemyDataBlock data, out EnemyBehaviorDataBlock behaviour) { if (data == null) { behaviour = null; return false; } behaviour = GameDataBlockBase<EnemyBehaviorDataBlock>.GetBlock(data.BehaviorDataId); return behaviour != null; } public static bool TryGetBalancingBlock(this EnemyDataBlock data, out EnemyBalancingDataBlock balancing) { if (data == null) { balancing = null; return false; } balancing = GameDataBlockBase<EnemyBalancingDataBlock>.GetBlock(data.BalancingDataId); return balancing != null; } } public static class GameObjectExtension { public static bool TryGetComp<T>(this GameObject obj, out T component) { component = obj.GetComponent<T>(); return component != null; } public static T AddOrGetComponent<T>(this GameObject obj) where T : Component { if (!obj.TryGetComp<T>(out var component)) { return obj.AddComponent<T>(); } return component; } public static GameObject FindChild(this GameObject obj, string name, bool includeInactive = false) { foreach (Transform componentsInChild in obj.GetComponentsInChildren<Transform>(includeInactive)) { if (!(((Object)((Component)componentsInChild).gameObject).name != name)) { return ((Component)componentsInChild).gameObject; } } return null; } public static GameObject RegexFindChild(this GameObject obj, Regex rx, bool includeInactive = false) { foreach (Transform componentsInChild in obj.GetComponentsInChildren<Transform>(includeInactive)) { if (rx.IsMatch(((Object)componentsInChild).name)) { return ((Component)componentsInChild).gameObject; } } return null; } public static GameObject Instantiate(this GameObject obj, Transform toParent, string name) { //IL_0018: 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_002d: Unknown result type (might be due to invalid IL or missing references) GameObject obj2 = Object.Instantiate<GameObject>(obj); obj2.transform.parent = toParent; obj2.transform.localPosition = Vector3.zero; obj2.transform.localRotation = Quaternion.Euler(Vector3.zero); ((Object)obj2).name = name; return obj2; } } public static class MonoBehaviourExtension { public static Coroutine StartCoroutine(this MonoBehaviour self, IEnumerator routine) { return self.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } } public static class ProjectileTargetingExtension { public static bool TryGetOwnerEnemyDataID(this ProjectileBase projectile, out uint id) { if ((Object)(object)projectile == (Object)null) { id = 0u; return false; } return ProjectileOwnerManager.TryGetDataID(((Object)((Component)projectile).gameObject).GetInstanceID(), out id); } public static bool TryGetOwnerEnemyDataID(this ProjectileTargeting projectile, out uint id) { if ((Object)(object)projectile == (Object)null) { id = 0u; return false; } return ProjectileOwnerManager.TryGetDataID(((Object)((Component)projectile).gameObject).GetInstanceID(), out id); } public static bool TryGetOwner(this ProjectileBase projectile, out EnemyAgent agent) { if ((Object)(object)projectile == (Object)null) { agent = null; return false; } return ProjectileOwnerManager.TryGet(((Object)((Component)projectile).gameObject).GetInstanceID(), out agent); } public static bool TryGetOwner(this ProjectileTargeting projectile, out EnemyAgent agent) { if ((Object)(object)projectile == (Object)null) { agent = null; return false; } return ProjectileOwnerManager.TryGet(((Object)((Component)projectile).gameObject).GetInstanceID(), out agent); } } public static class StringExtension { public static bool InvariantEquals(this string str, string strToCompare, bool ignoreCase = false) { return str.Equals(strToCompare, ignoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture); } public static bool InvariantContains(this string str, string strToCompare, bool ignoreCase = false) { return str.Contains(strToCompare, ignoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture); } public static bool InvariantStartsWith(this string str, string strToCompare, bool ignoreCase = false) { return str.StartsWith(strToCompare, ignoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture); } public static bool InvariantEndsWith(this string str, string strToCompare, bool ignoreCase = false) { return str.EndsWith(strToCompare, ignoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture); } public static bool EqualsAnyIgnoreCase(this string input, params string[] args) { return input.EqualsAny(ignoreCase: true, args); } public static bool EqualsAny(this string input, bool ignoreCase, params string[] args) { StringComparison comparisonType = (ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal); foreach (string value in args) { if (input.Equals(value, comparisonType)) { return true; } } return false; } public static bool ContainsAnyIgnoreCase(this string input, params string[] args) { return input.ContainsAny(ignoreCase: true, args); } public static bool ContainsAny(this string input, bool ignoreCase, params string[] args) { StringComparison comparisonType = (ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal); foreach (string value in args) { if (input.Contains(value, comparisonType)) { return true; } } return false; } } public static class Logger { public static ManualLogSource LogInstance { get; private set; } public static bool UsingDevMessage { get; private set; } public static bool UsingVerbose { get; private set; } public static bool DevLogAllowed => UsingDevMessage; public static bool VerboseLogAllowed { get { if (UsingDevMessage) { return UsingVerbose; } return false; } } internal static void Initialize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown LogInstance = new ManualLogSource("EEC"); Logger.Sources.Add((ILogSource)(object)LogInstance); UsingDevMessage = Configuration.UseDebugLog; UsingVerbose = Configuration.UseVerboseLog; } public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { ManualLogSource logInstance = LogInstance; if (logInstance != null) { logInstance.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { ManualLogSource logInstance = LogInstance; if (logInstance != null) { logInstance.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { ManualLogSource logInstance = LogInstance; if (logInstance != null) { logInstance.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (UsingDevMessage) { ManualLogSource logInstance = LogInstance; if (logInstance != null) { logInstance.LogDebug((object)str); } } } public static void Verbose(string format, params object[] args) { Verbose(string.Format(format, args)); } public static void Verbose(string str) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!UsingDevMessage || !UsingVerbose) { return; } ManualLogSource logInstance = LogInstance; if (logInstance != null) { bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(10, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(str); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Verbose)"); } logInstance.LogDebug(val); } } [Conditional("DEBUG")] [Obsolete("Logger.Dev call will be removed in release mode!")] public static void Dev(string format, params object[] args) { } [Conditional("DEBUG")] [Obsolete("Logger.Dev call will be removed in release mode!")] public static void Dev(string str) { //IL_000a: 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_000c: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logInstance = LogInstance; if (logInstance != null) { LogLevel val = (LogLevel)8; LogLevel val2 = val; bool flag = default(bool); BepInExLogInterpolatedStringHandler val3 = new BepInExLogInterpolatedStringHandler(6, 1, val, ref flag); if (flag) { val3.AppendLiteral("[DEV] "); val3.AppendFormatted<string>(str); } logInstance.Log(val2, val3); } } } } namespace EEC.Utils { public static class EnemyAnimUtil { private static readonly Dictionary<EnemyAnimType, int[]> _animHashsLookup; private static bool _initialized; static EnemyAnimUtil() { _animHashsLookup = new Dictionary<EnemyAnimType, int[]>(Enum.GetValues(typeof(EnemyAnimType)).Length); } internal static void Initialize() { if (!_initialized) { CacheLookup(); _initialized = true; } } private static void CacheLookup() { Type typeFromHandle = typeof(EnemyLocomotion); foreach (EnemyAnimType value in Enum.GetValues(typeof(EnemyAnimType))) { switch (value) { case EnemyAnimType.Heartbeats: _animHashsLookup.Add(value, Il2CppArrayBase<int>.op_Implicit((Il2CppArrayBase<int>)(object)EnemyLocomotion.s_hashHearbeats)); Logger.Verbose($"{value}, {string.Join(" / ", (IEnumerable<int>)EnemyLocomotion.s_hashHearbeats)}"); continue; case EnemyAnimType.None: continue; } string text = "s_hash" + Enum.GetName(typeof(EnemyAnimType), value); PropertyInfo property = typeFromHandle.GetProperty(text, BindingFlags.Static | BindingFlags.Public); if (property == null) { Logger.Warning(text + " does not exist!"); } else if (property.PropertyType == typeof(int)) { _animHashsLookup.Add(value, new int[1] { (int)property.GetValue(null) }); Logger.Verbose($"{value}, {property.GetValue(null)}"); } else if (property.PropertyType == typeof(Il2CppStructArray<int>)) { int[] array = Il2CppArrayBase<int>.op_Implicit((Il2CppArrayBase<int>)(object)(Il2CppStructArray<int>)property.GetValue(null)); _animHashsLookup.Add(value, array); Logger.Verbose($"{value}, {string.Join(" / ", array)}"); } else { Logger.Error($"{value} is not a valid hash property!"); } } } public static void DoAnimationLocal(EnemyAgent agent, EnemyAnimType type, float crossfadeTime, bool pauseAI) { if (!_initialized) { Logger.Error("EnemyAnimUtil.DoAnimation was called too fast before it got cached!"); } else { if (type == EnemyAnimType.None) { return; } if (!_animHashsLookup.TryGetValue(type, out var value)) { Logger.Error($"Cannot find AnimationHash with: {type}"); return; } int num = ((value.Length > 1) ? Rand.IndexOf(value) : 0); agent.Locomotion.m_animator.applyRootMotion = true; agent.Locomotion.m_animator.CrossFadeInFixedTime(value[num], crossfadeTime); if (pauseAI && ((AgentAI)agent.AI).m_navMeshAgent.isOnNavMesh) { ((AgentAI)agent.AI).m_navMeshAgent.isStopped = true; } } } public static void DoAnimation(EnemyAgent agent, EnemyAnimType type, float crossfadeTime, bool pauseAI) { if (!_initialized) { Logger.Error("EnemyAnimUtil.DoAnimation was called too fast before it got cached!"); } else if (type != 0) { if (!_animHashsLookup.TryGetValue(type, out var value)) { Logger.Error($"Cannot find AnimationHash with: {type}"); return; } int num = ((value.Length > 1) ? Rand.IndexOf(value) : 0); NetworkManager.EnemyAnim.Send(new EnemyAnimEvent.Packet { enemyID = ((Agent)agent).GlobalID, crossfadeTime = crossfadeTime, pauseAI = pauseAI, animHash = value[num] }); } } } public enum EnemyAnimType : byte { None, MoveOnGround, Forward, Right, ClimbLadder, GiveBirth, HitLights_Fwd, HitLights_Bwd, HitLights_Rt, HitLights_Lt, HitHeavys_Fwd, HitHeavys_Bwd, HitHeavys_Rt, HitHeavys_Lt, Screams, ScreamTurns, HibernationIn, Heartbeats, HibernationWakeups, HibernationWakeupTurns, AbilityFires, AbilityUse, AbilityUseOut, MeleeWalkSequences, MeleeSequences, Melee180Sequences, JumpStart, JumpLand } public static class EnemyProperty<T> where T : class, new() { private static readonly Dictionary<ushort, T> _properties; public static IEnumerable<T> Properties => _properties.Values; static EnemyProperty() { _properties = new Dictionary<ushort, T>(); EnemyEvents.Despawn += EnemyDespawn; LevelEvents.LevelCleanup += OnLevelCleanup; } private static void EnemyDespawn(EnemyAgent agent) { _properties.Remove(((Agent)agent).GlobalID); } private static void OnLevelCleanup() { _properties.Clear(); } public static T RegisterOrGet(EnemyAgent agent) { T val = RegisterEnemy(agent); if (val != null) { return val; } return Get(agent); } public static T RegisterEnemy(EnemyAgent agent) { ushort globalID = ((Agent)agent).GlobalID; if (_properties.ContainsKey(globalID)) { return null; } T val = new T(); _properties.Add(globalID, val); return val; } public static T Get(EnemyAgent agent) { return Get(((Agent)agent).GlobalID); } public static T Get(ushort id) { if (_properties.ContainsKey(id)) { return _properties[id]; } return null; } public static bool TryGet(EnemyAgent agent, out T property) { return TryGet(((Agent)agent).GlobalID, out property); } public static bool TryGet(ushort id, out T property) { return _properties.TryGetValue(id, out property); } } [Obsolete("Will be moved to ExplosionManager")] public static class ExplosionUtil { public static void MakeExplosion(Vector3 position, float damage, float enemyMulti, float minRange, float maxRange) { //IL_000a: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) ExplosionData data = default(ExplosionData); data.position = position; data.damage = damage; data.enemyMulti = enemyMulti; data.minRange = minRange; data.maxRange = maxRange; data.lightColor = ExplosionManager.FlashColor; ExplosionManager.DoExplosion(data); } } public static class PlayerData { public static float MaxHealth { get; internal set; } = 25f; public static float MaxInfection { get; internal set; } = 1f; } public static class Rand { public const int InclusiveDoublePrecision = 10000; public const double InclusiveDoubleConversion = 0.0001; private static readonly Random _rand = new Random(); public static Random CreateInstance() { return new Random(_rand.Next()); } public static T ItemOf<T>(T[] array) { return array[IndexOf(array)]; } public static int IndexOf(Array array) { if (array == null) { throw new ArgumentNullException("array"); } if (array.Length == 0) { throw new ArgumentException("Array Length was zero!", "array"); } return _rand.Next(0, array.Length); } public static int Index(int length) { return _rand.Next(0, length); } public static int Range(int min, int max) { return _rand.Next(min, max); } public static float Range(float min, float max) { return NextFloat() * (max - min) + min; } public static int RangeInclusive(int min, int max) { return _rand.Next(min, max + 1); } public static float RangeInclusive(float min, float max) { return NextFloatInclusive() * (max - min) + min; } public static float NextFloatInclusive() { return Math.Clamp((float)NextDoubleInclusive(), 0f, 1f); } public static double NextDoubleInclusive() { return Math.Clamp((double)_rand.Next(0, 10001) * 0.0001, 0.0, 1.0); } public static float NextFloat() { return (float)_rand.NextDouble(); } public static bool CanDoBy(float chance01) { return NextFloat() <= chance01; } public static int NextInt() { return _rand.Next(); } } public static class RegexUtil { private static readonly Regex _vectorRegex = new Regex("-?[0-9.]+"); public static bool TryParseVectorString(string input, out float[] vectorArray) { try { MatchCollection matchCollection = _vectorRegex.Matches(input); int count = matchCollection.Count; if (count < 1) { throw new Exception(); } vectorArray = new float[count]; for (int i = 0; i < count; i++) { Match match = matchCollection[i]; vectorArray[i] = float.Parse(match.Value, CultureInfo.InvariantCulture); } return true; } catch { vectorArray = null; return false; } } } } namespace EEC.Utils.Unity { [CallConstructorOnLoad] public static class InLevelCoroutine { [InjectToIl2Cpp] private sealed class InLevelCoroutineHandler : MonoBehaviour { } private static InLevelCoroutineHandler _handler; static InLevelCoroutine() { AssetEvents.AllAssetLoaded += AssetEvents_AllAssetLoaded; LevelEvents.LevelCleanup += LevelEvents_LevelCleanup; SNetEvents.PrepareRecall += SNetEvents_PrepareRecall; } private static void AssetEvents_AllAssetLoaded() { //IL_000d: 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_0018: Expected O, but got Unknown if ((Object)(object)_handler == (Object)null) { GameObject val = new GameObject(); Object.DontDestroyOnLoad((Object)val); _handler = val.AddComponent<InLevelCoroutineHandler>(); } } private static void SNetEvents_PrepareRecall(eBufferType _) { StopAll(); } private static void LevelEvents_LevelCleanup() { StopAll(); } public static Coroutine Start(IEnumerator coroutine) { if ((Object)(object)_handler != (Object)null && GameStateManager.IsInExpedition) { return ((MonoBehaviour)_handler).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(coroutine)); } return null; } public static void Stop(Coroutine coroutine) { if ((Object)(object)_handler != (Object)null && GameStateManager.IsInExpedition) { ((MonoBehaviour)_handler).StopCoroutine(coroutine); } } public static void StopAll() { if ((Object)(object)_handler != (Object)null) { ((MonoBehaviour)_handler).StopAllCoroutines(); } } } public struct LazyTimer { private float _lastTickTime; private float _durationInv; public float PassedTime { get; private set; } public float Duration { get; private set; } public bool Done => Progress >= 1f; public float Progress => Mathf.Clamp01(ProgressUnclamped); public float ProgressUnclamped { get { if (Duration != 0f) { return PassedTime * _durationInv; } return 1f; } } public LazyTimer(float duration) { PassedTime = 0f; Duration = duration; _durationInv = 1f / duration; _lastTickTime = GetTime(); } public void Reset(float newDuration = -1f) { PassedTime = 0f; if (newDuration >= 0f) { Duration = newDuration; _durationInv = 1f / newDuration; } _lastTickTime = GetTime(); } public void Tick() { float time = GetTime(); float num = time - _lastTickTime; _lastTickTime = time; PassedTime += num; } public bool TickAndCheckDone() { Tick(); return Done; } private static float GetTime() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)GameStateManager.CurrentStateName == 10) { return Clock.ExpeditionProgressionTime; } return Clock.Time; } } public struct Timer { private float _durationInv; public float PassedTime { get; private set; } public float Duration { get; private set; } public bool Done => Progress >= 1f; public float Progress => Mathf.Clamp01(ProgressUnclamped); public float ProgressUnclamped { get { if (Duration != 0f) { return PassedTime * _durationInv; } return 1f; } } public Timer(float duration) { PassedTime = 0f; Duration = duration; _durationInv = 1f / duration; } public void Reset(float newDuration = -1f) { PassedTime = 0f; if (newDuration >= 0f) { Duration = newDuration; _durationInv = 1f / newDuration; } } public void Tick() { PassedTime += Time.deltaTime; } public void Tick(float deltaTime) { PassedTime += deltaTime; } public bool TickAndCheckDone() { Tick(); return Done; } public bool TickAndCheckDone(float deltaTime) { Tick(deltaTime); return Done; } } public struct DoubleTimer { private double _durationInv; public double PassedTime { get; private set; } public double Duration { get; private set; } public bool Done => Progress >= 1.0; public double Progress => Math.Clamp(0.0, 1.0, ProgressUnclamped); public double ProgressUnclamped { get { if (Duration != 0.0) { return PassedTime * _durationInv; } return 1.0; } } public DoubleTimer(double duration) { PassedTime = 0.0; Duration = duration; _durationInv = 1.0 / duration; } public void Reset(double newDuration = -1.0) { PassedTime = 0.0; if (newDuration >= 0.0) { Duration = newDuration; _durationInv = 1.0 / newDuration; } } public void Tick() { PassedTime += Time.deltaTime; } public bool TickAndCheckDone() { Tick(); return Done; } } public static class WaitFor { public static readonly WaitForEndOfFrame EndOfFrame = new WaitForEndOfFrame(); public static readonly WaitForFixedUpdate FixedUpdate = new WaitForFixedUpdate(); public static readonly WaitForSecondsCollection Seconds = new WaitForSecondsCollection(); public static readonly WaitForSecondsRealtimeCollection SecondsRealtime = new WaitForSecondsRealtimeCollection(); } public sealed class WaitForSecondsCollection : WaitForCollection<WaitForSeconds> { protected override WaitForSeconds CreateInstance(float time) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown return new WaitForSeconds(time); } } public sealed class WaitForSecondsRealtimeCollection : WaitForCollection<WaitForSecondsRealtime> { protected override WaitForSecondsRealtime CreateInstance(float time) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown return new WaitForSecondsRealtime(time); } } public abstract class WaitForCollection<T> { private readonly Dictionary<int, T> _lookup = new Dictionary<int, T>(100); private T _temp; public T this[float time] { get { int key = ((!(time <= 0f)) ? Mathf.RoundToInt(time * 1000f) : 0); if (_lookup.TryGetValue(key, out _temp)) { return _temp; } _temp = CreateInstance(time); _lookup[key] = _temp; return _temp; } } protected abstract T CreateInstance(float time); } } namespace EEC.Utils.Json { public static class JSON { private static readonly JsonSerializerOptions _setting; static JSON() { _setting = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, IncludeFields = false, PropertyNameCaseInsensitive = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; _setting.Converters.Add(new ColorConverter()); _setting.Converters.Add(new LocalizedTextConverter()); _setting.Converters.Add(new JsonStringEnumConverter()); _setting.Converters.Add(new Vector2Converter()); _setting.Converters.Add(new Vector3Converter()); if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized) { _setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter); Logger.Log("PartialData Support Found!"); } } public static T Deserialize<T>(string json) { return JsonSerializer.Deserialize<T>(json, _setting); } public static object Deserialize(Type type, string json) { return JsonSerializer.Deserialize(json, type, _setting); } public static string Serialize(object value, Type type) { return JsonSerializer.Serialize(value, type, _setting); } } } namespace EEC.Utils.Json.Elements { [JsonConverter(typeof(AgentModeTargetConverter))] public struct AgentModeTarget { public static readonly AgentModeTarget All = new AgentModeTarget(AgentModeType.Off | AgentModeType.Hibernate | AgentModeType.Agressive | AgentModeType.Scout | AgentModeType.Patrolling); public static readonly AgentModeTarget Scout = new AgentModeTarget(AgentModeType.Scout); public static readonly AgentModeTarget Hibernate = new AgentModeTarget(AgentModeType.Hibernate); public static readonly AgentModeTarget Agressive = new AgentModeTarget(AgentModeType.Agressive); public static readonly AgentModeTarget None = new AgentModeTarget(AgentModeType.None); public AgentModeType Mode; public AgentModeTarget(AgentModeType modes) { Mode = modes; } public bool IsMatch(EnemyAgent agent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected I4, but got Unknown if ((Object)(object)agent == (Object)null) { return false; } AgentMode mode = ((AgentAI)agent.AI).Mode; return (int)mode switch { 0 => Mode.HasFlag(AgentModeType.Off), 4 => Mode.HasFlag(AgentModeType.Hibernate), 1 => Mode.HasFlag(AgentModeType.Agressive), 3 => Mode.HasFlag(AgentModeType.Scout), 2 => Mode.HasFlag(AgentModeType.Patrolling), _ => false, }; } } [Flags] public enum AgentModeType { None = 0, Off = 1, Hibernate = 2, Agressive = 4, Scout = 8, Patrolling = 0x10 } public sealed class AgentModeTargetConverter : JsonConverter<AgentModeTarget> { private static readonly char[] _separators = new char[2] { ',', '|' }; public override AgentModeTarget Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { case JsonTokenType.String: { string @string = reader.GetString(); string[] array = @string.Split(_separators, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { throw new JsonException("There are no entries in " + @string + "! Are you sure it's in right format?"); } AgentModeType agentModeType = AgentModeType.None; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { switch (array2[i].ToLowerInvariant().Trim()) { case "off": case "dead": agentModeType |= AgentModeType.Off; break; case "agressive": case "combat": agentModeType |= AgentModeType.Agressive; break; case "hibernate": case "hibernation": case "hibernating": case "sleeping": agentModeType |= AgentModeType.Hibernate; break; case "scout": case "scoutpatrolling": agentModeType |= AgentModeType.Scout; break; case "patrolling": agentModeType |= AgentModeType.Patrolling; break; } } return new AgentModeTarget(agentModeType); } case JsonTokenType.Number: Logger.Warning("Found flag number value in AgentModeTarget! : consider changing it to string."); return new AgentModeTarget((AgentModeType)reader.GetInt32()); default: throw new JsonException($"Token type: {reader.TokenType} in AgentModeTarget is not supported!"); } } public override void Write(Utf8JsonWriter writer, AgentModeTarget value, JsonSerializerOptions options) { writer.WriteNumberValue((int)value.Mode); } } [JsonConverter(typeof(BoolBaseConverter))] public struct BoolBase { public static readonly BoolBase False = new BoolBase(BoolMode.False); public static readonly BoolBase True = new BoolBase(BoolMode.True); public static readonly BoolBase Unchanged = new BoolBase(BoolMode.Unchanged); public BoolMode Mode; public BoolBase(bool mode) { Mode = (mode ? BoolMode.True : BoolMode.False); } public BoolBase(BoolMode mode) { Mode = mode; } public bool GetValue(bool originalValue) { switch (Mode) { case BoolMode.Unchanged: return originalValue; case BoolMode.True: return true; case BoolMode.False: return false; default: Logger.Error($"BoolBase.GetValue; Got Unknown Mode: {Mode}!\n{Environment.StackTrace}"); return originalValue; } } } public enum BoolMode { False, True, Unchanged } public sealed class BoolBaseConverter : JsonConverter<BoolBase> { public override bool HandleNull => false; public override bool CanConvert(Type objectType) { return objectType == typeof(BoolBase); } public override BoolBase Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { case JsonTokenType.String: { string text = reader.GetString().Trim(); if (text.EqualsAnyIgnoreCase("Unchanged", "Ignore", "Keep", "Original", "KeepOriginal")) { return BoolBase.Unchanged; } if (bool.TryParse(text, out var result)) { return new BoolBase(result); } throw new JsonException("Cannot parse BoolBase string: " + text + "! Are you sure it's in right format?"); } case JsonTokenType.True: return BoolBase.True; case JsonTokenType.False: return BoolBase.False; default: throw new JsonException($"BoolBaseJson type: {reader.TokenType} is not implemented!"); } } public override void Write(Utf8JsonWriter writer, BoolBase value, JsonSerializerOptions options) { switch (value.Mode) { case BoolMode.True: writer.WriteBooleanValue(value: true); break; case BoolMode.False: writer.WriteBooleanValue(value: false); break; case BoolMode.Unchanged: writer.WriteStringValue("Unchanged"); break; } writer.WriteCommentValue("BoolBase"); } } public sealed class CurveWrapper : Collection<CurveKeyFrame> { public const int KEYFRAME_FRAMECOUNT = 20; public const float KEYFRAME_PROGRESS_INV = 0.05f; public static readonly CurveWrapper Empty = new CurveWrapper(); private static readonly List<Keyframe> _keys = new List<Keyframe>(); public bool HasSetting => base.Count >= 2; public bool TryBuildCurve(out AnimationCurve curve) { //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if (base.Count < 2) { curve = null; return false; } CurveKeyFrame[] array = this.OrderBy((CurveKeyFrame x) => x.Time).ToArray(); _keys.Clear(); for (int i = 0; i < base.Count - 1; i++) { CurveKeyFrame curveKeyFrame = array[i]; CurveKeyFrame curveKeyFrame2 = array[i + 1]; if (curveKeyFrame.Time > 1f || curveKeyFrame.Time < 0f) { Logger.Error($"CurveWrapper Time '{curveKeyFrame.Time}' was invalid!, must be range of 0.0 ~ 1.0"); curve = null; return false; } float num = curveKeyFrame2.Time - curveKeyFrame.Time; float num2 = curveKeyFrame2.Value - curveKeyFrame.Value; float num3 = num2 / num; for (int j = 0; j < 20; j++) { float num4 = 0.05f * (float)j; float time = curveKeyFrame.Time + num * num4; float value = curveKeyFrame.Value + num2 * curveKeyFrame.OutEaseType.Evaluate(num4); List<Keyframe> keys = _keys; Keyframe item = default(Keyframe); ((Keyframe)(ref item)).time = time; ((Keyframe)(ref item)).value = value; ((Keyframe)(ref item)).inTangent = num3; ((Keyframe)(ref item)).outTangent = num3; keys.Add(item); } } curve = new AnimationCurve(_keys.ToArray()); return true; } } public struct CurveKeyFrame { public float Time { get; set; } public float Value { get; set; } public eEasingType OutEaseType { get; set; } } [JsonConverter(typeof(EventWrapperConverter))] public sealed class EventWrapper : IDisposable { private string _json; private WardenObjectiveEventData _cached; public EventWrapper(string json) { _json = json; } public void Cache() { _cached = JSON.Deserialize<WardenObjectiveEventData>(_json); _json = string.Empty; } public WardenObjectiveEventData ToEvent() { if (_cached == null) { Cache(); } return _cached; } public void Dispose() { _json = null; _cached = null; } } internal sealed class EventWrapperConverter : JsonConverter<EventWrapper> { public override bool HandleNull => false; public override EventWrapper Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType == JsonTokenType.StartObject) { using (JsonDocument jsonDocument = JsonDocument.ParseValue(ref reader)) { return new EventWrapper(jsonDocument.RootElement.ToString()); } } throw new JsonException($"{reader.TokenType} is not supported for EventWrapperValue!"); } public override void Write(Utf8JsonWriter writer, EventWrapper value, JsonSerializerOptions options) { } } [JsonConverter(typeof(ValueBaseConverter))] public struct ValueBase { public static readonly ValueBase Unchanged = new ValueBase(1f, ValueMode.Rel, fromDefault: true); public static readonly ValueBase Zero = new ValueBase(0f, ValueMode.Abs, fromDefault: false); public float Value; public ValueMode Mode; public bool FromDefault; public ValueBase(float value = 1f, ValueMode mode = ValueMode.Rel, bool fromDefault = true) { Value = value; Mode = mode; FromDefault = fromDefault; } public float GetAbsValue(float maxValue, float currentValue) { if (Mode == ValueMode.Rel) { if (FromDefault) { return currentValue * Value; } return maxValue * Value; } return Value; } public float GetAbsValue(float baseValue) { if (Mode == ValueMode.Rel) { return baseValue * Value; } return Value; } public int GetAbsValue(int maxValue, int currentValue) { return (int)Math.Round(GetAbsValue((float)maxValue, (float)currentValue)); } public int GetAbsValue(int baseValue) { return (int)Math.Round(GetAbsValue((float)baseValue)); } public override string ToString() { return $"[Mode: {Mode}, Value: {Value}]"; } } public enum ValueMode { Rel, Abs } public sealed class ValueBaseConverter : JsonConverter<ValueBase> { public override bool HandleNull => false; public override bool CanConvert(Type objectType) { return objectType == typeof(ValueBase); } public override ValueBase Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { case JsonTokenType.Number: return new ValueBase(reader.GetSingle(), ValueMode.Abs); case JsonTokenType.StartObject: { ValueBase result3 = default(ValueBase); while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return result3; } if (reader.TokenType != JsonTokenType.PropertyName) { throw new JsonException("Expected PropertyName token"); } string? @string = reader.GetString(); reader.Read(); switch (@string.ToLowerInvariant()) { case "value": result3.Value = reader.GetSingle(); break; case "mode": { if (Enum.TryParse<ValueMode>(reader.GetString(), out var result4)) { result3.Mode = result4; } break; } case "fromdefault": result3.FromDefault = reader.GetBoolean(); break; } } throw new JsonException("Expected EndObject token"); } case JsonTokenType.String: { string text = reader.GetString().Trim(); bool fromDefault = false; if (text.EndsWith("of default", StringComparison.OrdinalIgnoreCase)) { fromDefault = true; string text2 = text; text = text2.Substring(0, text2.Length - 10).TrimEnd(); } if (text.InvariantEndsWith("%")) { string text2 = text; if (float.TryParse(text2.Substring(0, text2.Length - 1).TrimEnd(), NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var result)) { return new ValueBase(result / 100f, ValueMode.Rel, fromDefault); } } else { if (text.EqualsAnyIgnoreCase("Unchanged", "Ignore", "Keep", "Original", "KeepOriginal")) { return new ValueBase(1f, ValueMode.Rel, fromDefault: false); } if (float.TryParse(text, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var result2)) { return new ValueBase(result2, ValueMode.Abs); } } throw new JsonException("Cannot parse ValueBase string: " + text + "! Are you sure it's in right format?"); } default: throw new JsonException($"ValueBaseJson type: {reader.TokenType} is not implemented!"); } } public override void Write(Utf8JsonWriter writer, ValueBase value, JsonSerializerOptions options) { switch (value.Mode) { case ValueMode.Rel: { if (Mathf.Approximately(value.Value, 1f)) { writer.WriteStringValue("Unchanged"); break; } string format = (value.FromDefault ? "{0}% of default" : "{0}%"); writer.WriteStringValue(string.Format(format, value.Value * 100f)); break; } case ValueMode.Abs: writer.WriteStringValue(value.Value.ToString()); break; } writer.WriteCommentValue("ValueBase"); } } } namespace EEC.Utils.Json.Converters { public sealed class ColorConverter : JsonConverter<Color> { public override bool HandleNull => false; public override bool CanConvert(Type objectType) { return objectType == typeof(Color); } public override Color Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { //IL_0002: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); float result = 1f; switch (reader.TokenType) { case JsonTokenType.StartObject: while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return color * result; } if (reader.TokenType != JsonTokenType.PropertyName) { throw new JsonException("Expected PropertyName token"); } string? @string = reader.GetString(); reader.Read(); switch (@string.ToLowerInvariant()) { case "r": color.r = reader.GetSingle(); break; case "g": color.g = reader.GetSingle(); break; case "b": color.b = reader.GetSingle(); break; case "a": color.a = reader.GetSingle(); break; case "multiplier": result = reader.GetSingle(); break; } } throw new JsonException("Expected EndObject token"); case JsonTokenType.String: { string text = reader.GetString().Trim(); string[] array = text.Split("*"); string text2; switch (array.Length) { case 1: result = 1f; text2 = array[0].Trim(); break; case 2: if (!float.TryParse(array[1].Trim(), NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result)) { throw new JsonException("Color multiplier is not valid number! (*): " + text); } text2 = array[0].Trim(); break; default: throw new JsonException("Color format has more than two Mutiplier (*): " + text); } if (ColorUtility.TryParseHtmlString(text2, ref color)) { return color * result; } if (TryParseColor(text, out color)) { return color * result; } throw new JsonException("Color format is not right: " + text); } default: throw new JsonException($"ColorJson type: {reader.TokenType} is not implemented!"); } } private static bool TryParseColor(string input, out Color color) { //IL_000b: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (!RegexUtil.TryParseVectorString(input, out var vectorArray)) { color = Color.white; return false; } if (vectorArray.Length < 3) { color = Color.white; return false; } float num = 1f; if (vectorArray.Length > 3) { num = vectorArray[3]; } color = new Color(vectorArray[0], vectorArray[1], vectorArray[2], num); return true; } public override void Write(Utf8JsonWriter writer, Color value, JsonSerializerOptions options) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) writer.WriteStringValue("#" + ColorUtility.ToHtmlStringRGBA(value)); } } public sealed class LocalizedTextConverter : JsonConverter<LocalizedText> { public override bool HandleNull => false; public override LocalizedText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0022: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown switch (reader.TokenType) { case JsonTokenType.String: { string @string = reader.GetString(); if (!MTFOPartialDataUtil.TryGetId(@string, out var id)) { return new LocalizedText { Id = 0u, UntranslatedText = @string }; } return new LocalizedText { Id = id, UntranslatedText = null }; } case JsonTokenType.Number: return new LocalizedText { Id = reader.GetUInt32(), UntranslatedText = null }; default: throw new JsonException($"LocalizedTextJson type: {reader.TokenType} is not implemented!"); } } public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options) { JsonSerializer.Serialize<LocalizedText>(writer, value, options); } } public sealed class Vector2Converter : JsonConverter<Vector2> { public override Vector2 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { //IL_0002: 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_00b2: Unknown result type (might be due to invalid IL or missing references) Vector2 vector = default(Vector2); switch (reader.TokenType) { case JsonTokenType.StartObject: while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return vector; } if (reader.TokenType != JsonTokenType.PropertyName) { throw new JsonException("Expected PropertyName token"); } string? @string = reader.GetString(); reader.Read(); string text2 = @string.ToLowerInvariant(); if (!(text2 == "x")) { if (text2 == "y") { vector.y = reader.GetSingle(); } } else { vector.x = reader.GetSingle(); } } throw new JsonException("Expected EndObject token"); case JsonTokenType.String: { string text = reader.GetString().Trim(); if (TryParseVector2(text, out vector)) { return vector; } throw new JsonException("Vector2 format is not right: " + text); } default: throw new JsonException($"Vector2Json type: {reader.TokenType} is not implemented!"); } } private static bool TryParseVector2(string input, out Vector2 vector) { //IL_000b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0023: Unknown result type (might be due to invalid IL or missing references) if (!RegexUtil.TryParseVectorString(input, out var vectorArray)) { vector = Vector2.zero; return false; } if (vectorArray.Length < 2) { vector = Vector2.zero; return false; } vector = new Vector2(vectorArray[0], vectorArray[1]); return true; } public override void Write(Utf8JsonWriter writer, Vector2 value, JsonSerializerOptions options) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) writer.WriteStringValue($"({value.x} {value.y})"); } } public sealed class Vector3Converter : JsonConverter<Vector3> { public override bool HandleNull => false; public override Vector3 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) Vector3 vector = default(Vector3); switch (reader.TokenType) { case JsonTokenType.StartObject: while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return vector; } if (reader.TokenType != JsonTokenType.PropertyName) { throw new JsonException("Expected PropertyName token"); } string? @string = reader.GetString(); reader.Read(); switch (@string.ToLowerInvariant()) { case "x": vector.x = reader.GetSingle(); break; case "y": vector.y = reader.GetSingle(); break; case "z": vector.z = reader.GetSingle(); break; } } throw new JsonException("Expected EndObject token"); case JsonTokenType.String: { string text = reader.GetString().Trim(); if (TryParseVector3(text, out vector)) { return vector; } throw new JsonException("Vector3 format is not right: " + text); } default: throw new JsonException($"Vector3Json type: {reader.TokenType} is not implemented!"); } } private static bool TryParseVector3(string input, out Vector3 vector) { //IL_000b: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!RegexUtil.TryParseVectorString(input, out var vectorArray)) { vector = Vector3.zero; return false; } if (vectorArray.Length < 3) { vector = Vector3.zero; return false; } vector = new Vector3(vectorArray[0], vectorArray[1], vectorArray[2]); return true; } public override void Write(Utf8JsonWriter writer, Vector3 value, JsonSerializerOptions options) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) writer.WriteStringValue($"({value.x} {value.y} {value.z})"); } } } namespace EEC.Utils.Integrations { public static class MTFOPartialDataUtil { public delegate bool TryGetDelegate(string guid, out uint id); public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks"; private static readonly TryGetDelegate _tryGetIDDelegate; public static JsonConverter PersistentIDConverter { get; private set; } public static JsonConverter LocalizedTextConverter { get; private set; } public static bool IsLoaded { get; private set; } public static bool Initialized { get; private set; } public static string PartialDataPath { get; private set; } public static string ConfigPath { get; private set; } static MTFOPartialDataUtil() { PersistentIDConverter = null; LocalizedTextConverter = null; IsLoaded = false; Initialized = false; PartialDataPath = string.Empty; ConfigPath = string.Empty; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type type = types.First((Type t) => t.Name == "PersistentIDConverter"); if ((object)type == null) { throw new Exception("Unable to Find PersistentIDConverter Class"); } Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class"); PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public); PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property3 = obj2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public); if ((object)property == null) { throw new Exception("Unable to Find Property: Initialized"); } if ((object)property2 == null) { throw new Exception("Unable to Find Property: PartialDataPath"); } if ((object)property3 == null) { throw new Exception("Unable to Find Field: ConfigPath"); } Initialized = (bool)property.GetValue(null); PartialDataPath = (string)property2.GetValue(null); ConfigPath = (string)property3.GetValue(null); _tryGetIDDelegate = (TryGetDelegate)(types.First((Type t) => t.Name == "PersistentIDManager") ?? throw new Exception("Unable to Find PersistentIDManager Class")).GetMethod("TryGetId", BindingFlags.Static | BindingFlags.Public).CreateDelegate(typeof(TryGetDelegate)); PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type); IsLoaded = true; } catch (Exception value2) { Logger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}"); } } public static bool TryGetId(string guid, out uint id) { if (!IsLoaded) { id = 0u; return false; } if (!Initialized) { id = 0u; return false; } if (_tryGetIDDelegate == null) { id = 0u; return false; } return _tryGetIDDelegate(guid, out id); } } public static class MTFOUtil { public const string PLUGIN_GUID = "com.dak.MTFO"; public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public; public static readonly Version MTFO_FORBID; public static readonly Version MTFO_V5; public static string GameDataPath { get; private set; } public static string CustomPath { get; private set; } public static bool HasCustomContent { get; private set; } public static bool IsLoaded { get; private set; } public static bool HasHotReload { get; private set; } public static FieldInfo HotReloaderField { get; private set; } public static event Action HotReloaded; static MTFOUtil() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown MTFO_FORBID = new Version("4.2.0", false); MTFO_V5 = new Version("4.3.5", false); GameDataPath = string.Empty; CustomPath = string.Empty; HasCustomContent = false; IsLoaded = false; HasHotReload = false; HotReloaderField = null; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value)) { return; } Version version = value.Metadata.Version; if (version >= MTFO_V5) { InitMTFO_V5(value); return; } if (version > MTFO_FORBID) { InitMTFO_V4(value); return; } throw new Exception("You are using unsupported version of MTFO!"); } private static void InitMTFO_V4(PluginInfo info) { try { Assembly obj = ((info == null) ? null : info.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); IsLoaded = true; } catch (Exception value) { Logger.Error($"Exception thrown while reading path from DataDumper (MTFO V{info.Metadata.Version}): \n{value}"); } } private static void InitMTFO_V5(PluginInfo info) { try { Assembly obj = ((info == null) ? null : info.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type obj2 = types.First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property = obj2.GetProperty("IsHotReloadEnabled", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } if ((object)property == null) { throw new Exception("Unable to Find Property: IsHotReloadEnabled"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); HasHotReload = (bool)property.GetValue(null); if (HasHotReload) { HotReloaderField = (types.First((Type t) => t.Name == "HotReloader") ?? throw new Exception("Unable to Find HotReloader Class")).GetField("Current", BindingFlags.Static | BindingFlags.Public) ?? throw new Exception("Unable to Find Field: Current"); } IsLoaded = true; } catch (Exception value) { Logger.Error($"Exception thrown while reading metadata from MTFO (V{info.Metadata.Version}): \n{value}"); } } internal static void OnHotReloaded(int _) { MTFOUtil.HotReloaded?.Invoke(); } } } namespace EEC.Utils.Integrations.Inject { [HarmonyPatch(typeof(CM_PageRundown_New), "OnEnable")] internal static class Inject_CM_PageRundown_New { private static bool _isInjected; [HarmonyWrapSafe] internal static void Postfix() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_isInjected) { return; } object obj = MTFOUtil.HotReloaderField?.GetValue(null) ?? null; if (obj != null) { FieldInfo field = obj.GetType().GetField("button", BindingFlags.Instance | BindingFlags.NonPublic); if ((object)field != null) { ((CM_Item)field.GetValue(obj)).OnBtnPressCallback += Action<int>.op_Implicit((Action<int>)MTFOUtil.OnHotReloaded); _isInjected = true; } } } } } namespace EEC.Patches { [CallConstructorOnLoad] public static class PatchManager { static PatchManager() { ConfigManager.EnemyPrefabBuilt += PrefabBuilt; } private static void PrefabBuilt(EnemyAgent agent, EnemyDataBlock enemyData) { if (ConfigManager.Global.UsingFlyerStuckCheck && enemyData.TryGetBehaviourBlock(out var behaviour) && behaviour.IsFlyer) { ((Component)agent).gameObject.AddComponent<FlyerStuckHandler>().Agent.Value = agent; Logger.Debug($"Added Flyer Check to {((GameDataBlockBase<EnemyDataBlock>)(object)enemyData).persistentID}"); } } } } namespace EEC.Patches.Inject { [HarmonyPatch(typeof(Dam_SyncedDamageBase))] internal static class Inject_Patch_HealerEnemies { [HarmonyPatch("TentacleAttackDamage")] [HarmonyPrefix] [HarmonyWrapSafe] internal static bool Pre_TentacleDamage(float dam, Dam_SyncedDamageBase __instance) { return DoHealer(dam, __instance); } [HarmonyPatch("MeleeDamage")] [HarmonyPrefix] [HarmonyWrapSafe] internal static bool Pre_PunchDamage(float dam, Dam_SyncedDamageBase __instance) { return DoHealer(dam, __instance); } [HarmonyPatch("ExplosionDamage")] [HarmonyPrefix] [HarmonyWrapSafe] internal static bool Pre_ExplosionDamage(float dam, Dam_SyncedDamageBase __instance) { return DoHealer(dam, __instance); } [HarmonyPatch("ShooterProjectileDamage")] [HarmonyPrefix] [HarmonyWrapSafe] internal static bool Pre_ShooterProjectileDamage(float dam, Dam_SyncedDamageBase __instance) { return DoHealer(dam, __instance); } private static bool DoHealer(float dam, Dam_SyncedDamageBase damBase) { if (dam >= 0f) { return true; } if (SNet.IsMaster) { float num = Math.Abs(dam); damBase.SendSetHealth(Math.Min(damBase.Health + num, damBase.HealthMax)); } return false; } } } namespace EEC.Patches.Handlers { [InjectToIl2Cpp] internal sealed class FlyerStuckHandler : MonoBehaviour { public Il2CppReferenceField<EnemyAgent> Agent; public float UpdateInterval = float.MaxValue; public int RetryCount = int.MaxValue; private EnemyAgent _agent; private Vector3 _firstPosition; private Vector2 _lastGoalXZ; private Timer _timer; private int _tryCount = -1; private bool _shouldCheck = true; private void Start() { if (!SNet.IsMaster) { ((Behaviour)this).enabled = false; return; } _agent = Il2CppReferenceField<EnemyAgent>.op_Implicit(Agent); if ((Object)(object)_agent == (Object)null) { ((Behaviour)this).enabled = false; return; } if (!_agent.EnemyBehaviorData.IsFlyer) { ((Behaviour)this).enabled = false; return; } UpdateInterval = ConfigManager.Global.FlyerStuck_Interval; RetryCount = ConfigManager.Global.FlyerStuck_Retry; } private void FixedUpdate() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0053: Unknown result type (might be due to invalid IL or missing references) if (_shouldCheck) { if ((int)((AgentAI)_agent.AI).Mode != 1 || !_timer.TickAndCheckDone()) { return; } _timer.Reset(UpdateInterval); if (_tryCount == -1) { _firstPosition = _agent.Position; _tryCount = 0; } else if (Vector3.Distance(_firstPosition, _agent.Position) < 0.1f) { _tryCount++; if (_tryCount >= RetryCount) { Logger.Debug("Flyer was stuck in Place!"); ((Agent)_agent).m_replicator.Despawn(); } } else { _shouldCheck = false; } return; } Vector3 navmeshAgentGoal = _agent.AI.NavmeshAgentGoal; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(navmeshAgentGoal.x, navmeshAgentGoal.z); Vector2 val2 = val - _lastGoalXZ; if (((Vector2)(ref val2)).sqrMagnitude < 0.1f) { if (((MachineState<EB_StateBase>)(object)((StateMachine<EB_StateBase>)(object)_agent.AI.m_behaviour).CurrentState).ENUM_ID == 5) { _tryCount = -1; _shouldCheck = true; } } else { _tryCount = -1; _shouldCheck = false; } _lastGoalXZ = val; } private void OnDestroy() { Agent = null; } } [Flags] public enum ShitpostType { ForceOff = -1, Enable = 0, Dinnerbone = 1 } } namespace EEC.Patches.Handlers.Yes.Yes.Yes.Yes { [CallConstructorOnLoad] public static class Shitpost2022 { static Shitpost2022() { if (Configuration.CanShitpostOf(ShitpostType.Dinnerbone)) { EnemyEvents.Spawned += EnemyEvents_Spawned; } } private static void EnemyEvents_Spawned(EnemyAgent agent) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) NavMarker marker = GuiManager.NavMarkerLayer.PlaceCustomMarker((NavMarkerOption)16, agent.ModelRef.m_markerTagAlign, "<alpha=#44>Dinnerbone", 0f, false); marker.SetVisualStates((NavMarkerOption)0, (NavMarkerOption)0, (NavMarkerOption)0, (NavMarkerOption)0); marker.m_titleSubObj.SetEnabled(false); marker.SetPinEnabled(false); ((MonoBehaviour)(object)agent.AI).StartCoroutine(UpdateMarker(agent, marker)); agent.AddOnDeadOnce(delegate { GuiManager.NavMarkerLayer.RemoveMarker(marker); }); Transform boneTransform = agent.Anim.GetBoneTransform((HumanBodyBones)0); if ((Object)(object)boneTransform != (Object)null) { BoneOffsetHandler boneOffsetHandler = ((Component)boneTransform).gameObject.AddComponent<BoneOffsetHandler>(); boneOffsetHandler.Animator = Il2CppReferenceField<Animator>.op_Implicit(agent.Anim); boneOffsetHandler.RotationOffset = Il2CppValueField<Vector3>.op_Implicit(new Vector3(0f, 180f, 0f)); } else { agent.MainModelTransform.Rotate(Vector3.forward, 180f); } } private static IEnumerator UpdateMarker(EnemyAgent agent, NavMarker marker) { WaitForSeconds yielder = WaitFor.Seconds[0.25f]; bool enabled = false; yield return yielder; while (((Agent)agent).Alive) { if ((int)marker.m_currentState == 2) { Vector3 val = agent.Position - ((Component)CameraManager.GetCurrentCamera()).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (!enabled && sqrMagnitude <= 64f) { marker.m_titleSubObj.SetEnabled(true); enabled = true; } else if (enabled && sqrMagnitude > 64f) { marker.m_titleSubObj.SetEnabled(false); enabled = false; } } else if (enabled) { marker.m_titleSubObj.SetEnabled(false); enabled = false; } yield return yielder; } } } } namespace EEC.Networking { public static class NetworkManager { public const ulong LOWEST_STEAMID64 = 76561197960265729uL; public static EnemyAgentModeReplicator EnemyAgentModeState { get; private set; } = new EnemyAgentModeReplicator(); public static EnemyHealthInfoReplicator EnemyHealthState { get; private set; } = new EnemyHealthInfoReplicator(); public static EnemyAnimEvent EnemyAnim { get; private set; } = new EnemyAnimEvent(); internal static void Initialize() { EnemyEvents.Spawned += EnemySpawned; EnemyEvents.Despawn += EnemyDespawn; EnemyAgentModeState.Initialize(); EnemyHealthState.Initialize(); EnemyAnim.Setup(); } private static void EnemySpawned(EnemyAgent agent) { //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) if (agent.TryGetSpawnData(out var spawnData)) { EnemyAgentModeReplicator.State state = default(EnemyAgentModeReplicator.State); state.mode = spawnData.mode; EnemyAgentModeReplicator.State startState = state; EnemyAgentModeState.Register(((Agent)agent).GlobalID, startState, delegate(EnemyAgentModeReplicator.State newState) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) ConfigManager.FireAgentModeChangedEvent(agent, newState.mode); }); } EnemyHealthInfoReplicator.State state2 = default(EnemyHealthInfoReplicator.State); state2.maxHealth = ((Dam_SyncedDamageBase)agent.Damage).HealthMax; state2.health = ((Dam_SyncedDamageBase)agent.Damage).Health; EnemyHealthInfoReplicator.State startState2 = state2; EnemyHealthState.Register(((Agent)agent).GlobalID, startState2, delegate(EnemyHealthInfoReplicator.State newState) { EnemyDamageEvents.OnHealthUpdated(agent, newState.maxHealth, newState.health); }); ((MonoBehaviour)(object)agent.AI).StartCoroutine(CheckHealth(agent)); } private static IEnumerator CheckHealth(EnemyAgent agent) { WaitForFixedUpdate fixedUpdateYielder = WaitFor.FixedUpdate; float health = ((Dam_SyncedDamageBase)agent.Damage).Health; while (true) { if (SNet.IsMaster) { float health2 = ((Dam_SyncedDamageBase)agent.Damage).Health; if (!Mathf.Approximately(health, health2)) { EnemyHealthState.UpdateInfo(agent); health = health2; } } yield return fixedUpdateYielder; } } private static void EnemyDespawn(EnemyAgent agent) { EnemyAgentModeState.Deregister(((Agent)agent).GlobalID); } } public delegate void SNetRecallEvent(eBufferType bufferType); public delegate void SNetPlayerEvent(SNet_Player player); public delegate void SNetPlayerEventWithReason(SNet_Player player, SNet_PlayerEventReason reason); public static class SNetEvents { public static event SNetPlayerEvent AgentSpawned; public static event SNetRecallEvent PrepareRecall; public static event SNetRecallEvent RecallComplete; internal static void OnAgentSpawned(SNet_Player player) { SNetEvents.AgentSpawned?.Invoke(player); } internal static void OnPrepareRecall(eBufferType bufferType) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) SNetEvents.PrepareRecall?.Invoke(bufferType); } internal static void OnRecallComplete(eBufferType bufferType) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) SNetEvents.RecallComplete?.Invoke(bufferType); } } internal struct ReplicatorPayload { public ushort key; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)] public byte[] stateBytes; public void Serialize<T>(T stateData) where T : struct { int num = Marshal.SizeOf(stateData); if (num >= 30) { throw new ArgumentException("StateData Exceed size of 30 : Unable to Serialize", "T"); } byte[] destination = new byte[30]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(stateData, intPtr, fDeleteOld: false); Marshal.Copy(intPtr, destination, 0, num); Marshal.FreeHGlobal(intPtr); stateBytes = destination; } public T Deserialize<T>() { int num = Marshal.SizeOf(typeof(T)); if (num > stateBytes.Length) { throw new ArgumentException("StateData Exceed size of 30 : Unable to Deserialize", "T"); } IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.Copy(stateBytes, 0, intPtr, num); T result = (T)Marshal.PtrToStructure(intPtr, typeof(T)); Marshal.FreeHGlobal(intPtr); return result; } } public sealed class StateContext<S> where S : struct { public bool Registered; public Action<S> OnStateChanged; public S State; } public abstract class StateReplicator<S> where S : struct { private static readonly Dictionary<ushort, StateContext<S>> _lookup = new Dictionary<ushort, StateContext<S>>(500); private bool _isInitialized; public abstract bool ClearOnLevelCleanup { get; } public abstract string GUID { get; } public bool IsSetup => _isInitialized; public string SetStateName { get; private set; } = string.Empty; public string ChangeRequestName { get; private set; } = string.Empty; public void Initialize() { if (!_isInitialized) { SNetEvents.AgentSpawned += SNetEvents_AgentSpawned; if (ClearOnLevelCleanup) { LevelEvents.LevelCleanup += Clear; } SetStateName = "EECRp" + GUID + "S"; ChangeRequestName = "EECRp" + GUID + "R"; NetworkAPI.RegisterEvent<ReplicatorPayload>(SetStateName, (Action<ulong, ReplicatorPayload>)ReceiveSetState_FromMaster); NetworkAPI.RegisterEvent<ReplicatorPayload>(ChangeRequestName, (Action<ulong, ReplicatorPayload>)ReceiveSetState_FromClient); _isInitialized = true; } } private void SNetEvents_AgentSpawned(SNet_Player player) { if (!SNet.IsMaster) { return; } foreach (KeyValuePair<ushort, StateContext<S>> item in _lookup) { ReplicatorPayload replicatorPayload = default(ReplicatorPayload); replicatorPayload.key = item.Key; ReplicatorPayload replicatorPayload2 = replicatorPayload; replicatorPayload2.Serialize(item.Value.State); NetworkAPI.InvokeEvent<ReplicatorPayload>(SetStateName, replicatorPayload2, player, (SNet_ChannelType)2); } } public void Register(ushort id, S startState, Action<S> onChanged = null) { if (TryGetContext(id, out var context)) { if (context.Registered) { return; } context.Registered = true; context.OnStateChanged = onChanged; } else { context = new StateContext<S> { Registered = true, OnStateChanged = onChanged, State = startState }; _lookup[id] = context; } context.OnStateChanged?.Invoke(context.State); OnStateChange(id, context.State); } public void Deregister(ushort id) { if (TryGetContext(id, out var context) && context.Registered) { _lookup.Remove(id); } } private void Clear() { _lookup.Clear(); } public void SetState(ushort id, S state) { if (TryGetContext(id, out var context) && context.Registered) { ReplicatorPayload replicatorPayload = default(ReplicatorPayload); replicatorPayload.key = id; ReplicatorPayload replicatorPayload2 = replicatorPayload; replicatorPayload2.Serialize(state); if (SNet.IsMaster) { NetworkAPI.InvokeEvent<ReplicatorPayload>(SetStateName, replicatorPayload2, (SNet_ChannelType)2); context.State = state; ReceiveSetState_FromMaster(SNet.Master.Lookup, replicatorPayload2); } else if (SNet.HasMaster) { NetworkAPI.InvokeEvent<ReplicatorPayload>(ChangeRequestName, replicatorPayload2, SNet.Master, (SNet_ChannelType)2); context.State = state; } } } public bool TryGetState(ushort id, out S state) { if (!TryGetContext(id, out var context) || !context.Registered) { Logger.Warning($"KEY: {id} has not registered; backing to Default"); state = default(S); return false; } state = context.State; return true; } private void ReceiveSetState_FromMaster(ulong sender, ReplicatorPayload statePacket) { ushort key = statePacket.key; S val = statePacket.Deserialize<S>(); if (TryGetContext(key, out var context)) { context.State = val; if (context.Registered) { context.OnStateChanged?.Invoke(val); OnStateChange(key, val); } } else { _lookup[key] = new StateContext<S> { Registered = false, State = val }; } } private void ReceiveSetState_FromClient(ulong sender, ReplicatorPayload statePacket) { if (SNet.IsMaster) { SetState(statePacket.key, statePacket.Deserialize<S>()); } } public bool TryGetContext(ushort id, out StateContext<S> context) { return _lookup.TryGetValue(id, out context); } public virtual void OnStateChange(ushort id, S newState) { } } public abstract class SyncedEvent<T> where T : struct { public delegate void ReceiveHandler(T packet); private bool _isSetup; public abstract string GUID { get; } public bool IsSetup => _isSetup; public string EventName { get; private set; } = string.Empty; public event ReceiveHandler OnReceive; public event ReceiveHandler OnReceiveLocal; public void Setup() { if (!_isSetup) { EventName = "EEC" + GUID; NetworkAPI.RegisterEvent<T>(EventName, (Action<ulong, T>)ReceiveClient_Callback); _isSetup = true; } } public void Send(T packetData, SNet_Player target = null) { if ((Object)(object)target != (Object)null) { NetworkAPI.InvokeEvent<T>(EventName, packetData, target, (SNet_ChannelType)2); } else { NetworkAPI.InvokeEvent<T>(EventName, packetData, (SNet_ChannelType)2); } ReceiveLocal_Callback(packetData); } private void ReceiveLocal_Callback(T packet) { ReceiveLocal(packet); this.OnReceiveLocal?.Invoke(packet); Receive(packet); this.OnReceive?.Invoke(packet); } private void ReceiveClient_Callback(ulong sender, T packet) { Receive(packet); this.OnReceive?.Invoke(packet); } protected virtual void ReceiveLocal(T packet) { } protected virtual void Receive(T packet) { } } internal struct SyncedPlayerEventPayload { public ulong lookup; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)] public byte[] packetBytes; public void Serialize<T>(T packet) where T : struct { int num = Marshal.SizeOf(packet); if (num >= 30) { throw new ArgumentException("PacketData Exceed size of 30 : Unable to Serialize", "T"); } byte[] destination = new byte[30]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(packet, intPtr, fDeleteOld: false); Marshal.Copy(intPtr, destination, 0, num); Marshal.FreeHGlobal(intPtr); packetBytes = destination; } public T Deserialize<T>() { int num = Marshal.SizeOf(typeof(T)); if (num > packetBytes.Length) { throw new ArgumentException("Packet Exceed size of 30 : Unable to Deserialize", "T"); } IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.Copy(packetBytes, 0, intPtr, num); T result = (T)Marshal.PtrToStructure(intPtr, typeof(T)); Marshal.FreeHGlobal(intPtr); return result; } public bool TryGetPlayer(out SNet_Player player) { if (lookup == 0L) { player = null; return false; } if (lookup < 76561197960265729L) { return SNet.Core.TryGetPlayerBot((int)lookup - 1, ref player); } return SNet.Core.TryGetPlayer(lookup, ref player, false); } } public abstract class SyncedPlayerEvent<T> where T : struct { public delegate void ReceiveHandler(T packet, SNet_Player receivedPlayer); private bool _isSetup; public abstract string GUID { get; } public abstract bool SendToTargetOnly { get; } public abstract bool AllowBots { get; } public bool IsSetup => _isSetup; public string EventName { get; private set; } = string.Empty; public event ReceiveHandler OnReceive; public void Setup() { if (!_isSetup) { EventName = "EECp" + GUID; NetworkAPI.RegisterEvent<SyncedPlayerEventPayload>(EventName, (Action<ulong, SyncedPlayerEventPayload>)Received_Callback); _isSetup = true; } } public bool TryGetPlayerAgent(SNet_Player player, out PlayerAgent agent) { if (!player.HasPlayerAgent) { agent = null; return false; } agent = ((Il2CppObjectBase)player.m_playerAgent).TryCast<PlayerAgent>(); return (Object)(object)agent != (Object)null; } public void SendToPlayers(T packetData, params PlayerAgent[] agents) { foreach (PlayerAgent val in agents) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.Owner == (Object)null)) { SendToPlayer(packetData, val.Owner); } } } public void SendToPlayers(T packetData, params SNet_Player[] players) { foreach (SNet_Player player in players) { SendToPlayer(packetData, player); } } public void SendToPlayer(T packetData, PlayerAgent agent) { if (!((Object)(object)agent == (Object)null) && !((Object)(object)agent.Owner == (Object)null)) { SendToPlayer(packetData, agent.Owner); } } public void SendToPlayer(T packetData, SNet_Player player) { if ((Object)(object)player == (Object)null) { Logger.Error(GetType().Name + " - SyncedPlayerEvent player was null!"); return; } if (player.Lookup == 0L) { Logger.Error(GetType().Name + " - SyncedPlayerEvent lookup for player was 0!"); return; } SyncedPlayerEventPayload syncedPlayerEventPayload = default(SyncedPlayerEventPayload); syncedPlayerEventPayload.lookup = player.Lookup; SyncedPlayerEventPayload syncedPlayerEventPayload2 = syncedPlayerEventPayload; syncedPlayerEventPayload2.Serialize(packetData); if (player.IsBot) { if (AllowBots) { if (SNet.IsMaster) { Received_Callback(SNet.Master.Lookup, syncedPlayerEventPayload2); } else if (SNet.HasMaster) { NetworkAPI.InvokeEvent<SyncedPlayerEventPayload>(EventName, syncedPlayerEventPayload2, SNet.Master, (SNet_ChannelType)2); } } } else if (player.IsLocal) { Received_Callback(player.Lookup, syncedPlayerEventPayload2); } else if (SendToTargetOnly) { NetworkAPI.InvokeEvent<SyncedPlayerEventPayload>(EventName, syncedPlayerEventPayload2, player, (SNet_ChannelType)2); } else { NetworkAPI.InvokeEvent<SyncedPlayerEventPayload>(EventName, syncedPlayerEventPayload2, (SNet_ChannelType)2); } } private void Received_Callback(ulong sender, SyncedPlayerEventPayload payload) { if (payload.TryGetPlayer(out var player) && (player.IsBot ? AllowBots : (player.IsLocal || !SendToTargetOnly))) { Received(payload.Deserialize<T>(), player); } } private void Received(T packet, SNet_Player receivedPlayer) { Receive(packet, receivedPlayer); this.OnReceive?.Invoke(packet, receivedPlayer); } protected virtual void Receive(T packet, SNet_Player receivedPlayer) { } } } namespace EEC.Networking.Replicators { public sealed class EnemyAgentModeReplicator : StateReplicator<EnemyAgentModeReplicator.State> { public struct State { public AgentMode mode; } public override bool ClearOnLevelCleanup => true; public override string GUID => "EMD"; public void SetState(ushort id, AgentMode newMode) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown
plugins/Heat/net6/PrequelCore.dll
Decompiled 5 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using AIGraph; using AK; using Agents; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using ChainedPuzzles; using Enemies; using GTFO.API; using GTFO.API.Extensions; using GTFO.API.JSON.Converters; using GTFO.API.Utilities; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Text; using LEGACY.LegacyOverride; using LEGACY.LegacyOverride.ElevatorCargo; using LEGACY.LegacyOverride.EnemyTagger; using LEGACY.LegacyOverride.ExtraExpeditionSettings; using LEGACY.LegacyOverride.FogBeacon; using LEGACY.LegacyOverride.HSUActivators; using LEGACY.LegacyOverride.PowerGenerator; using LEGACY.LegacyOverride.PowerGenerator.GeneratorCluster; using LEGACY.LegacyOverride.PowerGenerator.IndividualGenerator; using LEGACY.LegacyOverride.SecDoorIntText; using LEGACY.LegacyOverride.Terminal; using LEGACY.Utils; using LevelGeneration; using Localization; using MTFO.API; using Microsoft.CodeAnalysis; using Player; using SNetwork; using ScanPosOverride.Managers; using StateMachines; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("PrequelCore")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PrequelCore")] [assembly: AssemblyTitle("PrequelCore")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [HarmonyPatch(typeof(PUI_Watermark), "UpdateWatermark")] internal static class Patch_WatermarkUpdateWatermark { private static void Postfix(PUI_Watermark __instance) { string text = "4.5.0+git24bbb97-main".Remove("x.x.x".Length); ((TMP_Text)__instance.m_watermarkText).SetText("<color=red>MODDED</color> <color=orange>" + text + "</color>\n<color=#FF6781>criscriscris</color>", true); } } namespace LEGACY { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Inas07.PREQUELCore", "PREQUELCore", "1.0.0")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas07"; public const string RUNDOWN_NAME = "PREQUELCore"; public const string VERSION = "1.0.0"; private Harmony m_Harmony; public override void Load() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown m_Harmony = new Harmony("LEGACY"); m_Harmony.PatchAll(); LegacyLogger.Debug(""); LegacyOverrideManagers.Init(); } } } namespace LEGACY.Reactor { [HarmonyPatch] internal class Patch_ReactorShutdown { [HarmonyPostfix] [HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")] private static void Post_OnStateChange(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState) { //IL_000a: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected I4, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || oldState.status == newState.status) { return; } WardenObjectiveDataBlock val = null; if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null) { LegacyLogger.Error("Patch_ReactorShutdown: "); LegacyLogger.Error("Failed to get warden objective"); } else if ((int)val.Type == 2 && !val.OnActivateOnSolveItem) { eWardenObjectiveEventTrigger val2 = (eWardenObjectiveEventTrigger)0; eReactorStatus status = newState.status; switch (status - 7) { default: return; case 0: val2 = (eWardenObjectiveEventTrigger)1; break; case 1: val2 = (eWardenObjectiveEventTrigger)2; break; case 2: val2 = (eWardenObjectiveEventTrigger)3; break; } _ = __instance.SpawnNode.LayerType; WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(val.EventsOnActivate, val2, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); } } [HarmonyPrefix] [HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")] private static void Pre_OnBuildDone_ChainedPuzzleMidObjectiveFix(LG_WardenObjective_Reactor __instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) WardenObjectiveDataBlock val = null; if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null) { LegacyLogger.Error("Patch_ReactorShutdown: Failed to get warden objective"); } else if (val.ChainedPuzzleMidObjective != 0) { __instance.m_chainedPuzzleAlignMidObjective = __instance.m_chainedPuzzleAlign; } } [HarmonyPrefix] [HarmonyPatch(typeof(LG_WardenObjective_Reactor), "Update")] private static bool Pre_Update(LG_WardenObjective_Reactor __instance) { //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_000c: Invalid comparison between Unknown and I4 if ((int)__instance.m_currentState.status != 7) { return true; } if (!__instance.m_currentWaveData.HasVerificationTerminal) { return true; } __instance.SetGUIMessage(true, Text.Format(3000u, (Object[])(object)new Object[1] { Object.op_Implicit("<color=orange>" + __instance.m_currentWaveData.VerificationTerminalSerial + "</color>") }), (ePUIMessageStyle)3, false, "", ""); return false; } } [HarmonyPatch] internal class Patch_ReactorStartup_ExtraEventsExecution { [HarmonyPostfix] [HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnTerminalStartupSequenceVerify")] private static void Post_ExecuteEventsOnEndOnClientSide(LG_WardenObjective_Reactor __instance) { if (!SNet.IsMaster) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)3, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); } } [HarmonyPostfix] [HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")] private static void Post_ExecuteOnNoneEventsOnDefenseStart(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: 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) //IL_0016: Invalid comparison between Unknown and I4 if (oldState.status != newState.status && (int)newState.status == 3) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)0, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); } } [HarmonyPostfix] [HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")] private static void Post_OnBuildDone(LG_WardenObjective_Reactor __instance) { //IL_0011: 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_004c: Invalid comparison between Unknown and I4 WardenObjectiveDataBlock db = default(WardenObjectiveDataBlock); if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref db) || db == null) { LegacyLogger.Error("Patch_ReactorStartup_ExtraEventsExecution: "); LegacyLogger.Error("Failed to get warden objective"); } else if ((int)db.Type == 1 && !db.OnActivateOnSolveItem) { ChainedPuzzleInstance chainedPuzzleToStartSequence = __instance.m_chainedPuzzleToStartSequence; chainedPuzzleToStartSequence.OnPuzzleSolved += Action.op_Implicit((Action)delegate { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(db.EventsOnActivate, (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); }); } } } } namespace LEGACY.HardcodedBehaviours { [HarmonyPatch] internal class Patch_PickupItem_Hardcoded { [HarmonyPrefix] [HarmonyPatch(typeof(LG_Distribute_PickupItemsPerZone), "Build")] private static void Pre_LG_Distribute_PickupItemsPerZone(LG_Distribute_PickupItemsPerZone __instance) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("Legacy_L2E1_Gridlock"); if (block == null || RundownManager.ActiveExpedition.LevelLayoutData != ((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID) { return; } eLocalZoneIndex localIndex = __instance.m_zone.LocalIndex; if ((int)localIndex != 10) { if ((int)localIndex == 11) { __instance.m_zonePlacementWeights.Start = 0f; __instance.m_zonePlacementWeights.Middle = 5000f; __instance.m_zonePlacementWeights.End = 5000f; } } else { __instance.m_zonePlacementWeights.Start = 10000f; __instance.m_zonePlacementWeights.Middle = 0f; __instance.m_zonePlacementWeights.End = 0f; } } } } namespace LEGACY.VanillaFix { [HarmonyPatch] internal class Patch_FixHiddenCommandExecution { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReceiveCommand")] private static void Pre_TerminalInterpreter_ReceiveCommand(LG_ComputerTerminalCommandInterpreter __instance, ref TERM_Command cmd) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_007f: Expected I4, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 TERM_Command val = cmd; switch (val - 1) { default: if ((int)val != 43) { break; } goto case 0; case 0: case 1: case 2: case 3: case 11: case 13: case 14: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: if (__instance.m_terminal.CommandIsHidden(cmd)) { cmd = (TERM_Command)10; } break; case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 12: case 15: case 16: break; } } } [HarmonyPatch] internal class Patch_FixScoutFreeze { [HarmonyPrefix] [HarmonyPatch(typeof(ES_ScoutScream), "CommonUpdate")] private static bool Prefix_Debug(ES_ScoutScream __instance) { if (((AgentAI)((ES_Base)__instance).m_ai).Target == null) { return false; } return true; } } [HarmonyPatch] internal class Patch_LG_SecurityDoor_Fix_EventsOnUnlockDoor_Powergenerator { [HarmonyPrefix] [HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")] private static void Pre_OnSyncDoorStatusChange(LG_SecurityDoor __instance, pDoorState state, bool isRecall) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: 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_000b: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 eDoorStatus status = state.status; if ((status - 4 <= 1 || (int)status == 9) && (int)__instance.m_lastState.status == 6) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.LinkedToZoneData.EventsOnUnlockDoor, (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); } } } [HarmonyPatch] internal class Patch_LockSecurityDoor_FixCustomText { [HarmonyPostfix] [HarmonyPatch(typeof(LG_SecurityDoor_Locks), "Setup", new Type[] { typeof(LG_SecurityDoor) })] private static void Post_LG_SecurityDoor_Locks_Setup(LG_SecurityDoor door, LG_SecurityDoor_Locks __instance) { LocalizedText customText = door.LinkedToZoneData.ProgressionPuzzleToEnter.CustomText; __instance.m_lockedWithNoKeyInteractionText = customText; } } [HarmonyPatch] [HarmonyWrapSafe] internal class Patch_RepeatableCommandEventFix { [HarmonyPostfix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "SetupCommandEvents")] private static void Post_ResetupChainedPuzzleAfterExecution(LG_ComputerTerminalCommandInterpreter __instance) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected I4, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Invalid comparison between Unknown and I4 //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Invalid comparison between Unknown and I4 //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Invalid comparison between Unknown and I4 //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Invalid comparison between Unknown and I4 //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Invalid comparison between Unknown and I4 uint num = 0u; if ((Object)(object)__instance.m_terminal.ConnectedReactor != (Object)null) { return; } if (__instance.m_terminal.SpawnNode.m_dimension.IsMainDimension) { LG_LayerType layerType = __instance.m_terminal.SpawnNode.LayerType; switch ((int)layerType) { case 0: num = RundownManager.ActiveExpedition.LevelLayoutData; break; case 1: num = RundownManager.ActiveExpedition.SecondaryLayout; break; case 2: num = RundownManager.ActiveExpedition.ThirdLayout; break; default: LegacyLogger.Error("Unimplemented layer type."); return; } } else { num = __instance.m_terminal.SpawnNode.m_dimension.DimensionData.LevelLayoutData; } LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(num); List<CustomTerminalCommand> val = null; List<LG_ComputerTerminal> terminalsSpawnedInZone = __instance.m_terminal.SpawnNode.m_zone.TerminalsSpawnedInZone; int num2 = terminalsSpawnedInZone.IndexOf(__instance.m_terminal); ExpeditionZoneData val2 = null; Enumerator<ExpeditionZoneData> enumerator = block.Zones.GetEnumerator(); while (enumerator.MoveNext()) { ExpeditionZoneData current = enumerator.Current; if (current.LocalIndex == __instance.m_terminal.SpawnNode.m_zone.LocalIndex) { val2 = current; break; } } if (val2 == null) { LegacyLogger.Error("Cannot find target zone data."); return; } if (val2.TerminalPlacements.Count != terminalsSpawnedInZone.Count) { LegacyLogger.Error("The numbers of terminal placement and spawn, skipped for the zone terminal."); return; } val = val2.TerminalPlacements[num2].UniqueCommands; if (val.Count == 0) { return; } Enumerator<CustomTerminalCommand> enumerator2 = val.GetEnumerator(); TERM_Command CMD = default(TERM_Command); string text = default(string); string text2 = default(string); while (enumerator2.MoveNext()) { CustomTerminalCommand current2 = enumerator2.Current; if ((int)current2.SpecialCommandRule != 0 || !__instance.TryGetCommand(current2.Command, ref CMD, ref text, ref text2) || ((int)CMD != 38 && (int)CMD != 39 && (int)CMD != 40 && (int)CMD != 41 && (int)CMD != 42)) { continue; } ChainedPuzzleInstance OldCPInstance = null; List<WardenObjectiveEventData> CommandEvents = current2.CommandEvents; int eventIndex; for (eventIndex = 0; eventIndex < CommandEvents.Count && (CommandEvents[eventIndex].ChainPuzzle == 0 || !__instance.m_terminal.TryGetChainPuzzleForCommand(CMD, eventIndex, ref OldCPInstance) || !((Object)(object)OldCPInstance != (Object)null)); eventIndex++) { } if ((Object)(object)OldCPInstance == (Object)null) { continue; } ChainedPuzzleInstance obj = OldCPInstance; obj.OnPuzzleSolved += Action.op_Implicit((Action)delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) ChainedPuzzleInstance val3 = ChainedPuzzleManager.CreatePuzzleInstance(OldCPInstance.Data, OldCPInstance.m_sourceArea, __instance.m_terminal.m_wardenObjectiveSecurityScanAlign.position, __instance.m_terminal.m_wardenObjectiveSecurityScanAlign, CommandEvents[eventIndex].UseStaticBioscanPoints); ValueTuple<TERM_Command, int> val4 = null; foreach (Entry<ValueTuple<TERM_Command, int>, ChainedPuzzleInstance> item in (Il2CppArrayBase<Entry<ValueTuple<TERM_Command, int>, ChainedPuzzleInstance>>)(object)__instance.m_terminal.m_commandToChainPuzzleMap.entries) { ChainedPuzzleInstance value = item.value; if ((Object)(object)value.m_sourceArea == (Object)(object)OldCPInstance.m_sourceArea && (Object)(object)value.m_parent == (Object)(object)OldCPInstance.m_parent) { val4 = item.key; break; } } if (val4 != null) { __instance.m_terminal.m_commandToChainPuzzleMap.Remove(val4); __instance.m_terminal.SetChainPuzzleForCommand(CMD, eventIndex, val3); val3.OnPuzzleSolved = OldCPInstance.OnPuzzleSolved; } else { LegacyLogger.Error("value tuple is null!"); } }); } } } } namespace LEGACY.PlayerPortal { public class TeamPortal { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } } } namespace LEGACY.Utils { internal static class Json { private static readonly JsonSerializerOptions _setting; static Json() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown _setting = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, IncludeFields = false, PropertyNameCaseInsensitive = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; _setting.Converters.Add(new JsonStringEnumConverter()); _setting.Converters.Add((JsonConverter)new LocalizedTextConverter()); } public static T Deserialize<T>(string json) { return JsonSerializer.Deserialize<T>(json, _setting); } public static object Deserialize(Type type, string json) { return JsonSerializer.Deserialize(json, type, _setting); } public static string Serialize<T>(T value) { return JsonSerializer.Serialize(value, _setting); } public static void Load<T>(string filePath, out T config) where T : new() { config = Deserialize<T>(File.ReadAllText(filePath)); } } public class Vec3 { public float x { get; set; } public float y { get; set; } public float z { get; set; } public Vector3 ToVector3() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x, y, z); } public Quaternion ToQuaternion() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Euler(x, y, z); } } public static class Helper { public static LG_WardenObjective_Reactor FindReactor(LG_LayerType layer) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) LG_WardenObjective_Reactor val = null; Enumerator<LayerChainIndex, iWardenObjectiveItem> enumerator = WardenObjectiveManager.Current.m_wardenObjectiveItem.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<LayerChainIndex, iWardenObjectiveItem> current = enumerator.Current; if (current.Key.Layer == layer) { val = ((Il2CppObjectBase)current.Value).TryCast<LG_WardenObjective_Reactor>(); if (!((Object)(object)val == (Object)null)) { break; } } } return val; } public static bool TryGetComponent<T>(this GameObject obj, out T comp) { comp = obj.GetComponent<T>(); return comp != null; } public static bool IsPlayerInLevel(PlayerAgent player) { //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: Invalid comparison between Unknown and I4 return (int)player.Owner.Load<pGameState>().gameState == 10; } public static ChainedPuzzleInstance GetChainedPuzzleForCommandOnTerminal(LG_ComputerTerminal terminal, string command) { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected I4, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Invalid comparison between Unknown and I4 //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Invalid comparison between Unknown and I4 //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Invalid comparison between Unknown and I4 //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Invalid comparison between Unknown and I4 //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Invalid comparison between Unknown and I4 uint num = 0u; if (terminal.SpawnNode.m_dimension.IsMainDimension) { LG_LayerType layerType = terminal.SpawnNode.LayerType; switch ((int)layerType) { case 0: num = RundownManager.ActiveExpedition.LevelLayoutData; break; case 1: num = RundownManager.ActiveExpedition.SecondaryLayout; break; case 2: num = RundownManager.ActiveExpedition.ThirdLayout; break; default: LegacyLogger.Error("Unimplemented layer type."); return null; } } else { num = terminal.SpawnNode.m_dimension.DimensionData.LevelLayoutData; } LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(num); List<CustomTerminalCommand> val = null; List<LG_ComputerTerminal> terminalsSpawnedInZone = terminal.SpawnNode.m_zone.TerminalsSpawnedInZone; int num2 = terminalsSpawnedInZone.IndexOf(terminal); ExpeditionZoneData val2 = null; Enumerator<ExpeditionZoneData> enumerator = block.Zones.GetEnumerator(); while (enumerator.MoveNext()) { ExpeditionZoneData current = enumerator.Current; if (current.LocalIndex == terminal.SpawnNode.m_zone.LocalIndex) { val2 = current; break; } } if (val2 == null) { LegacyLogger.Error("Cannot find target zone data."); return null; } if (val2.TerminalPlacements.Count != terminalsSpawnedInZone.Count) { LegacyLogger.Error("The numbers of terminal placement and spawn, skipped for the zone terminal."); return null; } val = val2.TerminalPlacements[num2].UniqueCommands; if (val.Count == 0) { return null; } List<WardenObjectiveEventData> val3 = null; TERM_Command val4 = (TERM_Command)0; Enumerator<CustomTerminalCommand> enumerator2 = val.GetEnumerator(); string text = default(string); string text2 = default(string); while (enumerator2.MoveNext()) { CustomTerminalCommand current2 = enumerator2.Current; if (current2.Command == command) { val3 = current2.CommandEvents; if (!terminal.m_command.TryGetCommand(current2.Command, ref val4, ref text, ref text2)) { LegacyLogger.Error("Cannot get TERM_COMMAND for command {0} on the specified terminal."); } break; } } if (val3 == null || (int)val4 == 0) { return null; } if ((int)val4 != 38 && (int)val4 != 39 && (int)val4 != 40 && (int)val4 != 41 && (int)val4 != 42) { return null; } ChainedPuzzleInstance val5 = null; for (int i = 0; i < val3.Count && (val3[i].ChainPuzzle == 0 || !terminal.TryGetChainPuzzleForCommand(val4, i, ref val5) || !((Object)(object)val5 != (Object)null)); i++) { } return val5; } public static bool TryGetZoneEntranceSecDoor(LG_Zone zone, out LG_SecurityDoor door) { if ((Object)(object)zone == (Object)null) { door = null; return false; } if ((Object)(object)zone.m_sourceGate == (Object)null) { door = null; return false; } if (zone.m_sourceGate.SpawnedDoor == null) { door = null; return false; } door = ((Il2CppObjectBase)zone.m_sourceGate.SpawnedDoor).TryCast<LG_SecurityDoor>(); return (Object)(object)door != (Object)null; } internal static bool isSecDoorToZoneOpened(LG_Zone zone14) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 LG_SecurityDoor door = null; if (!TryGetZoneEntranceSecDoor(zone14, out door) || (Object)(object)door == (Object)null) { return false; } return (int)door.m_sync.GetCurrentSyncState().status == 10; } public static List<T> cast<T>(List<T> list) { List<T> list2 = new List<T>(); Enumerator<T> enumerator = list.GetEnumerator(); while (enumerator.MoveNext()) { T current = enumerator.Current; list2.Add(current); } return list2; } private static eDimensionIndex GetCurrentDimensionIndex() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (PlayerManager.PlayerAgentsInLevel.Count <= 0) { throw new Exception("? You don't have any player agent in level? How could that happen?"); } return ((Agent)PlayerManager.PlayerAgentsInLevel[0]).DimensionIndex; } public static void GetMinLayerAndLocalIndex(out LG_LayerType MinLayer, out eLocalZoneIndex MinLocalIndex) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between I4 and Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between I4 and Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected I4, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected I4, but got Unknown MinLayer = (LG_LayerType)2; MinLocalIndex = (eLocalZoneIndex)20; Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (IsPlayerInLevel(current)) { if ((int)MinLayer > (int)current.m_courseNode.LayerType) { MinLayer = (LG_LayerType)(int)current.m_courseNode.LayerType; MinLocalIndex = (eLocalZoneIndex)20; } if ((int)MinLocalIndex >= (int)current.m_courseNode.m_zone.LocalIndex) { MinLocalIndex = (eLocalZoneIndex)(int)current.m_courseNode.m_zone.LocalIndex; } } } } public static void GetMaxLayerAndLocalIndex(out LG_LayerType MaxLayer, out eLocalZoneIndex MaxLocalIndex) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between I4 and Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between I4 and Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected I4, but got Unknown MaxLayer = (LG_LayerType)0; MaxLocalIndex = (eLocalZoneIndex)0; Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (IsPlayerInLevel(current)) { if ((int)MaxLayer < (int)current.m_courseNode.LayerType) { MaxLayer = (LG_LayerType)(int)current.m_courseNode.LayerType; MaxLocalIndex = (eLocalZoneIndex)0; } if ((int)MaxLocalIndex < (int)current.m_courseNode.m_zone.LocalIndex) { MaxLocalIndex = (eLocalZoneIndex)(int)current.m_courseNode.m_zone.LocalIndex; } } } } public static int GetMinAreaIndex(LG_Zone zone) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0065: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)zone == (Object)null) { return -1; } LG_LayerType type = zone.m_layer.m_type; eLocalZoneIndex localIndex = zone.LocalIndex; GetCurrentDimensionIndex(); int num = zone.m_areas.Count; Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (current.m_courseNode.LayerType != type || current.m_courseNode.m_zone.LocalIndex != localIndex) { continue; } int i = 0; for (List<LG_Area> areas = zone.m_areas; i < areas.Count; i++) { if (((Object)((Component)areas[i]).gameObject).GetInstanceID() == ((Object)((Component)current.m_courseNode.m_area).gameObject).GetInstanceID()) { if (num > i) { num = i; } break; } } } return num; } public static LG_ComputerTerminal FindTerminal(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, int terminalIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) LG_Zone val = null; if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layerType, localIndex, ref val) || (Object)(object)val == (Object)null) { LegacyLogger.Error($"FindTerminal: Didn't find LG_Zone {dimensionIndex}, {layerType}, {localIndex}"); return null; } if (val.TerminalsSpawnedInZone == null || terminalIndex >= val.TerminalsSpawnedInZone.Count) { LegacyLogger.Error($"FindTerminal: Invalid terminal index {terminalIndex} - {((val.TerminalsSpawnedInZone != null) ? val.TerminalsSpawnedInZone.Count : 0)} terminals are spawned in {dimensionIndex}, {layerType}, {localIndex}"); return null; } if (terminalIndex >= 0) { return val.TerminalsSpawnedInZone[terminalIndex]; } return null; } } internal static class LegacyLogger { private static ManualLogSource logger = Logger.CreateLogSource("LEGACYCore"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } } public class SpawnHibernateEnemiesEvent { public eWardenObjectiveEventTrigger Trigger { get; set; } public int Type { get; set; } = 170; public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType Layer { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public string WorldEventObjectFilter { get; set; } = "RANDOM"; public uint EnemyID { get; set; } public int Count { get; set; } = 1; public float Delay { get; set; } public float Duration { get; set; } = 2f; } public class WeightedAreaSelector { private static readonly Dictionary<LG_Zone, WeightedAreaSelector> dict; private WeightedRandomBag<LG_Area> weightedRandomBag; public static WeightedAreaSelector Get(LG_Zone zone) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected I4, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!dict.ContainsKey(zone)) { WeightedAreaSelector weightedAreaSelector = new WeightedAreaSelector(); Enumerator<LG_Area> enumerator = zone.m_areas.GetEnumerator(); while (enumerator.MoveNext()) { LG_Area current = enumerator.Current; float num = 0f; LG_AreaSize size = current.m_size; switch (size - 1) { case 4: num = 7f; break; case 0: num = 20f; break; case 1: num = 30f; break; case 2: num = 35f; break; case 3: num = 45f; break; default: LegacyLogger.Error($"Unhandled LG_AreaSize: {current.m_size}. Won't build."); return null; } weightedAreaSelector.AddEntry(current, num); } dict.Add(zone, weightedAreaSelector); } return dict[zone]; } public static WeightedAreaSelector Get(eDimensionIndex eDimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex) { //IL_0005: 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_0007: Unknown result type (might be due to invalid IL or missing references) LG_Zone val = default(LG_Zone); if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(eDimensionIndex, layerType, localIndex, ref val) || !Object.op_Implicit((Object)(object)val)) { return null; } return Get(val); } private WeightedAreaSelector() { weightedRandomBag = new WeightedRandomBag<LG_Area>(); } private void AddEntry(LG_Area area, float weight) { weightedRandomBag.AddEntry(area, weight); } public LG_Area GetRandom() { return weightedRandomBag.GetRandom(); } private static void OnBuildDone() { } private static void Clear() { dict.Clear(); } static WeightedAreaSelector() { dict = new Dictionary<LG_Zone, WeightedAreaSelector>(); LevelAPI.OnLevelCleanup += dict.Clear; } } public class WeightedRandomBag<T> { private struct Entry { public double accumulatedWeight; public T item; } private List<Entry> entries = new List<Entry>(); private double accumulatedWeight; private Random rand = new Random(); public void AddEntry(T item, double weight) { if (weight <= 0.0) { LegacyLogger.Error("AddEntry: no non-positive weight pls."); return; } accumulatedWeight += weight; entries.Add(new Entry { item = item, accumulatedWeight = accumulatedWeight }); } public T GetRandom() { double num = rand.NextDouble() * accumulatedWeight; foreach (Entry entry in entries) { if (entry.accumulatedWeight >= num) { return entry.item; } } return default(T); } } } namespace LEGACY.LegacyOverride { public class InstanceManager<T> where T : Object { private Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), Dictionary<IntPtr, uint>> instances2Index = new Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), Dictionary<IntPtr, uint>>(); private Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), List<T>> index2Instance = new Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), List<T>>(); public const uint INVALID_INSTANCE_INDEX = uint.MaxValue; public uint Register((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex, T instance) { if (instance == null) { return uint.MaxValue; } Dictionary<IntPtr, uint> dictionary = null; List<T> list = null; if (!instances2Index.ContainsKey(globalZoneIndex)) { dictionary = new Dictionary<IntPtr, uint>(); list = new List<T>(); instances2Index[globalZoneIndex] = dictionary; index2Instance[globalZoneIndex] = list; } else { dictionary = instances2Index[globalZoneIndex]; list = index2Instance[globalZoneIndex]; } if (dictionary.ContainsKey(((Il2CppObjectBase)(object)instance).Pointer)) { LegacyLogger.Error($"InstanceManager<{typeof(T)}>: trying to register duplicate instance! Skipped...."); return uint.MaxValue; } uint count = (uint)dictionary.Count; dictionary[((Il2CppObjectBase)(object)instance).Pointer] = count; list.Add(instance); return count; } public uint Register(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, T instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Register((dimensionIndex, layerType, localIndex), instance); } public uint GetIndex((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex, T instance) { if (!instances2Index.ContainsKey(globalZoneIndex)) { return uint.MaxValue; } Dictionary<IntPtr, uint> dictionary = instances2Index[globalZoneIndex]; if (!dictionary.ContainsKey(((Il2CppObjectBase)(object)instance).Pointer)) { return uint.MaxValue; } return dictionary[((Il2CppObjectBase)(object)instance).Pointer]; } public uint GetIndex(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, T instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return GetIndex((dimensionIndex, layerType, localIndex), instance); } public T GetInstance((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex, uint instanceIndex) { if (!index2Instance.ContainsKey(globalZoneIndex)) { return default(T); } List<T> list = index2Instance[globalZoneIndex]; if (instanceIndex >= list.Count) { return default(T); } return list[(int)instanceIndex]; } public T GetInstance(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, uint instanceIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return GetInstance((dimensionIndex, layerType, localIndex), instanceIndex); } public List<T> GetInstanceInZone((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex) { if (!index2Instance.ContainsKey(globalZoneIndex)) { return null; } return index2Instance[globalZoneIndex]; } public List<T> GetInstanceInZone(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return GetInstanceInZone((dimensionIndex, layerType, localIndex)); } public IEnumerable<(eDimensionIndex, LG_LayerType, eLocalZoneIndex)> RegisteredZones() { return index2Instance.Keys; } public void Clear() { index2Instance.Clear(); instances2Index.Clear(); } } internal static class LegacyOverrideManagers { internal static readonly string LEGACY_CONFIG_PATH = Path.Combine(MTFOPathAPI.CustomPath, "LegacyOverride"); internal static void Init() { ElevatorCargoOverrideManager.Current.Init(); TerminalPositionOverrideManager.Current.Init(); FogBeaconSettingManager.Current.Init(); EnemyTaggerSettingManager.Current.Init(); SecDoorIntTextOverrideManager.Current.Init(); PowerGeneratorOverrideManager.Init(); HSUActivatorOverrideManager.Current.Init(); TerminalUplinkOverrideManager.Current.Init(); ExpeditionSettingsManager.Current.Init(); } } } namespace LEGACY.LegacyOverride.SecDoorIntText { public class DoorToZone { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public LocalizedText Prefix { get; set; } public LocalizedText Postfix { get; set; } public LocalizedText TextToReplace { get; set; } } public class LevelSecDoorIntTextOverride { public uint MainLevelLayout { get; set; } public List<DoorToZone> doorToZones { get; set; } = new List<DoorToZone> { new DoorToZone() }; } internal class SecDoorIntTextOverrideManager { public static readonly SecDoorIntTextOverrideManager Current; private Dictionary<uint, LevelSecDoorIntTextOverride> SecDoorIntTextOverrides = new Dictionary<uint, LevelSecDoorIntTextOverride>(); private LiveEditListener liveEditListener; private static readonly string CONFIG_PATH; internal LevelSecDoorIntTextOverride SettingForCurrentLevel { get; private set; } private void AddOverride(LevelSecDoorIntTextOverride _override) { if (_override != null) { if (SecDoorIntTextOverrides.ContainsKey(_override.MainLevelLayout)) { LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout); SecDoorIntTextOverrides[_override.MainLevelLayout] = _override; } else { SecDoorIntTextOverrides.Add(_override.MainLevelLayout, _override); } } } public void Init() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown if (!Directory.Exists(CONFIG_PATH)) { Directory.CreateDirectory(CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new LevelSecDoorIntTextOverride())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<LevelSecDoorIntTextOverride>(item, out var config); AddOverride(config); } LevelAPI.OnBuildStart += UpdateSetting; liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } private void FileChanged(LiveEditEventArgs e) { LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { LevelSecDoorIntTextOverride @override = Json.Deserialize<LevelSecDoorIntTextOverride>(content); AddOverride(@override); if (GameStateManager.IsInExpedition) { UpdateSetting(); } }); } private void UpdateSetting() { uint levelLayoutData = RundownManager.ActiveExpedition.LevelLayoutData; SettingForCurrentLevel = (SecDoorIntTextOverrides.ContainsKey(levelLayoutData) ? SecDoorIntTextOverrides[levelLayoutData] : null); } private SecDoorIntTextOverrideManager() { } static SecDoorIntTextOverrideManager() { CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "SecDoorIntText"); Current = new SecDoorIntTextOverrideManager(); } } } namespace LEGACY.LegacyOverride.Terminal { internal class TerminalUplinkOverrideManager { public static TerminalUplinkOverrideManager Current; private Dictionary<uint, LevelTerminalUplinks> uplinks = new Dictionary<uint, LevelTerminalUplinks>(); private LiveEditListener liveEditListener; private static readonly string CONFIG_PATH; private TextDataBlock UplinkAddrLogContentBlock; private Dictionary<IntPtr, TerminalUplink> uplinkTerminalConfigs = new Dictionary<IntPtr, TerminalUplink>(); private void AddOverride(LevelTerminalUplinks _override) { if (_override == null) { return; } _override.Uplinks.Sort(delegate(TerminalUplink u1, TerminalUplink u2) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (u1.DimensionIndex != u2.DimensionIndex) { if (u1.DimensionIndex >= u2.DimensionIndex) { return 1; } return -1; } if (u1.LayerType != u2.LayerType) { if (u1.LayerType >= u2.LayerType) { return 1; } return -1; } if (u1.LocalIndex != u2.LocalIndex) { if (u1.LocalIndex >= u2.LocalIndex) { return 1; } return -1; } return (u1.TerminalIndex != u2.TerminalIndex) ? ((u1.TerminalIndex >= u2.TerminalIndex) ? (-1) : (-1)) : 0; }); _override.Uplinks.ForEach(delegate(TerminalUplink u) { u.RoundOverrides.Sort(delegate(UplinkRound r1, UplinkRound r2) { if (r1.RoundIndex == r2.RoundIndex) { return 0; } return (r1.RoundIndex >= r2.RoundIndex) ? 1 : (-1); }); }); if (uplinks.ContainsKey(_override.MainLevelLayout)) { LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout); uplinks[_override.MainLevelLayout] = _override; } else { uplinks.Add(_override.MainLevelLayout, _override); } } public void Init() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown if (!Directory.Exists(CONFIG_PATH)) { Directory.CreateDirectory(CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new LevelTerminalUplinks())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<LevelTerminalUplinks>(item, out var config); AddOverride(config); } liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } private void FileChanged(LiveEditEventArgs e) { LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { LevelTerminalUplinks @override = Json.Deserialize<LevelTerminalUplinks>(content); AddOverride(@override); }); } internal List<TerminalUplink> GetLevelUplinkOverride(uint MainLevelLayout) { if (!uplinks.ContainsKey(MainLevelLayout)) { return null; } return uplinks[MainLevelLayout].Uplinks; } private void Build(TerminalUplink config) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown //IL_02e0: Expected O, but got Unknown //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) if (config.TerminalIndex < 0) { return; } LG_ComputerTerminal val = Helper.FindTerminal(config.DimensionIndex, config.LayerType, config.LocalIndex, config.TerminalIndex); if ((Object)(object)val == (Object)null) { return; } if (val.m_isWardenObjective && val.UplinkPuzzle != null) { LegacyLogger.Error("BuildUplinkOverride: Uplink already built by vanilla, aborting custom build!"); return; } if (config.SetupAsCorruptedUplink) { LG_ComputerTerminal val2 = Helper.FindTerminal(config.CorruptedUplinkReceiver.DimensionIndex, config.CorruptedUplinkReceiver.LayerType, config.CorruptedUplinkReceiver.LocalIndex, config.CorruptedUplinkReceiver.TerminalIndex); if ((Object)(object)val2 == (Object)null) { LegacyLogger.Error("BuildUplinkOverride: SetupAsCorruptedUplink specified but didn't find the receiver terminal, will fall back to normal uplink instead"); return; } if ((Object)(object)val2 == (Object)(object)val) { LegacyLogger.Error("BuildUplinkOverride: Don't specified uplink sender and receiver on the same terminal"); return; } val.CorruptedUplinkReceiver = val2; val2.CorruptedUplinkReceiver = val; } val.UplinkPuzzle = new TerminalUplinkPuzzle(); SetupUplinkPuzzle(val.UplinkPuzzle, val, config); TerminalUplinkPuzzle uplinkPuzzle = val.UplinkPuzzle; uplinkPuzzle.OnPuzzleSolved += Action.op_Implicit((Action)delegate { config.EventsOnComplete.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); }); val.m_command.AddCommand((TERM_Command)(((Object)(object)val.CorruptedUplinkReceiver == (Object)null) ? 25 : 33), config.UseUplinkAddress ? "UPLINK_CONNECT" : "UPLINK_ESTABLISH", new LocalizedText { UntranslatedText = Text.Get(3914968919u), Id = 3914968919u }, (TERM_CommandRule)0); val.m_command.AddCommand((TERM_Command)26, "UPLINK_VERIFY", new LocalizedText { UntranslatedText = Text.Get(1728022075u), Id = 1728022075u }, (TERM_CommandRule)0); if (config.UseUplinkAddress) { LG_ComputerTerminal val3 = null; LegacyLogger.Debug("BuildUplinkOverride: UseUplinkAddress"); val3 = Helper.FindTerminal(config.UplinkAddressLogPosition.DimensionIndex, config.UplinkAddressLogPosition.LayerType, config.UplinkAddressLogPosition.LocalIndex, config.UplinkAddressLogPosition.TerminalIndex); if ((Object)(object)val3 == (Object)null) { LegacyLogger.Error("BuildUplinkOverride: didn't find the terminal to put the uplink address log, will put on uplink terminal"); val3 = val; } val3.AddLocalLog(new TerminalLogFileData { FileName = $"UPLINK_ADDR_{val.m_serialNumber}.LOG", FileContent = new LocalizedText { UntranslatedText = string.Format((UplinkAddrLogContentBlock != null) ? Text.Get(((GameDataBlockBase<TextDataBlock>)(object)UplinkAddrLogContentBlock).persistentID) : "Available uplink address for TERMINAL_{0}: {1}", val.m_serialNumber, val.UplinkPuzzle.TerminalUplinkIP), Id = 0u } }, true); val3.m_command.ClearOutputQueueAndScreenBuffer(); val3.m_command.AddInitialTerminalOutput(); } if (config.ChainedPuzzleToStartUplink != 0) { ChainedPuzzleDataBlock block = GameDataBlockBase<ChainedPuzzleDataBlock>.GetBlock(config.ChainedPuzzleToStartUplink); if (block == null) { LegacyLogger.Error($"BuildTerminalUplink: ChainedPuzzleToActive with id {config.ChainedPuzzleToStartUplink} is specified but no ChainedPuzzleDataBlock definition is found... Won't build"); val.m_chainPuzzleForWardenObjective = null; } else { val.m_chainPuzzleForWardenObjective = ChainedPuzzleManager.CreatePuzzleInstance(block, val.SpawnNode.m_area, val.m_wardenObjectiveSecurityScanAlign.position, val.m_wardenObjectiveSecurityScanAlign); } } foreach (UplinkRound roundOverride in config.RoundOverrides) { if (roundOverride.ChainedPuzzleToEndRound == 0) { continue; } ChainedPuzzleDataBlock block2 = GameDataBlockBase<ChainedPuzzleDataBlock>.GetBlock(roundOverride.ChainedPuzzleToEndRound); if (block2 != null) { LG_ComputerTerminal val4 = null; switch (roundOverride.BuildChainedPuzzleOn) { case UplinkTerminal.SENDER: val4 = val; break; case UplinkTerminal.RECEIVER: if (config.SetupAsCorruptedUplink && (Object)(object)val.CorruptedUplinkReceiver != (Object)null) { val4 = val.CorruptedUplinkReceiver; break; } LegacyLogger.Error($"ChainedPuzzleToEndRound: {roundOverride.ChainedPuzzleToEndRound} specified to build on receiver but this is not a properly setup-ed corr-uplink! Will build ChainedPuzzle on sender side"); val4 = val; break; default: LegacyLogger.Error($"Unimplemented enum UplinkTerminal type {roundOverride.BuildChainedPuzzleOn}"); continue; } roundOverride.ChainedPuzzleToEndRoundInstance = ChainedPuzzleManager.CreatePuzzleInstance(block2, val4.SpawnNode.m_area, val4.m_wardenObjectiveSecurityScanAlign.position, val4.m_wardenObjectiveSecurityScanAlign); } else { LegacyLogger.Error($"ChainedPuzzleToEndRound: {roundOverride.ChainedPuzzleToEndRound} specified but didn't find its ChainedPuzzleDatablock definition! Will not build!"); } } uplinkTerminalConfigs[((Il2CppObjectBase)val).Pointer] = config; LegacyLogger.Debug($"BuildUplink: built on {(config.DimensionIndex, config.LayerType, config.LocalIndex, config.TerminalIndex)}"); } public TerminalUplink GetUplinkConfig(LG_ComputerTerminal terminal) { if (!uplinkTerminalConfigs.ContainsKey(((Il2CppObjectBase)terminal).Pointer)) { return null; } return uplinkTerminalConfigs[((Il2CppObjectBase)terminal).Pointer]; } private void BuildUplinkOverrides() { if (uplinks.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { uplinks[RundownManager.ActiveExpedition.LevelLayoutData].Uplinks.ForEach(Build); } } private void OnBuildDone() { if (UplinkAddrLogContentBlock == null) { UplinkAddrLogContentBlock = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.UplinkTerminal.UplinkAddrLog"); } BuildUplinkOverrides(); } private void OnLevelCleanup() { foreach (TerminalUplink value in uplinkTerminalConfigs.Values) { foreach (UplinkRound roundOverride in value.RoundOverrides) { roundOverride.ChainedPuzzleToEndRoundInstance = null; } } uplinkTerminalConfigs.Clear(); } private TerminalUplinkOverrideManager() { } static TerminalUplinkOverrideManager() { CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "TerminalUplink"); Current = new TerminalUplinkOverrideManager(); LevelAPI.OnBuildDone += Current.OnBuildDone; LevelAPI.OnLevelCleanup += Current.OnLevelCleanup; } private void SetupUplinkPuzzle(TerminalUplinkPuzzle uplinkPuzzle, LG_ComputerTerminal terminal, TerminalUplink config) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown uplinkPuzzle.m_rounds = ListExtensions.ToIl2Cpp<TerminalUplinkPuzzleRound>(new List<TerminalUplinkPuzzleRound>()); uplinkPuzzle.TerminalUplinkIP = SerialGenerator.GetIpAddress(); uplinkPuzzle.m_roundIndex = 0; uplinkPuzzle.m_lastRoundIndexToUpdateGui = -1; uplinkPuzzle.m_position = ((Component)terminal).transform.position; uplinkPuzzle.IsCorrupted = config.SetupAsCorruptedUplink && (Object)(object)terminal.CorruptedUplinkReceiver != (Object)null; uplinkPuzzle.m_terminal = terminal; uint num = Math.Max(config.NumberOfVerificationRounds, 1u); for (int i = 0; i < num; i++) { int num2 = 6; TerminalUplinkPuzzleRound val = new TerminalUplinkPuzzleRound { CorrectIndex = Builder.SessionSeedRandom.Range(0, num2, "NO_TAG"), Prefixes = Il2CppStringArray.op_Implicit(new string[num2]), Codes = Il2CppStringArray.op_Implicit(new string[num2]) }; for (int j = 0; j < num2; j++) { ((Il2CppArrayBase<string>)(object)val.Codes)[j] = SerialGenerator.GetCodeWord(); ((Il2CppArrayBase<string>)(object)val.Prefixes)[j] = SerialGenerator.GetCodeWordPrefix(); } uplinkPuzzle.m_rounds.Add(val); } } } public enum UplinkTerminal { SENDER, RECEIVER } public class Terminal { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public int TerminalIndex { get; set; } = -1; } public class UplinkRound { public int RoundIndex { get; set; } = -1; public uint ChainedPuzzleToEndRound { get; set; } public UplinkTerminal BuildChainedPuzzleOn { get; set; } [JsonIgnore] public ChainedPuzzleInstance ChainedPuzzleToEndRoundInstance { get; set; } public TimeSettings OverrideTimeSettings { get; set; } = new TimeSettings { TimeToStartVerify = -1f, TimeToCompleteVerify = -1f, TimeToRestoreFromFail = -1f }; public List<WardenObjectiveEventData> EventsOnRound { get; set; } = new List<WardenObjectiveEventData>(); } public class TimeSettings { public float TimeToStartVerify { get; set; } = 5f; public float TimeToCompleteVerify { get; set; } = 6f; public float TimeToRestoreFromFail { get; set; } = 6f; } public class TerminalUplink { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public int TerminalIndex { get; set; } = -1; public bool DisplayUplinkWarning { get; set; } = true; public bool SetupAsCorruptedUplink { get; set; } public Terminal CorruptedUplinkReceiver { get; set; } = new Terminal(); public bool UseUplinkAddress { get; set; } = true; public Terminal UplinkAddressLogPosition { get; set; } = new Terminal(); public uint ChainedPuzzleToStartUplink { get; set; } public uint NumberOfVerificationRounds { get; set; } = 1u; public TimeSettings DefaultTimeSettings { get; set; } = new TimeSettings(); public List<UplinkRound> RoundOverrides { get; set; } = new List<UplinkRound> { new UplinkRound() }; public List<WardenObjectiveEventData> EventsOnCommence { get; set; } = new List<WardenObjectiveEventData>(); public List<WardenObjectiveEventData> EventsOnComplete { get; set; } = new List<WardenObjectiveEventData>(); } public class LevelTerminalUplinks { public uint MainLevelLayout { get; set; } public List<TerminalUplink> Uplinks { get; set; } = new List<TerminalUplink> { new TerminalUplink() }; } public class TerminalPosition { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public int TerminalIndex { get; set; } = -1; public string Area { get; set; } = string.Empty; public Vec3 Position { get; set; } = new Vec3(); public Vec3 Rotation { get; set; } = new Vec3(); } public class LevelTerminalPosition { public uint MainLevelLayout { get; set; } public List<TerminalPosition> TerminalPositions { get; set; } = new List<TerminalPosition> { new TerminalPosition() }; } internal class TerminalPositionOverrideManager { public static TerminalPositionOverrideManager Current; private Dictionary<uint, LevelTerminalPosition> terminalPositions = new Dictionary<uint, LevelTerminalPosition>(); private LiveEditListener liveEditListener; private static readonly string CONFIG_PATH; private void AddOverride(LevelTerminalPosition _override) { if (_override != null) { if (terminalPositions.ContainsKey(_override.MainLevelLayout)) { LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout); terminalPositions[_override.MainLevelLayout] = _override; } else { terminalPositions.Add(_override.MainLevelLayout, _override); } } } public void Init() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown if (!Directory.Exists(CONFIG_PATH)) { Directory.CreateDirectory(CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new TerminalPosition())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<LevelTerminalPosition>(item, out var config); AddOverride(config); } liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } private void FileChanged(LiveEditEventArgs e) { LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { LevelTerminalPosition @override = Json.Deserialize<LevelTerminalPosition>(content); AddOverride(@override); }); } internal List<TerminalPosition> GetLevelTerminalPositionOverride(uint MainLevelLayout) { if (!terminalPositions.ContainsKey(MainLevelLayout)) { return null; } return terminalPositions[MainLevelLayout].TerminalPositions; } private TerminalPositionOverrideManager() { } static TerminalPositionOverrideManager() { CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "TerminalPositionOverride"); Current = new TerminalPositionOverrideManager(); } } } namespace LEGACY.LegacyOverride.PowerGenerator { internal static class PowerGeneratorOverrideManager { internal static readonly string BASE_CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "PowerGeneratorOverride"); internal static void Init() { if (!Directory.Exists(BASE_CONFIG_PATH)) { Directory.CreateDirectory(BASE_CONFIG_PATH); } IndividualGeneratorOverrideManager.Current.Init(); GeneratorClusterOverrideManager.Current.Init(); } } } namespace LEGACY.LegacyOverride.PowerGenerator.IndividualGenerator { public class IndividualGenerator { public uint PowerGeneratorIndex { get; set; } = uint.MaxValue; public bool ForceAllowPowerCellInsertion { get; set; } public List<WardenObjectiveEventData> EventsOnInsertCell { get; set; } = new List<WardenObjectiveEventData>(); public Vec3 Position { get; set; } = new Vec3(); public Vec3 Rotation { get; set; } = new Vec3(); } public class ZoneGenerators { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public List<IndividualGenerator> IndividualGeneratorsInZone { get; set; } = new List<IndividualGenerator> { new IndividualGenerator() }; } public class LevelIndividualGenerators { public uint MainLevelLayout { get; set; } public List<ZoneGenerators> PowerGeneratorsInLevel { get; set; } = new List<ZoneGenerators> { new ZoneGenerators() }; } internal class IndividualGeneratorOverrideManager { public static readonly IndividualGeneratorOverrideManager Current; private Dictionary<uint, LevelIndividualGenerators> levelPowerGenerators = new Dictionary<uint, LevelIndividualGenerators>(); private LiveEditListener liveEditListener; private static readonly string CONFIG_PATH; private InstanceManager<LG_PowerGenerator_Core> instanceManager = new InstanceManager<LG_PowerGenerator_Core>(); private HashSet<LG_PowerGenerator_Core> gcGenerators = new HashSet<LG_PowerGenerator_Core>(); private void AddOverride(LevelIndividualGenerators _override) { if (_override != null) { if (levelPowerGenerators.ContainsKey(_override.MainLevelLayout)) { LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout); levelPowerGenerators[_override.MainLevelLayout] = _override; } else { levelPowerGenerators.Add(_override.MainLevelLayout, _override); } } } public void Init() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown if (!Directory.Exists(CONFIG_PATH)) { Directory.CreateDirectory(CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new LevelIndividualGenerators())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<LevelIndividualGenerators>(item, out var config); AddOverride(config); } liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } private void FileChanged(LiveEditEventArgs e) { LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { LevelIndividualGenerators @override = Json.Deserialize<LevelIndividualGenerators>(content); AddOverride(@override); }); } public List<ZoneGenerators> GetLevelPowerGeneratorOverride(uint MainLevelLayout) { if (!levelPowerGenerators.ContainsKey(MainLevelLayout)) { return null; } return levelPowerGenerators[MainLevelLayout].PowerGeneratorsInLevel; } private void OutputLevelInstanceInfo() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) StringBuilder val = new StringBuilder(); val.AppendLine(); foreach (var item in instanceManager.RegisteredZones()) { val.AppendLine($"{item.Item3}, {item.Item2}, Dim {item.Item1}"); List<LG_PowerGenerator_Core> instanceInZone = instanceManager.GetInstanceInZone(item); for (int i = 0; i < instanceInZone.Count; i++) { LG_PowerGenerator_Core val2 = instanceInZone[i]; val.AppendLine($"GENERATOR_{val2.m_serialNumber}. Instance index: {i}"); } val.AppendLine(); } if (!string.IsNullOrWhiteSpace(((Object)val).ToString())) { LegacyLogger.Debug(((Object)val).ToString()); } } private void OnEnterLevel() { OutputLevelInstanceInfo(); } private void Clear() { instanceManager.Clear(); gcGenerators.Clear(); } public uint Register(LG_PowerGenerator_Core __instance) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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 instanceManager.Register(__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex, __instance); } public void MarkAsGCGenerator(LG_PowerGenerator_Core __instance) { gcGenerators.Add(__instance); } public bool IsGCGenerator(LG_PowerGenerator_Core __instance) { return gcGenerators.Contains(__instance); } public List<LG_PowerGenerator_Core> GetInstanceInZone((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex) { return instanceManager.GetInstanceInZone(globalZoneIndex); } public List<LG_PowerGenerator_Core> GetInstanceInZone(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return instanceManager.GetInstanceInZone(dimensionIndex, layerType, localIndex); } private IndividualGeneratorOverrideManager() { } static IndividualGeneratorOverrideManager() { CONFIG_PATH = Path.Combine(PowerGeneratorOverrideManager.BASE_CONFIG_PATH, "IndividualGenerator"); Current = new IndividualGeneratorOverrideManager(); LevelAPI.OnEnterLevel += Current.OnEnterLevel; LevelAPI.OnLevelCleanup += Current.Clear; } } } namespace LEGACY.LegacyOverride.PowerGenerator.GeneratorCluster { public class GeneratorCluster { public uint GeneratorClusterIndex { get; set; } public uint NumberOfGenerators { get; set; } public List<List<WardenObjectiveEventData>> EventsOnInsertCell { get; set; } = new List<List<WardenObjectiveEventData>> { new List<WardenObjectiveEventData>() }; public uint EndSequenceChainedPuzzle { get; set; } public List<WardenObjectiveEventData> EventsOnEndSequenceChainedPuzzleComplete { get; set; } = new List<WardenObjectiveEventData>(); } public class ZoneGeneratorCluster { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public List<GeneratorCluster> GeneratorClustersInZone { get; set; } = new List<GeneratorCluster> { new GeneratorCluster() }; } public class LevelGeneratorClusters { public uint MainLevelLayout { get; set; } public List<ZoneGeneratorCluster> GeneratorClustersInLevel { get; set; } = new List<ZoneGeneratorCluster> { new ZoneGeneratorCluster() }; } internal class GeneratorClusterOverrideManager { public static readonly GeneratorClusterOverrideManager Current; private Dictionary<uint, LevelGeneratorClusters> levelPowerGeneratorClusters = new Dictionary<uint, LevelGeneratorClusters>(); private LiveEditListener PGC_LEListener; private static readonly string PGC_CONFIG_PATH; private InstanceManager<LG_PowerGeneratorCluster> instanceManager = new InstanceManager<LG_PowerGeneratorCluster>(); private List<(LG_PowerGeneratorCluster, GeneratorCluster)> chainedPuzzleToBuild = new List<(LG_PowerGeneratorCluster, GeneratorCluster)>(); private void AddOverride(LevelGeneratorClusters _override) { if (_override == null) { return; } _override.GeneratorClustersInLevel.Sort(delegate(ZoneGeneratorCluster u1, ZoneGeneratorCluster u2) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (u1.DimensionIndex != u2.DimensionIndex) { if (u1.DimensionIndex >= u2.DimensionIndex) { return 1; } return -1; } if (u1.LayerType != u2.LayerType) { if (u1.LayerType >= u2.LayerType) { return 1; } return -1; } return (u1.LocalIndex != u2.LocalIndex) ? ((u1.LocalIndex >= u2.LocalIndex) ? 1 : (-1)) : 0; }); _override.GeneratorClustersInLevel.ForEach(delegate(ZoneGeneratorCluster u) { u.GeneratorClustersInZone.Sort(delegate(GeneratorCluster r1, GeneratorCluster r2) { if (r1.GeneratorClusterIndex == r2.GeneratorClusterIndex) { return 0; } return (r1.GeneratorClusterIndex >= r2.GeneratorClusterIndex) ? 1 : (-1); }); }); if (levelPowerGeneratorClusters.ContainsKey(_override.MainLevelLayout)) { LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout); levelPowerGeneratorClusters[_override.MainLevelLayout] = _override; } else { levelPowerGeneratorClusters.Add(_override.MainLevelLayout, _override); } } public void Init() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown if (!Directory.Exists(PGC_CONFIG_PATH)) { Directory.CreateDirectory(PGC_CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(PGC_CONFIG_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new LevelGeneratorClusters())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(PGC_CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<LevelGeneratorClusters>(item, out var config); AddOverride(config); } PGC_LEListener = LiveEdit.CreateListener(PGC_CONFIG_PATH, "*.json", true); PGC_LEListener.FileChanged += new LiveEditEventHandler(FileChanged); } private void FileChanged(LiveEditEventArgs e) { LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { LevelGeneratorClusters @override = Json.Deserialize<LevelGeneratorClusters>(content); AddOverride(@override); }); } public List<ZoneGeneratorCluster> GetLevelGeneratorClusterOverride(uint MainLevelLayout) { if (!levelPowerGeneratorClusters.ContainsKey(MainLevelLayout)) { return null; } return levelPowerGeneratorClusters[MainLevelLayout].GeneratorClustersInLevel; } public uint Register(LG_PowerGeneratorCluster __instance) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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 instanceManager.Register(__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex, __instance); } internal void RegisterForChainedPuzzleBuild(LG_PowerGeneratorCluster __instance, GeneratorCluster GeneratorClusterConfig) { chainedPuzzleToBuild.Add((__instance, GeneratorClusterConfig)); } private void OnBuildDone() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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) foreach (var item2 in chainedPuzzleToBuild) { LG_PowerGeneratorCluster item = item2.Item1; GeneratorCluster config = item2.Item2; ChainedPuzzleDataBlock block = GameDataBlockBase<ChainedPuzzleDataBlock>.GetBlock(config.EndSequenceChainedPuzzle); if (block == null) { continue; } LegacyLogger.Debug($"Building EndSequenceChainedPuzzle for LG_PowerGeneratorCluster in {item.SpawnNode.m_zone.LocalIndex}, {item.SpawnNode.LayerType}, {item.SpawnNode.m_dimension.DimensionIndex}"); item.m_chainedPuzzleMidObjective = ChainedPuzzleManager.CreatePuzzleInstance(block, item.SpawnNode.m_area, item.m_chainedPuzzleAlignMidObjective.position, item.m_chainedPuzzleAlignMidObjective); if (config.EventsOnEndSequenceChainedPuzzleComplete == null || config.EventsOnEndSequenceChainedPuzzleComplete.Count <= 0) { continue; } ChainedPuzzleInstance chainedPuzzleMidObjective = item.m_chainedPuzzleMidObjective; chainedPuzzleMidObjective.OnPuzzleSolved += Action.op_Implicit((Action)delegate { config.EventsOnEndSequenceChainedPuzzleComplete.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); }); LegacyLogger.Debug("EventsOnEndSequenceChainedPuzzleComplete: executing events..."); } } private void OnEnterLevel() { } private void OnLevelCleanup() { instanceManager.Clear(); chainedPuzzleToBuild.Clear(); } private GeneratorClusterOverrideManager() { } static GeneratorClusterOverrideManager() { PGC_CONFIG_PATH = Path.Combine(PowerGeneratorOverrideManager.BASE_CONFIG_PATH, "PowerGeneratorCluster"); Current = new GeneratorClusterOverrideManager(); LevelAPI.OnEnterLevel += Current.OnEnterLevel; LevelAPI.OnBuildDone += Current.OnBuildDone; LevelAPI.OnLevelCleanup += Current.OnLevelCleanup; } } } namespace LEGACY.LegacyOverride.FogBeacon { public class RepellerSphereSetting { public bool InfiniteDuration { get; set; } public float GrowDuration { get; set; } = 10f; public float ShrinkDuration { get; set; } = 10f; public float Range { get; set; } = 11f; } public class FogBeaconSetting { public uint MainLevelLayout { get; set; } public float TimeToPickup { get; set; } = 1f; public float TimeToPlace { get; set; } = 1f; public RepellerSphereSetting RSHold { get; set; } = new RepellerSphereSetting(); public RepellerSphereSetting RSPlaced { get; set; } = new RepellerSphereSetting(); } internal class FogBeaconSettingManager { public static readonly FogBeaconSettingManager Current; private Dictionary<uint, FogBeaconSetting> fogBeaconSettings = new Dictionary<uint, FogBeaconSetting>(); private LiveEditListener liveEditListener; private static readonly string CONFIG_PATH; internal FogBeaconSetting SettingForCurrentLevel { get; private set; } private void AddOverride(FogBeaconSetting _override) { if (_override != null) { if (fogBeaconSettings.ContainsKey(_override.MainLevelLayout)) { LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout); fogBeaconSettings[_override.MainLevelLayout] = _override; } else { fogBeaconSettings.Add(_override.MainLevelLayout, _override); } } } public void Init() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown if (!Directory.Exists(CONFIG_PATH)) { Directory.CreateDirectory(CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new FogBeaconSetting())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<FogBeaconSetting>(item, out var config); AddOverride(config); } LevelAPI.OnBuildStart += UpdateSetting; liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } private void FileChanged(LiveEditEventArgs e) { LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { FogBeaconSetting @override = Json.Deserialize<FogBeaconSetting>(content); AddOverride(@override); if (GameStateManager.IsInExpedition) { UpdateSetting(); } }); } private void UpdateSetting() { uint levelLayoutData = RundownManager.ActiveExpedition.LevelLayoutData; SettingForCurrentLevel = (fogBeaconSettings.ContainsKey(levelLayoutData) ? fogBeaconSettings[levelLayoutData] : null); LegacyLogger.Debug($"FogBeaconSettingManager: updated setting for level with main level layout id {levelLayoutData}"); } private FogBeaconSettingManager() { } static FogBeaconSettingManager() { CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "FogBeaconSetting"); Current = new FogBeaconSettingManager(); } } } namespace LEGACY.LegacyOverride.ElevatorCargo { internal class ElevatorCargoOverrideManager { public static readonly ElevatorCargoOverrideManager Current; private Dictionary<uint, LevelElevatorCargo> elevatorCargos = new Dictionary<uint, LevelElevatorCargo>(); private LiveEditListener liveEditListener; private static readonly string CONFIG_PATH; private void AddOverride(LevelElevatorCargo _override) { if (_override != null) { if (elevatorCargos.ContainsKey(_override.MainLevelLayout)) { LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout); elevatorCargos[_override.MainLevelLayout] = _override; } else { elevatorCargos.Add(_override.MainLevelLayout, _override); } } } public void Init() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown if (!Directory.Exists(CONFIG_PATH)) { Directory.CreateDirectory(CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new LevelElevatorCargo())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<LevelElevatorCargo>(item, out var config); AddOverride(config); } liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } private void FileChanged(LiveEditEventArgs e) { LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { LevelElevatorCargo @override = Json.Deserialize<LevelElevatorCargo>(content); AddOverride(@override); }); } internal LevelElevatorCargo GetLevelElevatorCargoItems(uint MainLevelLayout) { if (!elevatorCargos.ContainsKey(MainLevelLayout)) { return null; } return elevatorCargos[MainLevelLayout]; } private ElevatorCargoOverrideManager() { } static ElevatorCargoOverrideManager() { CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "ElevatorCargoOverride"); Current = new ElevatorCargoOverrideManager(); } } public enum ItemType { Consumable, BigPickup } public class ElevatorCargoItem { public uint ItemID { get; set; } public ItemType ItemType { get; set; } } public class LevelElevatorCargo { public uint MainLevelLayout { get; set; } public bool ForceDisable { get; set; } public List<ElevatorCargoItem> ElevatorCargoItems { get; set; } = new List<ElevatorCargoItem>(); } } namespace LEGACY.LegacyOverride.Patches { [HarmonyPatch] internal class Patch_Customize_SecDoor_Interaction_Text { [HarmonyPostfix] [HarmonyPatch(typeof(LG_SecurityDoor_Locks), "OnDoorState")] private static void Post_Customize_SecDoor_Interaction_Text(pDoorState state, LG_SecurityDoor_Locks __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //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_002d: Invalid comparison between Unknown and I4 //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) LevelSecDoorIntTextOverride settingForCurrentLevel = SecDoorIntTextOverrideManager.Current.SettingForCurrentLevel; if (settingForCurrentLevel == null || ((int)state.status != 9 && (int)state.status != 5)) { return; } int num = settingForCurrentLevel.doorToZones.FindIndex((DoorToZone door) => door.DimensionIndex == __instance.m_door.Gate.DimensionIndex && door.LayerType == __instance.m_door.LinksToLayerType && door.LocalIndex == __instance.m_door.LinkedToZoneData.LocalIndex); if (num != -1) { DoorToZone doorToZone = settingForCurrentLevel.doorToZones[num]; _ = __instance.m_door; Interact_Timed intOpenDoor = __instance.m_intOpenDoor; string text = LocalizedText.op_Implicit(doorToZone.Prefix); string text2 = LocalizedText.op_Implicit(doorToZone.Postfix); string text3 = LocalizedText.op_Implicit(doorToZone.TextToReplace); if (string.IsNullOrEmpty(text)) { text = string.Empty; } if (string.IsNullOrEmpty(text2)) { text2 = string.Empty; } if (string.IsNullOrEmpty(text3)) { text3 = intOpenDoor.InteractionMessage; } intOpenDoor.InteractionMessage = text + "\n" + text3 + "\n" + text2; LegacyLogger.Debug($"SecDoorIntTextOverride: Override IntText. {doorToZone.LocalIndex}, {doorToZone.LayerType}, {doorToZone.DimensionIndex}"); } } } [HarmonyPatch] internal class Patch_LG_PowerGeneratorCluster { [HarmonyPostfix] [HarmonyPatch(typeof(LG_PowerGeneratorCluster), "Setup")] private static void Post_PowerGeneratorCluster_Setup(LG_PowerGeneratorCluster __instance) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Invalid comparison between Unknown and I4 //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) uint zoneInstanceIndex = GeneratorClusterOverrideManager.Current.Register(__instance); List<ZoneGeneratorCluster> levelGeneratorClusterOverride = GeneratorClusterOverrideManager.Current.GetLevelGeneratorClusterOverride(RundownManager.ActiveExpedition.LevelLayoutData); if (levelGeneratorClusterOverride == null || levelGeneratorClusterOverride.Count < 1) { return; } int num = levelGeneratorClusterOverride.FindIndex((ZoneGeneratorCluster zonePGConfig) => __instance.SpawnNode.m_zone.LocalIndex == zonePGConfig.LocalIndex && __instance.SpawnNode.m_zone.Layer.m_type == zonePGConfig.LayerType && __instance.SpawnNode.m_dimension.DimensionIndex == zonePGConfig.DimensionIndex); if (num == -1) { return; } ZoneGeneratorCluster zoneGeneratorCluster = levelGeneratorClusterOverride[num]; num = zoneGeneratorCluster.GeneratorClustersInZone.FindIndex((GeneratorCluster config) => config.GeneratorClusterIndex == zoneInstanceIndex); if (num == -1) { return; } GeneratorCluster GeneratorClusterConfig = zoneGeneratorCluster.GeneratorClustersInZone[num]; if ((int)WardenObjectiveManager.Current.m_activeWardenObjectives[__instance.SpawnNode.LayerType].Type == 9) { LegacyLogger.Error("Found built Warden Objective LG_PowerGeneratorCluster but there's also a config for it! Won't apply this config"); LegacyLogger.Error($"Zone_{zoneGeneratorCluster.LocalIndex}, {zoneGeneratorCluster.LayerType}, {zoneGeneratorCluster.DimensionIndex}"); return; } LegacyLogger.Warning("Found LG_PowerGeneratorCluster and its config! Building this Generator cluster..."); __instance.m_serialNumber = SerialGenerator.GetUniqueSerialNo(); __instance.m_itemKey = "GENERATOR_CLUSTER_" + __instance.m_serialNumber; __instance.m_terminalItem = GOUtil.GetInterfaceFromComp<iTerminalItem>(__instance.m_terminalItemComp); __instance.m_terminalItem.Setup(__instance.m_itemKey, (AIG_CourseNode)null); __instance.m_terminalItem.FloorItemStatus = (eFloorInventoryObjectStatus)4; if (__instance.SpawnNode != null) { __instance.m_terminalItem.FloorItemLocation = __instance.SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7); } List<Transform> list = new List<Transform>((IEnumerable<Transform>)__instance.m_generatorAligns); uint numberOfGenerators = GeneratorClusterConfig.NumberOfGenerators; __instance.m_generators = Il2CppReferenceArray<LG_PowerGenerator_Core>.op_Implicit((LG_PowerGenerator_Core[])(object)new LG_PowerGenerator_Core[numberOfGenerators]); if (list.Count >= numberOfGenerators) { for (int i = 0; i < numberOfGenerators; i++) { int index = Builder.BuildSeedRandom.Range(0, list.Count, "NO_TAG"); LG_PowerGenerator_Core val = GOUtil.SpawnChildAndGetComp<LG_PowerGenerator_Core>(__instance.m_generatorPrefab, list[index]); ((Il2CppArrayBase<LG_PowerGenerator_Core>)(object)__instance.m_generators)[i] = val; val.SpawnNode = __instance.SpawnNode; IndividualGeneratorOverrideManager.Current.MarkAsGCGenerator(val); val.Setup(); val.SetCanTakePowerCell(true); val.OnSyncStatusChanged += Action<ePowerGeneratorStatus>.op_Implicit((Action<ePowerGeneratorStatus>)delegate(ePowerGeneratorStatus status) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //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) Debug.Log(Object.op_Implicit("LG_PowerGeneratorCluster.powerGenerator.OnSyncStatusChanged! status: " + ((object)(ePowerGeneratorStatus)(ref status)).ToString())); if ((int)status == 0) { uint num2 = 0u; for (int j = 0; j < ((Il2CppArrayBase<LG_PowerGenerator_Core>)(object)__instance.m_generators).Length; j++) { if ((int)((Il2CppArrayBase<LG_PowerGenerator_Core>)(object)__instance.m_generators)[j].m_stateReplicator.State.status == 0) { num2++; } } LegacyLogger.Log($"Generator Cluster PowerCell inserted ({num2} / {((Il2CppArrayBase<LG_PowerGenerator_Core>)(object)__instance.m_generators).Count})"); List<List<WardenObjectiveEventData>> eventsOnInsertCell = GeneratorClusterConfig.EventsOnInsertCell; int num3 = (int)(num2 - 1); if (num3 >= 0 && num3 < eventsOnInsertCell.Count) { LegacyLogger.Log($"Executing events ({num2} / {((Il2CppArrayBase<LG_PowerGenerator_Core>)(object)__instance.m_generators).Count}). Event count: {eventsOnInsertCell[num3].Count}"); eventsOnInsertCell[num3].ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); } if (num2 == ((Il2CppArrayBase<LG_PowerGenerator_Core>)(object)__instance.m_generators).Count && !__instance.m_endSequenceTriggered) { LegacyLogger.Log("All generators powered, executing end sequence"); ((MonoBehaviour)__instance).StartCoroutine(__instance.ObjectiveEndSequence()); __instance.m_endSequenceTriggered = true; } } }); Debug.Log(Object.op_Implicit("Spawning generator at alignIndex: " + index)); list.RemoveAt(index); } } else { Debug.LogError(Object.op_Implicit("LG_PowerGeneratorCluster does NOT have enough generator aligns to support the warden objective! Has " + list.Count + " needs " + numberOfGenerators)); } __instance.ObjectiveItemSolved = true; if (GeneratorClusterConfig.EndSequenceChainedPuzzle != 0) { GeneratorClusterOverrideManager.Current.RegisterForChainedPuzzleBuild(__instance, GeneratorClusterConfig); } } } [HarmonyPatch] internal class Patch_LG_HSUActivator_Core { [HarmonyPostfix] [HarmonyPatch(typeof(LG_HSUActivator_Core), "SetupFromCustomGeomorph")] private static void Post_LG_HSUActivator_Core_SetupFromCustomGeomorph(LG_HSUActivator_Core __instance) { //IL
plugins/Heat/net6/ScanPosOverride.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; 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 System.Text.Json; using System.Text.Json.Serialization; using System.Threading; using AIGraph; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using ChainedPuzzles; using GTFO.API; using GTFO.API.Utilities; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Text; using LevelGeneration; using Localization; using MTFO.API; using Microsoft.CodeAnalysis; using Player; using ScanPosOverride.JSON; using ScanPosOverride.Managers; using ScanPosOverride.PuzzleOverrideData; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ScanPosOverride")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ScanPosOverride")] [assembly: AssemblyTitle("ScanPosOverride")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ScanPosOverride { internal static class ScanPosOverrideLogger { private static readonly ManualLogSource logger = Logger.CreateLogSource("ScanPosOverride"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } public static void Log(BepInExDebugLogInterpolatedStringHandler logHandler) { logger.LogDebug(logHandler); } } [BepInPlugin("ScanPositionOverride", "ScanPositionOverride", "1.5.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class Plugin : BasePlugin { [CompilerGenerated] private static class <>O { public static LiveEditEventHandler <0>__LiveEdit_FileChanged; } private static Dictionary<uint, Dictionary<uint, PuzzleOverride>> PuzzleOverrides = new Dictionary<uint, Dictionary<uint, PuzzleOverride>>(); public static readonly string OVERRIDE_SCAN_POS_PATH = Path.Combine(MTFOPathAPI.CustomPath, "ScanPositionOverrides"); private static LiveEditListener listener = null; private static Harmony m_Harmony = null; public override void Load() { //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown ScanPosOverrideLogger.Error(OVERRIDE_SCAN_POS_PATH); if (!Directory.Exists(OVERRIDE_SCAN_POS_PATH)) { Directory.CreateDirectory(OVERRIDE_SCAN_POS_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(OVERRIDE_SCAN_POS_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new PuzzleOverrideJsonFile())); streamWriter.Flush(); streamWriter.Close(); return; } foreach (string item in Directory.EnumerateFiles(OVERRIDE_SCAN_POS_PATH, "*.json", SearchOption.AllDirectories)) { Json.Load<PuzzleOverrideJsonFile>(item, out var config); if (PuzzleOverrides.ContainsKey(config.MainLevelLayout)) { ScanPosOverrideLogger.Warning("Duplicate MainLevelLayout {0}, won't load.", config.MainLevelLayout); continue; } Dictionary<uint, PuzzleOverride> dictionary = new Dictionary<uint, PuzzleOverride>(); foreach (PuzzleOverride puzzle in config.Puzzles) { if (dictionary.ContainsKey(puzzle.Index)) { ScanPosOverrideLogger.Error("Duplicate Puzzle Override found. MainLevelLayout {0}, Index {1}.", config.MainLevelLayout, puzzle.Index); } else { dictionary.Add(puzzle.Index, puzzle); } } PuzzleOverrides.Add(config.MainLevelLayout, dictionary); } listener = LiveEdit.CreateListener(OVERRIDE_SCAN_POS_PATH, "*.json", true); LiveEditListener obj = listener; object obj2 = <>O.<0>__LiveEdit_FileChanged; if (obj2 == null) { LiveEditEventHandler val = LiveEdit_FileChanged; <>O.<0>__LiveEdit_FileChanged = val; obj2 = (object)val; } obj.FileChanged += (LiveEditEventHandler)obj2; m_Harmony = new Harmony("ScanPosOverride.Patches"); m_Harmony.PatchAll(); } private static void LiveEdit_FileChanged(LiveEditEventArgs e) { ScanPosOverrideLogger.Warning("LiveEdit File Changed: " + e.FullPath + "."); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { PuzzleOverrideJsonFile puzzleOverrideJsonFile = Json.Deserialize<PuzzleOverrideJsonFile>(content); if (!PuzzleOverrides.ContainsKey(puzzleOverrideJsonFile.MainLevelLayout)) { ScanPosOverrideLogger.Warning("MainLevelLayout not found, which is now not supported. Will not replace."); } else { Dictionary<uint, PuzzleOverride> dictionary = PuzzleOverrides[puzzleOverrideJsonFile.MainLevelLayout]; dictionary.Clear(); foreach (PuzzleOverride puzzle in puzzleOverrideJsonFile.Puzzles) { if (dictionary.ContainsKey(puzzle.Index)) { ScanPosOverrideLogger.Error("Duplicate Puzzle Override found. MainLevelLayout {0}, Index {1}.", puzzleOverrideJsonFile.MainLevelLayout, puzzle.Index); } else { dictionary.Add(puzzle.Index, puzzle); } } ScanPosOverrideLogger.Warning("Replaced Override Puzzle with MainLevelLayout {0}", puzzleOverrideJsonFile.MainLevelLayout); } }); } internal static PuzzleOverride GetOverride(uint mainLevelLayout, uint puzzleIndex) { if (!PuzzleOverrides.ContainsKey(mainLevelLayout)) { return null; } Dictionary<uint, PuzzleOverride> dictionary = PuzzleOverrides[mainLevelLayout]; if (!dictionary.ContainsKey(puzzleIndex)) { return null; } return dictionary[puzzleIndex]; } } } namespace ScanPosOverride.PuzzleOverrideData { internal sealed class PuzzleOverrideJsonFile { public uint MainLevelLayout { get; set; } public List<PuzzleOverride> Puzzles { get; set; } = new List<PuzzleOverride>(); } internal sealed class PuzzleOverride { public uint Index { get; set; } public Vec3 Position { get; set; } = new Vec3(); public Vec3 Rotation { get; set; } = new Vec3(); public bool HideSpline { get; set; } public bool ConcurrentCluster { get; set; } public float TMoveSpeedMulti { get; set; } = -1f; public List<Vec3> TPositions { get; set; } = new List<Vec3>(); public List<int> RequiredItemsIndices { get; set; } = new List<int> { 0 }; public List<WardenObjectiveEventData> EventsOnPuzzleSolved { get; set; } = new List<WardenObjectiveEventData>(); } public class Vec3 { public float x { get; set; } public float y { get; set; } public float z { get; set; } public Vector3 ToVector3() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x, y, z); } public Quaternion ToQuaternion() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Euler(x, y, z); } } } namespace ScanPosOverride.Patches { [HarmonyPatch] internal class Patch_CP_Bioscan_Core_OnSyncStateChange { [HarmonyPostfix] [HarmonyPatch(typeof(CP_Bioscan_Core), "OnSyncStateChange")] private static void Post_CP_Bioscan_Core_OnSyncStateChanged(CP_Bioscan_Core __instance, float progress, eBioscanStatus status, List<PlayerAgent> playersInScan) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Invalid comparison between Unknown and I4 //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Invalid comparison between Unknown and I4 //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Invalid comparison between Unknown and I4 //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) bool flag = PlayerScannerManager.Current.IsConcurrentCluster(__instance); if ((int)status != 3) { if (flag) { if ((int)status == 4) { CP_Cluster_Core parentClusterCore = PlayerScannerManager.Current.GetParentClusterCore(__instance); if ((Object)(object)parentClusterCore == (Object)null) { ScanPosOverrideLogger.Error("Cannot find parent cluster core! The concurrent cluster may fail!"); } else { PlayerScannerManager.Current.CompleteConcurrentCluster(parentClusterCore); } } else { PlayerScannerManager.Current.ConcurrentClusterShouldProgress(__instance, IsThisScanShouldProgress: false); } } if (__instance.m_reqItemsEnabled) { __instance.m_graphics.SetColorMode((eChainedPuzzleGraphicsColorMode)((!__instance.m_hasAlarm) ? 1 : 4)); } } else { if (!__instance.IsMovable && !flag && !__instance.m_reqItemsEnabled) { return; } CP_PlayerScanner cacheScanner = PlayerScannerManager.Current.GetCacheScanner(__instance); if ((Object)(object)cacheScanner == (Object)null) { ScanPosOverrideLogger.Error("Null CP_PlayerScanner"); return; } int count = playersInScan.Count; List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel; float num = 0f; float[] cacheOriginalScanSpeed = PlayerScannerManager.Current.GetCacheOriginalScanSpeed(__instance); if ((int)__instance.m_playerScanner.ScanPlayersRequired == 0) { num = ((count <= 0) ? 0f : cacheOriginalScanSpeed[count - 1]); } else if (((int)cacheScanner.m_playerRequirement == 1 && count == playerAgentsInLevel.Count) || ((int)cacheScanner.m_playerRequirement == 2 && count == 1)) { num = cacheOriginalScanSpeed[0]; } bool flag2 = num > 0f; if (flag2 && cacheScanner.m_reqItemsEnabled) { for (int i = 0; i < ((Il2CppArrayBase<iWardenObjectiveItem>)(object)cacheScanner.m_reqItems).Length; i++) { Vector3 val = Vector3.zero; if ((int)((Il2CppArrayBase<iWardenObjectiveItem>)(object)cacheScanner.m_reqItems)[i].PickupItemStatus == 0) { val = ((Il2CppArrayBase<iWardenObjectiveItem>)(object)cacheScanner.m_reqItems)[i].transform.position; } else if ((int)((Il2CppArrayBase<iWardenObjectiveItem>)(object)cacheScanner.m_reqItems)[i].PickupItemStatus == 1) { if ((Object)(object)((Il2CppArrayBase<iWardenObjectiveItem>)(object)cacheScanner.m_reqItems)[i].PickedUpByPlayer != (Object)null) { val = ((Agent)((Il2CppArrayBase<iWardenObjectiveItem>)(object)cacheScanner.m_reqItems)[i].PickedUpByPlayer).Position; } else { Debug.LogError(Object.op_Implicit("Playerscanner is looking for an item that has ePickupItemStatus.PickedUp but null player, how come!?")); } } Vector3 val2 = ((Component)cacheScanner).transform.position - val; if (((Vector3)(ref val2)).sqrMagnitude >= cacheScanner.m_scanRadiusSqr) { flag2 = false; break; } } } if (flag) { if (flag2) { flag2 = PlayerScannerManager.Current.ConcurrentClusterShouldProgress(__instance, IsThisScanShouldProgress: true); } else { PlayerScannerManager.Current.ConcurrentClusterShouldProgress(__instance, IsThisScanShouldProgress: false); } } if (flag2) { if (flag) { CP_Cluster_Core parentClusterCore2 = PlayerScannerManager.Current.GetParentClusterCore(__instance); if ((Object)(object)parentClusterCore2 == (Object)null) { ScanPosOverrideLogger.Error("null clusterParent"); } PlayerScannerManager.Current.RestoreConcurrentClusterScanSpeed(parentClusterCore2); } if (__instance.IsMovable) { __instance.m_movingComp.ResumeMovement(); } if (cacheScanner.m_reqItemsEnabled) { if ((int)cacheScanner.m_playerRequirement == 0) { ((Il2CppArrayBase<float>)(object)cacheScanner.m_scanSpeeds)[0] = ((count > 0) ? cacheOriginalScanSpeed[count - 1] : 0f); } __instance.m_graphics.SetColorMode((eChainedPuzzleGraphicsColorMode)(__instance.m_hasAlarm ? 5 : 2)); } return; } if (flag) { CP_Cluster_Core parentClusterCore3 = PlayerScannerManager.Current.GetParentClusterCore(__instance); if ((Object)(object)parentClusterCore3 == (Object)null) { ScanPosOverrideLogger.Error("null clusterParent"); } PlayerScannerManager.Current.ZeroConcurrentClusterScanSpeed(parentClusterCore3); } if (__instance.IsMovable) { __instance.m_movingComp.PauseMovement(); } if (cacheScanner.m_reqItemsEnabled) { if ((int)cacheScanner.m_playerRequirement == 0) { PlayerScannerManager.Current.GetCacheOriginalScanSpeed(__instance); ((Il2CppArrayBase<float>)(object)cacheScanner.m_scanSpeeds)[0] = 0f; } __instance.m_graphics.SetColorMode((eChainedPuzzleGraphicsColorMode)((!__instance.m_hasAlarm) ? 1 : 4)); } } } static Patch_CP_Bioscan_Core_OnSyncStateChange() { } } [HarmonyPatch] internal class Patch_CP_Bioscan_Core_Setup { [HarmonyPrefix] [HarmonyPatch(typeof(CP_Bioscan_Core), "Setup")] private static void Pre_CP_Bioscan_Core_Setup(CP_Bioscan_Core __instance, int puzzleIndex, iChainedPuzzleOwner owner, ref Vector3 prevPuzzlePos, ref bool revealWithHoloPath, ref bool onlyShowHUDWhenPlayerIsClose) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) ChainedPuzzleInstance val = ((Il2CppObjectBase)owner).TryCast<ChainedPuzzleInstance>(); if ((Object)(object)val != (Object)null) { if (puzzleIndex != 0) { CP_Bioscan_Core val2 = ((Il2CppObjectBase)((Il2CppArrayBase<iChainedPuzzleCore>)(object)val.m_chainedPuzzleCores)[puzzleIndex - 1]).TryCast<CP_Bioscan_Core>(); if ((Object)(object)val2 != (Object)null) { prevPuzzlePos = ((Component)val2).transform.position; } else { CP_Cluster_Core val3 = ((Il2CppObjectBase)((Il2CppArrayBase<iChainedPuzzleCore>)(object)val.m_chainedPuzzleCores)[puzzleIndex - 1]).TryCast<CP_Cluster_Core>(); if ((Object)(object)val3 == (Object)null) { ScanPosOverrideLogger.Error($"Cannot cast m_chainedPuzzleCores[{puzzleIndex - 1}] to neither CP_Bioscan_Core or CP_Cluster_Core! WTF???"); } else { prevPuzzlePos = ((Component)val3).transform.position; } } } } else { CP_Cluster_Core val4 = ((Il2CppObjectBase)owner).TryCast<CP_Cluster_Core>(); if ((Object)(object)val4 == (Object)null) { ScanPosOverrideLogger.Error("Onwer is not neither ChainedPuzzleInstance nor CP_Cluster_Core. What r u?"); return; } prevPuzzlePos = ((Component)val4).transform.position; val = ((Il2CppObjectBase)val4.m_owner).TryCast<ChainedPuzzleInstance>(); if ((Object)(object)val == (Object)null) { ScanPosOverrideLogger.Error("Failed to cast clusterOwner.m_owner to ChainedPuzzleInstance"); return; } if (val.Data.OnlyShowHUDWhenPlayerIsClose) { onlyShowHUDWhenPlayerIsClose = true; } } uint puzzleIndex2 = PuzzleOverrideManager.Current.Register(__instance); PuzzleOverride puzzleOverride = Plugin.GetOverride(PuzzleOverrideManager.MainLevelLayout, puzzleIndex2); if (puzzleOverride == null) { return; } if ((double)puzzleOverride.Position.x != 0.0 || (double)puzzleOverride.Position.y != 0.0 || (double)puzzleOverride.Position.z != 0.0 || (double)puzzleOverride.Rotation.x != 0.0 || (double)puzzleOverride.Rotation.y != 0.0 || (double)puzzleOverride.Rotation.z != 0.0) { ((Component)__instance).transform.SetPositionAndRotation(puzzleOverride.Position.ToVector3(), puzzleOverride.Rotation.ToQuaternion()); } if (puzzleOverride.EventsOnPuzzleSolved != null && puzzleOverride.EventsOnPuzzleSolved.Count > 0) { __instance.OnPuzzleDone += Action<int>.op_Implicit((Action<int>)delegate { foreach (WardenObjectiveEventData item in puzzleOverride.EventsOnPuzzleSolved) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(item, (eWardenObjectiveEventTrigger)0, true, 0f); } }); } if (puzzleOverride.HideSpline || ((Object)(object)__instance.m_movingComp != (Object)null && __instance.m_movingComp.IsMoveConfigured)) { revealWithHoloPath = false; } if (puzzleOverride.RequiredItemsIndices != null && puzzleOverride.RequiredItemsIndices.Count > 0) { PuzzleReqItemManager.Current.QueueForAddingReqItems(__instance, puzzleOverride.RequiredItemsIndices); } ScanPosOverrideLogger.Warning("Overriding CP_Bioscan_Core." + (((Object)(object)val == (Object)null) ? "" : $"Zone {val.m_sourceArea.m_zone.Alias}, Layer {val.m_sourceArea.m_zone.Layer.m_type}, Dim {val.m_sourceArea.m_zone.DimensionIndex}")); } } [HarmonyPatch] internal class Patch_ChainedPuzzleInstance_SetupMovement { [HarmonyPrefix] [HarmonyPatch(typeof(ChainedPuzzleInstance), "SetupMovement")] private static bool Pre_SetupMovement(ChainedPuzzleInstance __instance, GameObject gameObject) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) iChainedPuzzleMovable movingComp = gameObject.GetComponent<iChainedPuzzleMovable>(); if (movingComp == null || !movingComp.UsingStaticBioscanPoints) { return true; } CP_BasicMovable val = ((Il2CppObjectBase)movingComp).Cast<CP_BasicMovable>(); CP_Bioscan_Core val2 = ((Il2CppObjectBase)gameObject.GetComponent<iChainedPuzzleCore>()).TryCast<CP_Bioscan_Core>(); if ((Object)(object)val2 == (Object)null) { ScanPosOverrideLogger.Error("Pre_SetupMovement: iChainedPuzzleCore -> CP_Bioscan_Core failed"); return true; } uint bioscanCoreOverrideIndex = PuzzleOverrideManager.Current.GetBioscanCoreOverrideIndex(((Il2CppObjectBase)val2).Pointer); if (bioscanCoreOverrideIndex == 0) { ScanPosOverrideLogger.Error("Did not find registered movable override for this movable scan."); return true; } PuzzleOverride @override = Plugin.GetOverride(PuzzleOverrideManager.MainLevelLayout, bioscanCoreOverrideIndex); if (@override == null || @override.TPositions.Count < 1) { ScanPosOverrideLogger.Error("No Override for this T-Scan, falling back to vanilla impl."); return true; } @override.TPositions.ForEach(delegate(Vec3 pos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) movingComp.ScanPositions.Add(pos.ToVector3()); }); gameObject.transform.position = @override.TPositions[0].ToVector3(); ScanPosOverrideLogger.Warning("Overriding T-Scan pos!"); val.m_amountOfPositions = @override.TPositions.Count; if (@override.TMoveSpeedMulti > 0f) { val.m_movementSpeed *= @override.TMoveSpeedMulti; } return false; } } [HarmonyPatch] internal class Patch_CarryItemPickup_Core_Setup { [HarmonyPostfix] [HarmonyPatch(typeof(CarryItemPickup_Core), "Setup")] private static void Post_CarryItemPickup_Core_Setup(CarryItemPickup_Core __instance) { PuzzleReqItemManager.Current.Register(__instance); } } [HarmonyPatch] internal class Patch_CP_Cluster_Core_Setup { [HarmonyPrefix] [HarmonyPatch(typeof(CP_Cluster_Core), "Setup")] private static void Pre_CP_Cluster_Core_Setup(CP_Cluster_Core __instance, int puzzleIndex, iChainedPuzzleOwner owner, ref Vector3 prevPuzzlePos, ref bool revealWithHoloPath) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) ChainedPuzzleInstance val = new ChainedPuzzleInstance(((Il2CppObjectBase)owner).Pointer); if (puzzleIndex != 0) { CP_Bioscan_Core val2 = ((Il2CppObjectBase)((Il2CppArrayBase<iChainedPuzzleCore>)(object)val.m_chainedPuzzleCores)[puzzleIndex - 1]).TryCast<CP_Bioscan_Core>(); if ((Object)(object)val2 != (Object)null) { prevPuzzlePos = ((Component)val2).transform.position; } else { CP_Cluster_Core val3 = ((Il2CppObjectBase)((Il2CppArrayBase<iChainedPuzzleCore>)(object)val.m_chainedPuzzleCores)[puzzleIndex - 1]).TryCast<CP_Cluster_Core>(); if ((Object)(object)val3 == (Object)null) { ScanPosOverrideLogger.Error($"Cannot cast m_chainedPuzzleCores[{puzzleIndex - 1}] to neither CP_Bioscan_Core or CP_Cluster_Core! WTF???"); } else { prevPuzzlePos = ((Component)val3).transform.position; } } } uint puzzleIndex2 = PuzzleOverrideManager.Current.Register(__instance); PuzzleOverride puzzleOverride = Plugin.GetOverride(PuzzleOverrideManager.MainLevelLayout, puzzleIndex2); if (puzzleOverride == null) { return; } if ((double)puzzleOverride.Position.x != 0.0 || (double)puzzleOverride.Position.y != 0.0 || (double)puzzleOverride.Position.z != 0.0 || (double)puzzleOverride.Rotation.x != 0.0 || (double)puzzleOverride.Rotation.y != 0.0 || (double)puzzleOverride.Rotation.z != 0.0) { ((Component)__instance).transform.SetPositionAndRotation(puzzleOverride.Position.ToVector3(), puzzleOverride.Rotation.ToQuaternion()); } if (puzzleOverride.EventsOnPuzzleSolved != null && puzzleOverride.EventsOnPuzzleSolved.Count > 0) { __instance.OnPuzzleDone += Action<int>.op_Implicit((Action<int>)delegate { foreach (WardenObjectiveEventData item in puzzleOverride.EventsOnPuzzleSolved) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(item, (eWardenObjectiveEventTrigger)0, true, 0f); } }); } if (puzzleOverride.RequiredItemsIndices != null && puzzleOverride.RequiredItemsIndices.Count > 0) { PuzzleReqItemManager.Current.QueueForAddingReqItems(__instance, puzzleOverride.RequiredItemsIndices); } if (puzzleOverride.HideSpline) { revealWithHoloPath = false; } ScanPosOverrideLogger.Warning("Overriding CP_Cluster_Core!"); } [HarmonyPostfix] [HarmonyPatch(typeof(CP_Cluster_Core), "Setup")] private static void Post_CP_Cluster_Core_Setup(CP_Cluster_Core __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)__instance.m_childCores) { if (!item.IsMovable) { continue; } uint bioscanCoreOverrideIndex = PuzzleOverrideManager.Current.GetBioscanCoreOverrideIndex(((Il2CppObjectBase)item).Pointer); if (bioscanCoreOverrideIndex == 0) { continue; } PuzzleOverride @override = Plugin.GetOverride(PuzzleOverrideManager.MainLevelLayout, bioscanCoreOverrideIndex); if (@override == null || @override.TPositions == null || @override.TPositions.Count < 1) { ScanPosOverrideLogger.Error("No Override for this T-Scan, falling back to vanilla impl."); continue; } CP_Bioscan_Core val = new CP_Bioscan_Core(((Il2CppObjectBase)item).Pointer); if ((Object)(object)val.m_movingComp == (Object)null) { Debug.LogError(Object.op_Implicit("Chained puzzle instance set to movable but does not include iChainedPuzzleMovable.")); } else if (val.m_movingComp.UsingStaticBioscanPoints) { foreach (Vec3 tPosition in @override.TPositions) { val.m_movingComp.ScanPositions.Add(tPosition.ToVector3()); } ((Component)val).transform.position = @override.TPositions[0].ToVector3(); if ((double)@override.TMoveSpeedMulti > 0.0) { CP_BasicMovable obj = ((Il2CppObjectBase)val.m_movingComp).Cast<CP_BasicMovable>(); obj.m_movementSpeed *= @override.TMoveSpeedMulti; } __instance.m_revealWithHoloPath = false; ScanPosOverrideLogger.Warning("Overriding T-Scan pos!"); } else { Debug.LogError(Object.op_Implicit("Unimplemented.")); } } uint clusterCoreOverrideIndex = PuzzleOverrideManager.Current.GetClusterCoreOverrideIndex(__instance); if (clusterCoreOverrideIndex != 0) { PuzzleOverride override2 = Plugin.GetOverride(PuzzleOverrideManager.MainLevelLayout, clusterCoreOverrideIndex); if (override2 != null && override2.ConcurrentCluster) { PlayerScannerManager.Current.RegisterConcurrentCluster(__instance); ScanPosOverrideLogger.Warning("Setting up CP_Cluster_Core as Concurrent Cluster!"); } } } } [HarmonyPatch] internal class Patches_CP_Cluster_Hud_ReqItems { private static Dictionary<IntPtr, List<bool>> clustersChildrenReqItemEnabled; private static Dictionary<IntPtr, List<string[]>> clustersChildrenReqItemNames; private static Dictionary<IntPtr, List<Il2CppStructArray<bool>>> clustersChildrenReqItemsStatus; [HarmonyPostfix] [HarmonyPatch(typeof(CP_Bioscan_Core), "AddRequiredItems")] private static void Post_CP_Bioscan_Core_AddRequiredItems(CP_Bioscan_Core __instance, Il2CppReferenceArray<iWardenObjectiveItem> requiredItems) { CP_Cluster_Core val = ((Il2CppObjectBase)__instance.Owner).TryCast<CP_Cluster_Core>(); if ((Object)(object)val == (Object)null) { return; } if (__instance.m_hud == null) { ScanPosOverrideLogger.Error("CP_Cluster_Hud_ReqItems: replacement Cluster_hud is null."); return; } CP_Cluster_Hud val2 = ((Il2CppObjectBase)__instance.m_hud).TryCast<CP_Cluster_Hud>(); if ((Object)(object)val2 == (Object)null) { ScanPosOverrideLogger.Error("CP_Cluster_Hud_ReqItems: Find cluster owner but cannot cast m_hud to CP_Cluster_hud"); return; } string[] array = new string[((Il2CppArrayBase<iWardenObjectiveItem>)(object)requiredItems).Count]; for (int i = 0; i < __instance.m_reqItems.Count; i++) { if (__instance.m_reqItems[i] != null) { array[i] = __instance.m_reqItems[i].PublicName; } else { ScanPosOverrideLogger.Error("Post_CP_Bioscan_Core_AddRequiredItems: CP_Bioscan_Core " + ((Object)__instance).name + " has a missing m_reqItem! " + i); } } List<bool> list; List<string[]> list2; if (clustersChildrenReqItemEnabled.ContainsKey(((Il2CppObjectBase)val2).Pointer)) { list = clustersChildrenReqItemEnabled[((Il2CppObjectBase)val2).Pointer]; list2 = clustersChildrenReqItemNames[((Il2CppObjectBase)val2).Pointer]; } else { list = Enumerable.Repeat(element: false, val.NRofPuzzles()).ToList(); list2 = Enumerable.Repeat(new string[0], val.NRofPuzzles()).ToList(); clustersChildrenReqItemEnabled.Add(((Il2CppObjectBase)val2).Pointer, list); clustersChildrenReqItemNames.Add(((Il2CppObjectBase)val2).Pointer, list2); } list[__instance.m_puzzleIndex] = __instance.m_reqItemsEnabled; list2[__instance.m_puzzleIndex] = array; } [HarmonyPrefix] [HarmonyPatch(typeof(CP_Cluster_Hud), "SetRequiredItemData")] private static bool Pre_CP_Cluster_Hud_SetRequiredItemData(CP_Cluster_Hud __instance, int puzzleIndex, Il2CppStructArray<bool> reqItemStatus) { List<Il2CppStructArray<bool>> list; if (!clustersChildrenReqItemsStatus.ContainsKey(((Il2CppObjectBase)__instance).Pointer)) { list = Enumerable.Repeat<Il2CppStructArray<bool>>(null, __instance.m_clusterSize).ToList(); clustersChildrenReqItemsStatus.Add(((Il2CppObjectBase)__instance).Pointer, list); } else { list = clustersChildrenReqItemsStatus[((Il2CppObjectBase)__instance).Pointer]; } list[puzzleIndex] = reqItemStatus; return false; } [HarmonyPostfix] [HarmonyPatch(typeof(CP_Cluster_Hud), "UpdateDataFor")] private static void Post_CP_Cluster_Hud_UpdateDataFor(CP_Cluster_Hud __instance, int index) { if (clustersChildrenReqItemsStatus.ContainsKey(((Il2CppObjectBase)__instance).Pointer)) { if (!clustersChildrenReqItemEnabled.ContainsKey(((Il2CppObjectBase)__instance).Pointer) || !clustersChildrenReqItemNames.ContainsKey(((Il2CppObjectBase)__instance).Pointer)) { ScanPosOverrideLogger.Error("CP_Cluster_Hud_UpdateDataFor: Found registered reqItemStatus but ReqItemEnabled or ReqItemNames is missing!"); return; } Il2CppStructArray<bool> val = clustersChildrenReqItemsStatus[((Il2CppObjectBase)__instance).Pointer][index]; __instance.m_hud.SetupRequiredItems(clustersChildrenReqItemEnabled[((Il2CppObjectBase)__instance).Pointer][index], Il2CppStringArray.op_Implicit(clustersChildrenReqItemNames[((Il2CppObjectBase)__instance).Pointer][index])); __instance.m_hud.SetRequiredItemData(__instance.m_puzzleIndex, val); } } private static void Clear() { clustersChildrenReqItemsStatus.Clear(); clustersChildrenReqItemNames.Clear(); clustersChildrenReqItemEnabled.Clear(); } static Patches_CP_Cluster_Hud_ReqItems() { clustersChildrenReqItemEnabled = new Dictionary<IntPtr, List<bool>>(); clustersChildrenReqItemNames = new Dictionary<IntPtr, List<string[]>>(); clustersChildrenReqItemsStatus = new Dictionary<IntPtr, List<Il2CppStructArray<bool>>>(); LevelAPI.OnLevelCleanup += Clear; } } } namespace ScanPosOverride.Managers { public class PlayerScannerManager { public static readonly PlayerScannerManager Current; private Dictionary<CP_Cluster_Core, List<CP_PlayerScanner>> ConcurrentClusterCores = new Dictionary<CP_Cluster_Core, List<CP_PlayerScanner>>(); private Dictionary<CP_Cluster_Core, List<CP_Bioscan_Core>> ConcurrentClusterChildCores = new Dictionary<CP_Cluster_Core, List<CP_Bioscan_Core>>(); private Dictionary<IntPtr, CP_Cluster_Core> ConcurrentScanClusterParents = new Dictionary<IntPtr, CP_Cluster_Core>(); private Dictionary<CP_Cluster_Core, HashSet<IntPtr>> ConcurrentClusterChildScanState = new Dictionary<CP_Cluster_Core, HashSet<IntPtr>>(); private Mutex ConcurrentClusterStateMutex; private Dictionary<CP_Cluster_Core, float[]> OriginalClusterScanSpeeds = new Dictionary<CP_Cluster_Core, float[]>(); private Dictionary<IntPtr, CP_PlayerScanner> Scanners = new Dictionary<IntPtr, CP_PlayerScanner>(); private Dictionary<IntPtr, float[]> OriginalScanSpeed = new Dictionary<IntPtr, float[]>(); private static readonly float[] ZERO_SCAN_SPEED; internal bool RegisterConcurrentCluster(CP_Cluster_Core core) { if (ConcurrentClusterCores.ContainsKey(core)) { return false; } List<CP_PlayerScanner> list = Enumerable.Repeat<CP_PlayerScanner>(null, core.m_amountOfPuzzles).ToList(); List<CP_Bioscan_Core> list2 = Enumerable.Repeat<CP_Bioscan_Core>(null, core.m_amountOfPuzzles).ToList(); float[] array = new float[4]; for (int i = 0; i < ((Il2CppArrayBase<iChainedPuzzleCore>)(object)core.m_childCores).Count; i++) { if ((Object)(object)list[i] != (Object)null) { ScanPosOverrideLogger.Error("SetupConcurrentClusterScanners: Duplicate child scanner for child scan. ??"); continue; } iChainedPuzzleCore val = ((Il2CppArrayBase<iChainedPuzzleCore>)(object)core.m_childCores)[i]; CP_Bioscan_Core val2 = ((Il2CppObjectBase)val).TryCast<CP_Bioscan_Core>(); if ((Object)(object)val2 == (Object)null) { ScanPosOverrideLogger.Error("SetupConcurrentClusterScanners: Failed to cast child to CP_Bioscan_Core"); continue; } CP_PlayerScanner val3 = ((Il2CppObjectBase)val2.PlayerScanner).TryCast<CP_PlayerScanner>(); if ((Object)(object)val3 == (Object)null) { ScanPosOverrideLogger.Error("SetupConcurrentClusterScanners: Failed to cast CP_Bioscan_Core.PlayerScanner to CP_PlayerScanner"); continue; } list[i] = val3; Scanners.Add(((Il2CppObjectBase)val).Pointer, val3); list2[i] = val2; if (!OriginalClusterScanSpeeds.ContainsKey(core)) { Il2CppStructArray<float> scanSpeeds = val3.m_scanSpeeds; for (int j = 0; j < 4; j++) { array[j] = ((Il2CppArrayBase<float>)(object)scanSpeeds)[j]; } OriginalClusterScanSpeeds.Add(core, array); } ConcurrentScanClusterParents.Add(((Il2CppObjectBase)val).Pointer, core); } ConcurrentClusterCores.Add(core, list); ConcurrentClusterChildCores.Add(core, list2); ConcurrentClusterChildScanState.Add(core, new HashSet<IntPtr>()); return true; } internal bool IsConcurrentCluster(CP_Cluster_Core core) { return ConcurrentClusterCores.ContainsKey(core); } internal bool IsConcurrentCluster(CP_Bioscan_Core core) { return ConcurrentScanClusterParents.ContainsKey(((Il2CppObjectBase)core).Pointer); } internal void ZeroConcurrentClusterScanSpeed(CP_Cluster_Core clusterCore) { if (!ConcurrentClusterCores.ContainsKey(clusterCore)) { return; } foreach (CP_PlayerScanner item in ConcurrentClusterCores[clusterCore]) { bool flag = true; for (int i = 0; i < 4; i++) { flag = flag && ((Il2CppArrayBase<float>)(object)item.m_scanSpeeds)[i] == 0f; ((Il2CppArrayBase<float>)(object)item.m_scanSpeeds)[i] = 0f; } if (flag) { break; } } } internal void RestoreConcurrentClusterScanSpeed(CP_Cluster_Core clusterCore) { if (!ConcurrentClusterCores.ContainsKey(clusterCore) || !OriginalClusterScanSpeeds.ContainsKey(clusterCore)) { return; } float[] array = OriginalClusterScanSpeeds[clusterCore]; foreach (CP_PlayerScanner item in ConcurrentClusterCores[clusterCore]) { bool flag = false; for (int i = 0; i < 4; i++) { flag = flag || ((Il2CppArrayBase<float>)(object)item.m_scanSpeeds)[i] != 0f; ((Il2CppArrayBase<float>)(object)item.m_scanSpeeds)[i] = array[i]; } if (flag) { break; } } } internal float[] GetCacheOriginalScanSpeed(CP_Bioscan_Core core) { if (IsConcurrentCluster(core)) { if (!ConcurrentScanClusterParents.ContainsKey(((Il2CppObjectBase)core).Pointer)) { return ZERO_SCAN_SPEED; } CP_Cluster_Core key = ConcurrentScanClusterParents[((Il2CppObjectBase)core).Pointer]; if (!OriginalClusterScanSpeeds.ContainsKey(key)) { return ZERO_SCAN_SPEED; } return OriginalClusterScanSpeeds[key]; } if (OriginalScanSpeed.ContainsKey(((Il2CppObjectBase)core).Pointer)) { return OriginalScanSpeed[((Il2CppObjectBase)core).Pointer]; } CP_PlayerScanner cacheScanner = GetCacheScanner(core); if ((Object)(object)cacheScanner == (Object)null) { ScanPosOverrideLogger.Error("GetCacheOriginalScanSpeed: cannot get scanner for this CP_Bioscan_Core"); return ZERO_SCAN_SPEED; } float[] array = new float[4]; for (int i = 0; i < 4; i++) { array[i] = ((Il2CppArrayBase<float>)(object)cacheScanner.m_scanSpeeds)[i]; } OriginalScanSpeed.Add(((Il2CppObjectBase)core).Pointer, array); return array; } internal CP_Cluster_Core GetParentClusterCore(CP_Bioscan_Core core) { if (!ConcurrentScanClusterParents.ContainsKey(((Il2CppObjectBase)core).Pointer)) { return null; } return ConcurrentScanClusterParents[((Il2CppObjectBase)core).Pointer]; } public CP_PlayerScanner GetCacheScanner(CP_Bioscan_Core core) { if (Scanners.ContainsKey(((Il2CppObjectBase)core).Pointer)) { return Scanners[((Il2CppObjectBase)core).Pointer]; } CP_PlayerScanner val = ((Il2CppObjectBase)core.PlayerScanner).TryCast<CP_PlayerScanner>(); if ((Object)(object)val == (Object)null) { return null; } Scanners.Add(((Il2CppObjectBase)core).Pointer, val); return val; } internal bool ConcurrentClusterShouldProgress(CP_Bioscan_Core core, bool IsThisScanShouldProgress) { if (ConcurrentClusterStateMutex == null) { ScanPosOverrideLogger.Error("ConcurrentCluster: scan mutex uninitialized."); return false; } if (ConcurrentClusterStateMutex.WaitOne(2000)) { if (!ConcurrentScanClusterParents.ContainsKey(((Il2CppObjectBase)core).Pointer)) { ScanPosOverrideLogger.Error("ConcurrentClusterShouldProgress: failed to find cluster parent!"); ConcurrentClusterStateMutex.ReleaseMutex(); return false; } CP_Cluster_Core val = ConcurrentScanClusterParents[((Il2CppObjectBase)core).Pointer]; if (!ConcurrentClusterChildScanState.ContainsKey(val)) { ScanPosOverrideLogger.Error("ConcurrentClusterShouldProgress: ConcurrentClusterChildScanState initialization error!"); ConcurrentClusterStateMutex.ReleaseMutex(); return false; } HashSet<IntPtr> hashSet = ConcurrentClusterChildScanState[val]; bool result; if (IsThisScanShouldProgress) { hashSet.Add(((Il2CppObjectBase)core).Pointer); result = hashSet.Count == val.m_amountOfPuzzles; } else { hashSet.Remove(((Il2CppObjectBase)core).Pointer); result = false; } ConcurrentClusterStateMutex.ReleaseMutex(); return result; } ScanPosOverrideLogger.Debug("ConcurrentCluster: Failed to acquire scan mutex."); return false; } internal void CompleteConcurrentCluster(CP_Cluster_Core core) { if (!ConcurrentClusterChildCores.ContainsKey(core)) { return; } List<CP_Bioscan_Core> list = ConcurrentClusterChildCores[core]; ConcurrentClusterChildCores.Remove(core); foreach (CP_Bioscan_Core item in list) { item.m_sync.SetStateData((eBioscanStatus)4, 0f, (List<PlayerAgent>)null, 0, (Il2CppStructArray<bool>)null); } } public void Init() { ConcurrentClusterStateMutex = new Mutex(); } public void Clear() { ConcurrentClusterCores.Clear(); ConcurrentClusterChildCores.Clear(); ConcurrentScanClusterParents.Clear(); ConcurrentClusterChildScanState.Clear(); OriginalClusterScanSpeeds.Clear(); Scanners.Clear(); OriginalScanSpeed.Clear(); ConcurrentClusterStateMutex?.Dispose(); ConcurrentClusterStateMutex = null; } static PlayerScannerManager() { ZERO_SCAN_SPEED = new float[4]; Current = new PlayerScannerManager(); LevelAPI.OnBuildDone += Current.Init; LevelAPI.OnBuildStart += Current.Clear; LevelAPI.OnLevelCleanup += Current.Clear; } private PlayerScannerManager() { } } public class PuzzleReqItemManager { public static readonly PuzzleReqItemManager Current; private Dictionary<int, CarryItemPickup_Core> BigPickupItemsInLevel = new Dictionary<int, CarryItemPickup_Core>(); private int itemIndexCounter = 1; private List<(CP_Bioscan_Core, List<int>)> bioscanCoresToAddReqItems = new List<(CP_Bioscan_Core, List<int>)>(); private List<(CP_Cluster_Core, List<int>)> clusterCoresToAddReqItems = new List<(CP_Cluster_Core, List<int>)>(); private Dictionary<IntPtr, CP_Bioscan_Core> movableScansWithReqItems = new Dictionary<IntPtr, CP_Bioscan_Core>(); internal int Register(CarryItemPickup_Core item) { int num = itemIndexCounter; itemIndexCounter++; BigPickupItemsInLevel.Add(num, item); return num; } internal void QueueForAddingReqItems(CP_Bioscan_Core core, List<int> itemsIndices) { bioscanCoresToAddReqItems.Add((core, itemsIndices)); } internal void QueueForAddingReqItems(CP_Cluster_Core core, List<int> itemsIndices) { clusterCoresToAddReqItems.Add((core, itemsIndices)); } internal CP_Bioscan_Core GetMovableCoreWithReqItem(CP_PlayerScanner scanner) { if (!movableScansWithReqItems.ContainsKey(((Il2CppObjectBase)scanner).Pointer)) { return null; } return movableScansWithReqItems[((Il2CppObjectBase)scanner).Pointer]; } public CarryItemPickup_Core GetBigPickupItem(int bigPickupInLevelIndex) { if (!BigPickupItemsInLevel.ContainsKey(bigPickupInLevelIndex)) { return null; } return BigPickupItemsInLevel[bigPickupInLevelIndex]; } public bool AddReqItems(CP_Bioscan_Core puzzle, int itemIndex) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown if ((Object)(object)puzzle == (Object)null || itemIndex == 0L) { return false; } if (!BigPickupItemsInLevel.ContainsKey(itemIndex)) { ScanPosOverrideLogger.Error($"Unregistered BigPickup Item with index {itemIndex}"); return false; } CarryItemPickup_Core val = BigPickupItemsInLevel[itemIndex]; puzzle.AddRequiredItems(Il2CppReferenceArray<iWardenObjectiveItem>.op_Implicit((iWardenObjectiveItem[])(object)new iWardenObjectiveItem[1] { new iWardenObjectiveItem(((Il2CppObjectBase)val).Pointer) })); return true; } public bool AddReqItems(CP_Cluster_Core puzzle, int itemIndex) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown if ((Object)(object)puzzle == (Object)null || itemIndex == 0L) { return false; } if (!BigPickupItemsInLevel.ContainsKey(itemIndex)) { ScanPosOverrideLogger.Error($"Unregistered BigPickup Item with index {itemIndex}"); return false; } CarryItemPickup_Core val = BigPickupItemsInLevel[itemIndex]; foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)puzzle.m_childCores) { item.AddRequiredItems(Il2CppReferenceArray<iWardenObjectiveItem>.op_Implicit((iWardenObjectiveItem[])(object)new iWardenObjectiveItem[1] { new iWardenObjectiveItem(((Il2CppObjectBase)val).Pointer) })); } return true; } public bool AddReqItems(CP_Bioscan_Core puzzle, List<int> itemsIndices) { if ((Object)(object)puzzle == (Object)null || itemsIndices == null || itemsIndices.Count < 1) { return false; } bool flag = false; foreach (int item in itemsIndices.ToHashSet()) { flag |= AddReqItems(puzzle, item); } if (puzzle.IsMovable && flag) { movableScansWithReqItems.Add(((Il2CppObjectBase)puzzle.m_playerScanner).Pointer, puzzle); } return flag; } public void RemoveReqItem(CP_Bioscan_Core puzzle, int itemIndex) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown if (!((Object)(object)puzzle == (Object)null)) { if (!BigPickupItemsInLevel.ContainsKey(itemIndex) && itemIndex != 0L) { ScanPosOverrideLogger.Error($"Unregistered BigPickup Item with index {itemIndex}"); } else { CarryItemPickup_Core val = BigPickupItemsInLevel[itemIndex]; puzzle.RemoveRequiredItems((iWardenObjectiveItem[])(object)new iWardenObjectiveItem[1] { new iWardenObjectiveItem(((Il2CppObjectBase)val).Pointer) }); } } } public void RemoveReqItem(CP_Cluster_Core puzzle, int itemIndex) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if ((Object)(object)puzzle == (Object)null) { return; } if (!BigPickupItemsInLevel.ContainsKey(itemIndex) && itemIndex != 0L) { ScanPosOverrideLogger.Error($"Unregistered BigPickup Item with index {itemIndex}"); return; } CarryItemPickup_Core val = BigPickupItemsInLevel[itemIndex]; foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)puzzle.m_childCores) { item.RemoveRequiredItems((iWardenObjectiveItem[])(object)new iWardenObjectiveItem[1] { new iWardenObjectiveItem(((Il2CppObjectBase)val).Pointer) }); } } private void AddQueuedReqItems() { foreach (var (puzzle, itemsIndices) in bioscanCoresToAddReqItems) { AddReqItems(puzzle, itemsIndices); } foreach (var (val, itemsIndices2) in clusterCoresToAddReqItems) { foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)val.m_childCores) { CP_Bioscan_Core val2 = ((Il2CppObjectBase)item).TryCast<CP_Bioscan_Core>(); if ((Object)(object)val2 == (Object)null) { ScanPosOverrideLogger.Error("Failed to cast child core to CP_Bioscan_Core"); } else { AddReqItems(val2, itemsIndices2); } } } } public void OutputLevelBigPickupInfo() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) StringBuilder val = new StringBuilder(); val.AppendLine(); List<CarryItemPickup_Core> list = new List<CarryItemPickup_Core>(BigPickupItemsInLevel.Values); list.Sort(delegate(CarryItemPickup_Core b1, CarryItemPickup_Core b2) { //IL_0014: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) AIG_CourseNode spawnNode = b1.SpawnNode; AIG_CourseNode spawnNode2 = b2.SpawnNode; if (spawnNode.m_dimension.DimensionIndex != spawnNode2.m_dimension.DimensionIndex) { if (spawnNode.m_dimension.DimensionIndex > spawnNode2.m_dimension.DimensionIndex) { return 1; } return -1; } if (spawnNode.LayerType != spawnNode2.LayerType) { if (spawnNode.LayerType >= spawnNode2.LayerType) { return 1; } return -1; } return (spawnNode.m_zone.LocalIndex != spawnNode2.m_zone.LocalIndex) ? ((spawnNode.m_zone.LocalIndex >= spawnNode2.m_zone.LocalIndex) ? 1 : (-1)) : 0; }); Dictionary<CarryItemPickup_Core, int> dictionary = new Dictionary<CarryItemPickup_Core, int>(); foreach (int key in BigPickupItemsInLevel.Keys) { dictionary.Add(BigPickupItemsInLevel[key], key); } foreach (CarryItemPickup_Core item in list) { val.AppendLine("Item Name: " + ((Item)item).ItemDataBlock.publicName); val.AppendLine($"Zone {item.SpawnNode.m_zone.Alias}, {item.SpawnNode.LayerType}, Dim {item.SpawnNode.m_dimension.DimensionIndex}"); val.AppendLine($"Item Index: {dictionary[item]}"); val.AppendLine(); } ScanPosOverrideLogger.Debug(((Object)val).ToString()); } internal void OnEnterLevel() { AddQueuedReqItems(); OutputLevelBigPickupInfo(); } public void Clear() { BigPickupItemsInLevel.Clear(); itemIndexCounter = 1; bioscanCoresToAddReqItems.Clear(); clusterCoresToAddReqItems.Clear(); movableScansWithReqItems.Clear(); } static PuzzleReqItemManager() { Current = new PuzzleReqItemManager(); LevelAPI.OnBuildStart += Current.Clear; LevelAPI.OnLevelCleanup += Current.Clear; LevelAPI.OnEnterLevel += Current.OnEnterLevel; } private PuzzleReqItemManager() { } } public class PuzzleOverrideManager { public static readonly PuzzleOverrideManager Current; private Dictionary<CP_Bioscan_Core, uint> bioscanCore2Index = new Dictionary<CP_Bioscan_Core, uint>(); private Dictionary<CP_Cluster_Core, uint> clusterCore2Index = new Dictionary<CP_Cluster_Core, uint>(); private Dictionary<uint, CP_Bioscan_Core> index2BioscanCore = new Dictionary<uint, CP_Bioscan_Core>(); private Dictionary<uint, CP_Cluster_Core> index2ClusterCore = new Dictionary<uint, CP_Cluster_Core>(); private Dictionary<IntPtr, uint> bioscanCoreIntPtr2Index = new Dictionary<IntPtr, uint>(); private Dictionary<IntPtr, uint> clusterCoreIntPtr2Index = new Dictionary<IntPtr, uint>(); private uint puzzleOverrideIndex = 1u; public static uint MainLevelLayout => RundownManager.ActiveExpedition.LevelLayoutData; public uint Register(CP_Bioscan_Core __instance) { if ((Object)(object)__instance == (Object)null) { return 0u; } uint num = puzzleOverrideIndex; puzzleOverrideIndex++; if (!bioscanCore2Index.ContainsKey(__instance)) { bioscanCore2Index.Add(__instance, num); bioscanCoreIntPtr2Index.Add(((Il2CppObjectBase)__instance).Pointer, num); index2BioscanCore.Add(num, __instance); return num; } return GetBioscanCoreOverrideIndex(__instance); } public uint Register(CP_Cluster_Core __instance) { if ((Object)(object)__instance == (Object)null) { return 0u; } uint num = puzzleOverrideIndex; puzzleOverrideIndex++; if (!clusterCore2Index.ContainsKey(__instance)) { clusterCore2Index.Add(__instance, num); clusterCoreIntPtr2Index.Add(((Il2CppObjectBase)__instance).Pointer, num); index2ClusterCore.Add(num, __instance); return num; } return GetClusterCoreOverrideIndex(__instance); } public void OutputLevelPuzzleInfo() { //IL_00bd: 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) List<ChainedPuzzleInstance> list = new List<ChainedPuzzleInstance>(); Enumerator<ChainedPuzzleInstance> enumerator = ChainedPuzzleManager.Current.m_instances.GetEnumerator(); while (enumerator.MoveNext()) { ChainedPuzzleInstance current = enumerator.Current; list.Add(current); } list.Sort(delegate(ChainedPuzzleInstance c1, ChainedPuzzleInstance c2) { //IL_0019: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_002d: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) LG_Zone zone2 = c1.m_sourceArea.m_zone; LG_Zone zone3 = c2.m_sourceArea.m_zone; if (zone2.DimensionIndex != zone3.DimensionIndex) { if (zone2.DimensionIndex >= zone3.DimensionIndex) { return 1; } return -1; } if (zone2.Layer.m_type != zone3.Layer.m_type) { if (zone2.Layer.m_type >= zone3.Layer.m_type) { return 1; } return -1; } return (zone2.LocalIndex >= zone3.LocalIndex) ? 1 : (-1); }); StringBuilder stringBuilder = new StringBuilder(); foreach (ChainedPuzzleInstance item in list) { LG_Zone zone = item.m_sourceArea.m_zone; StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(15, 3, stringBuilder2); handler.AppendLiteral("\nZone "); handler.AppendFormatted(zone.Alias); handler.AppendLiteral(", "); handler.AppendFormatted<LG_LayerType>(zone.m_layer.m_type); handler.AppendLiteral(", Dim "); handler.AppendFormatted<eDimensionIndex>(zone.DimensionIndex); handler.AppendLiteral("\n"); stringBuilder3.Append(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(14, 1, stringBuilder2); handler.AppendLiteral("Alarm name: "); handler.AppendFormatted(item.Data.PublicAlarmName); handler.AppendLiteral(":\n"); stringBuilder4.Append(ref handler); for (int i = 0; i < ((Il2CppArrayBase<iChainedPuzzleCore>)(object)item.m_chainedPuzzleCores).Count; i++) { iChainedPuzzleCore val = ((Il2CppArrayBase<iChainedPuzzleCore>)(object)item.m_chainedPuzzleCores)[i]; if (bioscanCoreIntPtr2Index.ContainsKey(((Il2CppObjectBase)val).Pointer)) { uint value = bioscanCoreIntPtr2Index[((Il2CppObjectBase)val).Pointer]; stringBuilder2 = stringBuilder; StringBuilder stringBuilder5 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(15, 1, stringBuilder2); handler.AppendLiteral("puzzle index: "); handler.AppendFormatted(i); handler.AppendLiteral("\n"); stringBuilder5.Append(ref handler); stringBuilder.Append("type: CP_Bioscan_Core\n"); stringBuilder2 = stringBuilder; StringBuilder stringBuilder6 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(22, 1, stringBuilder2); handler.AppendLiteral("PuzzleOverrideIndex: "); handler.AppendFormatted(value); handler.AppendLiteral("\n"); stringBuilder6.Append(ref handler); } else if (clusterCoreIntPtr2Index.ContainsKey(((Il2CppObjectBase)val).Pointer)) { uint value2 = clusterCoreIntPtr2Index[((Il2CppObjectBase)val).Pointer]; CP_Cluster_Core val2 = ((Il2CppObjectBase)val).TryCast<CP_Cluster_Core>(); if ((Object)(object)val2 == (Object)null) { ScanPosOverrideLogger.Error("Found cluster core Pointer, but TryCast failed."); continue; } stringBuilder2 = stringBuilder; StringBuilder stringBuilder7 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(15, 1, stringBuilder2); handler.AppendLiteral("puzzle index: "); handler.AppendFormatted(i); handler.AppendLiteral("\n"); stringBuilder7.Append(ref handler); stringBuilder.Append("type: CP_Cluster_Core\n"); stringBuilder2 = stringBuilder; StringBuilder stringBuilder8 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(22, 1, stringBuilder2); handler.AppendLiteral("PuzzleOverrideIndex: "); handler.AppendFormatted(value2); handler.AppendLiteral("\n"); stringBuilder8.Append(ref handler); stringBuilder.Append("=== Clustered puzzles info: ===\n"); for (int j = 0; j < val2.m_amountOfPuzzles; j++) { iChainedPuzzleCore val3 = ((Il2CppArrayBase<iChainedPuzzleCore>)(object)val2.m_childCores)[j]; if (!bioscanCoreIntPtr2Index.ContainsKey(((Il2CppObjectBase)val3).Pointer)) { ScanPosOverrideLogger.Error("Unregistered clustered iChainedPuzzleCore found..."); continue; } uint value3 = bioscanCoreIntPtr2Index[((Il2CppObjectBase)val3).Pointer]; stringBuilder2 = stringBuilder; StringBuilder stringBuilder9 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(15, 1, stringBuilder2); handler.AppendLiteral("puzzle index: "); handler.AppendFormatted(j); handler.AppendLiteral("\n"); stringBuilder9.Append(ref handler); stringBuilder.Append("type: CP_Bioscan_Core\n"); stringBuilder2 = stringBuilder; StringBuilder stringBuilder10 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(22, 1, stringBuilder2); handler.AppendLiteral("PuzzleOverrideIndex: "); handler.AppendFormatted(value3); handler.AppendLiteral("\n"); stringBuilder10.Append(ref handler); } stringBuilder.Append("=== Clustered puzzles END ===\n"); } else { ScanPosOverrideLogger.Error("Unregistered iChainedPuzzleCore found..."); } } stringBuilder.Append('\n'); } ScanPosOverrideLogger.Debug(stringBuilder.ToString()); } public uint GetBioscanCoreOverrideIndex(CP_Bioscan_Core core) { if (bioscanCore2Index.ContainsKey(core)) { return bioscanCore2Index[core]; } return 0u; } public uint GetClusterCoreOverrideIndex(CP_Cluster_Core core) { if (clusterCore2Index.ContainsKey(core)) { return clusterCore2Index[core]; } return 0u; } public uint GetBioscanCoreOverrideIndex(IntPtr pointer) { if (bioscanCoreIntPtr2Index.ContainsKey(pointer)) { return bioscanCoreIntPtr2Index[pointer]; } return 0u; } public uint GetClusterCoreOverrideIndex(IntPtr pointer) { if (clusterCoreIntPtr2Index.ContainsKey(pointer)) { return clusterCoreIntPtr2Index[pointer]; } return 0u; } public CP_Bioscan_Core GetBioscanCore(uint puzzleOverrideIndex) { if (!index2BioscanCore.ContainsKey(puzzleOverrideIndex)) { return null; } return index2BioscanCore[puzzleOverrideIndex]; } public CP_Cluster_Core GetClusterCore(uint puzzleOverrideIndex) { if (!index2ClusterCore.ContainsKey(puzzleOverrideIndex)) { return null; } return index2ClusterCore[puzzleOverrideIndex]; } public void Clear() { puzzleOverrideIndex = 1u; bioscanCore2Index.Clear(); clusterCore2Index.Clear(); bioscanCoreIntPtr2Index.Clear(); clusterCoreIntPtr2Index.Clear(); index2BioscanCore.Clear(); index2ClusterCore.Clear(); ScanPosOverrideLogger.Warning("Cleared scan index"); } private PuzzleOverrideManager() { LevelAPI.OnEnterLevel += OutputLevelPuzzleInfo; LevelAPI.OnLevelCleanup += Clear; LevelAPI.OnBuildStart += Clear; } static PuzzleOverrideManager() { Current = new PuzzleOverrideManager(); } public iChainedPuzzleOwner ChainedPuzzleInstanceOwner(CP_Bioscan_Core bioscanCore) { if ((Object)(object)bioscanCore == (Object)null) { return null; } iChainedPuzzleOwner owner = bioscanCore.Owner; if ((Object)(object)((Il2CppObjectBase)owner).TryCast<ChainedPuzzleInstance>() != (Object)null) { return owner; } CP_Cluster_Core val = ((Il2CppObjectBase)owner).TryCast<CP_Cluster_Core>(); if ((Object)(object)val != (Object)null) { return val.m_owner; } ScanPosOverrideLogger.Error("Failed to find CP_BioScan_Core owner (instance of ChainedPuzzleInstance)."); return null; } } } namespace ScanPosOverride.JSON { public static class InjectLibUtil { public const string PLUGIN_GUID = "GTFO.InjectLib"; public static JsonConverter InjectLibConnector { get; private set; } public static bool IsLoaded { get; private set; } static InjectLibUtil() { if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("GTFO.InjectLib", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } InjectLibConnector = (JsonConverter)Activator.CreateInstance(obj.GetTypes().First((Type t) => t.Name == "InjectLibConnector") ?? throw new Exception("Unable to Find InjectLibConnector Class")); IsLoaded = true; } catch (Exception value2) { ScanPosOverrideLogger.Error($"Exception thrown while reading data from GTFO.AWO: {value2}"); } } } internal class LocalizedTextConverter : JsonConverter<LocalizedText> { public override bool HandleNull => false; public override LocalizedText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown switch (reader.TokenType) { case JsonTokenType.String: { string @string = reader.GetString(); return new LocalizedText { Id = 0u, UntranslatedText = @string }; } case JsonTokenType.Number: return new LocalizedText { Id = reader.GetUInt32(), UntranslatedText = null }; default: throw new JsonException($"LocalizedTextJson type: {reader.TokenType} is not implemented!"); } } public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options) { JsonSerializer.Serialize<LocalizedText>(writer, value, options); } } internal static class Json { private static readonly JsonSerializerOptions _setting; static Json() { _setting = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, IncludeFields = false, PropertyNameCaseInsensitive = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; _setting.Converters.Add(new JsonStringEnumConverter()); if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized) { _setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter); _setting.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter); ScanPosOverrideLogger.Log("PartialData Support Found!"); } else { _setting.Converters.Add(new LocalizedTextConverter()); } if (InjectLibUtil.IsLoaded) { _setting.Converters.Add(InjectLibUtil.InjectLibConnector); ScanPosOverrideLogger.Log("AWO support found!"); } } public static T Deserialize<T>(string json) { return JsonSerializer.Deserialize<T>(json, _setting); } public static object Deserialize(Type type, string json) { return JsonSerializer.Deserialize(json, type, _setting); } public static string Serialize<T>(T value) { return JsonSerializer.Serialize(value, _setting); } public static void Load<T>(string file, out T config) where T : new() { if (file.Length < ".json".Length) { config = default(T); return; } if (file.Substring(file.Length - ".json".Length) != ".json") { file += ".json"; } file = File.ReadAllText(Path.Combine(Plugin.OVERRIDE_SCAN_POS_PATH, file)); config = Deserialize<T>(file); } } public static class MTFOPartialDataUtil { public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks"; public static JsonConverter PersistentIDConverter { get; private set; } public static JsonConverter LocalizedTextConverter { get; private set; } public static bool IsLoaded { get; private set; } public static bool Initialized { get; private set; } public static string PartialDataPath { get; private set; } public static string ConfigPath { get; private set; } static MTFOPartialDataUtil() { PersistentIDConverter = null; LocalizedTextConverter = null; IsLoaded = false; Initialized = false; PartialDataPath = string.Empty; ConfigPath = string.Empty; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type type = types.First((Type t) => t.Name == "PersistentIDConverter"); if ((object)type == null) { throw new Exception("Unable to Find PersistentIDConverter Class"); } Type type2 = types.First((Type t) => t.Name == "PartialDataManager"); if ((object)type2 == null) { throw new Exception("Unable to Find PartialDataManager Class"); } Type type3 = types.First((Type t) => t.Name == "LocalizedTextConverter") ?? throw new Exception("Unable to Find LocalizedTextConverter Class"); PropertyInfo property = type2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public); PropertyInfo property2 = type2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property3 = type2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public); if ((object)property == null) { throw new Exception("Unable to Find Property: Initialized"); } if ((object)property2 == null) { throw new Exception("Unable to Find Property: PartialDataPath"); } if ((object)property3 == null) { throw new Exception("Unable to Find Field: ConfigPath"); } Initialized = (bool)property.GetValue(null); PartialDataPath = (string)property2.GetValue(null); ConfigPath = (string)property3.GetValue(null); PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type); LocalizedTextConverter = (JsonConverter)Activator.CreateInstance(type3); IsLoaded = true; } catch (Exception value2) { ScanPosOverrideLogger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}"); } } } public static class MTFOUtil { public const string PLUGIN_GUID = "com.dak.MTFO"; public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public; public static string GameDataPath { get; private set; } public static string CustomPath { get; private set; } public static bool HasCustomContent { get; private set; } public static bool IsLoaded { get; private set; } static MTFOUtil() { GameDataPath = string.Empty; CustomPath = string.Empty; HasCustomContent = false; IsLoaded = false; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); IsLoaded = true; } catch (Exception value2) { ScanPosOverrideLogger.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}"); } } } }
plugins/Heat/net6/WeaponPerExpedition.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; 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.Json; using System.Text.Json.Serialization; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using GTFO.API; using GTFO.API.JSON.Converters; using GTFO.API.Utilities; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using Player; using WeaponPerExpedition.JSON; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("WeaponPerExpedition")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WeaponPerExpedition")] [assembly: AssemblyTitle("WeaponPerExpedition")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WeaponPerExpedition { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Inas.WeaponPerExpedition", "WeaponPerExpedition", "1.0.0")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas"; public const string PLUGIN_NAME = "WeaponPerExpedition"; public const string VERSION = "1.0.0"; private Harmony m_Harmony; public override void Load() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown m_Harmony = new Harmony("WeaponPerExpedition"); m_Harmony.PatchAll(); ExpeditionGearManager.Current.Init(); } } public enum Mode { ALLOW, DISALLOW } public class ExpeditionGears { public eRundownTier Tier { get; set; } = (eRundownTier)1; public int ExpeditionIndex { get; set; } = -1; public Mode Mode { get; set; } = Mode.DISALLOW; public List<uint> GearIds { get; set; } = new List<uint> { 0u }; } public class RundownExpeditionGears { public uint RundownID { get; set; } public List<ExpeditionGears> ExpeditionGears { get; set; } = new List<ExpeditionGears> { new ExpeditionGears() }; } internal class ExpeditionGearManager { private GearManager vanillaGearManager; private Dictionary<uint, Dictionary<(eRundownTier Tier, int ExpeditionIndex), ExpeditionGears>> ExpeditionGearConfigs = new Dictionary<uint, Dictionary<(eRundownTier, int), ExpeditionGears>>(); private Mode mode = Mode.DISALLOW; private HashSet<uint> GearIDs = new HashSet<uint>(); private readonly LiveEditListener liveEditListener; internal readonly List<(InventorySlot inventorySlot, Dictionary<uint, GearIDRange> loadedGears)> gearSlots = new List<(InventorySlot, Dictionary<uint, GearIDRange>)> { ((InventorySlot)1, new Dictionary<uint, GearIDRange>()), ((InventorySlot)2, new Dictionary<uint, GearIDRange>()), ((InventorySlot)10, new Dictionary<uint, GearIDRange>()), ((InventorySlot)3, new Dictionary<uint, GearIDRange>()) }; public static ExpeditionGearManager Current { get; private set; } public (uint RundownId, eRundownTier Tier, int ExpeditionIndex) CurrentExpedition { get; private set; } = (0u, (eRundownTier)1, 0); public string CONFIG_DIR_PATH { get; private set; } = Path.Combine(MTFOUtil.CustomPath, "WeaponPerExpedition"); public void ClearLoadedGears() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected I4, but got Unknown foreach (var gearSlot in gearSlots) { ((Il2CppArrayBase<List<GearIDRange>>)(object)vanillaGearManager.m_gearPerSlot)[(int)gearSlot.inventorySlot].Clear(); } } public static uint GetOfflineGearPID(GearIDRange gearIDRange) { string playfabItemInstanceId = gearIDRange.PlayfabItemInstanceId; if (!playfabItemInstanceId.Contains("OfflineGear_ID_")) { WPELogger.Error("Find PlayfabItemInstanceId without substring 'OfflineGear_ID_'! " + playfabItemInstanceId); return 0u; } try { return uint.Parse(playfabItemInstanceId.Substring("OfflineGear_ID_".Length)); } catch { WPELogger.Error("Caught exception while trying to parse persistentID of PlayerOfflineGearDB from GearIDRange, which means itemInstanceId could be ill-formated"); return 0u; } } private bool IsGearAllowed(uint playerOfflineGearDBPID) { switch (mode) { case Mode.ALLOW: return GearIDs.Contains(playerOfflineGearDBPID); case Mode.DISALLOW: return !GearIDs.Contains(playerOfflineGearDBPID); default: WPELogger.Error($"Unimplemented Mode: {mode}, will allow gears anyway..."); return true; } } private void AddGearForCurrentExpedition() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected I4, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) foreach (var gearSlot in gearSlots) { List<GearIDRange> val = ((Il2CppArrayBase<List<GearIDRange>>)(object)vanillaGearManager.m_gearPerSlot)[(int)gearSlot.inventorySlot]; Dictionary<uint, GearIDRange> item = gearSlot.loadedGears; if (item.Count == 0) { WPELogger.Debug($"No gear has been loaded for {gearSlot.inventorySlot}."); continue; } foreach (uint key in item.Keys) { if (IsGearAllowed(key)) { val.Add(item[key]); } } if (val.Count == 0) { WPELogger.Error($"No gear is allowed for {gearSlot.inventorySlot}, there must be at least 1 allowed gear!"); val.Add(item.First().Value); } } } private void ResetPlayerSelectedGears() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected I4, but got Unknown vanillaGearManager.RescanFavorites(); foreach (var gearSlot in gearSlots) { int num = (int)gearSlot.inventorySlot; if (((Il2CppArrayBase<GearIDRange>)(object)vanillaGearManager.m_lastEquippedGearPerSlot)[num] != null) { PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase<GearIDRange>)(object)vanillaGearManager.m_lastEquippedGearPerSlot)[num]); } else if (((Il2CppArrayBase<List<GearIDRange>>)(object)vanillaGearManager.m_favoriteGearPerSlot)[num].Count > 0) { PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase<List<GearIDRange>>)(object)vanillaGearManager.m_favoriteGearPerSlot)[num][0]); } else if (((Il2CppArrayBase<List<GearIDRange>>)(object)vanillaGearManager.m_gearPerSlot)[num].Count > 0) { PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase<List<GearIDRange>>)(object)vanillaGearManager.m_gearPerSlot)[num][0]); } } } private void LoadWPEConfigForCurrentExpedition() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) var (key, item, item2) = CurrentExpedition; GearIDs.Clear(); mode = Mode.DISALLOW; if (ExpeditionGearConfigs.ContainsKey(key) && ExpeditionGearConfigs[key].ContainsKey((item, item2))) { mode = ExpeditionGearConfigs[key][(item, item2)].Mode; ExpeditionGearConfigs[key][(item, item2)].GearIds.ForEach(delegate(uint id) { GearIDs.Add(id); }); } } public void OnLevelSelected(eRundownTier expTier, int expIndexInTier) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) uint item = default(uint); if (!RundownManager.TryGetIdFromLocalRundownKey(RundownManager.ActiveRundownKey, ref item)) { WPELogger.Error("Failed to get active rundown ID, will fall back to rundown Id 1"); item = 1u; } CurrentExpedition = (item, expTier, expIndexInTier); LoadWPEConfigForCurrentExpedition(); ClearLoadedGears(); AddGearForCurrentExpedition(); ResetPlayerSelectedGears(); } private void OnManagersSetup() { vanillaGearManager = GearManager.Current; } private void AddConf(RundownExpeditionGears conf) { if (conf != null) { Dictionary<(eRundownTier, int), ExpeditionGears> rundownExpeditionConfig = null; if (!ExpeditionGearConfigs.ContainsKey(conf.RundownID)) { rundownExpeditionConfig = new Dictionary<(eRundownTier, int), ExpeditionGears>(); ExpeditionGearConfigs[conf.RundownID] = rundownExpeditionConfig; } else { WPELogger.Log($"Replaced rundown ID {conf.RundownID}"); rundownExpeditionConfig = ExpeditionGearConfigs[conf.RundownID]; } conf.ExpeditionGears.ForEach(delegate(ExpeditionGears expGearConf) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) rundownExpeditionConfig[(expGearConf.Tier, expGearConf.ExpeditionIndex)] = expGearConf; }); } } private void FileChanged(LiveEditEventArgs e) { WPELogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { RundownExpeditionGears conf = Json.Deserialize<RundownExpeditionGears>(content); AddConf(conf); }); } private ExpeditionGearManager() { //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown if (!Directory.Exists(CONFIG_DIR_PATH)) { Directory.CreateDirectory(CONFIG_DIR_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_DIR_PATH, "Template.json")); streamWriter.WriteLine(Json.Serialize(new RundownExpeditionGears())); streamWriter.Flush(); streamWriter.Close(); } foreach (string item in Directory.EnumerateFiles(CONFIG_DIR_PATH, "*.json", SearchOption.AllDirectories)) { RundownExpeditionGears conf = Json.Deserialize<RundownExpeditionGears>(File.ReadAllText(item)); AddConf(conf); } liveEditListener = LiveEdit.CreateListener(CONFIG_DIR_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); EventAPI.OnManagersSetup += OnManagersSetup; } public void Init() { } static ExpeditionGearManager() { Current = new ExpeditionGearManager(); } } internal static class WPELogger { private static ManualLogSource logger = Logger.CreateLogSource("WeaponPerExpedition"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } } } namespace WeaponPerExpedition.JSON { internal static class Json { private static readonly JsonSerializerOptions _setting; static Json() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown _setting = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, IncludeFields = false, PropertyNameCaseInsensitive = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; _setting.Converters.Add(new JsonStringEnumConverter()); if (MTFOPartialDataUtil.IsLoaded) { _setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter); _setting.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter); WPELogger.Log("PartialData support found!"); } else { _setting.Converters.Add((JsonConverter)new LocalizedTextConverter()); } } public static T Deserialize<T>(string json) { return JsonSerializer.Deserialize<T>(json, _setting); } public static object Deserialize(Type type, string json) { return JsonSerializer.Deserialize(json, type, _setting); } public static string Serialize<T>(T value) { return JsonSerializer.Serialize(value, _setting); } } public static class MTFOPartialDataUtil { public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks"; public static JsonConverter PersistentIDConverter { get; private set; } public static JsonConverter LocalizedTextConverter { get; private set; } public static bool IsLoaded { get; private set; } public static bool Initialized { get; private set; } public static string PartialDataPath { get; private set; } public static string ConfigPath { get; private set; } static MTFOPartialDataUtil() { PersistentIDConverter = null; LocalizedTextConverter = null; IsLoaded = false; Initialized = false; PartialDataPath = string.Empty; ConfigPath = string.Empty; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type type = types.First((Type t) => t.Name == "PersistentIDConverter"); if ((object)type == null) { throw new Exception("Unable to Find PersistentIDConverter Class"); } Type type2 = types.First((Type t) => t.Name == "PartialDataManager"); if ((object)type2 == null) { throw new Exception("Unable to Find PartialDataManager Class"); } Type type3 = types.First((Type t) => t.Name == "LocalizedTextConverter") ?? throw new Exception("Unable to Find LocalizedTextConverter Class"); PropertyInfo property = type2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public); PropertyInfo property2 = type2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property3 = type2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public); if ((object)property == null) { throw new Exception("Unable to Find Property: Initialized"); } if ((object)property2 == null) { throw new Exception("Unable to Find Property: PartialDataPath"); } if ((object)property3 == null) { throw new Exception("Unable to Find Field: ConfigPath"); } Initialized = (bool)property.GetValue(null); PartialDataPath = (string)property2.GetValue(null); ConfigPath = (string)property3.GetValue(null); PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type); LocalizedTextConverter = (JsonConverter)Activator.CreateInstance(type3); IsLoaded = true; } catch (Exception value2) { WPELogger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}"); } } } public static class MTFOUtil { public const string PLUGIN_GUID = "com.dak.MTFO"; public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public; public static string GameDataPath { get; private set; } public static string CustomPath { get; private set; } public static bool HasCustomContent { get; private set; } public static bool IsLoaded { get; private set; } static MTFOUtil() { GameDataPath = string.Empty; CustomPath = string.Empty; HasCustomContent = false; IsLoaded = false; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); IsLoaded = true; } catch (Exception value2) { WPELogger.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}"); } } } } namespace WeaponPerExpedition.Patches { [HarmonyPatch] internal class Patch_RundownManager { [HarmonyPostfix] [HarmonyPatch(typeof(RundownManager), "SetActiveExpedition")] private static void Post_RundownManager_SetActiveExpedition(RundownManager __instance, pActiveExpedition expPackage, ExpeditionInTierData expTierData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((int)expPackage.tier != 99) { eRundownTier tier = expPackage.tier; int expeditionIndex = expPackage.expeditionIndex; ExpeditionGearManager.Current.OnLevelSelected(tier, expeditionIndex); } } } [HarmonyPatch] internal class Patch_GearManager_LoadOfflineGearDatas { [HarmonyPostfix] [HarmonyPatch(typeof(GearManager), "LoadOfflineGearDatas")] private static void Pre_GearManager_LoadOfflineGearDatas(GearManager __instance) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown foreach (var gearSlot in ExpeditionGearManager.Current.gearSlots) { Enumerator<GearIDRange> enumerator2 = ((Il2CppArrayBase<List<GearIDRange>>)(object)__instance.m_gearPerSlot)[(int)gearSlot.inventorySlot].GetEnumerator(); while (enumerator2.MoveNext()) { GearIDRange current2 = enumerator2.Current; uint offlineGearPID = ExpeditionGearManager.GetOfflineGearPID(current2); gearSlot.loadedGears.Add(offlineGearPID, current2); } } } } }
plugins/Heat/x64/Release/netstandard2.1/DeleteMeIfGay.dll
Decompiled 5 months agousing System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.Json; using System.Text.Json.Serialization; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BoosterImplants; using BoosterPack.Manager; using BoosterPack.Models; using BoosterPack.Patches; using CellMenu; using DropServer.BoosterImplants; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Threading.Tasks; using Localization; using MTFO.API; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("BoosterPack")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+git465baee-dirty-master")] [assembly: AssemblyProduct("BoosterPack")] [assembly: AssemblyTitle("BoosterPack")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace BoosterPack { [BepInPlugin("Endskill.CustomBoosters", "CustomBoosters", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BepinExLoader : BasePlugin { public const string MODNAME = "CustomBoosters"; public const string AUTHOR = "Endskill"; public const string GUID = "Endskill.CustomBoosters"; public const string VERSION = "1.0.0"; public override void Load() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown LogManager.SetLogger(((BasePlugin)this).Log); LogManager._debugMessagesActive = ((BasePlugin)this).Config.Bind<bool>("Dev Settings", "DebugMessages", false, "This settings activates/deactivates debug messages in the console for this specific plugin.").Value; Harmony val = new Harmony("Endskill.CustomBoosters"); val.PatchAll(typeof(PersistentInventoryManagerPatches)); val.PatchAll(typeof(DropServerPatches)); val.PatchAll(typeof(BoosterImplantInventoryItemPatches)); val.PatchAll(typeof(CmPageLoadoutPatches)); MTFOHotReloadAPI.OnHotReload += ScriptManager.HotReaload; } } public static class CacheApiWrapper { internal static BoosterImplantPlayerData _inv; public static bool UseCustomData { get; set; } public static BoosterImplantPlayerData Inventory { get { return _inv; } set { _inv = value; } } } internal static class LogManager { private static ManualLogSource logger; internal static bool _debugMessagesActive; internal static void SetLogger(ManualLogSource log) { logger = log; } public static void Verbose(object msg) { if (_debugMessagesActive) { logger.LogInfo(msg); } } public static void Debug(object msg) { if (_debugMessagesActive) { logger.LogDebug(msg); } } public static void Message(object msg) { if (_debugMessagesActive) { logger.LogMessage(msg); } } public static void Error(object msg) { logger.LogError(msg); } public static void Warn(object msg) { logger.LogWarning(msg); } } [GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")] [CompilerGenerated] internal static class VersionInfo { public const string RootNamespace = "BoosterPack"; public const string Version = "1.0.0"; public const string VersionPrerelease = null; public const string VersionMetadata = "git465baee-dirty-master"; public const string SemVer = "1.0.0+git465baee-dirty-master"; public const string GitRevShort = "465baee-dirty"; public const string GitRevLong = "465baeed0cd33374f3d2e30104b8e8fe99e66f59-dirty"; public const string GitBranch = "master"; public const string GitTag = null; public const bool GitIsDirty = true; } } namespace BoosterPack.Patches { [HarmonyPatch(typeof(BoosterImplantInventoryItem))] public class BoosterImplantInventoryItemPatches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool Prefix(ref bool __result) { __result = true; return false; } } [HarmonyPatch(typeof(CM_PageLoadout))] public static class CmPageLoadoutPatches { [HarmonyPatch("ProcessBoosterImplantEvents")] [HarmonyPrefix] public static bool ProcessBoosterImplantEventsPrefix() { return false; } } [HarmonyPatch(typeof(DropServerManager))] public static class DropServerManagerPatches { private static PlayerInventoryData _cachedInventory; [HarmonyPatch("GetBoosterImplantPlayerDataAsync")] [HarmonyPrefix] public static bool GetBoosterImplantPlayerDataAsyncPrefix(ref Task<PlayerInventoryData> __result) { LogManager.Debug("Booster Patch"); __result = GetInventory(); return false; } [HarmonyPatch("GetInventoryPlayerDataAsync")] [HarmonyPrefix] public static bool GetInventoryPlayerDataAsyncPrefix(ref Task<PlayerInventoryData> __result) { LogManager.Debug("Inventar Patch"); __result = GetInventory(); return false; } private static Task<PlayerInventoryData> GetInventory() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_003b: 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) //IL_0046: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0058: Expected O, but got Unknown if (_cachedInventory != null) { return Task.FromResult<PlayerInventoryData>(_cachedInventory); } _cachedInventory = new PlayerInventoryData(); _cachedInventory.BoosterData = new Nullable<BoosterImplantPlayerData>(new BoosterImplantPlayerData { Basic = new Category(), Advanced = new Category(), Specialized = new Category() }); return Task.FromResult<PlayerInventoryData>(_cachedInventory); } } [HarmonyPatch(typeof(DropServerGameSession))] internal class DropServerPatches { [HarmonyPatch("ConsumeBoosters")] [HarmonyPrefix] public static bool ConsumeBoostersPrefix() { return false; } } [HarmonyPatch(typeof(PersistentInventoryManager))] public class PersistentInventoryManagerPatches { private static uint _id = 9599u; [HarmonyPatch("UpdateBoosterImplants")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool UpdateBoosterImplantsPrefix(PersistentInventoryManager __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 ScriptManager.Initialize(); if (!CacheApiWrapper.UseCustomData) { CreateData(); } BoosterImplant[] array = ((IEnumerable<BoosterImplantCategory>)BoosterImplantConstants.Categories).Select((BoosterImplantCategory c) => PersistentInventoryManager.GetActiveBoosterImplant((BoosterImplantCategory)c)).ToArray(); UpdateBoosterImplantInventoryModelMock(__instance); if ((int)__instance.m_boosterImplantDirtyState == 0) { __instance.ClearPendingBoosterImplantTransactions(); } else { PersistentInventoryManager.CleanupPendingBoosterImplantTransactions(__instance.m_boosterImplantPendingTransactions, __instance.m_boosterImplantInventory); PersistentInventoryManager.ApplyPendingBoosterImplantTransactionsToModel(__instance.m_boosterImplantInventory, __instance.m_boosterImplantPendingTransactions); } for (int i = 0; i < array.Length; i++) { if (PersistentInventoryManager.GetActiveBoosterImplant((BoosterImplantCategory)i) != array[i]) { Action onActiveBoosterImplantsChanged = __instance.OnActiveBoosterImplantsChanged; if (onActiveBoosterImplantsChanged != null) { onActiveBoosterImplantsChanged.Invoke(); } break; } } Action onBoosterImplantInventoryChanged = __instance.OnBoosterImplantInventoryChanged; if ((Delegate)(object)onBoosterImplantInventoryChanged == (Delegate)null) { return false; } onBoosterImplantInventoryChanged.Invoke(); return false; } private static void CreateData() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Expected O, but got Unknown //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Expected O, but got Unknown //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Expected I4, but got Unknown Il2CppArrayBase<BoosterImplantTemplateDataBlock> allBlocks = GameDataBlockBase<BoosterImplantTemplateDataBlock>.GetAllBlocks(); Il2CppArrayBase<BoosterImplantEffectDataBlock> allBlocks2 = GameDataBlockBase<BoosterImplantEffectDataBlock>.GetAllBlocks(); Il2CppArrayBase<BoosterImplantConditionDataBlock> allBlocks3 = GameDataBlockBase<BoosterImplantConditionDataBlock>.GetAllBlocks(); List<BoosterImplantInventoryItem> list = new List<BoosterImplantInventoryItem>(); List<BoosterImplantInventoryItem> list2 = new List<BoosterImplantInventoryItem>(); List<BoosterImplantInventoryItem> list3 = new List<BoosterImplantInventoryItem>(); foreach (BoosterImplantTemplateDataBlock item3 in allBlocks) { BoosterImplantInventoryItem val = new BoosterImplantInventoryItem(); ((BoosterImplantBase)val).Id = _id++; ((BoosterImplantBase)val).TemplateId = ((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)item3).persistentID; ((BoosterImplantBase)val).UsesRemaining = 88; List<BoosterImplantEffect> list4 = new List<BoosterImplantEffect>(); Enumerator<BoosterImplantEffectInstance> enumerator2 = item3.Effects.GetEnumerator(); while (enumerator2.MoveNext()) { BoosterImplantEffectInstance effect2 = enumerator2.Current; BoosterImplantEffectDataBlock val2 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect2.BoosterImplantEffect); LogManager.Debug($"Effect has: {val2.BoosterEffectCategory}, Param: {effect2.MaxValue}"); BoosterImplantEffect item = default(BoosterImplantEffect); item.Id = effect2.BoosterImplantEffect; item.Param = effect2.MaxValue; list4.Add(item); } bool flag = true; Enumerator<List<BoosterImplantEffectInstance>> enumerator3 = item3.RandomEffects.GetEnumerator(); while (enumerator3.MoveNext()) { List<BoosterImplantEffectInstance> current2 = enumerator3.Current; if (!flag) { continue; } flag = false; Enumerator<BoosterImplantEffectInstance> enumerator4 = current2.GetEnumerator(); while (enumerator4.MoveNext()) { BoosterImplantEffectInstance effect = enumerator4.Current; BoosterImplantEffectDataBlock val3 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect.BoosterImplantEffect); LogManager.Debug($"Effect has: {val3.BoosterEffectCategory}, Param: {effect.MaxValue}"); BoosterImplantEffect item2 = default(BoosterImplantEffect); item2.Id = effect.BoosterImplantEffect; item2.Param = effect.MaxValue; list4.Add(item2); } } ((BoosterImplantBase)val).Effects = Il2CppStructArray<BoosterImplantEffect>.op_Implicit(list4.ToArray()); foreach (BoosterImplantEffect item4 in (Il2CppArrayBase<BoosterImplantEffect>)(object)((BoosterImplantBase)val).Effects) { LogManager.Debug($"Effect2 has: {item4.Id}, Param: {item4.Param}"); } ((BoosterImplantBase)val).Conditions = new Il2CppStructArray<uint>(Il2CppArrayBase<uint>.op_Implicit(item3.Conditions?.ToArray())); BoosterImplantCategory implantCategory = item3.ImplantCategory; BoosterImplantCategory val4 = implantCategory; switch ((int)val4) { case 0: list.Add(val); break; case 1: list2.Add(val); break; case 2: list3.Add(val); break; } } Category val5 = new Category(); Category val6 = new Category(); Category val7 = new Category(); val5.Inventory = new Il2CppReferenceArray<BoosterImplantInventoryItem>(list.ToArray()); val6.Inventory = new Il2CppReferenceArray<BoosterImplantInventoryItem>(list2.ToArray()); val7.Inventory = new Il2CppReferenceArray<BoosterImplantInventoryItem>(list3.ToArray()); BoosterImplantPlayerData val8 = new BoosterImplantPlayerData(); val8.Basic = val5; val8.Advanced = val6; val8.Specialized = val7; val8.New = Il2CppStructArray<uint>.op_Implicit(new uint[0]); CacheApiWrapper.Inventory = val8; } private static void UpdateBoosterImplantInventoryModelMock(PersistentInventoryManager instance) { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown BoosterImplantPlayerData inventory = CacheApiWrapper.Inventory; BoosterImplantInventoryModel boosterImplantInventory = instance.m_boosterImplantInventory; boosterImplantInventory.New.Clear(); int num = 0; while (true) { int num2 = num; uint[] array = Il2CppArrayBase<uint>.op_Implicit((Il2CppArrayBase<uint>)(object)inventory.New); int num3 = ((array != null) ? array.Length : 0); if (num2 < num3) { boosterImplantInventory.New.Add(((Il2CppArrayBase<uint>)(object)inventory.New)[num]); num++; continue; } break; } Category[] array2 = (Category[])(object)new Category[3] { inventory.Basic, inventory.Advanced, inventory.Specialized }; int num4 = default(int); for (int i = 0; i < array2.Length; i++) { Category val = array2[i]; Category val2 = ((Il2CppArrayBase<Category>)(object)boosterImplantInventory.Categories)[i]; uint num5 = (boosterImplantInventory.FindPrepared((BoosterImplantCategory)i, ref num4) ? ((Il2CppArrayBase<Category>)(object)boosterImplantInventory.Categories)[i].Inventory[num4].InstanceId : uint.MaxValue); val2.Inventory.Clear(); for (int j = 0; j < ((Il2CppArrayBase<BoosterImplantInventoryItem>)(object)val.Inventory).Length; j++) { try { BoosterImplantInventoryItem val3 = ((Il2CppArrayBase<BoosterImplantInventoryItem>)(object)val.Inventory)[j]; foreach (BoosterImplantEffect item in (Il2CppArrayBase<BoosterImplantEffect>)(object)((BoosterImplantBase)val3).Effects) { LogManager.Debug($"testItem has: {item.Id} {item.Param}"); } BoosterImplantInventoryItem val4 = new BoosterImplantInventoryItem(((Il2CppArrayBase<BoosterImplantInventoryItem>)(object)val.Inventory)[j]); val4.Prepared = val4.InstanceId == num5; val2.Inventory.Add(val4); } catch (Exception ex) { PersistentInventoryManager.LogError(ex.Message); } } val2.Currency = val.Currency; val2.Missed = val.Missed; val2.MissedAcknowledged = Mathf.Clamp(val2.MissedAcknowledged, val.MissedAck, val.Missed); } } } } namespace BoosterPack.Models { public class ActivateableBoosterData { public bool UseCustomData { get; set; } public List<CustomBooster> CustomBoosters { get; set; } } public class CustomBooster { private List<CustomEffect> _effects; private List<CustomCondition> _conditions; public string PublicName { get; set; } public string Description { get; set; } public BoosterEffectCategory MainEffectType { get; set; } public BoosterImplantCategory ImplantCategory { get; set; } public List<CustomEffect> Effects { get { if (_effects == null) { _effects = new List<CustomEffect>(); } return _effects; } set { _effects = value; } } public List<CustomCondition> Conditions { get { if (_conditions == null) { _conditions = new List<CustomCondition>(); } return _conditions; } set { _conditions = value; } } } public class CustomCondition { public BoosterCondition Condition { get; set; } public string PublicShortName { get; set; } public string PublicName { get; set; } public string Description { get; set; } } public class CustomEffect { public AgentModifier Effect { get; set; } public string PublicShortName { get; set; } public string PublicName { get; set; } public string Description { get; set; } public string DescriptionNegative { get; set; } public BoosterEffectCategory EffectCategory { get; set; } public float Value { get; set; } } } namespace BoosterPack.Manager { public class DataBlockManager { private uint _templateIds = 306783378u; private uint _effectIds = 306783378u; private uint _conditionIds = 306783378u; private uint _itemId = 306783378u; private uint _id = 536870911u; public List<BoosterImplantInventoryItem> Basic { get; } public List<BoosterImplantInventoryItem> Advanced { get; } public List<BoosterImplantInventoryItem> Special { get; } public DataBlockManager() { Basic = new List<BoosterImplantInventoryItem>(); Advanced = new List<BoosterImplantInventoryItem>(); Special = new List<BoosterImplantInventoryItem>(); } public void CreateDataBlocksForBooster(CustomBooster booster) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Expected I4, but got Unknown BoosterImplantTemplateDataBlock val = new BoosterImplantTemplateDataBlock(); ((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)val).name = GetUniqueName(); ((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)val).persistentID = ++_templateIds; val.Deprecated = false; val.PublicName = GetTranslation(booster.PublicName); val.Description = GetTranslation(booster.Description); val.ImplantCategory = booster.ImplantCategory; val.MainEffectType = booster.MainEffectType; foreach (CustomEffect effect in booster.Effects) { BoosterImplantEffectDataBlock val2 = new BoosterImplantEffectDataBlock(); ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)val2).name = GetUniqueName(); val2.Effect = effect.Effect; val2.BoosterEffectCategory = effect.EffectCategory; val2.PublicShortName = GetTranslation(effect.PublicShortName); val2.PublicName = GetTranslation(effect.PublicName); val2.Description = GetTranslation(effect.Description); val2.DescriptionNegative = GetTranslation(effect.DescriptionNegative); ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)val2).persistentID = _effectIds++; BoosterImplantEffectInstance val3 = new BoosterImplantEffectInstance(); val3.BoosterImplantEffect = ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)val2).persistentID; val3.MinValue = effect.Value; val3.MaxValue = effect.Value; val.Effects.Add(val3); GameDataBlockBase<BoosterImplantEffectDataBlock>.AddBlock(val2, -1); } foreach (CustomCondition condition in booster.Conditions) { BoosterImplantConditionDataBlock val4 = new BoosterImplantConditionDataBlock(); ((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)val4).name = GetUniqueName(); val4.Condition = condition.Condition; val4.PublicShortName = GetTranslation(condition.PublicShortName); val4.PublicName = GetTranslation(condition.PublicName); val4.Description = GetTranslation(condition.Description); ((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)val4).persistentID = _conditionIds++; val.Conditions.Add(((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)val4).persistentID); GameDataBlockBase<BoosterImplantConditionDataBlock>.AddBlock(val4, -1); } GameDataBlockBase<BoosterImplantTemplateDataBlock>.AddBlock(val, -1); BoosterImplantInventoryItem val5 = new BoosterImplantInventoryItem(); ((BoosterImplantBase)val5).Id = _itemId++; ((BoosterImplantBase)val5).TemplateId = ((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)val).persistentID; ((BoosterImplantBase)val5).UsesRemaining = 99; List<BoosterImplantEffect> list = new List<BoosterImplantEffect>(); Enumerator<BoosterImplantEffectInstance> enumerator3 = val.Effects.GetEnumerator(); while (enumerator3.MoveNext()) { BoosterImplantEffectInstance current3 = enumerator3.Current; BoosterImplantEffect item = default(BoosterImplantEffect); item.Id = current3.BoosterImplantEffect; item.Param = current3.MaxValue; list.Add(item); } ((BoosterImplantBase)val5).Effects = Il2CppStructArray<BoosterImplantEffect>.op_Implicit(list.ToArray()); ((BoosterImplantBase)val5).Conditions = new Il2CppStructArray<uint>(Il2CppArrayBase<uint>.op_Implicit(val.Conditions?.ToArray())); BoosterImplantCategory implantCategory = val.ImplantCategory; BoosterImplantCategory val6 = implantCategory; switch ((int)val6) { case 0: Basic.Add(val5); break; case 1: Advanced.Add(val5); break; case 2: Special.Add(val5); break; } } private LocalizedText GetTranslation(string booLocalization) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown LocalizedText val = new LocalizedText(); val.UntranslatedText = booLocalization; return val; } private string GetUniqueName() { return $"CustomBoosters_{++_id}"; } } public static class ScriptManager { private static bool _initialized; internal static void HotReaload() { _initialized = false; Initialize(); PersistentInventoryManager.Current.UpdateBoosterImplants(ref CacheApiWrapper._inv); } public static void Initialize() { if (!_initialized) { _initialized = true; string text = Path.Combine(MTFOPathAPI.CustomPath, "CustomBoosters"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } WriteEnumValues(text); text = Path.Combine(text, "CustomBoosters.json"); WriteDefault(text); ActivateableBoosterData data = ReadData(text); PrepareForUseIngame(data); } } public static void PrepareForUseIngame(ActivateableBoosterData data) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown CacheApiWrapper.UseCustomData = data.UseCustomData; List<CustomBooster> customBoosters = data.CustomBoosters; DataBlockManager dataBlockManager = new DataBlockManager(); foreach (CustomBooster item in customBoosters) { dataBlockManager.CreateDataBlocksForBooster(item); } Category val = new Category(); Category val2 = new Category(); Category val3 = new Category(); val.Inventory = Il2CppReferenceArray<BoosterImplantInventoryItem>.op_Implicit(dataBlockManager.Basic.ToArray()); val2.Inventory = Il2CppReferenceArray<BoosterImplantInventoryItem>.op_Implicit(dataBlockManager.Advanced.ToArray()); val3.Inventory = Il2CppReferenceArray<BoosterImplantInventoryItem>.op_Implicit(dataBlockManager.Special.ToArray()); BoosterImplantPlayerData val4 = new BoosterImplantPlayerData(); val4.Basic = val; val4.Advanced = val2; val4.Specialized = val3; val4.New = Il2CppStructArray<uint>.op_Implicit(new uint[0]); CacheApiWrapper.Inventory = val4; } private static ActivateableBoosterData ReadData(string path) { JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { IncludeFields = false, ReadCommentHandling = JsonCommentHandling.Skip, PropertyNameCaseInsensitive = true, WriteIndented = true }; jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); return JsonSerializer.Deserialize<ActivateableBoosterData>(File.ReadAllText(path), jsonSerializerOptions) ?? ParseExistingDataBlocks(); } private static void WriteDefault(string path) { if (!File.Exists(path)) { JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { IncludeFields = false, ReadCommentHandling = JsonCommentHandling.Skip, PropertyNameCaseInsensitive = true, WriteIndented = true }; jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); File.WriteAllText(path, JsonSerializer.Serialize(ParseExistingDataBlocks(), jsonSerializerOptions)); } } private static void WriteEnumValues(string dictionaryPath) { string path = Path.Combine(dictionaryPath, "MainEffectType.txt"); if (!File.Exists(path)) { File.WriteAllText(path, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterEffectCategory)))); } string path2 = Path.Combine(dictionaryPath, "EffectCategory.txt"); if (!File.Exists(path2)) { File.WriteAllText(path2, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterEffectCategory)))); } string path3 = Path.Combine(dictionaryPath, "ImplantCategory.txt"); if (!File.Exists(path3)) { File.WriteAllText(path3, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterImplantCategory)))); } string path4 = Path.Combine(dictionaryPath, "Effect.txt"); if (!File.Exists(path4)) { File.WriteAllText(path4, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(AgentModifier)))); } string path5 = Path.Combine(dictionaryPath, "Condition.txt"); if (!File.Exists(path5)) { File.WriteAllText(path5, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterCondition)))); } } private static ActivateableBoosterData ParseExistingDataBlocks() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) ActivateableBoosterData activateableBoosterData = new ActivateableBoosterData(); List<CustomBooster> list2 = (activateableBoosterData.CustomBoosters = new List<CustomBooster>()); activateableBoosterData.UseCustomData = false; Il2CppArrayBase<BoosterImplantTemplateDataBlock> allBlocks = GameDataBlockBase<BoosterImplantTemplateDataBlock>.GetAllBlocks(); Il2CppArrayBase<BoosterImplantEffectDataBlock> allBlocks2 = GameDataBlockBase<BoosterImplantEffectDataBlock>.GetAllBlocks(); Il2CppArrayBase<BoosterImplantConditionDataBlock> allBlocks3 = GameDataBlockBase<BoosterImplantConditionDataBlock>.GetAllBlocks(); foreach (BoosterImplantTemplateDataBlock temp in allBlocks) { CustomBooster customBooster = new CustomBooster(); customBooster.PublicName = Text.Get(temp.PublicName.Id); customBooster.Description = Text.Get(temp.Description.Id); customBooster.MainEffectType = temp.MainEffectType; customBooster.ImplantCategory = temp.ImplantCategory; Enumerator<BoosterImplantEffectInstance> enumerator2 = temp.Effects.GetEnumerator(); while (enumerator2.MoveNext()) { BoosterImplantEffectInstance effect = enumerator2.Current; BoosterImplantEffectDataBlock effectDb2 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect.BoosterImplantEffect); customBooster.Effects.Add(ParseEffect(effectDb2, effect.MaxValue)); } if (temp.RandomEffects.Count > 0) { Enumerator<BoosterImplantEffectInstance> enumerator3 = temp.RandomEffects[0].GetEnumerator(); while (enumerator3.MoveNext()) { BoosterImplantEffectInstance effect2 = enumerator3.Current; BoosterImplantEffectDataBlock effectDb3 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect2.BoosterImplantEffect); customBooster.Effects.Add(ParseEffect(effectDb3, effect2.MaxValue)); } } Enumerator<uint> enumerator4 = temp.Conditions.GetEnumerator(); while (enumerator4.MoveNext()) { uint condition = enumerator4.Current; BoosterImplantConditionDataBlock conditionDb2 = ((IEnumerable<BoosterImplantConditionDataBlock>)allBlocks3).First((BoosterImplantConditionDataBlock x) => ((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)x).persistentID == condition); customBooster.Conditions.Add(ParseCondition(conditionDb2)); } if (temp.RandomConditions.Count > 0) { BoosterImplantConditionDataBlock conditionDb3 = ((IEnumerable<BoosterImplantConditionDataBlock>)allBlocks3).First((BoosterImplantConditionDataBlock x) => ((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)x).persistentID == temp.RandomConditions[0]); customBooster.Conditions.Add(ParseCondition(conditionDb3)); } list2.Add(customBooster); } return activateableBoosterData; static CustomCondition ParseCondition(BoosterImplantConditionDataBlock conditionDb) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) return new CustomCondition { PublicShortName = Text.Get(conditionDb.PublicShortName.Id), PublicName = Text.Get(conditionDb.PublicName.Id), Description = Text.Get(conditionDb.Description.Id), Condition = conditionDb.Condition }; } static CustomEffect ParseEffect(BoosterImplantEffectDataBlock effectDb, float value) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) return new CustomEffect { PublicShortName = Text.Get(effectDb.PublicShortName.Id), PublicName = Text.Get(effectDb.PublicName.Id), Description = Text.Get(effectDb.Description.Id), DescriptionNegative = Text.Get(effectDb.DescriptionNegative.Id), Effect = effectDb.Effect, EffectCategory = effectDb.BoosterEffectCategory, Value = value }; } } } }
plugins/Heat/x64/Release/netstandard2.1/Oxygen.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.Json; using System.Text.Json.Serialization; using AK; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using GTFO.API; using GTFO.API.Utilities; using GameData; using GameEvent; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Localization; using MTFO.Managers; using Microsoft.CodeAnalysis; using Oxygen.Components; using Oxygen.Config; using Oxygen.Utils; using Oxygen.Utils.PartialData; using Player; using SNetwork; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Oxygen")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Oxygen")] [assembly: AssemblyTitle("Oxygen")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Oxygen { [BepInPlugin("Inas.Oxygen", "Oxygen", "1.2.0")] [BepInProcess("GTFO.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { [CompilerGenerated] private static class <>O { public static Action <0>__Setup; public static Action <1>__OnBuildDone; public static Action <2>__OnLevelCleanup; public static Action <3>__Setup; public static Action <4>__OnLevelCleanup; public static Action <5>__OnBuildStart; public static Action <6>__OnLevelCleanup; public static LiveEditEventHandler <7>__Listener_FileChanged1; } public const string MODNAME = "Oxygen"; public const string AUTHOR = "Inas"; public const string GUID = "Inas.Oxygen"; public const string VERSION = "1.2.0"; public static readonly string OXYGEN_CONFIG_PATH = Path.Combine(ConfigManager.CustomPath, "Oxygen"); public static Dictionary<uint, OxygenBlock> lookup = new Dictionary<uint, OxygenBlock>(); private static LiveEditListener listener = null; public override void Load() { //IL_010b: 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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown if (!Directory.Exists(OXYGEN_CONFIG_PATH)) { Log.Error("Did not find oxygen config folder, will not load."); return; } ClassInjector.RegisterTypeInIl2Cpp<AirManager>(); LevelAPI.OnBuildStart += AirManager.Setup; LevelAPI.OnBuildDone += AirManager.OnBuildDone; LevelAPI.OnLevelCleanup += AirManager.OnLevelCleanup; ClassInjector.RegisterTypeInIl2Cpp<AirBar>(); LevelAPI.OnBuildStart += AirBar.Setup; LevelAPI.OnLevelCleanup += AirBar.OnLevelCleanup; ClassInjector.RegisterTypeInIl2Cpp<AirPlane>(); LevelAPI.OnBuildStart += AirPlane.OnBuildStart; LevelAPI.OnLevelCleanup += AirPlane.OnLevelCleanup; new Harmony("Inas.Oxygen").PatchAll(); foreach (string item in Directory.EnumerateFiles(OXYGEN_CONFIG_PATH, "*.json", SearchOption.AllDirectories)) { ConfigManager.Load<OxygenConfig>(item, out var config); foreach (OxygenBlock block in config.Blocks) { foreach (uint fogSetting in block.FogSettings) { if (!lookup.ContainsKey(fogSetting)) { lookup.Add(fogSetting, block); } } } } listener = LiveEdit.CreateListener(OXYGEN_CONFIG_PATH, "*.json", true); LiveEditListener obj = listener; object obj2 = <>O.<7>__Listener_FileChanged1; if (obj2 == null) { LiveEditEventHandler val = Listener_FileChanged1; <>O.<7>__Listener_FileChanged1 = val; obj2 = (object)val; } obj.FileChanged += (LiveEditEventHandler)obj2; } private static void Listener_FileChanged1(LiveEditEventArgs e) { Log.Warning("LiveEdit File Changed: " + e.FullPath + "."); LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content) { foreach (OxygenBlock block in ConfigManager.Deserialize<OxygenConfig>(content).Blocks) { foreach (uint fogSetting in block.FogSettings) { if (lookup.ContainsKey(fogSetting)) { lookup.Remove(fogSetting); } lookup.Add(fogSetting, block); Log.Warning($"Replaced OxygenConfig for FogSetting: {fogSetting}."); } } if (GameStateManager.IsInExpedition) { AirManager.Current.UpdateAirConfig(AirManager.Current.FogSetting(), LiveEditForceUpdate: true); } }); } } } namespace Oxygen.Utils { internal static class Extension { public static T Instantiate<T>(this GameObject gameObject, string name) where T : Component { GameObject obj = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent, false); ((Object)obj).name = name; return obj.GetComponent<T>(); } } internal class LocalizedTextConverter : JsonConverter<LocalizedText> { public override bool HandleNull => false; public override LocalizedText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown switch (reader.TokenType) { case JsonTokenType.String: { string @string = reader.GetString(); return new LocalizedText { Id = 0u, UntranslatedText = @string }; } case JsonTokenType.Number: return new LocalizedText { Id = reader.GetUInt32(), UntranslatedText = null }; default: throw new JsonException($"LocalizedTextJson type: {reader.TokenType} is not implemented!"); } } public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options) { JsonSerializer.Serialize<LocalizedText>(writer, value, options); } } internal static class Log { private static ManualLogSource source; static Log() { source = Logger.CreateLogSource("Oxygen"); } public static void Debug(object msg) { source.LogDebug(msg); } public static void Error(object msg) { source.LogError(msg); } public static void Fatal(object msg) { source.LogFatal(msg); } public static void Info(object msg) { source.LogInfo(msg); } public static void Message(object msg) { source.LogMessage(msg); } public static void Warning(object msg) { source.LogWarning(msg); } } } namespace Oxygen.Utils.PartialData { public static class MTFOPartialDataUtil { public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks"; public static JsonConverter PersistentIDConverter { get; private set; } public static JsonConverter LocalizedTextConverter { get; private set; } public static bool IsLoaded { get; private set; } public static bool Initialized { get; private set; } public static string PartialDataPath { get; private set; } public static string ConfigPath { get; private set; } static MTFOPartialDataUtil() { PersistentIDConverter = null; LocalizedTextConverter = null; IsLoaded = false; Initialized = false; PartialDataPath = string.Empty; ConfigPath = string.Empty; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type type = types.First((Type t) => t.Name == "PersistentIDConverter"); if ((object)type == null) { throw new Exception("Unable to Find PersistentIDConverter Class"); } Type type2 = types.First((Type t) => t.Name == "LocalizedTextConverter"); if ((object)type2 == null) { throw new Exception("Unable to Find LocalizedTextConverter Class"); } Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class"); PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public); PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property3 = obj2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public); if ((object)property == null) { throw new Exception("Unable to Find Property: Initialized"); } if ((object)property2 == null) { throw new Exception("Unable to Find Property: PartialDataPath"); } if ((object)property3 == null) { throw new Exception("Unable to Find Field: ConfigPath"); } Initialized = (bool)property.GetValue(null); PartialDataPath = (string)property2.GetValue(null); ConfigPath = (string)property3.GetValue(null); PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type); LocalizedTextConverter = (JsonConverter)Activator.CreateInstance(type2); IsLoaded = true; } catch (Exception value2) { Log.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}"); } } } public static class MTFOUtil { public const string PLUGIN_GUID = "com.dak.MTFO"; public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public; public static string GameDataPath { get; private set; } public static string CustomPath { get; private set; } public static bool HasCustomContent { get; private set; } public static bool IsLoaded { get; private set; } static MTFOUtil() { GameDataPath = string.Empty; CustomPath = string.Empty; HasCustomContent = false; IsLoaded = false; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); IsLoaded = true; } catch (Exception value2) { Log.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}"); } } } } namespace Oxygen.Patches { [HarmonyPatch] internal class Patches_Dam_PlayerDamageLocal { [HarmonyPrefix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveNoAirDamage")] public static bool Pre_ReceiveNoAirDamage(Dam_PlayerDamageLocal __instance, pMiniDamageData data) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax); ((Dam_PlayerDamageBase)__instance).m_nextRegen = Clock.Time + ((Dam_PlayerDamageBase)__instance).Owner.PlayerData.healthRegenStartDelayAfterDamage; if (((Agent)((Dam_PlayerDamageBase)__instance).Owner).IsLocallyOwned) { DramaManager.CurrentState.OnLocalDamage(num); GameEventManager.PostEvent((eGameEvent)13, ((Dam_PlayerDamageBase)__instance).Owner, num, "", (Dictionary<string, string>)null); } else { DramaManager.CurrentState.OnTeammatesDamage(num); } if (((Dam_PlayerDamageBase)__instance).IgnoreAllDamage) { return false; } if (SNet.IsMaster && !((Dam_SyncedDamageBase)__instance).RegisterDamage(num)) { ((Dam_SyncedDamageBase)__instance).SendSetHealth(((Dam_SyncedDamageBase)__instance).Health); } __instance.Hitreact(((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax), Vector3.zero, true, false, false); return false; } [HarmonyPostfix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveBulletDamage")] public static void Post_ReceiveBulletDamage() { AirManager.Current.ResetHealthToRegen(); } [HarmonyPostfix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveMeleeDamage")] public static void Post_ReceiveMeleeDamage() { AirManager.Current.ResetHealthToRegen(); } [HarmonyPostfix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveFireDamage")] public static void Post_ReceiveFireDamage() { AirManager.Current.ResetHealthToRegen(); } [HarmonyPostfix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveShooterProjectileDamage")] public static void Post_ReceiveShooterProjectileDamage() { AirManager.Current.ResetHealthToRegen(); } [HarmonyPostfix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveTentacleAttackDamage")] public static void Post_ReceiveTentacleAttackDamage() { AirManager.Current.ResetHealthToRegen(); } [HarmonyPostfix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceivePushDamage")] public static void Post_ReceivePushDamage() { AirManager.Current.ResetHealthToRegen(); } [HarmonyPostfix] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveSetDead")] public static void Post_ReceiveSetDead() { AirManager.Current.ResetHealthToRegen(); } } [HarmonyPatch(typeof(EnvironmentStateManager), "UpdateFog")] internal class EnvironmentStateManager_UpdateFog { public static void Prefix(EnvironmentStateManager __instance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) if ((Object)(object)AirManager.Current == (Object)null) { return; } FogState val = ((Il2CppArrayBase<FogState>)(object)__instance.m_stateReplicator.State.FogStates)[__instance.m_latestKnownLocalDimensionCreationIndex]; if (val.FogDataID != 0) { AirManager.Current.UpdateAirConfig(val.FogDataID); if (!AirManager.Current.HasAirConfig()) { AirManager.Current.StopInfectionLoop(); } } } } [HarmonyPatch(typeof(FogRepeller_Sphere), "StartRepelling")] internal class FogRepeller_Sphere_StartRepelling { public static void Postfix(ref FogRepeller_Sphere __instance) { if (__instance.m_infectionShield != null) { EffectVolumeManager.UnregisterVolume((EffectVolume)(object)__instance.m_infectionShield); ((EffectVolume)__instance.m_infectionShield).contents = (eEffectVolumeContents)0; EffectVolumeManager.RegisterVolume((EffectVolume)(object)__instance.m_infectionShield); } } } [HarmonyPatch(typeof(LocalPlayerAgentSettings), "UpdateBlendTowardsTargetFogSetting")] internal class LocalPlayerAgentSettings_UpdateBlendTowardsTargetFogSetting { public static void Postfix(LocalPlayerAgentSettings __instance, float amount) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!AirManager.Current.HasAirConfig()) { AirPlane.Current.Unregister(); } else { if (__instance.m_targetFogSettings == null || !SNet.LocalPlayer.HasPlayerAgent) { return; } PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent(); if ((Object)(object)localPlayerAgent.FPSCamera == (Object)null) { return; } AirPlane current = AirPlane.Current; if (!((Object)(object)current == (Object)null) && RundownManager.ExpeditionIsStarted) { float num = 0f; Dimension val = default(Dimension); if (Dimension.GetDimension(((Agent)localPlayerAgent).DimensionIndex, ref val)) { num = val.GroundY; } PreLitVolume prelitVolume = localPlayerAgent.FPSCamera.PrelitVolume; ((EffectVolume)current.airPlane).invert = (double)prelitVolume.m_densityHeightMaxBoost > (double)prelitVolume.m_fogDensity; ((EffectVolume)current.airPlane).contents = (eEffectVolumeContents)1; ((EffectVolume)current.airPlane).modification = (eEffectVolumeModification)0; ((EffectVolume)current.airPlane).modificationScale = AirManager.Current.AirLoss(); current.airPlane.lowestAltitude = prelitVolume.m_densityHeightAltitude + num; current.airPlane.highestAltitude = prelitVolume.m_densityHeightAltitude + prelitVolume.m_densityHeightRange + num; AirPlane.Current.Register(); } } } } [HarmonyPatch(typeof(PlayerAgent), "ReceiveModification")] internal class PlayerAgent_ReceiveModification { public static void Prefix(PlayerAgent __instance, ref EV_ModificationData data) { if (AirManager.Current.HasAirConfig()) { if ((double)data.health != 0.0) { AirManager.Current.RemoveAir(data.health); } else { AirManager.Current.AddAir(); } data.health = 0f; } } } } namespace Oxygen.Config { public class ConfigManager { private static readonly JsonSerializerOptions s_SerializerOptions; public static T Deserialize<T>(string json) { return JsonSerializer.Deserialize<T>(json, s_SerializerOptions); } static ConfigManager() { s_SerializerOptions = new JsonSerializerOptions { AllowTrailingCommas = true, ReadCommentHandling = JsonCommentHandling.Skip, PropertyNameCaseInsensitive = true }; s_SerializerOptions.Converters.Add(new JsonStringEnumConverter()); if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized) { s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter); s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter); Log.Message("PartialData Support Found!"); } else { s_SerializerOptions.Converters.Add(new LocalizedTextConverter()); } } public static void Load<T>(string file, out T config) where T : new() { if (file.Length < ".json".Length) { config = default(T); return; } if (file.Substring(file.Length - ".json".Length) != ".json") { file += ".json"; } file = File.ReadAllText(Path.Combine(ConfigManager.CustomPath, "Oxygen", file)); config = Deserialize<T>(file); } } public class AirText { public float x { get; set; } public float y { get; set; } public LocalizedText Text { get; set; } } public class OxygenConfig { public List<OxygenBlock> Blocks { get; set; } = new List<OxygenBlock> { new OxygenBlock() }; } public class OxygenBlock { public float AirLoss { get; set; } public float AirGain { get; set; } = 1f; public float DamageTime { get; set; } = 1f; public float DamageAmount { get; set; } public bool ShatterGlass { get; set; } public float ShatterAmount { get; set; } public float DamageThreshold { get; set; } = 0.1f; public bool AlwaysDisplayAirBar { get; set; } public float HealthRegenProportion { get; set; } = 1f; public float TimeToStartHealthRegen { get; set; } = 3f; public float TimeToCompleteHealthRegen { get; set; } = 5f; public AirText AirText { get; set; } public List<uint> FogSettings { get; set; } = new List<uint> { 0u }; } } namespace Oxygen.Components { public class AirBar : MonoBehaviour { public static AirBar Current; private TextMeshPro m_airText; private TextMeshPro m_airTextLocalization; private float m_airTextX; private float m_airTextY; private float m_airTextZ; private RectTransform m_air1; private RectTransform m_air2; private SpriteRenderer m_airBar1; private SpriteRenderer m_airBar2; private float m_airWidth = 100f; private float m_barHeightMin = 3f; private float m_barHeightMax = 9f; private Color m_airLow = new Color(0f, 0.5f, 0.5f); private Color m_airHigh = new Color(0f, 0.3f, 0.8f); public AirBar(IntPtr value) : base(value) { }//IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) public static void Setup() { if ((Object)(object)Current == (Object)null) { Current = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus).gameObject.AddComponent<AirBar>(); Current.Init(); } } private void Init() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_airText == (Object)null) { m_airText = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_healthText).gameObject.Instantiate<TextMeshPro>("AirText"); TextMeshPro airText = m_airText; ((TMP_Text)airText).fontSize = ((TMP_Text)airText).fontSize / 1.25f; m_airText.transform.Translate(0f, -30f, 0f); } if ((Object)(object)m_airTextLocalization == (Object)null) { m_airTextLocalization = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_pulseText).gameObject.Instantiate<TextMeshPro>("AirText Localization"); ((Behaviour)m_airTextLocalization).enabled = true; m_airTextLocalization.transform.Translate(300f - m_airWidth, -45f, 0f); m_airTextX = m_airTextLocalization.transform.position.x; m_airTextY = m_airTextLocalization.transform.position.y; m_airTextZ = m_airTextLocalization.transform.position.z; } if ((Object)(object)m_air1 == (Object)null) { m_air1 = ((Component)((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_health1).gameObject.transform.parent).gameObject.Instantiate<RectTransform>("AirFill Right"); ((Component)m_air1).transform.Translate(0f, -30f, 0f); SpriteRenderer component = ((Component)((Transform)m_air1).GetChild(0)).GetComponent<SpriteRenderer>(); component.size = new Vector2(m_airWidth, component.size.y); m_airBar1 = ((Component)((Transform)m_air1).GetChild(1)).GetComponent<SpriteRenderer>(); ((Renderer)((Component)((Transform)m_air1).GetChild(2)).GetComponent<SpriteRenderer>()).enabled = false; } if ((Object)(object)m_air2 == (Object)null) { m_air2 = ((Component)((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_health2).gameObject.transform.parent).gameObject.Instantiate<RectTransform>("AirFill Left"); ((Component)m_air2).transform.Translate(0f, 30f, 0f); SpriteRenderer component2 = ((Component)((Transform)m_air2).GetChild(0)).GetComponent<SpriteRenderer>(); component2.size = new Vector2(m_airWidth, component2.size.y); m_airBar2 = ((Component)((Transform)m_air2).GetChild(1)).GetComponent<SpriteRenderer>(); ((Renderer)((Component)((Transform)m_air2).GetChild(2)).GetComponent<SpriteRenderer>()).enabled = false; } UpdateAirBar(1f); SetVisible(vis: false); } public void UpdateAirBar(float air) { SetAirPercentageText(air); SetAirBar(m_airBar1, air); SetAirBar(m_airBar2, air); } private void SetAirBar(SpriteRenderer bar, float val) { //IL_001b: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) bar.size = new Vector2(val * m_airWidth, Mathf.Lerp(m_barHeightMin, m_barHeightMax, val)); bar.color = Color.Lerp(m_airLow, m_airHigh, val); } private void SetAirPercentageText(float val) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0029: 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) Color color = Color.Lerp(m_airLow, m_airHigh, val); ((TMP_Text)m_airText).text = "O<size=75%>2</size>"; ((Graphic)m_airText).color = color; ((TMP_Text)m_airText).ForceMeshUpdate(true, false); ((Graphic)m_airTextLocalization).color = color; ((TMP_Text)m_airTextLocalization).ForceMeshUpdate(true, false); } public void UpdateAirText(OxygenBlock config) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (config != null) { string text = LocalizedText.op_Implicit(config.AirText.Text); float x = config.AirText.x; float y = config.AirText.y; ((TMP_Text)m_airTextLocalization).text = text; ((TMP_Text)m_airTextLocalization).ForceMeshUpdate(true, false); CoroutineManager.BlinkIn(((Component)m_airTextLocalization).gameObject, 0f); m_airTextLocalization.transform.SetPositionAndRotation(new Vector3(m_airTextX + x, m_airTextY + y, m_airTextZ), m_airTextLocalization.transform.rotation); } } public void SetVisible(bool vis) { ((Component)m_airText).gameObject.SetActive(vis); ((Component)m_airTextLocalization).gameObject.SetActive(vis); ((Component)m_air1).gameObject.SetActive(vis); ((Component)m_air2).gameObject.SetActive(vis); } public static void OnLevelCleanup() { if (!((Object)(object)Current == (Object)null)) { Current.SetVisible(vis: false); } } } public class AirManager : MonoBehaviour { public static AirManager Current; public PlayerAgent m_playerAgent; private HUDGlassShatter m_hudGlass; private Dam_PlayerDamageBase Damage; public OxygenBlock config; private uint fogSetting; private FogSettingsDataBlock fogSettingDB; private float airAmount = 1f; private float damageTick; private float glassShatterAmount; private bool m_isInInfectionLoop; private bool isRegeningHealth; private float healthToRegen; private float healthRegenTick; private float tickUntilHealthRegenHealthStart; private readonly float regenHealthTickInterval = 0.25f; private float healthRegenAmountPerInterval; internal bool PlayerShouldCough; private readonly float CoughPerLoss = 0.1f; private float CoughLoss; public AirManager(IntPtr value) : base(value) { } public static void Setup() { if ((Object)(object)Current == (Object)null) { Current = ((Component)PlayerManager.Current.m_localPlayerAgentInLevel).gameObject.AddComponent<AirManager>(); } } public static void OnBuildDone() { if (!((Object)(object)Current == (Object)null)) { Current.m_playerAgent = PlayerManager.GetLocalPlayerAgent(); Current.m_hudGlass = ((Component)Current.m_playerAgent.FPSCamera).GetComponent<HUDGlassShatter>(); Current.Damage = ((Component)Current.m_playerAgent).gameObject.GetComponent<Dam_PlayerDamageBase>(); Current.UpdateAirConfig(RundownManager.ActiveExpedition.Expedition.FogSettings); AirBar.Current.UpdateAirText(Current.config); } } public static void OnLevelCleanup() { if (!((Object)(object)Current == (Object)null)) { if (Current.m_isInInfectionLoop) { Current.StopInfectionLoop(); } Current.config = null; Current.fogSetting = 0u; Current.fogSettingDB = null; Current.airAmount = 0f; Current.damageTick = 0f; Current.glassShatterAmount = 0f; Current.healthToRegen = 0f; Current.m_playerAgent = null; Current.m_hudGlass = null; Current.Damage = null; } } private void Update() { if (!RundownManager.ExpeditionIsStarted) { return; } if (!HasAirConfig()) { AirBar.Current.SetVisible(vis: false); return; } if (airAmount == 1f) { if (config.AlwaysDisplayAirBar) { AirBar.Current.SetVisible(vis: true); } else { AirBar.Current.SetVisible(vis: false); } } else { AirBar.Current.SetVisible(vis: true); } if (airAmount <= config.DamageThreshold) { damageTick += Time.deltaTime; if (damageTick > config.DamageTime && ((Dam_SyncedDamageBase)Damage).Health > 0f && ((Agent)m_playerAgent).Alive) { AirDamage(); } isRegeningHealth = false; } else if (healthToRegen > 0f) { tickUntilHealthRegenHealthStart += Time.deltaTime; if (tickUntilHealthRegenHealthStart > config.TimeToStartHealthRegen) { if (healthRegenAmountPerInterval == 0f) { healthRegenAmountPerInterval = healthToRegen * (regenHealthTickInterval / config.TimeToCompleteHealthRegen); } RegenHealth(); if (!isRegeningHealth) { Damage.m_nextRegen = Clock.Time + config.TimeToStartHealthRegen + config.TimeToCompleteHealthRegen; isRegeningHealth = true; } } } else { isRegeningHealth = false; } } public void AddAir() { if (HasAirConfig()) { float airGain = config.AirGain; airAmount = Mathf.Clamp01(airAmount + airGain); AirBar.Current.UpdateAirBar(airAmount); if (fogSettingDB.Infection <= 0f && m_isInInfectionLoop) { StopInfectionLoop(); } } } public void RemoveAir(float amount) { if (HasAirConfig()) { amount = config.AirLoss; airAmount = Mathf.Clamp01(airAmount - amount); AirBar.Current.UpdateAirBar(airAmount); if (fogSettingDB.Infection <= 0f && amount > 0f) { StartInfectionLoop(); } } } public void AirDamage() { float health = ((Dam_SyncedDamageBase)Damage).Health; float num = config.DamageAmount; if (num > health) { num = ((health > 0f) ? (health - 0.001f) : 0f); } ((Dam_SyncedDamageBase)Damage).NoAirDamage(num); if (config.ShatterGlass) { glassShatterAmount += config.ShatterAmount; m_hudGlass.SetGlassShatterProgression(glassShatterAmount); } damageTick = 0f; tickUntilHealthRegenHealthStart = 0f; healthRegenAmountPerInterval = 0f; healthToRegen += num * config.HealthRegenProportion; CoughLoss += num; if (CoughLoss > CoughPerLoss) { PlayerShouldCough = true; CoughLoss = 0f; } } public void RegenHealth() { if (healthToRegen <= 0f) { return; } tickUntilHealthRegenHealthStart = config.TimeToStartHealthRegen; healthRegenTick += Time.deltaTime; if (healthRegenTick > regenHealthTickInterval) { float num = healthRegenAmountPerInterval; if (num >= healthToRegen) { num = healthToRegen; healthToRegen = 0f; tickUntilHealthRegenHealthStart = 0f; healthRegenAmountPerInterval = 0f; isRegeningHealth = false; } else { healthToRegen -= num; } ((Dam_SyncedDamageBase)Damage).AddHealth(num, (Agent)(object)m_playerAgent); healthRegenTick = 0f; } } public void UpdateAirConfig(uint fogsetting, bool LiveEditForceUpdate = false) { if (fogsetting != 0 && (fogsetting != fogSetting || LiveEditForceUpdate)) { if (Plugin.lookup.ContainsKey(fogsetting)) { config = Plugin.lookup[fogsetting]; } else if (Plugin.lookup.ContainsKey(0u)) { config = Plugin.lookup[0u]; } else { config = null; airAmount = 1f; } fogSetting = fogsetting; fogSettingDB = GameDataBlockBase<FogSettingsDataBlock>.GetBlock(fogsetting); if (GameStateManager.IsInExpedition) { AirBar.Current.UpdateAirText(config); } } } public void ResetHealthToRegen() { healthRegenTick = 0f; healthToRegen = 0f; tickUntilHealthRegenHealthStart = 0f; } public float AirLoss() { if (config != null) { return config.AirLoss; } return 0f; } public bool AlwaysDisplayAirBar() { if (config != null) { return config.AlwaysDisplayAirBar; } return false; } public uint FogSetting() { return fogSetting; } public float HealthToRegen() { return healthToRegen; } public string AirText() { return LocalizedText.op_Implicit((config == null) ? null : config.AirText.Text); } public float AirTextX() { if (config != null) { return config.AirText.x; } return 0f; } public float AirTextY() { if (config != null) { return config.AirText.y; } return 0f; } public bool HasAirConfig() { return config != null; } public void StartInfectionLoop() { if (!m_isInInfectionLoop) { m_playerAgent.Sound.Post(EVENTS.INFECTION_EFFECT_LOOP_START, true); m_isInInfectionLoop = true; } } public void StopInfectionLoop() { if (m_isInInfectionLoop) { if ((Object)(object)m_playerAgent != (Object)null && m_playerAgent.Sound != null) { m_playerAgent.Sound.Post(EVENTS.INFECTION_EFFECT_LOOP_STOP, true); } m_isInInfectionLoop = false; } } } public class AirPlane : MonoBehaviour { public static AirPlane Current; public EV_Plane airPlane; private bool isAirPlaneRegistered; public AirPlane(IntPtr value) : base(value) { } public static void OnBuildStart() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if ((Object)(object)Current == (Object)null) { Current = ((Component)LocalPlayerAgentSettings.Current).gameObject.AddComponent<AirPlane>(); } Current.airPlane = new EV_Plane(); uint num = RundownManager.ActiveExpedition.Expedition.FogSettings; if (num == 0) { num = 21u; } OxygenBlock oxygenBlock = (Plugin.lookup.ContainsKey(num) ? Plugin.lookup[num] : ((!Plugin.lookup.ContainsKey(0u)) ? null : Plugin.lookup[0u])); FogSettingsDataBlock block = GameDataBlockBase<FogSettingsDataBlock>.GetBlock(num); ((EffectVolume)Current.airPlane).invert = block.DensityHeightMaxBoost > block.FogDensity; ((EffectVolume)Current.airPlane).contents = (eEffectVolumeContents)1; ((EffectVolume)Current.airPlane).modification = (eEffectVolumeModification)0; Current.airPlane.lowestAltitude = block.DensityHeightAltitude; Current.airPlane.highestAltitude = block.DensityHeightAltitude + block.DensityHeightRange; if (oxygenBlock != null) { ((EffectVolume)Current.airPlane).modificationScale = oxygenBlock.AirLoss; Current.Register(); } } public static void OnLevelCleanup() { if (!((Object)(object)Current == (Object)null)) { Current.Unregister(); Current.isAirPlaneRegistered = false; Current.airPlane = null; } } public void Register() { if (airPlane != null && !isAirPlaneRegistered) { EffectVolumeManager.RegisterVolume((EffectVolume)(object)airPlane); isAirPlaneRegistered = true; } } public void Unregister() { if (airPlane != null && isAirPlaneRegistered) { EffectVolumeManager.UnregisterVolume((EffectVolume)(object)airPlane); isAirPlaneRegistered = false; } } } }