Decompiled source of ProjectEternal v2.3.0
plugins/ProjectEternal/Custom/AdvancedWardenObjective.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; 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.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using System.Text.RegularExpressions; using AIGraph; using AK; using AWO.CustomFields; using AWO.Jsons; using AWO.Modules.TSL; using AWO.Modules.WEE; using AWO.Modules.WEE.Detours; using AWO.Modules.WEE.Events; using AWO.Modules.WEE.JsonInjects; using AWO.Modules.WEE.Replicators; using AWO.Modules.WOE; using AWO.Networking; using AWO.Networking.Patches; using AWO.Sessions; using AWO.Utils; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Hook; using BepInEx.Unity.IL2CPP.Utils; using BepInEx.Unity.IL2CPP.Utils.Collections; using CellMenu; using ChainedPuzzles; using Enemies; using Expedition; using FluffyUnderware.Curvy.Utils; using GTFO.API; using GTFO.API.Extensions; using GameData; 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.Runtime; using Il2CppJsonNet; using Il2CppJsonNet.Linq; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using InjectLib.FieldInjection; using InjectLib.JsonNETInjection; using InjectLib.JsonNETInjection.Converter; using InjectLib.JsonNETInjection.Handler; using InjectLib.JsonNETInjection.Supports; using LevelGeneration; using Localization; using MTFO.Ext.PartialData; using Microsoft.CodeAnalysis; using Player; using PlayerCoverage; using SNetwork; using SemanticVersioning; using TMPro; using UnityEngine; using UnityEngine.UI; [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 = ".NET 6.0")] [assembly: AssemblyCompany("AdvancedWardenObjective")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("2.2.4")] [assembly: AssemblyInformationalVersion("2.2.4+git460567c-dirty-master.460567cd7114789b68cc515b2e1634433b28abee")] [assembly: AssemblyProduct("AdvancedWardenObjective")] [assembly: AssemblyTitle("AdvancedWardenObjective")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.2.4.0")] [module: UnverifiableCode] 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 AWO { internal static class Configuration { public static bool VerboseEnabled { get; private set; } public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown BindAll(new ConfigFile(Path.Combine(Paths.ConfigPath, "AWO.cfg"), true)); bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Verbose logging is enabled: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(VerboseEnabled); } Logger.Debug(val); } private static void BindAll(ConfigFile config) { string text = "General Settings"; string text2 = "Enable Verbose Debug Logging"; string text3 = "Prints some additional logs to the console, which may be useful for rundown devs"; VerboseEnabled = config.Bind<bool>(text, text2, false, text3).Value; } } [BepInPlugin("GTFO.AWO", "AWO", "2.2.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class EntryPoint : BasePlugin { [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Coroutines { public static float CountdownStarted { get; set; } } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct TimerMods { public static float TimeModifier { get; set; } public static Color TimerColor { get; set; } public static float SpeedModifier { get; set; } public static LocaleText TimerTitleText { get; set; } public static LocaleText TimerBodyText { get; set; } } public static bool PartialDataIsLoaded { get; private set; } = false; public static BlackoutState BlackoutState { get; private set; } = new BlackoutState(); public static SessionRandReplicator SessionRand { get; private set; } = new SessionRandReplicator(); public override void Load() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value) && value.Metadata.Version.CompareTo(new Version(1, 5, 2, (string)null, (string)null)) >= 0) { Logger.Debug("Flowaria's PartialData v1.5.2(+) support found"); PartialDataIsLoaded = true; } Configuration.Init(); WardenEventExt.Initialize(); new Harmony("AWO.Harmony").PatchAll(); AssetAPI.OnStartupAssetsLoaded += delegate { LevelFailUpdateState.AssetLoaded(); }; LevelAPI.OnBuildDone += OnBuildDone; LevelAPI.OnLevelCleanup += OnLevelCleanup; WOEventDataFields.Init(); SerialLookupManager.Init(); Logger.Info("AWO is done loading!"); } private void OnBuildDone() { BlackoutState.Setup(); SessionRand.Setup(1u, RundownManager.GetActiveExpeditionData().sessionSeed); } private void OnLevelCleanup() { _ = WardenObjectiveManager.m_exitEventsTriggered; WardenObjectiveManager.m_exitEventsTriggered = false; BlackoutState.Cleanup(); SessionRand.Cleanup(); } } internal static class Logger { private static readonly ManualLogSource MLS; private const string Dev = "Dev"; static Logger() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown MLS = new ManualLogSource("AWO"); Logger.Sources.Add((ILogSource)(object)MLS); } private static string Format(string module, object msg) { return $"[{module}] {msg}"; } public static void Info(BepInExInfoLogInterpolatedStringHandler handler) { MLS.LogInfo(handler); } public static void Info(string str) { MLS.LogMessage((object)str); } public static void Info(string module, object data) { MLS.LogMessage((object)Format(module, data)); } public static void Debug(BepInExDebugLogInterpolatedStringHandler handler) { MLS.LogDebug(handler); } public static void Debug(string str) { MLS.LogDebug((object)str); } public static void Debug(string module, object data) { MLS.LogDebug((object)Format(module, data)); } public static void Error(BepInExErrorLogInterpolatedStringHandler handler) { MLS.LogError(handler); } public static void Error(string str) { MLS.LogError((object)str); } public static void Error(string module, object data) { MLS.LogError((object)Format(module, data)); } public static void Warn(BepInExWarningLogInterpolatedStringHandler handler) { MLS.LogWarning(handler); } public static void Warn(string str) { MLS.LogWarning((object)str); } public static void Warn(string module, object data) { MLS.LogWarning((object)Format(module, data)); } public static void Verbose(LogLevel level, string data) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0011: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if (!Configuration.VerboseEnabled) { return; } if ((int)level <= 4) { if ((int)level != 2) { if ((int)level == 4) { Warn("Dev", data); } } else { Debug("Dev", data); } } else if ((int)level != 16) { if ((int)level == 32) { Debug("Dev", data); } } else { Info("Dev", data); } } } [GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")] [CompilerGenerated] internal static class VersionInfo { public const string RootNamespace = "AWO"; public const string Version = "2.2.4"; public const string VersionPrerelease = null; public const string VersionMetadata = "git460567c-dirty-master"; public const string SemVer = "2.2.4+git460567c-dirty-master"; public const string GitRevShort = "460567c-dirty"; public const string GitRevLong = "460567cd7114789b68cc515b2e1634433b28abee-dirty"; public const string GitBranch = "master"; public const string GitTag = null; public const bool GitIsDirty = true; } } namespace AWO.Utils { public static class DictionaryExtensions { public static TValue GetOrAddNew<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key) where TValue : new() { if (!dict.TryGetValue(key, out TValue value)) { value = (dict[key] = new TValue()); } return value; } public static void ForEachValue<TKey, TValue>(this Dictionary<TKey, TValue> dict, Action<TValue> action) where TKey : notnull { foreach (TValue value in dict.Values) { action(value); } } public static void ForEachValue<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, Action<TValue> action) where TKey : notnull { foreach (TValue value in dict.Values) { action(value); } } } public static class GameObjectExtensions { public static bool TryAndGetComponent<T>(this GameObject go, out T component) { component = go.GetComponent<T>(); return component != null; } public static T AddOrGetComponent<T>(this GameObject go) where T : Component { if (!go.TryAndGetComponent<T>(out var component)) { return go.AddComponent<T>(); } return component; } public static string GetFullPath(this GameObject go) { StringBuilder stringBuilder = new StringBuilder(((Object)go).name); Transform parent = go.transform.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } } public static class LocalizedTextExtensions { public static string ToText(this LocalizedText text) { return text.HasTranslation ? Text.Get(text.Id) : text.UntranslatedText; } } public static class NumberExtension { public static bool IsPrime(this int num) { if (num < 2) { return false; } if (num % 2 == 0) { return num == 2; } int num2 = (int)Math.Sqrt(num); for (int i = 3; i <= num2; i += 2) { if (num % i == 0) { return false; } } return true; } } public static class RandomExtensions { public static bool MeetProbability(this Random rand, float prob) { if (prob >= 1f) { return true; } if (prob <= 0f) { return false; } return prob >= rand.NextFloat(); } public static float NextRange(this Random rand, float min, float max) { return rand.NextFloat() * (max - min) + min; } public static float NextFloat(this Random rand) { return (float)rand.NextDouble(); } } public static class Vector3Extensions { public static bool IsWithinSqrDistance(this Vector3 a, Vector3 b, float threshold, out float sqrDistance) { //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_0004: 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) Vector3 val = a - b; sqrDistance = ((Vector3)(ref val)).sqrMagnitude; return sqrDistance < threshold * threshold; } public static bool IsApproximatelySqrDistance(this Vector3 a, Vector3 b, float threshold, out float sqrDistance) { //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_0004: 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) Vector3 val = a - b; sqrDistance = ((Vector3)(ref val)).sqrMagnitude; return CurvyUtility.Approximately(sqrDistance, threshold * threshold); } } } namespace AWO.Sessions { internal struct BlackoutStatus { public bool blackoutEnabled; } internal sealed class BlackoutState : IStateReplicatorHolder<BlackoutStatus> { public StateReplicator<BlackoutStatus>? Replicator { get; private set; } public bool BlackoutEnabled { get; private set; } public void Setup() { BlackoutEnabled = false; Replicator = StateReplicator<BlackoutStatus>.Create(1u, new BlackoutStatus { blackoutEnabled = false }, LifeTimeType.Session, this); } public void Cleanup() { BlackoutEnabled = false; Replicator?.Unload(); } public void SetEnabled(bool enabled) { Replicator?.SetState(new BlackoutStatus { blackoutEnabled = enabled }); } public void OnStateChange(BlackoutStatus oldState, BlackoutStatus state, bool isRecall) { //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Invalid comparison between Unknown and I4 //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Invalid comparison between Unknown and I4 bool flag = !state.blackoutEnabled; foreach (LG_LabDisplay item in LG_Objects.TrackedList<LG_LabDisplay>()) { if ((Object)(object)((item != null) ? item.m_Text : null) != (Object)null) { ((Behaviour)item.m_Text).enabled = flag; } } foreach (LG_ComputerTerminal item2 in LG_Objects.TrackedList<LG_ComputerTerminal>()) { if ((Object)(object)item2 == (Object)null) { continue; } item2.OnProximityExit(); Interact_ComputerTerminal componentInChildren = ((Component)item2).GetComponentInChildren<Interact_ComputerTerminal>(true); if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = flag; ((Interact_Base)componentInChildren).SetActive(flag); } if (((Component)item2).gameObject.TryAndGetComponent<GUIX_VirtualSceneLink>(out var component) && (Object)(object)component.m_virtualScene != (Object)null) { GUIX_VirtualCamera virtualCamera = component.m_virtualScene.virtualCamera; float num = (flag ? 0.3f : 0f); float num2 = (flag ? 1000f : 0f); virtualCamera.SetFovAndClip(virtualCamera.paramCamera.fieldOfView, num, num2); } if ((Object)(object)item2.m_text != (Object)null) { ((Behaviour)item2.m_text).enabled = flag; } if (!flag) { PlayerAgent localInteractionSource = item2.m_localInteractionSource; if ((Object)(object)localInteractionSource != (Object)null && localInteractionSource.FPItemHolder.InTerminalTrigger) { item2.ExitFPSView(); } } } foreach (LG_DoorButton item3 in LG_Objects.TrackedList<LG_DoorButton>()) { if ((Object)(object)item3 == (Object)null) { continue; } ((Component)item3.m_anim).gameObject.SetActive(flag); item3.m_enabled = flag; if (flag) { LG_WeakLock componentInChildren2 = ((Component)item3).GetComponentInChildren<LG_WeakLock>(); if ((Object)(object)componentInChildren2 != (Object)null && (int)componentInChildren2.Status != 3) { item3.m_enabled = false; } } } foreach (LG_WeakLock item4 in LG_Objects.TrackedList<LG_WeakLock>()) { if (!((Object)(object)item4 == (Object)null)) { ((Interact_Base)item4.m_intHack).m_isActive = flag; Transform val = ((Component)item4).transform.FindChild("HackableLock/SecurityLock/g_WeakLock/Security_Display_Locked") ?? ((Component)item4).transform.FindChild("HackableLock/Security_Display_Locked"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.active = flag; } } } foreach (LG_HSUActivator_Core item5 in LG_Objects.TrackedList<LG_HSUActivator_Core>()) { if ((Object)(object)item5 == (Object)null || !item5.m_isWardenObjective || (int)item5.m_stateReplicator.State.status != 0) { continue; } item5.m_insertHSUInteraction.SetActive(flag); foreach (GameObject item6 in (Il2CppArrayBase<GameObject>)(object)item5.m_activateWhenActive) { item6.SetActive(flag); } } BlackoutEnabled = state.blackoutEnabled; } } internal enum LevelFailMode { Default, Never, AnyPlayerDown } internal struct LevelFailCheck { public LevelFailMode mode; } internal sealed class LevelFailUpdateState { public static StateReplicator<LevelFailCheck>? Replicator; public static bool LevelFailAllowed { get; private set; } = true; public static bool LevelFailWhenAnyPlayerDown { get; private set; } = false; internal static void AssetLoaded() { Replicator = StateReplicator<LevelFailCheck>.Create(1u, new LevelFailCheck { mode = LevelFailMode.Default }, LifeTimeType.Permanent); LG_Factory.OnFactoryBuildStart += Action.op_Implicit((Action)delegate { Replicator.ClearAllRecallSnapshot(); Replicator.SetState(new LevelFailCheck { mode = LevelFailMode.Default }); }); Replicator.OnStateChanged += OnStateChanged; LevelAPI.OnLevelCleanup += LevelCleanup; } private static void LevelCleanup() { SetFailAllowed(allowed: true); } public static void SetFailAllowed(bool allowed) { Replicator?.SetState(new LevelFailCheck { mode = ((!allowed) ? LevelFailMode.Never : LevelFailMode.Default) }); } public static void SetFailWhenAnyPlayerDown(bool enabled) { Replicator?.SetState(new LevelFailCheck { mode = (enabled ? LevelFailMode.AnyPlayerDown : LevelFailMode.Default) }); } private static void OnStateChanged(LevelFailCheck _, LevelFailCheck state, bool __) { switch (state.mode) { case LevelFailMode.Default: LevelFailAllowed = true; LevelFailWhenAnyPlayerDown = false; break; case LevelFailMode.Never: LevelFailAllowed = false; LevelFailWhenAnyPlayerDown = false; break; case LevelFailMode.AnyPlayerDown: LevelFailAllowed = true; LevelFailWhenAnyPlayerDown = true; break; } } } public static class LG_Objects { public static Dictionary<Type, HashSet<Component>> TrackedTypes { get; private set; } static LG_Objects() { TrackedTypes = new Dictionary<Type, HashSet<Component>> { { typeof(LG_ComputerTerminal), new HashSet<Component>() }, { typeof(LG_DoorButton), new HashSet<Component>() }, { typeof(LG_HSUActivator_Core), new HashSet<Component>() }, { typeof(LG_LabDisplay), new HashSet<Component>() }, { typeof(LG_WeakLock), new HashSet<Component>() } }; LevelAPI.OnLevelCleanup += Clear; } private static void Clear() { TrackedTypes.ForEachValue<Type, HashSet<Component>>(delegate(HashSet<Component> set) { set.Clear(); }); } public static IEnumerable<T> TrackedList<T>() where T : Component { if (TrackedTypes.TryGetValue(typeof(T), out HashSet<Component> value)) { return value.Cast<T>(); } return Enumerable.Empty<T>(); } public static void AddToTrackedList(Component itemToAdd) { if (TrackedTypes.TryGetValue(((object)itemToAdd).GetType(), out HashSet<Component> value)) { value.Add(itemToAdd); } } public static void RemoveFromTrackedList(Component itemToRemove) { if (TrackedTypes.TryGetValue(((object)itemToRemove).GetType(), out HashSet<Component> value)) { value.Remove(itemToRemove); } } } public struct SessionRandState { public uint currentStep; } public sealed class SessionRandReplicator : IStateReplicatorHolder<SessionRandState> { public StateReplicator<SessionRandState>? Replicator { get; private set; } public int Seed { get; private set; } public uint Step { get; private set; } public uint State { get; private set; } public void Setup(uint id, int seed) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown Seed = seed; Step = 0u; State = (uint)Seed; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(12, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SessionSeed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Seed); } Logger.Info(val); Replicator = StateReplicator<SessionRandState>.Create(id, new SessionRandState { currentStep = Step }, LifeTimeType.Session, this); } public void Cleanup() { Step = 0u; Replicator?.Unload(); } public void SyncStep() { Replicator?.SetState(new SessionRandState { currentStep = Step }); } public void OnStateChange(SessionRandState oldState, SessionRandState state, bool isRecall) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (state.currentStep != Step) { bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(47, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Jumping ahead from local step "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(Step); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to session step "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(state.currentStep); } Logger.Debug(val); Step = state.currentStep; Jump(Step); } else { Logger.Verbose((LogLevel)32, "No change in SessionRand step from received state"); } } public uint Next() { Replicator?.SetStateUnsynced(new SessionRandState { currentStep = ++Step }); uint num = (State += 2654435769u); num ^= num >> 16; num *= 569420461; num ^= num >> 15; num *= 1935289751; return num ^ (num >> 15); } public void Jump(ulong steps) { if (steps != 0) { State += (uint)(int)(steps * 2654435769u); } } public int NextInt() { return (int)(Next() & 0x7FFFFFFF); } public int NextInt(int max) { if (max <= 0) { throw new ArgumentOutOfRangeException("max", "max must be positive."); } return (int)(NextFloat() * (float)max); } public int NextInt(int min, int max) { if (min > max) { throw new ArgumentOutOfRangeException("min", "min must be less than or equal to max."); } return min + NextInt(max - min); } public float NextFloat() { return (float)Next() * 2.3283064E-10f; } } } namespace AWO.Sessions.Patches { [HarmonyPatch] internal static class Patch_InteractionOnBlackout { [HarmonyPatch(typeof(LG_ComputerTerminal), "OnProximityEnter")] [HarmonyPatch(typeof(LG_ComputerTerminal), "OnProximityExit")] [HarmonyPatch(typeof(LG_DoorButton), "OnWeakLockUnlocked")] [HarmonyPrefix] private static bool Pre_ToggleInteraction() { return !EntryPoint.BlackoutState.BlackoutEnabled; } } [HarmonyPatch] internal static class Patch_LevelFailCheck { [HarmonyPatch(typeof(WardenObjectiveManager), "CheckExpeditionFailed")] [HarmonyPostfix] [HarmonyAfter(new string[] { })] private static void Post_CheckLevelFail(ref bool __result) { if (!LevelFailUpdateState.LevelFailAllowed) { __result = false; } else if (LevelFailUpdateState.LevelFailWhenAnyPlayerDown && HasAnyDownedPlayer()) { __result = true; } } private static bool HasAnyDownedPlayer() { Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (!((Agent)current).Alive) { return true; } } return false; } } [HarmonyPatch] internal static class Patch_LG_ObjectsTrack { [HarmonyTargetMethods] private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(LG_ComputerTerminal), "Setup", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(LG_DoorButton), "Setup", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(LG_HSUActivator_Core), "Start", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(LG_LabDisplay), "GenerateText", new Type[2] { typeof(int), typeof(SubComplex) }, (Type[])null); yield return AccessTools.Method(typeof(LG_WeakLock), "Setup", (Type[])null, (Type[])null); } [HarmonyPostfix] private static void Post_TrackObject(Component __instance) { LG_Objects.AddToTrackedList(__instance); } } } namespace AWO.Networking { public interface IStateReplicatorHolder<S> where S : struct { StateReplicator<S>? Replicator { get; } void OnStateChange(S oldState, S state, bool isRecall); } public sealed class ReplicatorHandshake { public delegate void ClientRequestedSyncDel(SNet_Player requestedPlayer); public struct Packet { public uint replicatorID; public PacketAction action; } public enum PacketAction : byte { Created, Destroyed, SyncRequest } public sealed class Data { public bool SetupOnHost = false; public bool SetupOnClient = false; } private readonly Dictionary<uint, Data> _Lookup = new Dictionary<uint, Data>(); public string EventName { get; private set; } public bool IsReadyToSync { get; private set; } public event ClientRequestedSyncDel OnClientSyncRequested; public static ReplicatorHandshake Create(string guid) { if (string.IsNullOrWhiteSpace(guid)) { return null; } string text = "RHs" + guid; return NetworkAPI.IsEventRegistered(text) ? null : new ReplicatorHandshake(text); } private ReplicatorHandshake(string eventName) { EventName = eventName; NetworkAPI.RegisterEvent<Packet>(eventName, (Action<ulong, Packet>)OnSyncAction); Patch_OnRecallDone.OnRecallDone += delegate { Logger.Warn("ReplicatorHandshake: Client sending sync request"); ClientSyncRequest(); }; } private void ClientSyncRequest() { if (SNet.IsMaster) { return; } foreach (uint key in _Lookup.Keys) { NetworkAPI.InvokeEvent<Packet>(EventName, new Packet { replicatorID = key, action = PacketAction.SyncRequest }, SNet.Master, (SNet_ChannelType)2); } } public void Reset() { _Lookup.Clear(); } private void OnSyncAction(ulong sender, Packet packet) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown if (!SNet.IsMaster && sender == SNet.Master.Lookup) { if (packet.action == PacketAction.Created) { SetHostState(packet.replicatorID, isSetup: true); } else if (packet.action == PacketAction.Destroyed) { SetHostState(packet.replicatorID, isSetup: false); } } else { if (!SNet.IsMaster) { return; } if (packet.action == PacketAction.Created) { SetClientState(packet.replicatorID, isSetup: true); } else if (packet.action == PacketAction.Destroyed) { SetClientState(packet.replicatorID, isSetup: false); } else { if (packet.action != PacketAction.SyncRequest) { return; } SNet_Player requestedPlayer = default(SNet_Player); if (!SNet.TryGetPlayer(sender, ref requestedPlayer)) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot find player from sender: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(sender); } Logger.Error(val); } else { this.OnClientSyncRequested?.Invoke(requestedPlayer); } } } } public void UpdateCreated(uint id) { if (SNet.IsInLobby) { if (SNet.IsMaster) { SetHostState(id, isSetup: true); NetworkAPI.InvokeEvent<Packet>(EventName, new Packet { replicatorID = id, action = PacketAction.Created }, (SNet_ChannelType)2); } else if (SNet.HasMaster) { SetClientState(id, isSetup: true); NetworkAPI.InvokeEvent<Packet>(EventName, new Packet { replicatorID = id, action = PacketAction.Created }, SNet.Master, (SNet_ChannelType)2); } else { Logger.Error("Handshake::MASTER is NULL in lobby; This should NOT happen!!!!!!!!!!!!"); } } else { Logger.Error("Handshake::Session Type StateReplicator cannot be created without lobby!"); } } public void UpdateDestroyed(uint id) { if (SNet.IsInLobby) { if (SNet.IsMaster) { SetHostState(id, isSetup: true); NetworkAPI.InvokeEvent<Packet>(EventName, new Packet { replicatorID = id, action = PacketAction.Destroyed }, (SNet_ChannelType)2); } else if (SNet.HasMaster) { SetClientState(id, isSetup: true); NetworkAPI.InvokeEvent<Packet>(EventName, new Packet { replicatorID = id, action = PacketAction.Destroyed }, SNet.Master, (SNet_ChannelType)2); } else { Logger.Error("Handshake::MASTER is NULL in lobby; This should NOT happen!!!!!!!!!!!!"); } } else { Logger.Error("Handshake::Session Type StateReplicator cannot be created without lobby!"); } } private void SetHostState(uint id, bool isSetup) { if (_Lookup.TryGetValue(id, out Data value)) { value.SetupOnHost = isSetup; } else { _Lookup[id] = new Data { SetupOnHost = isSetup }; } UpdateSyncState(id); } private void SetClientState(uint id, bool isSetup) { if (_Lookup.TryGetValue(id, out Data value)) { value.SetupOnClient = isSetup; } else { _Lookup[id] = new Data { SetupOnClient = isSetup }; } UpdateSyncState(id); } private void UpdateSyncState(uint id) { bool isReadyToSync = IsReadyToSync; if (_Lookup.TryGetValue(id, out Data value)) { IsReadyToSync = value.SetupOnHost && value.SetupOnClient; } else { IsReadyToSync = false; } if (IsReadyToSync && isReadyToSync != IsReadyToSync && SNet.HasMaster && !SNet.IsMaster) { NetworkAPI.InvokeEvent<Packet>(EventName, new Packet { replicatorID = id, action = PacketAction.SyncRequest }, SNet.Master, (SNet_ChannelType)2); } } } public delegate void OnReceiveDel<S>(ulong sender, uint replicatorID, S newState) where S : struct; public static class StatePayloads { public enum Size { State4Byte = 4, State8Byte = 8, State16Byte = 16, State32Byte = 32, State48Byte = 48, State64Byte = 64, State80Byte = 80, State96Byte = 96, State128Byte = 128, State196Byte = 196, State256Byte = 256 } public static Size GetSizeType(int size) { Size size2 = Size.State8Byte; foreach (object value in Enum.GetValues(typeof(Size))) { if (size <= (int)value && (int)size2 < (int)value) { size2 = (Size)value; break; } } return size2; } public static IReplicatorEvent<S> CreateEvent<S>(Size size, string eventName, OnReceiveDel<S> onReceiveCallback) where S : struct { return size switch { Size.State4Byte => ReplicatorPayloadWrapper<S, StatePayload4Byte>.Create(eventName, onReceiveCallback), Size.State8Byte => ReplicatorPayloadWrapper<S, StatePayload8Byte>.Create(eventName, onReceiveCallback), Size.State16Byte => ReplicatorPayloadWrapper<S, StatePayload16Byte>.Create(eventName, onReceiveCallback), Size.State32Byte => ReplicatorPayloadWrapper<S, StatePayload32Byte>.Create(eventName, onReceiveCallback), Size.State48Byte => ReplicatorPayloadWrapper<S, StatePayload48Byte>.Create(eventName, onReceiveCallback), Size.State64Byte => ReplicatorPayloadWrapper<S, StatePayload64Byte>.Create(eventName, onReceiveCallback), Size.State80Byte => ReplicatorPayloadWrapper<S, StatePayload80Byte>.Create(eventName, onReceiveCallback), Size.State96Byte => ReplicatorPayloadWrapper<S, StatePayload96Byte>.Create(eventName, onReceiveCallback), Size.State128Byte => ReplicatorPayloadWrapper<S, StatePayload128Byte>.Create(eventName, onReceiveCallback), Size.State196Byte => ReplicatorPayloadWrapper<S, StatePayload196Byte>.Create(eventName, onReceiveCallback), Size.State256Byte => ReplicatorPayloadWrapper<S, StatePayload256Byte>.Create(eventName, onReceiveCallback), _ => null, }; } public static S Get<S>(byte[] bytes, int bytesLength) where S : struct { int num = Marshal.SizeOf(typeof(S)); if (num > bytesLength) { throw new ArgumentException($"StateData Exceed size of {bytesLength} : Unable to Deserialize", "S"); } IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.Copy(bytes, 0, intPtr, num); S result = (S)Marshal.PtrToStructure(intPtr, typeof(S)); Marshal.FreeHGlobal(intPtr); return result; } public static void Set<S>(S stateData, int size, ref byte[] payloadBytes) where S : struct { int num = Marshal.SizeOf(stateData); if (num > size) { throw new ArgumentException($"StateData Exceed size of {size} : Unable to Serialize", "S"); } byte[] array = new byte[size]; IntPtr intPtr = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(stateData, intPtr, fDeleteOld: false); Marshal.Copy(intPtr, array, 0, size); Marshal.FreeHGlobal(intPtr); payloadBytes = array; } } public interface IReplicatorEvent<S> where S : struct { string Name { get; } bool IsRegistered { get; } void Invoke(uint replicatorID, S data); void Invoke(uint replicatorID, S data, SNet_ChannelType channelType); void Invoke(uint replicatorID, S data, SNet_Player target); void Invoke(uint replicatorID, S data, SNet_Player target, SNet_ChannelType channelType); } public class ReplicatorPayloadWrapper<S, P> : IReplicatorEvent<S> where S : struct where P : struct, IStatePayload { public string Name { get; private set; } public bool IsRegistered { get; private set; } = false; public static IReplicatorEvent<S> Create(string eventName, OnReceiveDel<S> onReceiveCallback) { ReplicatorPayloadWrapper<S, P> replicatorPayloadWrapper = new ReplicatorPayloadWrapper<S, P>(); replicatorPayloadWrapper.Register(eventName, onReceiveCallback); object result; if (!replicatorPayloadWrapper.IsRegistered) { result = null; } else { IReplicatorEvent<S> replicatorEvent = replicatorPayloadWrapper; result = replicatorEvent; } return (IReplicatorEvent<S>)result; } public void Register(string eventName, OnReceiveDel<S> onReceiveCallback) { OnReceiveDel<S> onReceiveCallback2 = onReceiveCallback; if (!IsRegistered && !NetworkAPI.IsEventRegistered(eventName)) { NetworkAPI.RegisterEvent<P>(eventName, (Action<ulong, P>)delegate(ulong sender, P payload) { onReceiveCallback2?.Invoke(sender, payload.ID, payload.Get<S>()); }); IsRegistered = true; Name = eventName; } } public void Invoke(uint replicatorID, S data) { P val = new P { ID = replicatorID }; val.Set(data); NetworkAPI.InvokeEvent<P>(Name, val, (SNet_ChannelType)2); } public void Invoke(uint replicatorID, S data, SNet_ChannelType channelType) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) P val = new P { ID = replicatorID }; val.Set(data); NetworkAPI.InvokeEvent<P>(Name, val, channelType); } public void Invoke(uint replicatorID, S data, SNet_Player target) { P val = new P { ID = replicatorID }; val.Set(data); NetworkAPI.InvokeEvent<P>(Name, val, target, (SNet_ChannelType)2); } public void Invoke(uint replicatorID, S data, SNet_Player target, SNet_ChannelType channelType) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) P val = new P { ID = replicatorID }; val.Set(data); NetworkAPI.InvokeEvent<P>(Name, val, target, channelType); } } public interface IStatePayload { uint ID { get; set; } S Get<S>() where S : struct; void Set<S>(S stateData) where S : struct; } public struct StatePayload4Byte : IStatePayload { public const int Size = 4; private uint id; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] PayloadBytes; public uint ID { get { return id; } set { id = value; } } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 4); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 4, ref PayloadBytes); } } public struct StatePayload8Byte : IStatePayload { public const int Size = 8; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 8); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 8, ref PayloadBytes); } } public struct StatePayload16Byte : IStatePayload { public const int Size = 16; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 16); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 16, ref PayloadBytes); } } public struct StatePayload32Byte : IStatePayload { public const int Size = 32; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 32); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 32, ref PayloadBytes); } } public struct StatePayload48Byte : IStatePayload { public const int Size = 48; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 48); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 48, ref PayloadBytes); } } public struct StatePayload64Byte : IStatePayload { public const int Size = 64; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 64); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 64, ref PayloadBytes); } } public struct StatePayload80Byte : IStatePayload { public const int Size = 80; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 80); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 80, ref PayloadBytes); } } public struct StatePayload96Byte : IStatePayload { public const int Size = 96; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 96)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 96); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 96, ref PayloadBytes); } } public struct StatePayload128Byte : IStatePayload { public const int Size = 128; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 128); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 128, ref PayloadBytes); } } public struct StatePayload196Byte : IStatePayload { public const int Size = 196; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 196)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 196); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 196, ref PayloadBytes); } } public struct StatePayload256Byte : IStatePayload { public const int Size = 256; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] PayloadBytes; [field: MarshalAs(UnmanagedType.U4)] public uint ID { get; set; } public S Get<S>() where S : struct { return StatePayloads.Get<S>(PayloadBytes, 256); } public void Set<S>(S stateData) where S : struct { StatePayloads.Set(stateData, 256, ref PayloadBytes); } } public enum LifeTimeType { Permanent, Session } public sealed class StateReplicator<S> where S : struct { private readonly Dictionary<eBufferType, S> _RecallStateSnapshots = new Dictionary<eBufferType, S>(); public static readonly string Name; public static readonly string HashName; public static readonly string ClientRequestEventName; public static readonly string HostSetStateEventName; public static readonly string HostSetRecallStateEventName; public static readonly int StateSize; public static readonly StatePayloads.Size StateSizeType; private static readonly IReplicatorEvent<S> _C_RequestEvent; private static readonly IReplicatorEvent<S> _H_SetStateEvent; private static readonly IReplicatorEvent<S> _H_SetRecallStateEvent; private static readonly ReplicatorHandshake _Handshake; private static readonly Dictionary<uint, StateReplicator<S>> _Replicators; public bool IsValid => ID != 0; public bool IsInvalid => ID == 0; public uint ID { get; private set; } public LifeTimeType LifeTime { get; private set; } public IStateReplicatorHolder<S> Holder { get; private set; } public S State { get; private set; } public bool ClientSendStateAllowed { get; set; } = true; public bool CanSendToClient => SNet.IsInLobby && SNet.IsMaster; public bool CanSendToHost => SNet.IsInLobby && !SNet.IsMaster && SNet.HasMaster && ClientSendStateAllowed; public event Action<S, S, bool> OnStateChanged; public void SetState(S state) { if (!IsInvalid) { DoSync(state); } } public void SetStateUnsynced(S state) { if (!IsInvalid) { State = state; } } public void Unload() { if (IsValid) { _Replicators.Remove(ID); _RecallStateSnapshots.Clear(); _Handshake.UpdateDestroyed(ID); ID = 0u; } } private void DoSync(S newState) { if (!IsInvalid) { if (CanSendToClient) { _H_SetStateEvent.Invoke(ID, newState); Internal_ChangeState(newState, isRecall: false); } else if (CanSendToHost) { _C_RequestEvent.Invoke(ID, newState, SNet.Master); } } } private void Internal_ChangeState(S state, bool isRecall) { if (!IsInvalid) { S state2 = State; State = state; this.OnStateChanged?.Invoke(state2, state, isRecall); Holder?.OnStateChange(state2, state, isRecall); } } private void SendDropInState(SNet_Player target) { if (!IsInvalid) { if ((Object)(object)target == (Object)null) { Logger.Error("SendDropInState::Target was null??"); } else { _H_SetRecallStateEvent.Invoke(ID, State, target); } } } public void ClearAllRecallSnapshot() { if (!IsInvalid) { _RecallStateSnapshots.Clear(); } } private void SaveSnapshot(eBufferType type) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!IsInvalid) { _RecallStateSnapshots[type] = State; } } private void RestoreSnapshot(eBufferType type) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (IsInvalid || !CanSendToClient) { return; } if (_RecallStateSnapshots.TryGetValue(type, out var value)) { _H_SetRecallStateEvent.Invoke(ID, value); Internal_ChangeState(value, isRecall: true); return; } bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RestoreSnapshot"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("::There was no snapshot for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eBufferType>(type); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("?"); } Logger.Error(val); } static StateReplicator() { _Replicators = new Dictionary<uint, StateReplicator<S>>(); Name = typeof(S).Name; StateSize = Marshal.SizeOf(typeof(S)); StateSizeType = StatePayloads.GetSizeType(StateSize); using MD5 mD = MD5.Create(); byte[] inArray = mD.ComputeHash(Encoding.UTF8.GetBytes(typeof(S).FullName)); HashName = Convert.ToBase64String(inArray); ClientRequestEventName = "SRs" + Name + "-" + HashName; HostSetStateEventName = "SRr" + Name + "-" + HashName; HostSetRecallStateEventName = "SRre" + Name + "-" + HashName; _C_RequestEvent = StatePayloads.CreateEvent<S>(StateSizeType, ClientRequestEventName, ClientRequestEventCallback); _H_SetStateEvent = StatePayloads.CreateEvent<S>(StateSizeType, HostSetStateEventName, HostSetStateEventCallback); _H_SetRecallStateEvent = StatePayloads.CreateEvent<S>(StateSizeType, HostSetRecallStateEventName, HostSetRecallStateEventCallback); _Handshake = ReplicatorHandshake.Create(Name + "-" + HashName); _Handshake.OnClientSyncRequested += ClientSyncRequested; Patch_SNet_Capture.OnBufferCapture += BufferStored; Patch_SNet_Capture.OnBufferRecalled += BufferRecalled; LevelAPI.OnLevelCleanup += LevelCleanedUp; } private static void ClientSyncRequested(SNet_Player requestedPlayer) { foreach (StateReplicator<S> value in _Replicators.Values) { if (value.IsValid) { value.SendDropInState(requestedPlayer); } } } private static void BufferStored(eBufferType type) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) foreach (StateReplicator<S> value in _Replicators.Values) { if (value.IsValid) { value.SaveSnapshot(type); } } } private static void BufferRecalled(eBufferType type) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) foreach (StateReplicator<S> value in _Replicators.Values) { if (value.IsValid) { value.RestoreSnapshot(type); } } } private static void LevelCleanedUp() { UnloadSessionReplicator(); } private StateReplicator() { } public static StateReplicator<S> Create(uint replicatorID, S startState, LifeTimeType lifeTime, IStateReplicatorHolder<S> holder = null) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown if (replicatorID == 0) { Logger.Error("Replicator ID 0 is reserved for empty!"); return null; } if (_Replicators.ContainsKey(replicatorID)) { Logger.Error("Replicator ID has already assigned!"); return null; } StateReplicator<S> stateReplicator = new StateReplicator<S> { ID = replicatorID, LifeTime = lifeTime, Holder = holder, State = startState }; switch (lifeTime) { case LifeTimeType.Permanent: Logger.Debug("LifeTime is Permanent :: Handshaking is disabled!"); break; case LifeTimeType.Session: _Handshake.UpdateCreated(replicatorID); break; default: { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LifeTime is invalid!: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<LifeTimeType>(lifeTime); } Logger.Error(val); return null; } } _Replicators[replicatorID] = stateReplicator; return stateReplicator; } public static void UnloadSessionReplicator() { List<uint> list = new List<uint>(); foreach (StateReplicator<S> value in _Replicators.Values) { if (value.LifeTime == LifeTimeType.Session) { list.Add(value.ID); value.Unload(); } } foreach (uint item in list) { _Replicators.Remove(item); } _Handshake.Reset(); } private static void ClientRequestEventCallback(ulong sender, uint replicatorID, S newState) { if (SNet.IsMaster && _Replicators.TryGetValue(replicatorID, out StateReplicator<S> value)) { value.SetState(newState); } } private static void HostSetStateEventCallback(ulong sender, uint replicatorID, S newState) { if (SNet.HasMaster && SNet.Master.Lookup == sender && _Replicators.TryGetValue(replicatorID, out StateReplicator<S> value)) { value.Internal_ChangeState(newState, isRecall: false); } } private static void HostSetRecallStateEventCallback(ulong sender, uint replicatorID, S newState) { if (SNet.HasMaster && SNet.Master.Lookup == sender && _Replicators.TryGetValue(replicatorID, out StateReplicator<S> value)) { value.Internal_ChangeState(newState, isRecall: true); } } } } namespace AWO.Networking.Patches { [HarmonyPatch(typeof(SNet_Capture))] internal static class Patch_OnRecallDone { public static event Action? OnRecallDone; [HarmonyPostfix] [HarmonyPatch(typeof(SNet_SyncManager), "OnRecallDone")] private static void Post_OnRecallDone() { Patch_OnRecallDone.OnRecallDone?.Invoke(); } } [HarmonyPatch(typeof(SNet_Capture))] internal static class Patch_SNet_Capture { public static event Action<eBufferType>? OnBufferCapture; public static event Action<eBufferType>? OnBufferRecalled; [HarmonyPatch("TriggerCapture")] [HarmonyPrefix] [HarmonyWrapSafe] private static void Pre_TriggerCapture(SNet_Capture __instance) { //IL_0002: 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_0013: Unknown result type (might be due to invalid IL or missing references) eBufferType primedBufferType = __instance.PrimedBufferType; Patch_SNet_Capture.OnBufferCapture?.Invoke(primedBufferType); } [HarmonyPatch("RecallBuffer")] [HarmonyPostfix] [HarmonyWrapSafe] private static void Post_RecallBuffer(SNet_Capture __instance, eBufferType bufferType) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsRecalling) { Patch_SNet_Capture.OnBufferRecalled?.Invoke(bufferType); } } } } namespace AWO.Modules.WOE { [Obsolete] public static class WardenObjectiveExt { private static readonly Dictionary<eWardenObjectiveType, Type> _DTOTypes; private static readonly List<WOE_ContextBase> _ActiveContexts; static WardenObjectiveExt() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown _DTOTypes = new Dictionary<eWardenObjectiveType, Type>(); _ActiveContexts = new List<WOE_ContextBase>(); IEnumerable<Type> enumerable = from x in typeof(WOE_ContextBase).Assembly.GetTypes() where !x.IsAbstract where x.IsAssignableTo(typeof(WOE_ContextBase)) select x; bool flag = default(bool); foreach (Type item in enumerable) { WOE_ContextBase wOE_ContextBase = (WOE_ContextBase)Activator.CreateInstance(item); if (_DTOTypes.TryGetValue(wOE_ContextBase.TargetType, out Type _)) { Logger.Error("Duplicate TargetType Detected!"); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("With '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' and '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(wOE_ContextBase.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'"); } Logger.Error(val); } else if (!wOE_ContextBase.DataType.IsAssignableTo(typeof(WOE_DataBase))) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" does not have valid "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("DataType"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (not derived from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("WOE_DataBase"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } Logger.Error(val); } else { _DTOTypes[wOE_ContextBase.TargetType] = item; } } WOEvents.OnSetup += ObjectiveSetup; LevelAPI.OnLevelCleanup += LevelCleanup; } internal static void Initialize() { } private static void ObjectiveSetup(LG_LayerType layer, int chainIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0083: 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) WardenObjectiveDataBlock val = default(WardenObjectiveDataBlock); Type value; if (!WardenObjectiveManager.TryGetWardenObjectiveDataForLayer(layer, chainIndex, ref val)) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(44, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<LG_LayerType>(layer); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Layer (CI: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(chainIndex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") does not have ObjectiveData!!!"); } Logger.Error(val2); } else if (_DTOTypes.TryGetValue(val.Type, out value)) { WOE_ContextBase wOE_ContextBase = (WOE_ContextBase)Activator.CreateInstance(value); wOE_ContextBase.Setup(layer, chainIndex); _ActiveContexts.Add(wOE_ContextBase); } } private static void LevelCleanup() { foreach (WOE_ContextBase activeContext in _ActiveContexts) { activeContext.OnLevelCleanup(); } _ActiveContexts.Clear(); } } public delegate void SetupObjectiveDel(LG_LayerType layer, int chainIndex); [Obsolete] internal static class WOEvents { public static event SetupObjectiveDel? OnSetup; internal static void Invoke_OnSetup(LG_LayerType layer, int chainIndex) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) WOEvents.OnSetup?.Invoke(layer, chainIndex); } } [Obsolete] internal abstract class WOE_ContextBase { public abstract eWardenObjectiveType TargetType { get; } public abstract Type DataType { get; } protected WOE_DataBase? Data { get; private set; } protected LG_LayerType Layer { get; private set; } protected int ChainIndex { get; private set; } public void Setup(LG_LayerType layer, int chainIndex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Layer = layer; ChainIndex = chainIndex; } public virtual void OnSetup() { } public virtual void OnBuildDone() { } public virtual void OnBuildDoneLate() { } public virtual void OnLevelCleanup() { } } [Obsolete] internal abstract class WOE_DataBase { public uint ObjectiveID { get; set; } public WardenObjectiveDataBlock? GameData { get; set; } } } namespace AWO.Modules.WOE.Objectives.Uplinks { [Obsolete] internal sealed class WOE_UplinkContext : WOE_ContextBase { public override eWardenObjectiveType TargetType => (eWardenObjectiveType)8; public override Type DataType => typeof(WOE_UplinkData); } [Obsolete] internal sealed class WOE_UplinkData : WOE_DataBase { public UplinkCodeBehaviour[] CodeBehaviours { get; set; } = Array.Empty<UplinkCodeBehaviour>(); } internal sealed class UplinkCodeBehaviour { public bool ShowCodesOnTerminal { get; set; } = false; public bool ShowCodesOnHUD { get; set; } = true; public bool ShowCodeToOtherTerminal { get; set; } = true; public TerminalZoneSelectionData TerminalZone { get; set; } = new TerminalZoneSelectionData(); public TerminalOutput[] StartOutputs { get; set; } = Array.Empty<TerminalOutput>(); public TerminalOutput[] EndOutputs { get; set; } = Array.Empty<TerminalOutput>(); public WardenObjectiveEventData[] EventsOnStart { get; set; } = Array.Empty<WardenObjectiveEventData>(); public WardenObjectiveEventData[] EventsOnEnd { get; set; } = Array.Empty<WardenObjectiveEventData>(); } } namespace AWO.Modules.WOE.Objectives.ReactorStartups { [Obsolete] internal sealed class WOE_ReactorStartupContext : WOE_ContextBase { public override eWardenObjectiveType TargetType => (eWardenObjectiveType)1; public override Type DataType => typeof(WOE_ReactorStartupData); } internal enum ReactorWavePuzzleType { Default, CustomLock, UseCommand_OnMainTerminal, UseCommand_InZone, PowerGenerator_InZone } [Obsolete] internal sealed class WOE_ReactorStartupData : WOE_DataBase { public bool RemoveMainStartupCommand { get; set; } = false; public bool RemoveMainVerifyCommand { get; set; } = false; public ScriptedWaveData[] WaveDatas { get; set; } = Array.Empty<ScriptedWaveData>(); public ReactorWavePuzzleData[] WavePuzzles { get; set; } = Array.Empty<ReactorWavePuzzleData>(); } internal enum SettingWarpMode { Clamped, Repeat, PingPong } internal sealed class ScriptedWaveData { public float[] IntroDuration { get; set; } = Array.Empty<float>(); public SettingWarpMode IntroDurationWarpMode { get; set; } = SettingWarpMode.Clamped; public float[] WaveDuration { get; set; } = Array.Empty<float>(); public SettingWarpMode WaveDurationWarpMode { get; set; } = SettingWarpMode.Clamped; public string[][] WaveInstructions { get; set; } = Array.Empty<string[]>(); public SettingWarpMode WaveInstructionsWarpMode { get; set; } = SettingWarpMode.Clamped; } internal sealed class ReactorWavePuzzleData { public ReactorWavePuzzleType Type { get; set; } = ReactorWavePuzzleType.Default; public bool ShowBeacon { get; set; } = false; public string BeaconText { get; set; } = "Auxiliary Terminal"; public Color BeaconColor { get; set; } = Color.magenta; public string Command { get; set; } = "REACTOR_CONTINUE"; public string CommandDescription { get; set; } = "CONTINUE REACTOR STARTUP PROCESS"; public bool ForceJumpWaveWhenSolved { get; set; } = true; } } namespace AWO.Modules.WOE.Objectives.GenClusters { [Obsolete] internal sealed class WOE_GenClusterContext : WOE_ContextBase { public override eWardenObjectiveType TargetType => (eWardenObjectiveType)9; public override Type DataType => typeof(int); } } namespace AWO.Modules.WOE.JsonInjects { [Obsolete] internal class ObjectiveDataHandler : Il2CppJsonReferenceTypeHandler<WardenObjectiveDataBlock> { public override void OnRead(in Object result, in JToken jToken) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 if ((int)jToken.Type == 1) { JObject val = (JObject)jToken; JToken val2 = default(JToken); if (val.TryGetValue("woeEnabled", ref val2) && (int)val2.Type == 9 && (bool)val2) { WardenObjectiveDataBlock val3 = ((Il2CppObjectBase)result).Cast<WardenObjectiveDataBlock>(); } } } } } namespace AWO.Modules.WEE { internal static class VanillaEventOvr { internal static bool HasOverride(eWardenObjectiveEventType type, WardenObjectiveEventData e) { //IL_0002: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 bool flag = e.Position != Vector3.zero; if (type - 3 > 1) { if ((int)type != 5) { if ((int)type == 16) { return flag || e.Count > 0; } return false; } return flag; } return (int)e.DimensionIndex > 0; } internal static void HandleEvent(eWardenObjectiveEventType type, WardenObjectiveEventData e, float currentDuration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Handle(type, e, currentDuration)), (Action)null); } private static IEnumerator Handle(eWardenObjectiveEventType type, WardenObjectiveEventData e, float currentDuration) { //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) float delay = Mathf.Max(e.Delay - currentDuration, 0f); if (delay > 0f) { yield return (object)new WaitForSeconds(delay); } if (WorldEventManager.GetCondition(e.Condition.ConditionIndex) != e.Condition.IsTrue) { Logger.Verbose((LogLevel)32, $"Condition {e.Condition.ConditionIndex} is not met"); yield break; } WardenObjectiveManager.DisplayWardenIntel(e.Layer, e.WardenIntel); if (e.DialogueID != 0) { PlayerDialogManager.WantToStartDialog(e.DialogueID, -1, false, false); } if (e.SoundID != 0) { PlaySound(e); } if (!SNet.IsMaster) { yield break; } switch (type - 3) { case 1: ToggleDimensionLights(mode: true, e.DimensionIndex); yield break; case 0: ToggleDimensionLights(mode: false, e.DimensionIndex); yield break; case 2: yield break; } if ((int)type == 16) { CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(SpawnEnemyOnPoint(e)), (Action)null); } } private static void PlaySound(WardenObjectiveEventData e) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((int)e.Type != 5) { WardenObjectiveManager.Current.m_sound.Post(e.SoundID, true); } else { CellSoundPlayer val = new CellSoundPlayer(); val.Post(e.SoundID, e.Position, 1u, EventCallback.op_Implicit((Action<Object, AkCallbackType, AkCallbackInfo>)SoundDoneCallback), (Object)(object)val); } string text = ((Object)e.SoundSubtitle).ToString(); if (!string.IsNullOrWhiteSpace(text)) { GuiManager.PlayerLayer.ShowMultiLineSubtitle(text); } } private static void SoundDoneCallback(Object in_cookie, AkCallbackType in_type, AkCallbackInfo callbackInfo) { CellSoundPlayer val = ((Il2CppObjectBase)in_cookie).Cast<CellSoundPlayer>(); if (val != null) { val.Recycle(); } } private static void ToggleDimensionLights(bool mode, eDimensionIndex dimension) { //IL_0003: 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_001b: 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_0021: 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_0033: Unknown result type (might be due to invalid IL or missing references) pEnvironmentInteraction val = default(pEnvironmentInteraction); val.EnvironmentStateChangeType = (EnvironmentStateChangeType)1; val.LightsEnabled = mode; val.DimensionIndex = dimension; pEnvironmentInteraction val2 = val; EnvironmentStateManager.LogEnvironmentState("VEO SetLightMode Attempt"); EnvironmentStateManager.Current.AttemptInteract(val2); } private static IEnumerator SpawnEnemyOnPoint(WardenObjectiveEventData e) { int count = ((e.Count < 2) ? 1 : e.Count); LG_WorldEventObject weObject = default(LG_WorldEventObject); Vector3 pos = (WorldEventUtils.TryGetRandomWorldEventObjectFromFilter(e.WorldEventObjectFilter, (uint)Builder.SessionSeedRandom.Seed, ref weObject) ? ((Component)weObject).gameObject.transform.position : e.Position); AIG_CourseNode courseNode = default(AIG_CourseNode); if (!Dimension.TryGetCourseNodeFromPos(pos, ref courseNode)) { Logger.Error("SpawnEnemyOnPoint", "Failed to find valid CourseNode from Position!"); yield break; } AgentMode val = ((!e.Enabled) ? ((e.EnemyID != 20) ? ((AgentMode)4) : ((AgentMode)3)) : ((AgentMode)1)); AgentMode mode = val; WaitForSeconds spawnInterval = new WaitForSeconds(2f / (float)count); for (int i = 0; i < count; i++) { EnemyAgent.SpawnEnemy(e.EnemyID, pos, courseNode, mode); yield return spawnInterval; } } } internal static class WardenEventExt { internal static readonly Dictionary<WEE_Type, BaseEvent> _EventsToTrigger; static WardenEventExt() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown _EventsToTrigger = new Dictionary<WEE_Type, BaseEvent>(); IEnumerable<Type> enumerable = from x in typeof(BaseEvent).Assembly.GetTypes() where !x.IsAbstract where x.IsAssignableTo(typeof(BaseEvent)) select x; bool flag = default(bool); foreach (Type item in enumerable) { BaseEvent baseEvent = (BaseEvent)Activator.CreateInstance(item); if (_EventsToTrigger.TryGetValue(baseEvent.EventType, out BaseEvent value)) { Logger.Error("Duplicate EventType detected!"); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("With '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' and '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(baseEvent.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'"); } Logger.Error(val); } else { baseEvent.Setup(); _EventsToTrigger[baseEvent.EventType] = baseEvent; } } } internal static void Initialize() { ClassInjector.RegisterTypeInIl2Cpp<ScanPositionReplicator>(); ClassInjector.RegisterTypeInIl2Cpp<ZoneLightReplicator>(); JsonInjector.SetConverter<eWardenObjectiveEventType>((Il2CppJsonUnmanagedTypeConverter<eWardenObjectiveEventType>)new EventTypeConverter()); JsonInjector.AddHandler<WardenObjectiveEventData>((Il2CppJsonReferenceTypeHandler<WardenObjectiveEventData>)(object)new EventDataHandler()); JsonInjector.AddHandler<WorldEventFromSourceData>((Il2CppJsonReferenceTypeHandler<WorldEventFromSourceData>)(object)new TriggerDataHandler()); WEE_EnumInjector.Inject(); Detour_ExecuteEvent.Patch(); } internal static void HandleEvent(WEE_Type type, WardenObjectiveEventData e, float currentDuration) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown WEE_EventData wEEData = e.GetWEEData(); if (wEEData != null) { CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Handle(type, wEEData, currentDuration)), (Action)null); return; } bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(72, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("WardenEvent Type is Extension ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<WEE_Type>(type); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), but it's not registered to dataholder!"); } Logger.Error(val); } private static IEnumerator Handle(WEE_Type type, WEE_EventData e, float currentDuration) { float delay = Mathf.Max(e.Delay - currentDuration, 0f); if (delay > 0f) { yield return (object)new WaitForSeconds(delay); } if (WorldEventManager.GetCondition(e.Condition.ConditionIndex) != e.Condition.IsTrue) { Logger.Verbose((LogLevel)32, $"Condition {e.Condition.ConditionIndex} is not met"); yield break; } WardenObjectiveManager.DisplayWardenIntel(e.Layer, (LocalizedText)e.WardenIntel); if (e.Type != WEE_Type.ForcePlayPlayerDialogue) { if (e.DialogueID != 0) { PlayerDialogManager.WantToStartDialog(e.DialogueID, -1, false, false); } if (e.SoundID != 0) { WardenObjectiveManager.Current.m_sound.Post(e.SoundID, true); string line = e.SoundSubtitle; if (!string.IsNullOrWhiteSpace(line) && e.Type != WEE_Type.PlaySubtitles) { GuiManager.PlayerLayer.ShowMultiLineSubtitle(line); } } } if (e.SubObjective.DoUpdate && e.Type != WEE_Type.MultiProgression) { WardenObjectiveManager.UpdateSyncCustomSubObjective((LocalizedText)e.SubObjective.CustomSubObjectiveHeader, (LocalizedText)e.SubObjective.CustomSubObjective); } if (e.Fog.DoUpdate) { EnvironmentStateManager.AttemptStartFogTransition(e.Fog.FogSetting, e.Fog.FogTransitionDuration, e.DimensionIndex); } if (_EventsToTrigger.TryGetValue(type, out BaseEvent eventInstance)) { eventInstance.Trigger(e); yield break; } bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<WEE_Type>(type); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" does not exist in lookup!"); } Logger.Error(val); } } internal static class WEE_EnumInjector { public const int ExtendedIndex = 10000; private static readonly Dictionary<string, object> _EventTypes; private static int _CurrentIndex; static WEE_EnumInjector() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown _EventTypes = new Dictionary<string, object>(); _CurrentIndex = 0; WEE_Type[] values = Enum.GetValues<WEE_Type>(); bool flag = default(bool); for (int i = 0; i < values.Length; i++) { WEE_Type wEE_Type = values[i]; string text = wEE_Type.ToString(); AddEvent(text); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Injecting EWOEvent: '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'"); } Logger.Debug(val); } } private static void AddEvent(string name) { _EventTypes[name] = _CurrentIndex + 10000; _CurrentIndex++; } internal static void Inject() { EnumInjector.InjectEnumValues<eWardenObjectiveEventType>(_EventTypes); } } public sealed class WEE_EventData { public WEE_Type Type { get; set; } public WorldEventConditionPair Condition { get; set; } = new WorldEventConditionPair { ConditionIndex = -1, IsTrue = false }; public eWardenObjectiveEventTrigger Trigger { get; set; } = (eWardenObjectiveEventTrigger)0; public uint ChainPuzzle { get; set; } = 0u; public bool UseStaticBioscanPoints { get; set; } = false; public eDimensionIndex DimensionIndex { get; set; } = (eDimensionIndex)0; public LG_LayerType Layer { get; set; } = (LG_LayerType)0; public eLocalZoneIndex LocalIndex { get; set; } = (eLocalZoneIndex)0; public Vector3 Position { get; set; } = Vector3.zero; public float Delay { get; set; } = 0f; public float Duration { get; set; } = 0f; public LocaleText WardenIntel { get; set; } = LocaleText.Empty; public uint SoundID { get; set; } = 0u; public LocaleText SoundSubtitle { get; set; } = LocaleText.Empty; public uint DialogueID { get; set; } = 0u; public int Count { get; set; } = 0; public bool Enabled { get; set; } = true; public bool SpecialBool { get; set; } = false; public int SpecialNumber { get; set; } = -1; public LocaleText SpecialText { get; set; } = LocaleText.Empty; public string WorldEventObjectFilter { get { return SpecialText; } set { SpecialText = new LocaleText(value); } } public WEE_SubObjectiveData SubObjective { get; set; } = new WEE_SubObjectiveData(); public WEE_UpdateFogData Fog { get; set; } = new WEE_UpdateFogData(); public bool CleanUpEnemiesBehind { get; set; } = true; public WEE_ReactorEventData Reactor { get; set; } = new WEE_ReactorEventData(); public WEE_CountdownData Countdown { get; set; } = new WEE_CountdownData(); public WEE_ZoneLightData SetZoneLight { get; set; } = new WEE_ZoneLightData(); public WEE_CleanupEnemiesData CleanupEnemies { get; set; } = new WEE_CleanupEnemiesData(); public WEE_SpawnHibernateData SpawnHibernates { get; set; } = new WEE_SpawnHibernateData(); public WEE_SpawnScoutData SpawnScouts { get; set; } = new WEE_SpawnScoutData(); public WEE_AddTerminalCommand AddTerminalCommand { get; set; } = new WEE_AddTerminalCommand(); public WEE_AddTerminalCommand AddCommand { get { return AddTerminalCommand; } set { AddTerminalCommand = value; } } public WEE_HideTerminalCommand HideTerminalCommand { get; set; } = new WEE_HideTerminalCommand(); public WEE_HideTerminalCommand HideCommand { get { return HideTerminalCommand; } set { HideTerminalCommand = value; } } public WEE_UnhideTerminalCommand UnhideTerminalCommand { get; set; } = new WEE_UnhideTerminalCommand(); public WEE_UnhideTerminalCommand UnhideCommand { get { return UnhideTerminalCommand; } set { UnhideTerminalCommand = value; } } public WEE_NestedEvent NestedEvent { get; set; } = new WEE_NestedEvent(); public WEE_StartEventLoop StartEventLoop { get; set; } = new WEE_StartEventLoop(); public WEE_StartEventLoop EventLoop { get { return StartEventLoop; } set { StartEventLoop = value; } } public WEE_TeleportPlayer TeleportPlayer { get; set; } = new WEE_TeleportPlayer(); public WEE_InfectPlayer InfectPlayer { get; set; } = new WEE_InfectPlayer(); public WEE_DamagePlayer DamagePlayer { get; set; } = new WEE_DamagePlayer(); public WEE_RevivePlayer RevivePlayer { get; set; } = new WEE_RevivePlayer(); public WEE_AdjustTimer AdjustTimer { get; set; } = new WEE_AdjustTimer(); public WEE_CountupData Countup { get; set; } = new WEE_CountupData(); public WEE_NavMarkerData NavMarker { get; set; } = new WEE_NavMarkerData(); public WEE_ShakeScreen CameraShake { get; set; } = new WEE_ShakeScreen(); public WEE_StartPortalMachine Portal { get; set; } = new WEE_StartPortalMachine(); public WEE_SetSuccessScreen SuccessScreen { get; set; } = new WEE_SetSuccessScreen(); public List<WEE_SubObjectiveData> MultiProgression { get; set; } = new List<WEE_SubObjectiveData>(); public WEE_PlayWaveDistantRoar WaveRoarSound { get; set; } = new WEE_PlayWaveDistantRoar(); public WEE_CustomHudText CustomHudText { get; set; } = new WEE_CustomHudText(); public WEE_CustomHudText CustomHud { get { return CustomHudText; } set { CustomHudText = value; } } public WEE_SpecialHudTimer SpecialHudTimer { get; set; } = new WEE_SpecialHudTimer(); public WEE_SpecialHudTimer SpecialHud { get { return SpecialHudTimer; } set { SpecialHudTimer = value; } } public WEE_ForcePlayerDialogue PlayerDialogue { get; set; } = new WEE_ForcePlayerDialogue(); public WEE_SetTerminalLog SetTerminalLog { get; set; } = new WEE_SetTerminalLog(); public WEE_SetTerminalLog TerminalLog { get { return SetTerminalLog; } set { SetTerminalLog = value; } } public List<WEE_SetPocketItem> ObjectiveItems { get; set; } = new List<WEE_SetPocketItem>(); } public sealed class WEE_SubObjectiveData { public bool DoUpdate { get; set; } = false; public LocaleText CustomSubObjectiveHeader { get; set; } = LocaleText.Empty; public LocaleText CustomSubObjective { get; set; } = LocaleText.Empty; public uint Index { get; set; } = 0u; public int Priority { get; set; } = 1; public LG_LayerType Layer { get; set; } = (LG_LayerType)0; public bool IsLayerIndependent { get; set; } = true; public LocaleText OverrideTag { get; set; } = LocaleText.Empty; } public sealed class WEE_UpdateFogData { public bool DoUpdate { get; set; } = false; public uint FogSetting { get; set; } = 0u; public float FogTransitionDuration { get; set; } = 0f; } public sealed class WEE_ReactorEventData { public enum WaveState { Intro, Wave, Verify, Idle } public WaveState State { get; set; } = WaveState.Intro; public int Wave { get; set; } = 1; public float Progress { get; set; } = 0f; } public sealed class WEE_CountdownData { public float Duration { get; set; } = 0f; public bool CanShowHours { get; set; } = true; public LocaleText TimerText { get; set; } = LocaleText.Empty; public LocaleText TitleText { get { return TimerText; } set { TimerText = value; } } public Color TimerColor { get; set; } = Color.red; public List<EventsOnTimerProgress> EventsOnProgress { get; set; } = new List<EventsOnTimerProgress>(); public List<WardenObjectiveEventData> EventsOnDone { get; set; } = new List<WardenObjectiveEventData>(); } public sealed class WEE_CleanupEnemiesData { public enum CleanUpType { Kill, Despawn } public CleanUpType Type { get; set; } = CleanUpType.Despawn; public int AreaIndex { get; set; } = -1; public bool IncludeHibernate { get; set; } = true; public bool IncludeAggressive { get; set; } = true; public bool IncludeScout { get; set; } = true; public uint[] ExcludeEnemyID { get; set; } = Array.Empty<uint>(); public uint[] IncludeOnlyID { get; set; } = Array.Empty<uint>(); public void DoClear(AIG_CourseNode node) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0065: Expected I4, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if (!SNet.IsMaster || node == null || node.m_enemiesInNode == null) { return; } foreach (EnemyAgent item in node.m_enemiesInNode.ToArray()) { AgentMode mode = ((AgentAI)item.AI).Mode; if ((mode - 1) switch { 0 => IncludeAggressive, 2 => IncludeScout, 3 => IncludeHibernate, _ => true, } && !ExcludeEnemyID.Contains(item.EnemyDataID) && (IncludeOnlyID.Length == 0 || IncludeOnlyID.Contains(item.EnemyDataID))) { switch (Type) { case CleanUpType.Despawn: ((Agent)item).m_replicator.Despawn(); break; case CleanUpType.Kill: item.Damage.IsImortal = false; item.Damage.BulletDamage(((Dam_SyncedDamageBase)item.Damage).DamageMax, (Agent)null, default(Vector3), default(Vector3), default(Vector3), false, 0, 1f, 1f, 0u); break; } } } } } public sealed class WEE_ZoneLightData { public enum ModifierType : byte { RevertToOriginal, SetZoneLightData } public ModifierType Type { get; set; } = ModifierType.RevertToOriginal; public uint LightDataID { get; set; } = 0u; public float TransitionDuration { get; set; } = 0.5f; public int Seed { get; set; } = 0; public bool UseRandomSeed => Seed == 0; } public sealed class WEE_SpawnHibernateData { public int AreaIndex { get; set; } = -1; public int[] AreaBlacklist { get; set; } = Array.Empty<int>(); public uint EnemyID { get; set; } = 0u; public int Count { get; set; } = 0; public Vector3 Position { get; set; } = Vector3.zero; public Vector3 Rotation { get; set; } = Vector3.zero; } public sealed class WEE_SpawnScoutData { public int AreaIndex { get; set; } = -1; public int[] AreaBlacklist { get; set; } = Array.Empty<int>(); public eEnemyGroupType GroupType { get; set; } public eEnemyRoleDifficulty Difficulty { get; set; } public int Count { get; set; } = 0; } public sealed class WEE_AddTerminalCommand { public int TerminalIndex { get; set; } = 0; public int CommandNumber { get; set; } = 6; public string Command { get; set; } = string.Empty; public LocaleText CommandDesc { get; set; } = LocaleText.Empty; public bool AutoIndentCommandDesc { get; set; } = false; public List<TerminalOutput> PostCommandOutputs { get; set; } = new List<TerminalOutput>(); public List<WardenObjectiveEventData> CommandEvents { get; set; } = new List<WardenObjectiveEventData>(); public bool ProgressWaitBeforeEvents { get; set; } = false; public TERM_CommandRule SpecialCommandRule { get; set; } = (TERM_CommandRule)0; } public sealed class WEE_HideTerminalCommand { public int TerminalIndex { get; set; } = 0; public TERM_Command CommandEnum { get; set; } = (TERM_Command)0; public int CommandNumber { get; set; } = 0; public bool DeleteCommand { get; set; } = false; } public sealed class WEE_UnhideTerminalCommand { public int TerminalIndex { get; set; } = 0; public TERM_Command CommandEnum { get; set; } = (TERM_Command)0; public int CommandNumber { get; set; } = 0; } public sealed class WEE_NestedEvent { public enum NestedMode : byte { ActivateAll, RandomAny, RandomWeighted } public struct EventsOnRandomWeight { public string DebugName { get; set; } public float Weight { get; set; } public int RepeatCount { get; set; } public bool IsInfinite { get; set; } public List<WardenObjectiveEventData> Events { get; set; } } public NestedMode Type { get; set; } = NestedMode.ActivateAll; public int MaxRandomEvents { get; set; } = -1; public bool AllowRepeatsInRandom { get; set; } = false; public List<WardenObjectiveEventData> EventsToActivate { get; set; } = new List<WardenObjectiveEventData>(); public List<EventsOnRandomWeight> WheelOfEvents { get; set; } = new List<EventsOnRandomWeight>(); } public sealed class WEE_StartEventLoop { public int LoopIndex { get; set; } = 0; public float LoopDelay { get; set; } = 1f; public int LoopCount { get; set; } = -1; public List<WardenObjectiveEventData> EventsToActivate { get; set; } = new List<WardenObjectiveEventData>(); } public enum PlayerIndex : byte { P0, P1, P2, P3 } public sealed class WEE_TeleportPlayer { public struct TeleportData { public PlayerIndex PlayerIndex { get; set; } [JsonPropertyName("DimensionIndex")] public eDimensionIndex Dimension { get; set; } public Vector3 Position { get; set; } public string WorldEventObjectFilter { get; set; } [JsonPropertyName("LookDirection")] public int LookDir { get; set; } [JsonPropertyName("LookDirectionV3")] public Vector3 LookDirV3 { get; set; } public bool PlayWarpAnimation { get; set; } [JsonPropertyName("FlashDuration")] public float Duration { get; set; } [JsonIgnore] public PlayerAgent Player { get; set; } [JsonIgnore] public eDimensionIndex LastDimension { get; set; } [JsonIgnore] public Vector3 LastPosition { get; set; } [JsonIgnore] public Vector3 LastLookDirV3 { get; set; } [JsonIgnore] public List<IWarpableObject> ItemsToWarp { get; set; } } public HashSet<PlayerIndex> PlayerFilter { get; set; } = new HashSet<PlayerIndex>(); public bool PlayWarpAnimation { get; set; } = true; public bool SendBPUsToHost { get; set; } = false; public Vector3 Player0Position { get; set; } = Vector3.zero; public int P0LookDir { get; set; } = 0; public Vector3 Player1Position { get; set; } = Vector3.zero; public int P1LookDir { get; set; } = 0; public Vector3 Player2Position { get; set; } = Vector3.zero; public int P2LookDir { get; set; } = 0; public Vector3 Player3Position { get; set; } = Vector3.zero; public int P3LookDir { get; set; } = 0; public bool FlashTeleport { get; set; } = false; public bool WarpSentries { get; set; } = true; public bool WarpBigPickups { get; set; } = true; public bool SendBigPickupsToHost { get { return SendBPUsToHost; } set { SendBPUsToHost = value; } } public List<TeleportData> TPData { get; set; } = new List<TeleportData>(); } public sealed class WEE_InfectPlayer { public HashSet<PlayerIndex> PlayerFilter { get; set; } = new HashSet<PlayerIndex> { PlayerIndex.P0, PlayerIndex.P1, PlayerIndex.P2, PlayerIndex.P3 }; public float InfectionAmount { get; set; } = 0f; public bool InfectOverTime { get; set; } = false; public float Interval { get; set; } = 1f; public bool UseZone { get; set; } = false; } public sealed class WEE_DamagePlayer { public HashSet<PlayerIndex> PlayerFilter { get; set; } = new HashSet<PlayerIndex> { PlayerIndex.P0, PlayerIndex.P1, PlayerIndex.P2, PlayerIndex.P3 }; public float DamageAmount { get; set; } = 0f; public bool DamageOverTime { get; set; } = false; public float Interval { get; set; } = 1f; public bool UseZone { get; set; } = false; } public sealed class WEE_RevivePlayer { public HashSet<PlayerIndex> PlayerFilter { get; set; } = new HashSet<PlayerIndex> { PlayerIndex.P0, PlayerIndex.P1, PlayerIndex.P2, PlayerIndex.P3 }; } public sealed class WEE_AdjustTimer { public float Duration { get; set; } = 0f; public float Speed { get; set; } = 0f; public bool UpdateTitleText { get; set; } = false; public LocaleText TitleText { get; set; } = LocaleText.Empty; public bool UpdateText { get; set; } = false; public bool UpdateBodyText { get { return UpdateText; } set { UpdateText = value; } } public LocaleText CustomText { get; set; } = LocaleText.Empty; public LocaleText BodyText { get { return CustomText; } set { CustomText = value; } } public bool UpdateColor { get; set; } = false; public Color TimerColor { get; set; } = Color.red; } public sealed class WEE_CountupData { public float Duration { get; set; } = 0f; public float StartValue { get; set; } = 0f; public float Speed { get; set; } = 1f; public LocaleText TimerText { get; set; } = LocaleText.Empty; public LocaleText TitleText { get { return TimerText; } set { TimerText = value; } } public LocaleText CustomText { get; set; } = LocaleText.Empty; public LocaleText BodyText { get { return CustomText; } set { CustomText = value; } } public Color TimerColor { get; set; } = Color.red; public int DecimalPoints { get; set; } = 0; public List<EventsOnTimerProgress> EventsOnProgress { get; set; } = new List<EventsOnTimerProgress>(); public List<WardenObjectiveEventData> EventsOnDone { get; set; } = new List<WardenObjectiveEventData>(); } public struct EventsOnTimerProgress { public float Progress { get; set; } public List<WardenObjectiveEventData> Events { get; set; } } public sealed class WEE_NavMarkerData { public int Index { get; set; } = 0; public NavMarkerOption Style { get; set; } = (NavMarkerOption)10; public LocaleText Title { get; set; } = LocaleText.Empty; public Color Color { get; set; } = new Color(0.701f, 0.435f, 0.964f, 1f); public bool UsePin { get; set; } = true; } public sealed class WEE_ShakeScreen { public float Radius { get; set; } = 0f; public float Duration { get; set; } = 0f; public float Amplitude { get; set; } = 0f; public float Frequency { get; set; } = 0f; public bool Directional { get; set; } = true; } public sealed class WEE_StartPortalMachine { public eDimensionIndex TargetDimension { get; set; } = (eDimensionIndex)1; public float TeleportDelay { get; set; } = 5f; public bool PreventPortalWarpTeamEvent { get; set; } = false; } public sealed class WEE_SetSuccessScreen { public enum ScreenType : byte { SetSuccessScreen, FlashFakeScreen } public ScreenType Type { get; set; } = ScreenType.SetSuccessScreen; public WinScreen CustomSuccessScreen { get; set; } = WinScreen.Empty; public eCM_MenuPage FakeEndScreen { get; set; } = (eCM_MenuPage)17; } public sealed class WEE_PlayWaveDistantRoar { public enum WaveRoarSound : byte { Striker, Shooter, Birther, Shadow, Tank, Flyer, Immortal, Bullrush, Pouncer, Striker_Berserk, Shooter_Spread } public enum WaveRoarSize : byte { Small, Medium, Big } public WaveRoarSound RoarSound { get; set; } = WaveRoarSound.Striker; public WaveRoarSize RoarSize { get; set; } = WaveRoarSize.Small; public bool IsOutside { get; set; } = false; } public sealed class WEE_CustomHudText { public LocaleText Title { get; set; } = LocaleText.Empty; public LocaleText TitleText { get { return Title; } set { Title = value; } } public LocaleText Body { get; set; } = LocaleText.Empty; public LocaleText BodyText { get { return Body; } set { Body = value; } } } public sealed class WEE_SpecialHudTimer { public enum SpecialHudType : byte { StartTimer, StartIndexTimer, StartPersistent, StopIndex, StopAll } public float Duration { get; set; } = 0f; public SpecialHudType Type { get; set; } = SpecialHudType.StartTimer; public int Index { get; set; } = 0; public LocaleText Message { get; set; } = LocaleText.Empty; public ePUIMessageStyle Style { get; set; } = (ePUIMessageStyle)0; public int Priority { get; set; } = -2; public bool ShowTimeInProgressBar { get; set; } = true; public List<EventsOnTimerProgress> EventsOnProgress { get; set; } = new List<EventsOnTimerProgress>(); public List<WardenObjectiveEventData> EventsOnDone { get; set; } = new List<WardenObjectiveEventData>(); } public sealed class WEE_ForcePlayerDialogue { public enum DialogueType : byte { Closest, Specific, Random } public enum PlayerIntensityState : byte { Exploration, Stealth, Encounter, Combat } public DialogueType Type { get; set; } = DialogueType.Closest; public PlayerIndex CharacterID { get; set; } = PlayerIndex.P0; public PlayerIntensityState IntensityState { get; set; } = PlayerIntensityState.Exploration; } public sealed class WEE_SetTerminalLog { public enum LogEventType : byte { Add, Remove } public int TerminalIndex { get; set; } = 0; public LogEventType Type { get; set; } = LogEventType.Add; public string FileName { get; set; } = string.Empty; public LocaleText FileContent { get; set; } = LocaleText.Empty; public Language FileContentOriginalLanguage { get; set; } = (Language)1; public uint AttachedAudioFile { get; set; } = 0u; public int AttachedAudioByteSize { get; set; } = 0; public uint PlayerDialogToTriggerAfterAudio { get; set; } = 0u; public List<WardenObjectiveEventData> EventsOnFileRead { get; set; } = new List<WardenObjectiveEventData>(); } public sealed class WEE_SetPocketItem { public enum PlayerTagType : byte { Custom, Specific, Random, Closest } public int Index { get; set; } = 0; public int Count { get; set; } = 0; public bool IsOnTop { get; set; } = false; public LocaleText ItemName { get; set; } = LocaleText.Empty; public PlayerTagType TagType { get; set; } = PlayerTagType.Custom; public PlayerIndex PlayerIndex { get; set; } = PlayerIndex.P0; public string CustomTag { get; set; } = string.Empty; [JsonIgnore] public string? Tag { get; set; } = string.Empty; public bool ShouldRemove => Count < 1; private string LiveCount => (Count > 1) ? $"{Count} " : string.Empty; public string FormatString() { return $"{LiveCount}{ItemName} <uppercase><color=#ffffff{MathUtil.ZeroOneRangeToHex(0.2f)}>[{Tag}]</color></uppercase>"; } } public enum WEE_Type { CloseSecurityDoor = 10000, LockSecurityDoor = 10001, SetDoorInteraction = 10002, TriggerSecurityDoorAlarm = 10003, SolveSecurityDoorAlarm = 10004, StartReactor = 10005, ModifyReactorWaveState = 10006, ForceCompleteReactor = 10007, ForceCompleteLevel = 10008, ForceFailLevel = 10009, Countdown = 10010, SetLevelFailCheckEnabled = 10011, SetLevelFailWhenAnyPlayerDowned = 10012, KillAllPlayers = 10013, KillPlayersInZone = 10014, SolveSingleObjectiveItem = 10015, SetLightDataInZone = 10016, AlertEnemiesInZone = 10017, CleanupEnemiesInZone = 10018, SpawnHibernateInZone = 10019, SpawnScoutInZone = 10020, SaveCheckpoint = 10021, MoveExtractionWorldPosition = 10022, SetBlackoutEnabled = 10023, AddTerminalCommand = 10024, HideTerminalCommand = 10025, UnhideTerminalCommand = 10026, AddChainPuzzleToSecurityDoor = 10027, NestedEvent = 20000, StartEventLoop = 20001, StopEventLoop = 20002, TeleportPlayer = 20003, InfectPlayer = 20004, DamagePlayer = 20005, RevivePlayer = 20006, AdjustAWOTimer = 20007, Countup = 20008, ForceCompleteChainPuzzle = 20009, SpawnNavMarker = 20010, ShakeScreen = 20011, StartPortalMachine = 20012, SetSuccessScreen = 20013, PlaySubtitles = 20014, MultiProgression = 20015, PlayWaveRoarSound = 20016, CustomHudText = 20017, SpecialHudTimer = 20018, ForcePlayPlayerDialogue = 20019, SetTerminalLog = 20020, SetPocketItem = 20021, DoInteractWeakDoorsInZone = 20022, ToggleInteractWeakDoorsInZone = 20023, PickupSentries = 20024 } } namespace AWO.Modules.WEE.Replicators { public struct ScanPositionState { public Vector3 position; public int nodeID; } public sealed class ScanPositionReplicator : MonoBehaviour, IStateReplicatorHolder<ScanPositionState> { public CP_Bioscan_Core? TrackingScan; public NavMarker? Marker; public bool IsExitScan; [HideFromIl2Cpp] public StateReplicator<ScanPositionState>? Replicator { get; private set; } public void Setup(uint id, CP_Bioscan_Core scan, NavMarker marker, bool isExit) { //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) Replicator = StateReplicator<ScanPositionState>.Create(id, new ScanPositionState { position = ((Component)scan).transform.position, nodeID = scan.CourseNode.NodeID }, LifeTimeType.Session, this); TrackingScan = scan; Marker = marker; IsExitScan = isExit; } public void OnDestroy() { Replicator?.Unload(); } public void TryUpdatePosition(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to in
plugins/ProjectEternal/Custom/CustomEndScreen.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CellMenu; using GTFO.API; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; 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 = ".NET 6.0")] [assembly: AssemblyCompany("CustomEndScreen")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CustomEndScreen")] [assembly: AssemblyTitle("CustomEndScreen")] [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 CustomEndScreen { [HarmonyPatch(typeof(MainMenuGuiLayer), "AddPage")] public static class AddPagePatch { public static CM_PageBase defaultPageBase; public static bool Prefix(MainMenuGuiLayer __instance, eCM_MenuPage pageEnum, string pageResourcePath, ref CM_PageBase __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected I4, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected I4, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected I4, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) EntryPoint.LogSource.LogDebug((object)pageResourcePath); if ((int)GameStateManager.Current.m_currentStateName == 1) { return true; } if (!pageResourcePath.Contains('/')) { return true; } ((Il2CppArrayBase<CM_PageBase>)(object)__instance.m_pages)[(int)pageEnum] = GOUtil.SpawnChildAndGetComp<CM_PageBase>(AssetAPI.GetLoadedAsset<GameObject>(pageResourcePath), ((Component)((GuiLayer)__instance).GuiLayerBase).transform); ((Il2CppArrayBase<CM_PageBase>)(object)__instance.m_pages)[(int)pageEnum].Setup(__instance); __result = ((Il2CppArrayBase<CM_PageBase>)(object)__instance.m_pages)[(int)pageEnum]; __result.OnResolutionChange(__instance.m_currentScaledRes); return false; } } [HarmonyPatch(typeof(MainMenuGuiLayer), "OnExpeditionUpdated")] public static class ExpeditionUpdatedPatch { private static readonly List<string> RundownEightCustomScreens = new List<string>(4) { "CM_PageExpeditionSuccess_Completed", "CM_PageExpeditionSuccess_Resources expended_CellUI 2", "CM_PageExpeditionSuccess_SignalLost_CellUI", "CM_PageExpeditionSuccess_Stack Empty_CellUI 1" }; private static Dictionary<string, string> CachedCustomExpeditions = new Dictionary<string, string>(); private static string BackupOverride = string.Empty; public static void Prefix(MainMenuGuiLayer __instance, pActiveExpedition activeExpedition, ExpeditionInTierData expeditionInTierData) { if (CachedCustomExpeditions.TryGetValue(expeditionInTierData.Descriptive.PublicName, out string value)) { BackupOverride = value; } else { BackupOverride = expeditionInTierData.SpecialOverrideData.CustomSuccessScreen; } if (!RundownEightCustomScreens.Contains(expeditionInTierData.SpecialOverrideData.CustomSuccessScreen)) { if (!CachedCustomExpeditions.ContainsKey(expeditionInTierData.Descriptive.PublicName)) { CachedCustomExpeditions.Add(expeditionInTierData.Descriptive.PublicName, expeditionInTierData.SpecialOverrideData.CustomSuccessScreen); } expeditionInTierData.SpecialOverrideData.CustomSuccessScreen = null; } } public static void Postfix(MainMenuGuiLayer __instance, pActiveExpedition activeExpedition, ExpeditionInTierData expeditionInTierData) { if (BackupOverride != null && BackupOverride.Contains('/')) { __instance.PageCustomExpeditionSuccess = __instance.AddPage((eCM_MenuPage)17, BackupOverride); } } } [BepInPlugin("com.Breeze.CustomEndScreen", "CustomEndScreen", "0.0.1")] [BepInProcess("GTFO.exe")] internal class EntryPoint : BasePlugin { public static ManualLogSource? LogSource { get; private set; } public static Harmony? m_Harmony { get; private set; } public override void Load() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown LogSource = ((BasePlugin)this).Log; m_Harmony = new Harmony("_CustomExpeditionSuccessScreen"); m_Harmony.PatchAll(); } } }
plugins/ProjectEternal/Custom/DeleteMeIfGay.dll
Decompiled 4 days 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/ProjectEternal/Custom/Inas07.EOSExt.EnvTemperature.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Agents; using BepInEx; using BepInEx.Unity.IL2CPP; using EOSExt.EnvTemperature.Components; using EOSExt.EnvTemperature.Definitions; using EOSExt.EnvTemperature.Patches; using ExtraObjectiveSetup.BaseClasses; using ExtraObjectiveSetup.Utils; using FloLib.Infos; using GTFO.API; using GTFO.API.Utilities; using GameData; using GameEvent; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Localization; using Microsoft.CodeAnalysis; 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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Inas07.EOSExt.EnvTemperature")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8ea4fc529bf4c30b0880418d9bd567d7c57ce903")] [assembly: AssemblyProduct("Inas07.EOSExt.EnvTemperature")] [assembly: AssemblyTitle("Inas07.EOSExt.EnvTemperature")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EOSExt.EnvTemperature { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Inas.EOSExt.EnvTemperature", "EOSExt.EnvTemperature", "1.0.1")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas"; public const string PLUGIN_NAME = "EOSExt.EnvTemperature"; public const string VERSION = "1.0.1"; private Harmony m_Harmony; public override void Load() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown SetupManagers(); m_Harmony = new Harmony("EOSExt.EnvTemperature"); m_Harmony.PatchAll(); EOSLogger.Log("ExtraObjectiveSetup.EnvTemperature loaded."); } private void SetupManagers() { ((GenericDefinitionManager<TemperatureDefinition>)TemperatureDefinitionManager.Current).Init(); } } public class TemperatureDefinitionManager : GenericDefinitionManager<TemperatureDefinition> { public static readonly TemperatureZoneDefinition DEFAULT_ZONE_DEF; public static TemperatureDefinitionManager Current { get; } protected override string DEFINITION_NAME => "EnvTemperature"; private Dictionary<(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex), TemperatureZoneDefinition> zoneDefs { get; } = new Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), TemperatureZoneDefinition>(); protected override void AddDefinitions(GenericDefinition<TemperatureDefinition> definition) { List<TemperatureSetting> settings = definition.Definition.Settings; if (settings.Count > 0) { settings.Sort((TemperatureSetting t1, TemperatureSetting t2) => t1.Temperature.CompareTo(t2.Temperature)); bool flag = true; if (settings[0].Temperature < 0f) { EOSLogger.Error($"Found negative temperature: '{settings[0].Temperature}'"); flag = false; } if (settings[settings.Count - 1].Temperature > 1f) { EOSLogger.Error($"Found temperature greater than 1: '{settings[settings.Count - 1].Temperature}'"); flag = false; } if (!flag) { EOSLogger.Error($"Found invalid temperature for MainLevelLayout '{definition.ID}'. Correct it first to make it effective"); return; } if (settings[0].Temperature != 0f) { List<TemperatureSetting> list = new List<TemperatureSetting>(); TemperatureSetting item = new TemperatureSetting(settings[0]) { Temperature = 0f }; list.Add(item); list.AddRange(settings); definition.Definition.Settings = list; settings.Clear(); settings = list; } } foreach (TemperatureZoneDefinition zone in definition.Definition.Zones) { zone.DecreaseRate = Math.Abs(zone.DecreaseRate); } base.AddDefinitions(definition); } protected override void FileChanged(LiveEditEventArgs e) { base.FileChanged(e); Clear(); OnBuildDone(); if (PlayerTemperatureManager.TryGetCurrentManager(out var mgr) && base.definitions.TryGetValue(RundownManager.ActiveExpedition.LevelLayoutData, out var value)) { mgr.UpdateTemperatureDefinition(value.Definition); mgr.UpdateGUIText(); } } private void OnBuildDone() { if (!base.definitions.TryGetValue(RundownManager.ActiveExpedition.LevelLayoutData, out var value)) { return; } value.Definition.Zones.ForEach(delegate(TemperatureZoneDefinition def) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_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) if (zoneDefs.ContainsKey((((GlobalZoneIndex)def).DimensionIndex, ((GlobalZoneIndex)def).LayerType, ((GlobalZoneIndex)def).LocalIndex))) { EOSLogger.Warning($"TemperatureDefinitionManager: duplicate definition found: {(((GlobalZoneIndex)def).DimensionIndex, ((GlobalZoneIndex)def).LayerType, ((GlobalZoneIndex)def).LocalIndex)}"); } zoneDefs[(((GlobalZoneIndex)def).DimensionIndex, ((GlobalZoneIndex)def).LayerType, ((GlobalZoneIndex)def).LocalIndex)] = def; }); } private void Clear() { zoneDefs.Clear(); } public bool TryGetZoneDefinition(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, out TemperatureZoneDefinition def) { //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 zoneDefs.TryGetValue((dimensionIndex, layerType, localIndex), out def); } public bool TryGetLevelTemperatureSettings(out List<TemperatureSetting> settings) { if (base.definitions.TryGetValue(RundownManager.ActiveExpedition.LevelLayoutData, out var value)) { settings = value.Definition.Settings; if (settings != null) { return settings.Count > 0; } return false; } settings = null; return false; } private TemperatureDefinitionManager() { LevelAPI.OnBuildDone += OnBuildDone; LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } static TemperatureDefinitionManager() { Current = new TemperatureDefinitionManager(); DEFAULT_ZONE_DEF = new TemperatureZoneDefinition { DecreaseRate = 0f }; } } } namespace EOSExt.EnvTemperature.Patches { [HarmonyPatch] internal static class Patch_BulletWeapon { private static TemperatureSetting? m_curSetting; private static Dictionary<uint, float> DefaultReloadTimes; [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch(typeof(BulletWeaponArchetype), "OnWield")] public static void Post_OnWield(BulletWeaponArchetype __instance) { uint persistentID = ((GameDataBlockBase<ArchetypeDataBlock>)(object)__instance.m_archetypeData).persistentID; if (!DefaultReloadTimes.ContainsKey(persistentID)) { DefaultReloadTimes[persistentID] = __instance.m_archetypeData.DefaultReloadTime; } TemperatureSetting curSetting = m_curSetting; if (curSetting != null && curSetting.SlowDownMultiplier_Reload > 0f) { __instance.m_archetypeData.DefaultReloadTime = DefaultReloadTimes[persistentID] * curSetting.SlowDownMultiplier_Reload; EOSLogger.Debug("Temperature: Slowing down reload!"); } } [HarmonyPostfix] [HarmonyPatch(typeof(BulletWeaponArchetype), "Update")] private static void Post_Update(BulletWeaponArchetype __instance) { TemperatureSetting currentTemperatureSetting = PlayerTemperatureManager.GetCurrentTemperatureSetting(); if (m_curSetting == currentTemperatureSetting) { return; } uint persistentID = ((GameDataBlockBase<ArchetypeDataBlock>)(object)__instance.m_archetypeData).persistentID; if (DefaultReloadTimes.ContainsKey(persistentID)) { float num = DefaultReloadTimes[persistentID]; if (currentTemperatureSetting == null || currentTemperatureSetting.SlowDownMultiplier_Reload <= 0f) { __instance.m_archetypeData.DefaultReloadTime = num; } else { __instance.m_archetypeData.DefaultReloadTime = num * currentTemperatureSetting.SlowDownMultiplier_Reload; } } m_curSetting = currentTemperatureSetting; } [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch(typeof(BulletWeaponArchetype), "OnUnWield")] private static void Pre_OnUnWield(BulletWeaponArchetype __instance) { uint persistentID = ((GameDataBlockBase<ArchetypeDataBlock>)(object)__instance.m_archetypeData).persistentID; if (DefaultReloadTimes.ContainsKey(persistentID)) { float defaultReloadTime = DefaultReloadTimes[persistentID]; __instance.m_archetypeData.DefaultReloadTime = defaultReloadTime; } } private static void Clear() { DefaultReloadTimes.Clear(); } static Patch_BulletWeapon() { m_curSetting = null; DefaultReloadTimes = new Dictionary<uint, float>(); LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } } [HarmonyPatch] internal static class Patch_MWS_ChargeUp_Enter { private static float DefaultChargeTime = 1f; [HarmonyPostfix] [HarmonyPatch(typeof(MWS_ChargeUp), "Enter")] private static void Postfix_Enter(MWS_ChargeUp __instance) { DefaultChargeTime = __instance.m_maxDamageTime; TemperatureSetting currentTemperatureSetting = PlayerTemperatureManager.GetCurrentTemperatureSetting(); if (currentTemperatureSetting != null && currentTemperatureSetting.SlowDownMultiplier_Melee > 0f) { __instance.m_maxDamageTime *= currentTemperatureSetting.SlowDownMultiplier_Melee; } } [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch(typeof(MWS_ChargeUp), "Exit")] private static void Pre_Exit(MWS_ChargeUp __instance) { __instance.m_maxDamageTime = DefaultChargeTime; } } [HarmonyPatch] internal static class Patch_Dam_PlayerDamageBase { internal static bool s_disableDialog; [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveFallDamage")] private static bool Pre_ReceiveFallDamage(Dam_PlayerDamageLocal __instance, pMiniDamageData data) { //IL_00aa: 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) { if (((Dam_SyncedDamageBase)__instance).RegisterDamage(num)) { ((Dam_SyncedDamageBase)__instance).SendSetDead(true); } else { ((Dam_SyncedDamageBase)__instance).SendSetHealth(((Dam_SyncedDamageBase)__instance).Health); } } __instance.Hitreact(((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax), Vector3.zero, true, !s_disableDialog, false); return false; } } [HarmonyPatch] internal static class Patch_PlayerAgent { [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch(typeof(PlayerAgent), "Setup")] private static void Post_Setup(PlayerAgent __instance) { if (((Agent)__instance).IsLocallyOwned && !((Object)(object)((Component)__instance).gameObject.GetComponent<PlayerTemperatureManager>() != (Object)null)) { ((Component)__instance).gameObject.AddComponent<PlayerTemperatureManager>().Setup(); } } } [HarmonyPatch] internal static class Patches_PLOC { private const float MIN_MOD = 0.1f; private static float s_moveSpeedMult = 1f; [HarmonyPrefix] [HarmonyPatch(typeof(PLOC_Base), "GetHorizontalVelocityFromInput")] private static void Pre_GetHorizontalVelocityFromInput(ref float moveSpeed) { moveSpeed *= s_moveSpeedMult; } internal static void SetMoveSpeedModifier(float m) { s_moveSpeedMult = Math.Max(0.1f, m); } internal static void ResetMoveSpeedModifier() { s_moveSpeedMult = 1f; } } } namespace EOSExt.EnvTemperature.Definitions { public class TemperatureSetting { public float Temperature { get; set; } = 1f; public float Damage { get; set; } = -1f; public float DamageTick { get; set; } public float SlowDownMultiplier_Reload { get; set; } = -1f; public float SlowDownMultiplier_Melee { get; set; } = -1f; public float SlowDownMultiplier_Move { get; set; } = -1f; public TemperatureSetting() { } public TemperatureSetting(TemperatureSetting o) { Temperature = o.Temperature; Damage = o.Damage; DamageTick = o.DamageTick; SlowDownMultiplier_Reload = o.SlowDownMultiplier_Reload; SlowDownMultiplier_Melee = o.SlowDownMultiplier_Melee; SlowDownMultiplier_Move = o.SlowDownMultiplier_Move; } } public class TemperatureZoneDefinition : GlobalZoneIndex { public float Temperature { get; set; } = 0.5f; public float DecreaseRate { get; set; } } public class TemperatureDefinition { public float StartTemperature { get; set; } = 0.5f; public float JumpActionHeatGained { get; set; } public float SprintActionHeatGained { get; set; } public float CrouchActionHeatGained { get; set; } public float StandingActionHeatGained { get; set; } public float LadderClimbingActionHeatGained { get; set; } public List<TemperatureZoneDefinition> Zones { get; set; } = new List<TemperatureZoneDefinition> { new TemperatureZoneDefinition() }; public List<TemperatureSetting> Settings { get; set; } = new List<TemperatureSetting> { new TemperatureSetting() }; } } namespace EOSExt.EnvTemperature.Components { public class PlayerTemperatureManager : MonoBehaviour { public const float DEFAULT_PLAYER_TEMPERATURE = 0.5f; public const float TEMPERATURE_SETTING_UPDATE_TIME = 1f; public const float TEMPERATURE_FLUCTUATE_TIME = 1f; private float m_tempSettingLastUpdateTime; private float m_lastDamageTime; private float m_tempFluctuateTime; private bool m_ShowDamageWarning = true; private TextMeshPro m_TemperatureText; private const string DEFAULT_GUI_TEXT = "SUIT TEMP: <color=orange>{0}</color>"; private string m_GUIText = "SUIT TEMP: <color=orange>{0}</color>"; private readonly Color m_lowTempColor = new Color(0f, 0.5f, 0.5f); private readonly Color m_midTempColor = new Color(1f, 0.64f, 0f); private readonly Color m_highTempColor = new Color(1f, 0.07f, 0.576f); public PlayerAgent PlayerAgent { get; private set; } public TemperatureDefinition? TemperatureDef { get; private set; } public TemperatureSetting? TemperatureSetting { get; private set; } public float PlayerTemperature { get; private set; } = 0.5f; internal void Setup() { TemperatureDef = null; PlayerAgent = ((Component)this).gameObject.GetComponent<PlayerAgent>(); LevelAPI.OnBuildDone += OnBuildDone; LevelAPI.OnEnterLevel += OnEnterLevel; } private void OnDestroy() { Object.Destroy((Object)(object)m_TemperatureText); LevelAPI.OnBuildDone -= OnBuildDone; LevelAPI.OnEnterLevel -= OnEnterLevel; } private void SetupGUI() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_TemperatureText == (Object)null) { m_TemperatureText = Object.Instantiate<TextMeshPro>(GuiManager.PlayerLayer.m_objectiveTimer.m_titleText); m_TemperatureText.transform.SetParent(((Component)GuiManager.PlayerLayer.m_playerStatus).gameObject.transform, false); ((Component)m_TemperatureText).GetComponent<RectTransform>().anchoredPosition = new Vector2(-5f, 8f); ((Component)m_TemperatureText).gameObject.transform.localPosition = new Vector3(268.2203f, 25.3799f, 0f); ((Component)m_TemperatureText).gameObject.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f); } ((Component)m_TemperatureText).gameObject.SetActive(TemperatureDef != null); } internal void UpdateGUIText() { TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("EnvTemperature.Text"); m_GUIText = ((block != null) ? Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID) : "SUIT TEMP: <color=orange>{0}</color>"); } private void UpdateGui() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (TemperatureDef != null) { ((Component)m_TemperatureText).gameObject.SetActive(true); ((TMP_Text)m_TemperatureText).SetText(string.Format(m_GUIText, (PlayerTemperature * 100f).ToString("N0")), true); if (PlayerTemperature > 0.5f) { ((Graphic)m_TemperatureText).color = Color.Lerp(m_midTempColor, m_highTempColor, (PlayerTemperature - 0.5f) * 2f); } else { ((Graphic)m_TemperatureText).color = Color.Lerp(m_lowTempColor, m_midTempColor, PlayerTemperature * 2f); } ((TMP_Text)m_TemperatureText).ForceMeshUpdate(false, false); } else { ((Component)m_TemperatureText).gameObject.SetActive(false); } } private void UpdateMoveSpeed() { if (TemperatureSetting == null || TemperatureSetting.SlowDownMultiplier_Move <= 0f) { Patches_PLOC.ResetMoveSpeedModifier(); } else { Patches_PLOC.SetMoveSpeedModifier(TemperatureSetting.SlowDownMultiplier_Move); } } private void ResetMoveSpeed() { Patches_PLOC.ResetMoveSpeedModifier(); } public void UpdateTemperatureDefinition(TemperatureDefinition def) { TemperatureDef = def; TemperatureSetting = null; PlayerTemperature = def?.StartTemperature ?? 0.5f; } private void OnBuildDone() { UpdateTemperatureDefinition(((GenericDefinitionManager<TemperatureDefinition>)TemperatureDefinitionManager.Current).GetDefinition(RundownManager.ActiveExpedition.LevelLayoutData)?.Definition ?? null); } private void OnEnterLevel() { PlayerTemperature = ((TemperatureDef != null) ? TemperatureDef.StartTemperature : 0.5f); UpdateGUIText(); SetupGUI(); ResetMoveSpeed(); } private void DealDamage() { if (TemperatureSetting != null && !(TemperatureSetting.Damage < 0f) && !(Time.time - m_lastDamageTime < TemperatureSetting.DamageTick)) { Patch_Dam_PlayerDamageBase.s_disableDialog = true; ((Dam_SyncedDamageBase)PlayerAgent.Damage).FallDamage(TemperatureSetting.Damage); Patch_Dam_PlayerDamageBase.s_disableDialog = false; m_lastDamageTime = Time.time; } } private void UpdateTemperatureSettings() { if (Time.time - m_tempSettingLastUpdateTime < 1f) { return; } if (!TemperatureDefinitionManager.Current.TryGetLevelTemperatureSettings(out var settings)) { TemperatureSetting = null; return; } int num = 0; int num2 = settings.Count - 1; float playerTemperature = PlayerTemperature; while (num < num2) { int num3 = (num + num2) / 2; float temperature = settings[num3].Temperature; float num4 = ((num3 + 1 < settings.Count) ? settings[num3 + 1].Temperature : 1f); if (temperature <= playerTemperature && playerTemperature < num4) { break; } if (playerTemperature < temperature) { num2 = num3 - 1; } else { num = num3 + 1; } } TemperatureSetting = settings[Math.Clamp((num + num2) / 2, 0, settings.Count - 1)]; m_tempSettingLastUpdateTime = Time.time; } private void Update() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected I4, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) if ((int)GameStateManager.CurrentStateName != 10 || TemperatureDef == null || (Object)(object)PlayerAgent == (Object)null) { return; } Vector3 lastMoveDelta = PlayerAgent.Locomotion.LastMoveDelta; float num = ((Vector3)(ref lastMoveDelta)).magnitude / Clock.FixedDelta; float num2 = (PlayerAgent.PlayerData.walkMoveSpeed + PlayerAgent.PlayerData.runMoveSpeed) * 0.5f; float num3 = 0f; PLOC_State currentStateEnum = PlayerAgent.Locomotion.m_currentStateEnum; switch ((int)currentStateEnum) { case 0: num3 = TemperatureDef.StandingActionHeatGained * Time.deltaTime; break; case 1: num3 = ((!(num <= num2)) ? ((TemperatureDef.CrouchActionHeatGained + TemperatureDef.SprintActionHeatGained) * Time.deltaTime) : (TemperatureDef.CrouchActionHeatGained * Time.deltaTime)); break; case 2: num3 = TemperatureDef.SprintActionHeatGained * Time.deltaTime; break; case 3: num3 = ((!(num <= num2)) ? ((TemperatureDef.JumpActionHeatGained + TemperatureDef.SprintActionHeatGained) * Time.deltaTime) : (TemperatureDef.JumpActionHeatGained * Time.deltaTime)); break; case 7: num3 = 0f; break; case 8: num3 = TemperatureDef.LadderClimbingActionHeatGained * Time.deltaTime; break; } if ((double)num3 < 1E-05) { if (Time.time - m_tempFluctuateTime > 1f) { float num4 = TemperatureDef.StartTemperature; LG_Zone zone = ((Agent)PlayerAgent).CourseNode.m_zone; if (TemperatureDefinitionManager.Current.TryGetZoneDefinition(zone.DimensionIndex, zone.Layer.m_type, zone.LocalIndex, out var def)) { num4 = def.Temperature; } float num5 = def.DecreaseRate * Random.RandomRange(0f, 1f); if (PlayerTemperature > num4) { PlayerTemperature -= num5; } else { PlayerTemperature += num5; } m_tempFluctuateTime = Time.time; } } else { m_tempFluctuateTime = Time.time; } PlayerTemperature += num3; UpdateTemperatureSettings(); TemperatureSetting? temperatureSetting = TemperatureSetting; if (temperatureSetting != null && temperatureSetting.Damage > 0f) { DealDamage(); } UpdateGui(); UpdateMoveSpeed(); } public static bool TryGetCurrentManager(out PlayerTemperatureManager mgr) { mgr = null; LocalPlayerAgent val = default(LocalPlayerAgent); if (!LocalPlayer.TryGetLocalAgent(ref val)) { EOSLogger.Debug("Temperature: cannot get localplayeragent"); return false; } mgr = ((Component)val).gameObject.GetComponent<PlayerTemperatureManager>(); if ((Object)(object)val == (Object)null) { EOSLogger.Error("LocalPlayerAgent does not have `PlayerTemperatureManager`!"); return false; } return true; } public static TemperatureSetting? GetCurrentTemperatureSetting() { if (!TryGetCurrentManager(out var mgr)) { return null; } return mgr.TemperatureSetting; } static PlayerTemperatureManager() { ClassInjector.RegisterTypeInIl2Cpp<PlayerTemperatureManager>(); } } }
plugins/ProjectEternal/Custom/Inas07.EOSExt.SecurityDoorTerminal.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AIGraph; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Unity.IL2CPP; using ChainedPuzzles; using EOSExt.ExtraDoor; using EOSExt.SecurityDoorTerminal.Definition; using ExtraObjectiveSetup; using ExtraObjectiveSetup.BaseClasses; using ExtraObjectiveSetup.BaseClasses.CustomTerminalDefinition; using ExtraObjectiveSetup.ExtendedWardenEvents; using ExtraObjectiveSetup.Utils; using GTFO.API; using GTFO.API.Extensions; using GameData; using Il2CppInterop.Runtime.InteropTypes; using Il2CppSystem; using LevelGeneration; using Localization; using Microsoft.CodeAnalysis; using Player; using SecDoorTerminalInterface; 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 = ".NET 6.0")] [assembly: AssemblyCompany("Inas07.EOSExt.SecurityDoorTerminal")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c36c394f7a0da82e30909e7b11f71b6c56705201")] [assembly: AssemblyProduct("Inas07.EOSExt.SecurityDoorTerminal")] [assembly: AssemblyTitle("Inas07.EOSExt.SecurityDoorTerminal")] [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 EOSExt.SecurityDoorTerminal { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Inas.EOSExt.SecurityDoorTerminal", "EOSExt.SecurityDoorTerminal", "1.1.3")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas"; public const string PLUGIN_NAME = "EOSExt.SecurityDoorTerminal"; public const string VERSION = "1.1.3"; public override void Load() { SetupManagers(); EOSLogger.Log("ExtraObjectiveSetup.SecurityDoorTerminal loaded."); } private void SetupManagers() { ((ZoneDefinitionManager<SecurityDoorTerminalDefinition>)SecurityDoorTerminalManager.Current).Init(); } } public static class ExtraDoorUtils { public const string PLUGIN_NAME = "Inas.EOSExt.ExtraDoor"; public static bool PluginLoaded => ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("Inas.EOSExt.ExtraDoor"); public static LG_SecurityDoor GetFCDoor(string worldEventObjectFilter) { if (!PluginLoaded) { EOSLogger.Error("ExtraDoorUtils: plugin not loaded"); return null; } return DoGetFCDoor(worldEventObjectFilter); } private static LG_SecurityDoor DoGetFCDoor(string worldEventObjectFilter) { return ForceConnectManager.Current.GetFCDoor(worldEventObjectFilter); } } public sealed class SecurityDoorTerminalManager : ZoneDefinitionManager<SecurityDoorTerminalDefinition> { private enum SDTWardenEvents { ADD_OVERRIDE_COMMAND = 1000 } private const string OVERRIDE_COMMAND = "ACCESS_OVERRIDE"; private List<(SecDoorTerminal sdt, SecurityDoorTerminalDefinition def)> regularSDTs = new List<(SecDoorTerminal, SecurityDoorTerminalDefinition)>(); private Dictionary<string, (SecDoorTerminal sdt, SecurityDoorTerminalDefinition def)> extraSDTs = new Dictionary<string, (SecDoorTerminal, SecurityDoorTerminalDefinition)>(); public static SecurityDoorTerminalManager Current { get; private set; } protected override string DEFINITION_NAME => "SecDoorTerminal"; public 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; } protected override void AddDefinitions(ZoneDefinitionsForLevel<SecurityDoorTerminalDefinition> definitions) { base.Sort(definitions); base.AddDefinitions(definitions); } private void AddOverrideCommandWithAlarmText(SecDoorTerminal sdt) { if (sdt.CmdProcessor.HasRegisteredCommand((TERM_Command)254)) { return; } string text = "<color=orange>" + Text.Get(841u) + "</color>"; if ((Object)(object)sdt.LinkedDoorLocks.ChainedPuzzleToSolve != (Object)null && sdt.LinkedDoorLocks.ChainedPuzzleToSolve.Data.TriggerAlarmOnActivate) { string format = Text.Get(840u); ChainedPuzzleInstance chainedPuzzleToSolve = sdt.LinkedDoorLocks.ChainedPuzzleToSolve; text = "<color=orange>" + string.Format(format, (chainedPuzzleToSolve != null) ? chainedPuzzleToSolve.Data.PublicAlarmName : null) + "</color>"; int num = text.IndexOf('['); if (num >= 0 && num < text.Length) { text = text.Insert(num, "\n"); } } sdt.AddOverrideCommand("ACCESS_OVERRIDE", text, (Action<LG_ComputerTerminalCommandInterpreter>)null); } private unsafe void BuildSDT_UniqueCommands(SecDoorTerminal sdt, SecurityDoorTerminalDefinition def) { //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_0042: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Invalid comparison between Unknown and I4 //IL_00b7: Unknown result type (might be due to invalid IL or missing references) TerminalPlacementData val = new TerminalPlacementData { UniqueCommands = ListExtensions.ToIl2Cpp<CustomTerminalCommand>(def.TerminalSettings.UniqueCommands.ConvertAll((CustomCommand x) => x.ToVanillaDataType())) }; ((LG_FactoryJob)new LG_TerminalUniqueCommandsSetupJob(sdt.ComputerTerminal, val)).Build(); TERM_Command val2 = default(TERM_Command); string text = default(string); string text2 = default(string); ChainedPuzzleInstance val3 = default(ChainedPuzzleInstance); foreach (CustomCommand uniqueCommand in def.TerminalSettings.UniqueCommands) { if (!sdt.ComputerTerminal.m_command.TryGetCommand(uniqueCommand.Command, ref val2, ref text, ref text2) || (int)sdt.ComputerTerminal.GetCommandRule(val2) != 0) { continue; } for (int i = 0; i < uniqueCommand.CommandEvents.Count; i++) { if (sdt.ComputerTerminal.TryGetChainPuzzleForCommand(val2, i, ref val3)) { ChainedPuzzleInstance obj = val3; obj.OnPuzzleSolved += Action.op_Implicit(new Action(val3, (nint)(delegate*<ChainedPuzzleInstance, void>)(&EOSUtils.ResetProgress))); } } } } private void BuildLevelSDTs_UniqueCommands() { regularSDTs.ForEach(delegate((SecDoorTerminal sdt, SecurityDoorTerminalDefinition def) tp) { BuildSDT_UniqueCommands(tp.sdt, tp.def); }); } private void BuildLevelSDTs_Passwords() { regularSDTs.ForEach(delegate((SecDoorTerminal sdt, SecurityDoorTerminalDefinition def) tp) { EOSTerminalUtils.BuildPassword(tp.sdt.ComputerTerminal, tp.def.TerminalSettings.PasswordData); }); } private void WardenEvent_AddOverrideCommand(WardenObjectiveEventData e) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) Predicate<(SecDoorTerminal, SecurityDoorTerminalDefinition)> predicate = null; SecDoorTerminal val = null; if (e.WorldEventObjectFilter != null && e.WorldEventObjectFilter.Length > 0) { if (!extraSDTs.TryGetValue(e.WorldEventObjectFilter, out (SecDoorTerminal, SecurityDoorTerminalDefinition) value)) { EOSLogger.Error("SDT_AddOverrideCommand: SDT not found on ExtraDoor(WorldEventObjectFilter) '" + e.WorldEventObjectFilter + "'"); return; } (val, _) = value; } else { int num = regularSDTs.FindIndex(delegate((SecDoorTerminal sdt, SecurityDoorTerminalDefinition def) tp) { //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) AIG_CourseNode courseNode = ((LG_ZoneExpander)tp.sdt.LinkedDoor.Gate).m_linksTo.m_courseNode; return courseNode.m_dimension.DimensionIndex == e.DimensionIndex && courseNode.LayerType == e.Layer && courseNode.m_zone.LocalIndex == e.LocalIndex; }); if (num == -1) { EOSLogger.Error($"SDT_AddOverrideCommand: SDT not found on door to {(e.DimensionIndex, e.Layer, e.LocalIndex)}"); return; } val = regularSDTs[num].sdt; } AddOverrideCommandWithAlarmText(val); if (e.WorldEventObjectFilter != null && e.WorldEventObjectFilter.Length > 0) { EOSLogger.Debug("SDT_AddOverrideCommand: added for ExtraDoor(WorldEventObjectFilter) '" + e.WorldEventObjectFilter + "'"); return; } EOSLogger.Debug($"SDT_AddOverrideCommand: added for SDT {(e.DimensionIndex, e.Layer, e.LocalIndex)}"); } private SecDoorTerminal BuildSDT_Instantiation(SecurityDoorTerminalDefinition def) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected I4, but got Unknown LG_SecurityDoor door = null; if (def.FCDoorWorldEventObjectFilter != null && def.FCDoorWorldEventObjectFilter.Length > 0) { door = ExtraDoorUtils.GetFCDoor(def.FCDoorWorldEventObjectFilter); if ((Object)(object)door == (Object)null) { EOSLogger.Error("SecDoorTerminal: cannot find ExtraDoor with name '" + def.FCDoorWorldEventObjectFilter + "'"); return null; } } else { var (val, val2, val3) = ((GlobalZoneIndex)def).GlobalZoneIndexTuple(); LG_Zone val4 = default(LG_Zone); if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(val, val2, val3, ref val4) || (Object)(object)val4 == (Object)null) { EOSLogger.Error($"SecDoorTerminal: Cannot find target zone {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}"); return null; } if (!TryGetZoneEntranceSecDoor(val4, out door) || (Object)(object)door == (Object)null) { EOSLogger.Error($"SecDoorTerminal: Cannot find spawned sec-door for zone {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}"); return null; } } SecDoorTerminal sdt = SecDoorTerminal.Place(door, new TerminalStartStateData { StartingState = (TERM_State)0 }, (TerminalPlacementData)null); sdt.BioscanScanSolvedBehaviour = def.StateSettings.OnPuzzleSolved; if (sdt == null) { EOSLogger.Error("SecDoorTerminal: Build failed - Can only attach SDT to regular security door"); return null; } ((LG_ZoneExpander)door.Gate).m_linksFrom.m_zone.TerminalsSpawnedInZone.Add(sdt.ComputerTerminal); sdt.BioscanScanSolvedBehaviour = def.StateSettings.OnPuzzleSolved; def.TerminalSettings.LocalLogFiles.ForEach(delegate(TerminalLogFileData log) { sdt.ComputerTerminal.AddLocalLog(log, true); }); eDoorStatus status = sdt.LinkedDoor.m_sync.GetCurrentSyncState().status; eDoorStatus val5 = status; switch (val5 - 1) { case 2: if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked) { sdt.LinkedDoorLocks.m_gateKeyItemNeeded.keyPickupCore.m_interact.OnPickedUpByPlayer += Action<PlayerAgent>.op_Implicit((Action<PlayerAgent>)delegate { sdt.SetTerminalActive(false); }); sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked); List<string> list4 = new List<string> { string.Format("<color=orange>" + Text.Get(849u) + "</color>", sdt.LinkedDoorLocks.m_gateKeyItemNeeded.PublicName) }; sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list4)); } break; case 5: sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked); if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked) { List<string> list2 = new List<string> { string.Format("<color=orange>" + Text.Get(842u) + "</color>", sdt.LinkedDoorLocks.m_powerGeneratorNeeded.PublicName) }; sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list2)); } break; case 14: sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked); if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked) { List<string> list = new List<string> { string.Format("<color=orange>" + Text.Get(843u) + "</color>", sdt.LinkedDoorLocks.m_bulkheadDCNeeded.PublicName) }; sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list)); } break; case 6: sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked); if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked) { List<string> list3 = new List<string> { sdt.LinkedDoorLocks.m_intCustomMessage.m_message }; sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list3)); } else { sdt.SetCustomMessageActive(true); } break; case 0: case 3: case 4: case 8: if (def.StateSettings.OverrideCommandAccessibility != OverrideCmdAccess.ADDED_BY_WARDEN_EVENT) { AddOverrideCommandWithAlarmText(sdt); } sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenUnlocked); break; } sdt.LinkedDoor.m_sync.OnDoorStateChange += Action<pDoorState, bool>.op_Implicit((Action<pDoorState, bool>)delegate(pDoorState state, bool isDropin) { //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_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_000a: 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_0046: Expected I4, but got Unknown //IL_0069: 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_0070: Invalid comparison between Unknown and I4 eDoorStatus status3 = state.status; eDoorStatus val7 = status3; switch (val7 - 3) { case 0: case 3: case 4: case 12: sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked); if ((int)state.status == 7) { sdt.SetCustomMessageActive(true); } break; case 1: case 2: case 6: sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenUnlocked); break; case 5: case 7: case 8: case 9: case 10: case 11: break; } }); switch (def.StateSettings.OverrideCommandAccessibility) { case OverrideCmdAccess.ALWAYS: AddOverrideCommandWithAlarmText(sdt); break; case OverrideCmdAccess.ON_UNLOCK: sdt.LinkedDoor.m_sync.OnDoorStateChange += Action<pDoorState, bool>.op_Implicit((Action<pDoorState, bool>)delegate(pDoorState state, bool isDropin) { //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_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_000a: 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_000e: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 eDoorStatus status2 = state.status; eDoorStatus val6 = status2; if (val6 - 4 <= 1 || (int)val6 == 9) { AddOverrideCommandWithAlarmText(sdt); } }); break; } return sdt; } public override void Init() { base.Init(); } private void BuildLevelSDTs_Instantiation() { if (!base.definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { return; } foreach (SecurityDoorTerminalDefinition definition in base.definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions) { SecDoorTerminal val = BuildSDT_Instantiation(definition); if (val != null) { if (definition.FCDoorWorldEventObjectFilter != null && definition.FCDoorWorldEventObjectFilter.Length > 0) { extraSDTs[definition.FCDoorWorldEventObjectFilter] = (val, definition); } else { regularSDTs.Add((val, definition)); } } } } private void OnLevelCleanup() { regularSDTs.Clear(); } private SecurityDoorTerminalManager() { EOSWardenEventManager.Current.AddEventDefinition(SDTWardenEvents.ADD_OVERRIDE_COMMAND.ToString(), 1000u, (Action<WardenObjectiveEventData>)WardenEvent_AddOverrideCommand); BatchBuildManager.Current.Add_OnBatchDone((BatchName)75, (Action)BuildLevelSDTs_Instantiation); BatchBuildManager.Current.Add_OnBatchDone((BatchName)76, (Action)BuildLevelSDTs_Passwords); LevelAPI.OnBuildDone += BuildLevelSDTs_UniqueCommands; LevelAPI.OnLevelCleanup += OnLevelCleanup; } static SecurityDoorTerminalManager() { Current = new SecurityDoorTerminalManager(); } } } namespace EOSExt.SecurityDoorTerminal.Definition { public enum OverrideCmdAccess { ALWAYS, ON_UNLOCK, ADDED_BY_WARDEN_EVENT } public class SDTStateSetting_Locked { public bool AccessibleWhenLocked { get; set; } = false; public bool AccessibleWhenUnlocked { get; set; } = true; } public class SDTStateSetting { public SDTStateSetting_Locked LockedStateSetting { get; set; } = new SDTStateSetting_Locked(); public OverrideCmdAccess OverrideCommandAccessibility { get; set; } = OverrideCmdAccess.ON_UNLOCK; public CPSolvedBehaviour OnPuzzleSolved { get; set; } = (CPSolvedBehaviour)1; } public class SecurityDoorTerminalDefinition : GlobalZoneIndex { public string FCDoorWorldEventObjectFilter { get; set; } = string.Empty; public SDTStateSetting StateSettings { get; set; } = new SDTStateSetting(); public TerminalDefinition TerminalSettings { get; set; } = new TerminalDefinition(); } }
plugins/ProjectEternal/Custom/Inas07.EOSExt.TacticalBigPickup.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AIGraph; using AK; using Agents; using BepInEx; using BepInEx.Unity.IL2CPP; using EOSExt.TacticalBigPickup.Definitions.Generic.BigPickup.Definition; using EOSExt.TacticalBigPickup.Functions.EnemyTagger; using EOSExt.TacticalBigPickup.Functions.FogBeacon.BigPickup; using EOSExt.TacticalBigPickup.Functions.FogBeacon.LevelSpawned; using EOSExt.TacticalBigPickup.Functions.Generic.BigPickup; using EOSExt.TacticalBigPickup.Functions.Generic.BigPickup.Definition; using EOSExt.TacticalBigPickup.Impl; using EOSExt.TacticalBigPickup.Impl.FogBeacon.LeveSpawned; using EOSExt.TacticalBigPickup.Managers; using Enemies; using ExtraObjectiveSetup.BaseClasses; using ExtraObjectiveSetup.ExtendedWardenEvents; using ExtraObjectiveSetup.Utils; using GTFO.API; using GTFO.API.Extensions; 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 LevelGeneration; using Microsoft.CodeAnalysis; using Player; using SNetwork; 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 = ".NET 6.0")] [assembly: AssemblyCompany("Inas07.EOSExt.TacticalBigPickup")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8a6ff135634820cf2fae15f8a25ff483cb3eb81b")] [assembly: AssemblyProduct("Inas07.EOSExt.TacticalBigPickup")] [assembly: AssemblyTitle("Inas07.EOSExt.TacticalBigPickup")] [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 EOSExt.TacticalBigPickup { internal static class Assets { public static GameObject OBSVisual { get; private set; } public static void Init() { OBSVisual = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/OBSVisual.prefab"); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Inas.EOSExt.TacticalBigPickup", "EOSExt.TacticalBigPickup", "1.0.0")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas"; public const string PLUGIN_NAME = "EOSExt.TacticalBigPickup"; public const string VERSION = "1.0.0"; private Harmony m_Harmony; public override void Load() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown SetupManagers(); m_Harmony = new Harmony("EOSExt.TacticalBigPickup"); m_Harmony.PatchAll(); EOSLogger.Log("ExtraObjectiveSetup.TacticalBigPickup loaded."); } private void SetupManagers() { ((GenericDefinitionManager<EnemyTaggerSetting>)EnemyTaggerSettingManager.Current).Init(); ((GenericExpeditionDefinitionManager<LevelSpawnedFogBeaconDefinition>)LevelSpawnedFogBeaconSettingManager.Current).Init(); ((GenericDefinitionManager<BigPickupFogBeaconSetting>)BigPickupFogBeaconSettingManager.Current).Init(); ((GenericExpeditionDefinitionManager<BigPickups>)BigPickupCustomizationManager.Current).Init(); AssetAPI.OnAssetBundlesLoaded += Assets.Init; } } } namespace EOSExt.TacticalBigPickup.Patches { [HarmonyPatch] internal static class FixLevelSpawnedFogBeaconRange { [HarmonyPostfix] [HarmonyPatch(typeof(HeavyFogRepellerGlobalState), "AttemptInteract")] private static void Post_HeavyFogRepellerGlobalState_AttemptInteract(HeavyFogRepellerGlobalState __instance) { LevelSpawnedFogBeaconSettings lSFBDef = LevelSpawnedFogBeaconSettingManager.Current.GetLSFBDef(__instance); if (lSFBDef != null) { __instance.m_repellerSphere.Range = lSFBDef.Range; } } } [HarmonyPatch] public static class SetupBigPickupItemWithItemId { public const string BIG_PICKUP_FOG_BEACON_NAME = "Carry_FogBeacon - ConstantFog"; public const string BIG_PICKUP_OBSERVER_NAME = "Carry_Observer"; [HarmonyPostfix] [HarmonyPatch(typeof(LG_PickupItem), "SetupBigPickupItemWithItemId")] private static void Post_Setup(LG_PickupItem __instance, uint itemId) { BigPickupItemManager.Current.Register(__instance); } } } namespace EOSExt.TacticalBigPickup.Managers { public class BigPickupItemManager : PickupItemManager<CarryItemPickup_Core> { public static BigPickupItemManager Current { get; } private BigPickupItemManager() { } static BigPickupItemManager() { Current = new BigPickupItemManager(); } } public static class ItemInLevelUtils { public static (eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex localIndex) GetGlobalZoneIndex(this ItemInLevel item) { //IL_0002: 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_0032: Unknown result type (might be due to invalid IL or missing references) pItemData pItemData = ((Item)item).pItemData; AIG_CourseNode val = default(AIG_CourseNode); if (((pCourseNode)(ref pItemData.originCourseNode)).TryGet(ref val)) { return (val.m_dimension.DimensionIndex, val.LayerType, val.m_zone.LocalIndex); } throw new NullReferenceException("originCourseNode is null"); } public static LG_PickupItem GetLGPickupItem(this ItemInLevel item) { return ((Component)item).GetComponentInParent<LG_PickupItem>(); } } public abstract class PickupItemManager<T> where T : ItemInLevel { protected Dictionary<uint, List<T>> RegisteredItems { get; private set; } = new Dictionary<uint, List<T>>(); public virtual void Register(LG_PickupItem item) { T componentInChildren = ((Component)item.m_root).GetComponentInChildren<T>(); Register(componentInChildren); } public virtual void Register(T item) { ItemDataBlock itemDataBlock = ((Item)(object)item).ItemDataBlock; if (!RegisteredItems.TryGetValue(((GameDataBlockBase<ItemDataBlock>)(object)itemDataBlock).persistentID, out var value)) { value = new List<T>(); RegisteredItems[((GameDataBlockBase<ItemDataBlock>)(object)itemDataBlock).persistentID] = value; } value.Add(item); } public virtual Dictionary<(eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex localIndex), List<T>> GetItemsOf(uint itemId) { List<T> value; return RegisteredItems.TryGetValue(itemId, out value) ? (from item in value group item by ((ItemInLevel)(object)item).GetGlobalZoneIndex()).ToDictionary((IGrouping<(eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex localIndex), T> g) => g.Key, (IGrouping<(eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex localIndex), T> g) => g.ToList()) : null; } protected virtual void OnBuildDone() { } protected virtual void Clear() { RegisteredItems.Clear(); } protected PickupItemManager() { LevelAPI.OnBuildDone += OnBuildDone; LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } static PickupItemManager() { } } } namespace EOSExt.TacticalBigPickup.Impl { public abstract class CustomBigPickupFunctionImplementor { private static Dictionary<string, CustomBigPickupFunctionImplementor> s_implementors; protected abstract string FunctionName { get; } public static void SetupCustomBigPickupFunctions(LG_PickupItem item, List<BigPickupFunction> functions) { foreach (BigPickupFunction function in functions) { if (s_implementors.TryGetValue(function.Type, out var value)) { value.SetupCustomBigPickupFunction(item, function.SettingID); EOSLogger.Log("ICustomBigPickupFunctionImplementor: function '" + function.Type + "' applied to " + ((Object)item).name); } else { EOSLogger.Error("ICustomBigPickupFunctionImplementor: function '" + function.Type + "' not found"); } } } static CustomBigPickupFunctionImplementor() { s_implementors = new Dictionary<string, CustomBigPickupFunctionImplementor>(); IEnumerable<Type> enumerable = from x in typeof(CustomBigPickupFunctionImplementor).Assembly.GetTypes() where !x.IsAbstract where x.IsAssignableTo(typeof(CustomBigPickupFunctionImplementor)) select x; foreach (Type item in enumerable) { CustomBigPickupFunctionImplementor customBigPickupFunctionImplementor = (CustomBigPickupFunctionImplementor)Activator.CreateInstance(item, nonPublic: true); if (s_implementors.TryGetValue(customBigPickupFunctionImplementor.FunctionName, out var _)) { EOSLogger.Error("CustomBigPickupFunctionImplementor: Duplicate " + customBigPickupFunctionImplementor.FunctionName + "!"); continue; } EOSLogger.Log("CustomBigPickupFunctionImplementor: registered " + customBigPickupFunctionImplementor.FunctionName + "!"); s_implementors[customBigPickupFunctionImplementor.FunctionName] = customBigPickupFunctionImplementor; } } public abstract void SetupCustomBigPickupFunction(LG_PickupItem item, uint settingID); } } namespace EOSExt.TacticalBigPickup.Impl.FogBeacon.LeveSpawned { public class LevelSpawnedFogBeacon { public static uint LSFB_ITEM_DB_ID { get; private set; } public static bool HasFogBeaconItemDBDefinition => LSFB_ITEM_DB_ID != 0; public string WorldEventObjectFilter => def?.WorldEventObjectFilter ?? string.Empty; public LevelSpawnedFogBeaconSettings def { get; private set; } public HeavyFogRepellerGlobalState GlobalState { get; private set; } public LG_PickupItem LG_PickupItem { get; private set; } public NavMarker NavMarker { get; private set; } public Vector3 Position { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) LG_PickupItem lG_PickupItem = LG_PickupItem; return (lG_PickupItem != null) ? ((Component)lG_PickupItem).transform.position : Vector3.zero; } } public Color NAV_MARKER_COLOR { get; } = new Color(1f, 0.75686276f, 0.14509805f); public static LevelSpawnedFogBeacon Instantiate(eDimensionIndex dimensionIndex, LG_LayerType layer, eLocalZoneIndex localIndex, LevelSpawnedFogBeaconSettings def) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!HasFogBeaconItemDBDefinition) { EOSLogger.Error("LevelSpawnedFogBeaconManager: ItemDatablock Definition of vanilla Fog Repeller Turbine is not found..."); return null; } LG_Zone val = default(LG_Zone); if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layer, localIndex, ref val) || (Object)(object)val == (Object)null || def.AreaIndex < 0 || def.AreaIndex >= val.m_areas.Count) { EOSLogger.Error($"LevelSpawnedFogBeacon: cannot find {(dimensionIndex, layer, localIndex)}, Area_{(ushort)(65 + def.AreaIndex)}"); return null; } AIG_CourseNode courseNode = val.m_areas[def.AreaIndex].m_courseNode; LevelSpawnedFogBeacon levelSpawnedFogBeacon = new LevelSpawnedFogBeacon(def, courseNode); levelSpawnedFogBeacon.def = def; return levelSpawnedFogBeacon; } internal void Destroy() { Object.Destroy((Object)(object)((Component)LG_PickupItem.m_root).gameObject); GlobalState = null; LG_PickupItem = null; def = null; } private LevelSpawnedFogBeacon(LevelSpawnedFogBeaconSettings def, AIG_CourseNode node) { //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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0087: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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) this.def = def; GameObject val = new GameObject($"LSBF_{def.WorldEventObjectFilter}-Area_{(ushort)(65 + def.AreaIndex)}"); val.transform.SetPositionAndRotation(def.Position.ToVector3(), Quaternion.identity); LG_PickupItem = LG_PickupItem.SpawnGenericPickupItem(val.transform); LG_PickupItem.SpawnNode = node; int count = ((Il2CppArrayBase<Dictionary<byte, iCarryItemWithGlobalState>>)(object)CarryItemWithGlobalStateManager.Current.m_carryItemGlobalStatesInstancesPerType)[0].Count; LG_PickupItem.SetupAsBigPickupItem(1, LSFB_ITEM_DB_ID, false, -1); CarryItemPickup_Core componentInChildren = ((Component)LG_PickupItem.m_root).GetComponentInChildren<CarryItemPickup_Core>(); LG_PickupItem_Sync val2 = ((Il2CppObjectBase)componentInChildren.m_sync).Cast<LG_PickupItem_Sync>(); if ((Object)(object)val2 != (Object)null) { pPickupItemState state = val2.m_stateReplicator.State; ((pCourseNode)(ref state.placement.node)).Set(LG_PickupItem.SpawnNode); } Interact_Pickup_PickupItem val3 = ((Il2CppObjectBase)componentInChildren.m_interact).Cast<Interact_Pickup_PickupItem>(); ((Component)val3).gameObject.SetActive(false); iTerminalItem componentInChildren2 = ((Component)LG_PickupItem).GetComponentInChildren<iTerminalItem>(); if (componentInChildren2 != null) { LG_LevelInteractionManager.DeregisterTerminalItem(componentInChildren2); } NavMarker = GuiManager.NavMarkerLayer.PrepareGenericMarker(((Component)LG_PickupItem).gameObject); if ((Object)(object)NavMarker != (Object)null) { NavMarker.SetColor(NAV_MARKER_COLOR); NavMarker.SetStyle((eNavMarkerStyle)14); NavMarker.SetVisible(false); } iCarryItemWithGlobalState val4 = default(iCarryItemWithGlobalState); if (!CarryItemWithGlobalStateManager.TryGetItemInstance((eCarryItemWithGlobalStateType)0, (byte)count, ref val4)) { EOSLogger.Error("LevelSpawnedFogBeaconManager: Didn't find GlobalState of '" + def.WorldEventObjectFilter + "'"); return; } GlobalState = ((Il2CppObjectBase)val4).Cast<HeavyFogRepellerGlobalState>(); FogRepeller_Sphere repellerSphere = GlobalState.m_repellerSphere; repellerSphere.GrowDuration = def.GrowDuration; repellerSphere.ShrinkDuration = def.ShrinkDuration; repellerSphere.Range = def.Range; HeavyFogRepellerGlobalState globalState = GlobalState; globalState.CallbackOnStateChange += Action<pCarryItemWithGlobalState_State, pCarryItemWithGlobalState_State, bool>.op_Implicit((Action<pCarryItemWithGlobalState_State, pCarryItemWithGlobalState_State, bool>)delegate(pCarryItemWithGlobalState_State oldState, pCarryItemWithGlobalState_State newState, bool isRecall) { //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_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_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_001e: Expected I4, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown eHeavyFogRepellerStatus val5 = (eHeavyFogRepellerStatus)newState.status; eHeavyFogRepellerStatus val6 = val5; eHeavyFogRepellerStatus val7 = val6; switch ((int)val7) { case 0: case 2: NavMarker.SetVisible(false); break; case 1: NavMarker.SetVisible(true); if (isRecall) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(new WardenObjectiveEventData { Type = (eWardenObjectiveEventType)922, WorldEventObjectFilter = WorldEventObjectFilter, Enabled = true, Delay = 1.1f }, (eWardenObjectiveEventTrigger)0, true, 0f); } break; } }); } private static void FindFogTurbineItemDBID() { if (!HasFogBeaconItemDBDefinition) { LSFB_ITEM_DB_ID = ((GameDataBlockBase<ItemDataBlock>)(object)GameDataBlockBase<ItemDataBlock>.GetBlock("Carry_HeavyFogRepeller"))?.persistentID ?? 0; if (LSFB_ITEM_DB_ID == 0) { EOSLogger.Error("LevelSpawnedFogBeaconManager: ItemDatablock Definition of vanilla Fog Repeller Turbine is not found..."); } } } static LevelSpawnedFogBeacon() { LSFB_ITEM_DB_ID = 0u; FindFogTurbineItemDBID(); LevelAPI.OnBuildStart += FindFogTurbineItemDBID; } } } namespace EOSExt.TacticalBigPickup.Impl.FogBeacon.BigPickup { internal class BigPickupFogBeaconImplementor : CustomBigPickupFunctionImplementor { protected override string FunctionName => "FogBeacon"; public override void SetupCustomBigPickupFunction(LG_PickupItem item, uint settingID) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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_0289: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) GenericDefinition<BigPickupFogBeaconSetting> definition = ((GenericDefinitionManager<BigPickupFogBeaconSetting>)BigPickupFogBeaconSettingManager.Current).GetDefinition(settingID); if (definition == null || definition.Definition == null) { EOSLogger.Error($"BigPickupFogBeacon: setting ID {settingID} not found"); return; } BigPickupFogBeaconSetting setting = definition.Definition; FogRepeller_Sphere val = new GameObject("FogInstance_Beacon_Fake").AddComponent<FogRepeller_Sphere>(); val.InfiniteDuration = false; val.LifeDuration = 99999f; val.GrowDuration = 99999f; val.ShrinkDuration = 99999f; val.Range = 1f; FogRepeller_Sphere fogRepHold = new GameObject("FogInstance_Beacon_SmallLayer").AddComponent<FogRepeller_Sphere>(); fogRepHold.InfiniteDuration = setting.RSHold.InfiniteDuration; fogRepHold.GrowDuration = setting.RSHold.GrowDuration; fogRepHold.ShrinkDuration = setting.RSHold.ShrinkDuration; fogRepHold.Range = setting.RSHold.Range; fogRepHold.Offset = Vector3.zero; FogRepeller_Sphere fogRepPlaced = new GameObject("FogInstance_Beacon_BigLayer").AddComponent<FogRepeller_Sphere>(); fogRepPlaced.InfiniteDuration = setting.RSPlaced.InfiniteDuration; fogRepPlaced.GrowDuration = setting.RSPlaced.GrowDuration; fogRepPlaced.ShrinkDuration = setting.RSPlaced.ShrinkDuration; fogRepPlaced.Range = setting.RSPlaced.Range; fogRepPlaced.Offset = Vector3.zero; CarryItemPickup_Core componentInChildren = ((Component)item.m_root).GetComponentInChildren<CarryItemPickup_Core>(); HeavyFogRepellerPickup val2 = ((Il2CppObjectBase)componentInChildren).Cast<HeavyFogRepellerPickup>(); iCarryItemWithGlobalState val3 = default(iCarryItemWithGlobalState); byte byteId = default(byte); if (CarryItemWithGlobalStateManager.TryCreateItemInstance((eCarryItemWithGlobalStateType)0, item.m_root, ref val3, ref byteId)) { pItemData_Custom customData = ((Item)val2).GetCustomData(); customData.byteId = byteId; pItemData_Custom val4 = customData; ((Item)val2).SetCustomData(val4, true); } HeavyFogRepellerGlobalState val5 = ((Il2CppObjectBase)val3).Cast<HeavyFogRepellerGlobalState>(); ((Component)fogRepHold).transform.SetParent(((Component)val5).transform, false); ((Component)fogRepPlaced).transform.SetParent(((Component)val5).transform, false); val5.m_repellerSphere = val; fogRepHold.m_sphereAllocator = new FogSphereAllocator(); fogRepPlaced.m_sphereAllocator = new FogSphereAllocator(); Interact_Pickup_PickupItem interact = ((Il2CppObjectBase)componentInChildren.m_interact).Cast<Interact_Pickup_PickupItem>(); ((Interact_Timed)interact).InteractDuration = setting.TimeToPickup; val5.CallbackOnStateChange += Action<pCarryItemWithGlobalState_State, pCarryItemWithGlobalState_State, bool>.op_Implicit((Action<pCarryItemWithGlobalState_State, pCarryItemWithGlobalState_State, bool>)delegate(pCarryItemWithGlobalState_State oldState, pCarryItemWithGlobalState_State newState, bool isRecall) { //IL_0030: 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_0037: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (isRecall) { FogRepeller_Sphere obj = fogRepHold; if (obj != null) { obj.KillRepellerInstantly(); } FogRepeller_Sphere obj2 = fogRepPlaced; if (obj2 != null) { obj2.KillRepellerInstantly(); } } else { eHeavyFogRepellerStatus val6 = (eHeavyFogRepellerStatus)newState.status; eHeavyFogRepellerStatus val7 = val6; if ((int)val7 != 1) { if ((int)val7 == 2) { FogRepeller_Sphere obj3 = fogRepHold; if (obj3 != null) { obj3.StopRepelling(); } FogRepeller_Sphere obj4 = fogRepPlaced; if (obj4 != null) { obj4.StartRepelling(); } ((Interact_Timed)interact).InteractDuration = setting.TimeToPickup; } } else { FogRepeller_Sphere obj5 = fogRepHold; if (obj5 != null) { obj5.StartRepelling(); } if (oldState.status != 0) { FogRepeller_Sphere obj6 = fogRepPlaced; if (obj6 != null) { obj6.StopRepelling(); } } ((Interact_Timed)interact).InteractDuration = setting.TimeToPlace; } } }); } internal BigPickupFogBeaconImplementor() { } } } namespace EOSExt.TacticalBigPickup.Impl.EnemyTagger { internal class EnemyTaggerImplementor : CustomBigPickupFunctionImplementor { private List<GameObject> obsVisuals = new List<GameObject>(); protected override string FunctionName => "EnemyTagger"; public IEnumerable<GameObject> OBSVisuals => obsVisuals; public override void SetupCustomBigPickupFunction(LG_PickupItem __instance, uint settingID) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) GenericDefinition<EnemyTaggerSetting> definition = ((GenericDefinitionManager<EnemyTaggerSetting>)EnemyTaggerSettingManager.Current).GetDefinition(settingID); if (definition == null || definition.Definition == null) { EOSLogger.Error($"EnemyTagger: setting ID {settingID} not found"); return; } EnemyTaggerSetting setting = definition.Definition; CarryItemPickup_Core core = ((Component)__instance.m_root).GetComponentInChildren<CarryItemPickup_Core>(); Interact_Pickup_PickupItem interact = ((Il2CppObjectBase)core.m_interact).Cast<Interact_Pickup_PickupItem>(); LG_PickupItem_Sync val = ((Il2CppObjectBase)core.m_sync).Cast<LG_PickupItem_Sync>(); EnemyTaggerComponent tagger = ((Component)core).gameObject.AddComponent<EnemyTaggerComponent>(); tagger.Parent = core; ((Component)tagger).gameObject.SetActive(true); ((Interact_Timed)interact).InteractDuration = setting.TimeToPickup; tagger.MaxTagPerScan = setting.MaxTagPerScan; tagger.TagInterval = setting.TagInterval; tagger.TagRadius = setting.TagRadius; tagger.WarmupTime = setting.WarmupTime; GameObject obsVisual = null; if (setting.UseVisual) { obsVisual = Object.Instantiate<GameObject>(Assets.OBSVisual, ((Component)__instance).transform); obsVisual.transform.localScale = new Vector3(setting.TagRadius, setting.TagRadius, setting.TagRadius); obsVisual.SetActive(false); obsVisuals.Add(obsVisual); } val.OnSyncStateChange += Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>.op_Implicit((Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>)delegate(ePickupItemStatus status, pPickupPlacement placement, PlayerAgent playerAgent, bool isRecall) { //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) //IL_0004: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) if ((int)status != 0) { if ((int)status == 1) { ((Component)tagger).gameObject.SetActive(true); tagger.PickedByPlayer = playerAgent; tagger.ChangeState((!setting.TagWhenHold) ? eEnemyTaggerState.Inactive : eEnemyTaggerState.Active_Warmup); ((Interact_Timed)interact).InteractDuration = setting.TimeToPlace; if ((Object)(object)obsVisual != (Object)null && obsVisual.active) { CoroutineManager.BlinkOut(obsVisual, 0f); } } } else { tagger.PickedByPlayer = null; tagger.ChangeState((!setting.TagWhenPlaced) ? eEnemyTaggerState.Inactive : eEnemyTaggerState.Active_Warmup); ((Interact_Timed)interact).InteractDuration = setting.TimeToPickup; if ((Object)(object)obsVisual != (Object)null) { obsVisual.gameObject.transform.SetPositionAndRotation(placement.position, placement.rotation); if (isRecall) { if (((ItemInLevel)core).CanWarp) { CoroutineManager.BlinkIn(obsVisual, tagger.WarmupTime); } } else if (!obsVisual.active && setting.TagWhenPlaced) { CoroutineManager.BlinkIn(obsVisual, tagger.WarmupTime); } } } }); } private void AddOBSVisualRenderers() { } private void Clear() { obsVisuals.Clear(); } internal EnemyTaggerImplementor() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } } public enum eEnemyTaggerState { Uninitialized, Inactive, Active_Warmup, Active_Tagging } public class EnemyTaggerComponent : MonoBehaviour { private const float INACTIVE_SOUND_UPDATE_INTERVAL = 4f; internal int MaxTagPerScan = 12; internal float TagInterval = 3f; internal float TagRadius = 12f; internal float WarmupTime = 3f; private eEnemyTaggerState CurrentState = eEnemyTaggerState.Uninitialized; private CellSoundPlayer m_sound = new CellSoundPlayer(); private List<EnemyAgent> TaggableEnemies = new List<EnemyAgent>(); private float UpdateTime = 0f; internal CarryItemPickup_Core Parent { get; set; } = null; internal PlayerAgent PickedByPlayer { get; set; } = null; internal Vector3 Position => ((Object)(object)Parent == (Object)null) ? Vector3.zero : (((Object)(object)PickedByPlayer == (Object)null) ? ((Component)Parent).transform.position : ((Component)PickedByPlayer).transform.position); public void ChangeState(eEnemyTaggerState newState) { if (CurrentState == newState) { return; } switch (newState) { case eEnemyTaggerState.Uninitialized: EOSLogger.Error("Enemy Tagger changed to state 'uninitialized'?"); return; case eEnemyTaggerState.Inactive: UpdateTime = 0f; TaggableEnemies.Clear(); m_sound.Post(EVENTS.BULKHEAD_BUTTON_CLOSE, true); break; case eEnemyTaggerState.Active_Warmup: UpdateTime = 0f; m_sound.Post(EVENTS.BUTTONGENERICDEACTIVATE, true); break; case eEnemyTaggerState.Active_Tagging: if (CurrentState != eEnemyTaggerState.Active_Warmup) { UpdateTime = 0f; } break; default: EOSLogger.Error($"Enemy Tagger: Undefined state {CurrentState}"); return; } CurrentState = newState; } private bool UpdateTaggableEnemies() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) TaggableEnemies.Clear(); bool result = false; List<EnemyAgent> reachableEnemiesInNodes = AIG_CourseGraph.GetReachableEnemiesInNodes(((Object)(object)PickedByPlayer == (Object)null) ? ((ItemInLevel)Parent).m_courseNode : ((Agent)PickedByPlayer).CourseNode, 2); Enumerator<EnemyAgent> enumerator = reachableEnemiesInNodes.GetEnumerator(); while (enumerator.MoveNext()) { EnemyAgent current = enumerator.Current; if (!((Agent)current).Alive) { continue; } Vector3 val = ((Component)current).transform.position - Position; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude > TagRadius)) { result = true; if (!current.IsTagged) { TaggableEnemies.Add(current); } if (TaggableEnemies.Count >= MaxTagPerScan) { break; } } } return result; } private void StartTagging() { if (!(UpdateTime >= TagInterval)) { return; } if (SNet.IsMaster) { UpdateTaggableEnemies(); foreach (EnemyAgent taggableEnemy in TaggableEnemies) { ToolSyncManager.WantToTagEnemy(taggableEnemy); } } UpdateTime = 0f; } private void StopTagging() { if (UpdateTime >= 4f) { m_sound.Post(EVENTS.BUTTONGENERICDEACTIVATE, true); UpdateTime = 0f; } } private void Warmup() { if (UpdateTime >= WarmupTime) { ChangeState(eEnemyTaggerState.Active_Tagging); UpdateTime = TagInterval; } } private void Update() { //IL_0047: 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) if (CurrentState == eEnemyTaggerState.Uninitialized) { return; } if ((Object)(object)Parent == (Object)null) { EOSLogger.Error("EnemyTagger: null parent"); return; } UpdateTime += Time.deltaTime; m_sound.UpdatePosition(Position); switch (CurrentState) { case eEnemyTaggerState.Active_Warmup: Warmup(); break; case eEnemyTaggerState.Active_Tagging: StartTagging(); break; case eEnemyTaggerState.Inactive: StopTagging(); break; } } private void OnDestroy() { StopTagging(); TaggableEnemies.Clear(); TaggableEnemies = null; if (m_sound != null) { m_sound.Stop(); m_sound.Recycle(); m_sound = null; } Parent = null; } static EnemyTaggerComponent() { ClassInjector.RegisterTypeInIl2Cpp<EnemyTaggerComponent>(); } } } namespace EOSExt.TacticalBigPickup.Definitions.Generic.BigPickup.Definition { public class BigPickupFunction { public string Type { get; set; } = string.Empty; public uint SettingID { get; set; } = 0u; } } namespace EOSExt.TacticalBigPickup.Functions.FogBeacon.LevelSpawned { public class LevelSpawnedFogBeaconSettings { public int AreaIndex { get; set; } = 0; public float GrowDuration { get; set; } = 10f; public float ShrinkDuration { get; set; } = 10f; public float Range { get; set; } = 11f; public string WorldEventObjectFilter { get; set; } = string.Empty; public Vec3 Position { get; set; } = new Vec3(); } public class LevelSpawnedFogBeaconDefinition : GlobalZoneIndex { public List<LevelSpawnedFogBeaconSettings> SpawnedBeaconsInZone { get; set; } = new List<LevelSpawnedFogBeaconSettings> { new LevelSpawnedFogBeaconSettings() }; } public class LevelSpawnedFogBeaconSettingManager : GenericExpeditionDefinitionManager<LevelSpawnedFogBeaconDefinition> { public enum LSFBEvent { ToggleLevelSpawnedFogBeaconState = 922 } private Dictionary<IntPtr, LevelSpawnedFogBeaconSettings> LSFBGlobalStatesSet = new Dictionary<IntPtr, LevelSpawnedFogBeaconSettings>(); public static LevelSpawnedFogBeaconSettingManager Current { get; } protected override string DEFINITION_NAME => "LevelSpawnedFogBeacon_EOS"; private Dictionary<string, LevelSpawnedFogBeacon> LevelSpawnedFogBeacons { get; } = new Dictionary<string, LevelSpawnedFogBeacon>(); private void Build(LevelSpawnedFogBeaconDefinition def) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) foreach (LevelSpawnedFogBeaconSettings item in def.SpawnedBeaconsInZone) { if (item.WorldEventObjectFilter == null || item.WorldEventObjectFilter == string.Empty || LevelSpawnedFogBeacons.ContainsKey(item.WorldEventObjectFilter)) { EOSLogger.Error("LevelSpawnedFogBeaconManager: WorldEventObjectFilter '" + item.WorldEventObjectFilter + "' is either unassigned or has already been assigned."); continue; } LevelSpawnedFogBeacon levelSpawnedFogBeacon = LevelSpawnedFogBeacon.Instantiate(((GlobalZoneIndex)def).DimensionIndex, ((GlobalZoneIndex)def).LayerType, ((GlobalZoneIndex)def).LocalIndex, item); if (levelSpawnedFogBeacon != null) { LevelSpawnedFogBeacons[item.WorldEventObjectFilter] = levelSpawnedFogBeacon; LSFBGlobalStatesSet[((Il2CppObjectBase)levelSpawnedFogBeacon.GlobalState).Pointer] = item; EOSLogger.Debug($"LevelSpawnedFogBeaconManager: spawned '{item.WorldEventObjectFilter}' in {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}, Area_{(ushort)(65 + item.AreaIndex)}"); } } } public LevelSpawnedFogBeaconSettings GetLSFBDef(HeavyFogRepellerGlobalState h) { LevelSpawnedFogBeaconSettings value; return LSFBGlobalStatesSet.TryGetValue(((Il2CppObjectBase)h).Pointer, out value) ? value : null; } public void ToggleLSFBState(string worldEventgObjectFilter, bool enable) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!LevelSpawnedFogBeacons.TryGetValue(worldEventgObjectFilter, out var value)) { EOSLogger.Error("ToggleLSFBState: '" + worldEventgObjectFilter + "' is not defined"); } else if (SNet.IsMaster) { value.GlobalState.AttemptInteract(new pCarryItemWithGlobalState_Interaction { type = (byte)((!enable) ? 1 : 0), owner = (eCarryItemWithGlobalStateOwner)2, staticPosition = value.Position }); } } private void Clear() { foreach (LevelSpawnedFogBeacon value in LevelSpawnedFogBeacons.Values) { value.Destroy(); } LSFBGlobalStatesSet.Clear(); LevelSpawnedFogBeacons.Clear(); } private void BuildLevelSpawnedFogBeacons() { if (base.definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { base.definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions.ForEach(Build); } } private LevelSpawnedFogBeaconSettingManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; LevelAPI.OnBuildDone += BuildLevelSpawnedFogBeacons; EOSWardenEventManager.Current.AddEventDefinition(LSFBEvent.ToggleLevelSpawnedFogBeaconState.ToString(), 922u, (Action<WardenObjectiveEventData>)ToggleLevelSpawnedFogBeaconState); } static LevelSpawnedFogBeaconSettingManager() { Current = new LevelSpawnedFogBeaconSettingManager(); } private static void ToggleLevelSpawnedFogBeaconState(WardenObjectiveEventData e) { Current.ToggleLSFBState(e.WorldEventObjectFilter, e.Enabled); } } } namespace EOSExt.TacticalBigPickup.Functions.FogBeacon.BigPickup { public class RepellerSphereSetting { public bool InfiniteDuration { get; set; } = false; public float GrowDuration { get; set; } = 10f; public float ShrinkDuration { get; set; } = 10f; public float Range { get; set; } = 11f; } public class BigPickupFogBeaconSetting { 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 BigPickupFogBeaconSettingManager : GenericDefinitionManager<BigPickupFogBeaconSetting> { public static BigPickupFogBeaconSettingManager Current { get; private set; } protected override string DEFINITION_NAME => "BigPickupFogBeacon_EOS"; public override void Init() { } private BigPickupFogBeaconSettingManager() { } static BigPickupFogBeaconSettingManager() { Current = new BigPickupFogBeaconSettingManager(); } } } namespace EOSExt.TacticalBigPickup.Functions.EnemyTagger { public class EnemyTaggerSetting { public float TimeToPickup { get; set; } = 1f; public float TimeToPlace { get; set; } = 1f; public float WarmupTime { get; set; } = 5f; public int MaxTagPerScan { get; set; } = 12; public float TagInterval { get; set; } = 3f; public float TagRadius { get; set; } = 12f; public bool TagWhenPlaced { get; set; } = true; public bool TagWhenHold { get; set; } = false; public bool UseVisual { get; set; } = false; } public class EnemyTaggerSettingManager : GenericDefinitionManager<EnemyTaggerSetting> { public static EnemyTaggerSettingManager Current { get; } protected override string DEFINITION_NAME => "EnemyTagger_EOS"; private EnemyTaggerSettingManager() { } static EnemyTaggerSettingManager() { Current = new EnemyTaggerSettingManager(); Current = new EnemyTaggerSettingManager(); } } } namespace EOSExt.TacticalBigPickup.Functions.Generic.BigPickup { public class BigPickupCustomHelper : MonoBehaviour { private Dictionary<ePickupItemStatus, List<WardenObjectiveEventData>> eventsOnState = new Dictionary<ePickupItemStatus, List<WardenObjectiveEventData>>(); public ItemInLevel Item { get; private set; } private void Setup(ItemInLevel item) { Item = item; item.GetSyncComponent().OnSyncStateChange += Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>.op_Implicit((Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>)OnSyncStateChange); } public bool TryGetEvents(ePickupItemStatus state, out List<WardenObjectiveEventData> events) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return eventsOnState.TryGetValue(state, out events); } private void OnSyncStateChange(ePickupItemStatus state, pPickupPlacement placement, PlayerAgent player, bool isRecall) { //IL_000d: 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) if (!isRecall && TryGetEvents(state, out var events)) { EOSLogger.Log($"item {((Item)Item).PublicName} on state {state}, executing {events.Count} events"); WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(ListExtensions.ToIl2Cpp<WardenObjectiveEventData>(events), (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); } } private void OnDestroy() { eventsOnState.Clear(); eventsOnState = null; } private BigPickupCustomHelper() { } public static void Setup(ItemInLevel item, BigPickupCustomization states) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) BigPickupCustomHelper bigPickupCustomHelper = ((Component)item).gameObject.GetComponent<BigPickupCustomHelper>(); if ((Object)(object)bigPickupCustomHelper == (Object)null) { bigPickupCustomHelper = ((Component)item).gameObject.AddComponent<BigPickupCustomHelper>(); bigPickupCustomHelper.Setup(item); } foreach (BigPickupStateEvent item2 in states.OnState) { if (!bigPickupCustomHelper.eventsOnState.TryGetValue(item2.State, out var value)) { value = new List<WardenObjectiveEventData>(); bigPickupCustomHelper.eventsOnState[item2.State] = value; } value.AddRange(item2.EventsOnState); } } static BigPickupCustomHelper() { ClassInjector.RegisterTypeInIl2Cpp<BigPickupCustomHelper>(); } } public class BigPickupCustomizationManager : GenericExpeditionDefinitionManager<BigPickups> { public static BigPickupCustomizationManager Current { get; } = new BigPickupCustomizationManager(); protected override string DEFINITION_NAME => "BigPickupCustomization"; private void Build(BigPickups def) { Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), List<CarryItemPickup_Core>> itemsOf = BigPickupItemManager.Current.GetItemsOf(def.ItemId); foreach (BigPickupCustomization bigPickupItem in def.BigPickupItems) { if (!itemsOf.TryGetValue(((GlobalZoneIndex)bigPickupItem).GlobalZoneIndexTuple(), out var value)) { EOSLogger.Error($"EventsOnBigPickup: zone not found {((GlobalZoneIndex)bigPickupItem).GlobalZoneIndexTuple()}"); } else if (bigPickupItem.Index < 0 || bigPickupItem.Index >= value.Count) { EOSLogger.Error($"EventsOnBigPickup: itemID {def.ItemId}, index {bigPickupItem.Index} is invalid - there're {value.Count} items in {((GlobalZoneIndex)bigPickupItem).GlobalZoneIndexTuple()} - valid value falls in range [0, {value.Count - 1})"); } else { CarryItemPickup_Core item = value[bigPickupItem.Index]; BigPickupCustomHelper.Setup((ItemInLevel)(object)item, bigPickupItem); CustomBigPickupFunctionImplementor.SetupCustomBigPickupFunctions(((ItemInLevel)(object)item).GetLGPickupItem(), bigPickupItem.Functions); } } } private void Build() { if (base.definitions.TryGetValue(RundownManager.ActiveExpedition.LevelLayoutData, out var value)) { value.Definitions.ForEach(Build); } } public BigPickupCustomizationManager() { LevelAPI.OnBuildDone += Build; } } } namespace EOSExt.TacticalBigPickup.Functions.Generic.BigPickup.Definition { public class BigPickupCustomization : GlobalZoneIndex { public int Index { get; set; } = 0; public List<BigPickupFunction> Functions { get; set; } = new List<BigPickupFunction> { new BigPickupFunction() }; public List<BigPickupStateEvent> OnState { get; set; } = new List<BigPickupStateEvent> { new BigPickupStateEvent() }; } public class BigPickupStateEvent { public ePickupItemStatus State { get; set; } public List<WardenObjectiveEventData> EventsOnState { get; set; } = new List<WardenObjectiveEventData>(); } public class BigPickups { public uint ItemId { get; set; } = 0u; public List<BigPickupCustomization> BigPickupItems { get; set; } = new List<BigPickupCustomization> { new BigPickupCustomization() }; } }
plugins/ProjectEternal/Custom/Inas07.ThermalSights.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json.Serialization; using AssetShards; using BepInEx; using BepInEx.Unity.IL2CPP; using ChainedPuzzles; using ExtraObjectiveSetup.BaseClasses; using ExtraObjectiveSetup.Expedition.Gears; using ExtraObjectiveSetup.Utils; using FirstPersonItem; using GTFO.API; using GTFO.API.Utilities; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using ThermalSights.Definition; 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("Inas07.ThermalSights")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Inas07.ThermalSights")] [assembly: AssemblyTitle("Inas07.ThermalSights")] [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 ThermalSights { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Inas.ThermalSights", "ThermalSights", "1.0.0")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas"; public const string PLUGIN_NAME = "ThermalSights"; public const string VERSION = "1.0.0"; private Harmony m_Harmony; public override void Load() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown SetupManagers(); m_Harmony = new Harmony("ThermalSights"); m_Harmony.PatchAll(); EOSLogger.Log("ThermalSights loaded."); } private void SetupManagers() { AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)delegate { ((GenericDefinitionManager<TSADefinition>)TSAManager.Current).Init(); }); } } public class TSAManager : GenericDefinitionManager<TSADefinition> { public class PuzzleVisualWrapper { public GameObject GO { get; set; } public Renderer Renderer { get; set; } public float Intensity { get; set; } public float BehindWallIntensity { get; set; } public void SetIntensity(float t) { if (GO.active) { if (Intensity > 0f) { Renderer.material.SetFloat("_Intensity", Intensity * t); } if (BehindWallIntensity > 0f) { Renderer.material.SetFloat("_BehindWallIntensity", BehindWallIntensity * t); } } } } private const bool OUTPUT_THERMAL_SHADER_SETTINGS_ON_WIELD = false; public static TSAManager Current { get; } protected override string DEFINITION_NAME => "ThermalSight"; private Dictionary<uint, Renderer[]> InLevelGearThermals { get; } = new Dictionary<uint, Renderer[]>(); private HashSet<uint> ModifiedInLevelGearThermals { get; } = new HashSet<uint>(); private HashSet<uint> ThermalOfflineGears { get; } = new HashSet<uint>(); public uint CurrentGearPID { get; private set; } private List<PuzzleVisualWrapper> PuzzleVisuals { get; } = new List<PuzzleVisualWrapper>(); protected override void FileChanged(LiveEditEventArgs e) { base.FileChanged(e); InitThermalOfflineGears(); CleanupInLevelGearThermals(keepCurrentGear: true); TrySetThermalSightRenderer(CurrentGearPID); } public override void Init() { InitThermalOfflineGears(); } private void InitThermalOfflineGears() { ThermalOfflineGears.Clear(); foreach (PlayerOfflineGearDataBlock allBlock in GameDataBlockBase<PlayerOfflineGearDataBlock>.GetAllBlocks()) { if (((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).name.ToLowerInvariant().EndsWith("_t")) { ThermalOfflineGears.Add(((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).persistentID); } } EOSLogger.Debug($"Found OfflineGear with thermal sight, count: {ThermalOfflineGears.Count}"); } private bool TryGetInLevelGearThermalRenderersFromItem(ItemEquippable item, uint gearPID, out Renderer[] renderers) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) renderers = null; if (item.GearIDRange == null) { return false; } if (gearPID == 0) { gearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange); } if (gearPID == 0 || !IsGearWithThermal(gearPID)) { return false; } bool flag = false; if (!InLevelGearThermals.ContainsKey(gearPID)) { flag = true; } else { try { _ = ((Component)InLevelGearThermals[gearPID][0]).gameObject.transform.position; flag = false; } catch { ModifiedInLevelGearThermals.Remove(gearPID); flag = true; } } if (flag) { renderers = (from x in ((IEnumerable<Renderer>)((Component)item).GetComponentsInChildren<Renderer>(true))?.Where((Renderer x) => (Object)(object)x.sharedMaterial != (Object)null && (Object)(object)x.sharedMaterial.shader != (Object)null) where ((Object)x.sharedMaterial.shader).name.ToLower().Contains("Thermal".ToLower()) select x).ToArray() ?? null; if (renderers != null) { if (renderers.Length != 1) { EOSLogger.Warning(((Item)item).PublicName + " contains more than 1 thermal renderers!"); } InLevelGearThermals[gearPID] = renderers; return true; } EOSLogger.Debug(((Item)item).PublicName + ": thermal renderer not found"); return false; } renderers = InLevelGearThermals[gearPID]; return true; } internal bool TrySetThermalSightRenderer(uint gearPID = 0u) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) if (gearPID == 0) { gearPID = CurrentGearPID; } if (!IsGearWithThermal(gearPID)) { return false; } if (ModifiedInLevelGearThermals.Contains(gearPID)) { return true; } if (base.definitions.TryGetValue(gearPID, out var value) && InLevelGearThermals.TryGetValue(gearPID, out var value2)) { TSShader shader = value.Definition.Shader; Renderer[] array = value2; foreach (Renderer val in array) { PropertyInfo[] properties = shader.GetType().GetProperties(); foreach (PropertyInfo propertyInfo in properties) { Type type = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType; string text = "_" + propertyInfo.Name; if (type == typeof(float)) { val.material.SetFloat(text, (float)propertyInfo.GetValue(shader)); } else if (type == typeof(EOSColor)) { EOSColor val2 = (EOSColor)propertyInfo.GetValue(shader); val.material.SetVector(text, Color.op_Implicit(val2.ToUnityColor())); } else if (type == typeof(bool)) { bool flag = (bool)propertyInfo.GetValue(shader); val.material.SetFloat(text, flag ? 1f : 0f); } else if (type == typeof(Vec4)) { Vec4 val3 = (Vec4)propertyInfo.GetValue(shader); val.material.SetVector(text, val3.ToVector4()); } } } ModifiedInLevelGearThermals.Add(gearPID); return true; } return false; } internal void OnPlayerItemWielded(FirstPersonItemHolder fpsItemHolder, ItemEquippable item) { if (item.GearIDRange == null) { CurrentGearPID = 0u; return; } CurrentGearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange); TryGetInLevelGearThermalRenderersFromItem(item, CurrentGearPID, out var _); TrySetThermalSightRenderer(CurrentGearPID); } public bool IsGearWithThermal(uint gearPID) { return ThermalOfflineGears.Contains(gearPID); } private void CleanupInLevelGearThermals(bool keepCurrentGear = false) { if (!keepCurrentGear || !InLevelGearThermals.ContainsKey(CurrentGearPID)) { InLevelGearThermals.Clear(); } else { Renderer[] value = InLevelGearThermals[CurrentGearPID]; InLevelGearThermals.Clear(); InLevelGearThermals[CurrentGearPID] = value; } ModifiedInLevelGearThermals.Clear(); } internal void SetCurrentThermalSightSettings(float t) { if (InLevelGearThermals.TryGetValue(CurrentGearPID, out var value) && base.definitions.TryGetValue(CurrentGearPID, out var value2)) { Renderer[] array = value; foreach (Renderer obj in array) { float zoom = value2.Definition.Shader.Zoom; float offAimPixelZoom = value2.Definition.OffAimPixelZoom; float num = Mathf.Lerp(zoom, offAimPixelZoom, t); obj.material.SetFloat("_Zoom", num); } } } private void Clear() { CurrentGearPID = 0u; CleanupInLevelGearThermals(); CleanupPuzzleVisuals(); } private TSAManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } static TSAManager() { Current = new TSAManager(); } public void RegisterPuzzleVisual(CP_Bioscan_Core core) { Il2CppArrayBase<Renderer> componentsInChildren = ((Component)core).gameObject.GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null) { return; } foreach (Renderer item2 in ((IEnumerable<Renderer>)componentsInChildren).Where((Renderer comp) => ((Object)((Component)comp).gameObject).name.Equals("Zone")).ToList()) { GameObject gameObject = ((Component)item2).gameObject; float @float = item2.material.GetFloat("_Intensity"); float float2 = item2.material.GetFloat("_BehindWallIntensity"); PuzzleVisualWrapper item = new PuzzleVisualWrapper { GO = gameObject, Renderer = item2, Intensity = @float, BehindWallIntensity = float2 }; PuzzleVisuals.Add(item); } } public void RegisterPuzzleVisual(PuzzleVisualWrapper wrapper) { PuzzleVisuals.Add(wrapper); } internal void SetPuzzleVisualsIntensity(float t) { PuzzleVisuals.ForEach(delegate(PuzzleVisualWrapper v) { v.SetIntensity(t); }); } private void CleanupPuzzleVisuals() { PuzzleVisuals.Clear(); } } } namespace ThermalSights.Patches { internal static class CP_Bioscan_Core_Setup { [HarmonyPostfix] [HarmonyPatch(typeof(CP_Bioscan_Core), "Setup")] private static void Post_CaptureBioscanVisual(CP_Bioscan_Core __instance) { TSAManager.Current.RegisterPuzzleVisual(__instance); } } [HarmonyPatch] internal static class FirstPersonItemHolder_SetWieldedItem { public static event Action<FirstPersonItemHolder, ItemEquippable> OnItemWielded; [HarmonyPostfix] [HarmonyPatch(typeof(FirstPersonItemHolder), "SetWieldedItem")] private static void Post_SetWieldedItem(FirstPersonItemHolder __instance, ItemEquippable item) { TSAManager.Current.OnPlayerItemWielded(__instance, item); TSAManager.Current.SetPuzzleVisualsIntensity(1f); TSAManager.Current.SetCurrentThermalSightSettings(1f); FirstPersonItemHolder_SetWieldedItem.OnItemWielded?.Invoke(__instance, item); } } [HarmonyPatch] internal static class FPIS_Aim_Update { public static event Action<FPIS_Aim, float> OnAimUpdate; [HarmonyPostfix] [HarmonyPatch(typeof(FPIS_Aim), "Update")] private static void Post_Aim_Update(FPIS_Aim __instance) { if (!((Object)(object)((FPItemState)__instance).Holder.WieldedItem == (Object)null)) { float num = 1f - FirstPersonItemHolder.m_transitionDelta; if (!TSAManager.Current.IsGearWithThermal(TSAManager.Current.CurrentGearPID)) { num = Math.Max(0.05f, num); } else { TSAManager.Current.SetCurrentThermalSightSettings(num); } TSAManager.Current.SetPuzzleVisualsIntensity(num); FPIS_Aim_Update.OnAimUpdate?.Invoke(__instance, num); } } } } namespace ThermalSights.Definition { public class TSADefinition { public float OffAimPixelZoom { get; set; } = 1f; public TSShader Shader { get; set; } = new TSShader(); } public class TSShader { [JsonPropertyName("DistanceFalloff")] [Range(0.0, 1.0)] public float HeatFalloff { get; set; } = 0.01f; [Range(0.0, 1.0)] public float FogFalloff { get; set; } = 0.1f; [JsonPropertyName("PixelZoom")] [Range(0.0, 1.0)] public float Zoom { get; set; } = 0.8f; [JsonPropertyName("AspectRatioAdjust")] [Range(0.0, 2.0)] public float RatioAdjust { get; set; } = 1f; [Range(0.0, 1.0)] public float DistortionCenter { get; set; } = 0.5f; public float DistortionScale { get; set; } = 1f; public float DistortionSpeed { get; set; } = 1f; public float DistortionSignalSpeed { get; set; } = 0.025f; [Range(0.0, 1.0)] public float DistortionMin { get; set; } = 0.01f; [Range(0.0, 1.0)] public float DistortionMax { get; set; } = 0.4f; [JsonPropertyName("AmbientTemperature")] [Range(0.0, 1.0)] public float AmbientTemp { get; set; } = 0.15f; [JsonPropertyName("BackgroundTemperature")] [Range(0.0, 1.0)] public float BackgroundTemp { get; set; } = 0.05f; [Range(0.0, 10.0)] public float AlbedoColorFactor { get; set; } = 0.5f; [Range(0.0, 10.0)] public float AmbientColorFactor { get; set; } = 5f; public float OcclusionHeat { get; set; } = 0.5f; public float BodyOcclusionHeat { get; set; } = 2.5f; [Range(0.0, 1.0)] public float ScreenIntensity { get; set; } = 0.2f; [Range(0.0, 1.0)] public float OffAngleFade { get; set; } = 0.95f; [Range(0.0, 1.0)] public float Noise { get; set; } = 0.1f; [JsonPropertyName("MinShadowEnemyDistortion")] [Range(0.0, 1.0)] public float DistortionMinShadowEnemies { get; set; } = 0.2f; [JsonPropertyName("MaxShadowEnemyDistortion")] [Range(0.0, 1.0)] public float DistortionMaxShadowEnemies { get; set; } = 1f; [Range(0.0, 1.0)] public float DistortionSignalSpeedShadowEnemies { get; set; } = 1f; public float ShadowEnemyFresnel { get; set; } = 10f; [Range(0.0, 1.0)] public float ShadowEnemyHeat { get; set; } = 0.1f; public EOSColor ReticuleColorA { get; set; } = new EOSColor { r = 1f, g = 1f, b = 1f, a = 1f }; public EOSColor ReticuleColorB { get; set; } = new EOSColor { r = 1f, g = 1f, b = 1f, a = 1f }; public EOSColor ReticuleColorC { get; set; } = new EOSColor { r = 1f, g = 1f, b = 1f, a = 1f }; [Range(0.0, 20.0)] public float SightDirt { get; set; } public bool LitGlass { get; set; } public bool ClipBorders { get; set; } = true; public Vec4 AxisX { get; set; } = new Vec4(); public Vec4 AxisY { get; set; } = new Vec4(); public Vec4 AxisZ { get; set; } = new Vec4(); public bool Flip { get; set; } = true; [JsonPropertyName("Distance1")] [Range(0.0, 100.0)] public float ProjDist1 { get; set; } = 100f; [JsonPropertyName("Distance2")] [Range(0.0, 100.0)] public float ProjDist2 { get; set; } = 66f; [JsonPropertyName("Distance3")] [Range(0.0, 100.0)] public float ProjDist3 { get; set; } = 33f; [JsonPropertyName("Size1")] [Range(0.0, 3.0)] public float ProjSize1 { get; set; } = 1f; [JsonPropertyName("Size2")] [Range(0.0, 3.0)] public float ProjSize2 { get; set; } = 1f; [JsonPropertyName("Size3")] [Range(0.0, 3.0)] public float ProjSize3 { get; set; } = 1f; [JsonPropertyName("Zeroing")] [Range(-1.0, 1.0)] public float ZeroOffset { get; set; } } }
plugins/ProjectEternal/Custom/LEGACY.dll
Decompiled 4 days 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.Immutable; using System.Diagnostics; 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 AIGraph; using AK; using Agents; using AssetShards; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using BoosterImplants; using CellMenu; using ChainedPuzzles; using EOSExt.Reactor.Managers; using Enemies; using ExtraObjectiveSetup; using ExtraObjectiveSetup.BaseClasses; using ExtraObjectiveSetup.ExtendedWardenEvents; using ExtraObjectiveSetup.Instances; using ExtraObjectiveSetup.JSON; using ExtraObjectiveSetup.Utils; using FloLib.Infos; using FloLib.Networks.Replications; using GTFO.API; using GTFO.API.Utilities; using GameData; using GameEvent; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LEGACY.ExtraEvents; using LEGACY.ExtraEvents.Patches; using LEGACY.LegacyOverride; using LEGACY.LegacyOverride.DummyVisual; using LEGACY.LegacyOverride.DummyVisual.VisualGOAnimation; using LEGACY.LegacyOverride.DummyVisual.VisualGOAnimation.AnimationConfig; using LEGACY.LegacyOverride.DummyVisual.VisualSequenceType; using LEGACY.LegacyOverride.ElevatorCargo; using LEGACY.LegacyOverride.EnemyTagger; using LEGACY.LegacyOverride.EventScan; using LEGACY.LegacyOverride.ExpeditionIntelNotification; using LEGACY.LegacyOverride.ExpeditionSuccessPage; using LEGACY.LegacyOverride.FogBeacon; using LEGACY.LegacyOverride.ForceFail; using LEGACY.LegacyOverride.Music; using LEGACY.LegacyOverride.ResourceStations; using LEGACY.LegacyOverride.Restart; using LEGACY.Utils; using LEGACY.VanillaFix; using LevelGeneration; using Localization; using MTFO.API; using Microsoft.CodeAnalysis; using Player; using SNetwork; using ScanPosOverride.Managers; using TMPro; using ThermalSights; using UnityEngine; using UnityEngine.UI; [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 = ".NET 6.0")] [assembly: AssemblyCompany("LEGACY")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LEGACY")] [assembly: AssemblyTitle("LEGACY")] [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.6.2+git44e73d7-dirty-main".Remove("x.x.x".Length); ((TMP_Text)__instance.m_watermarkText).SetText("<color=red>MODDED</color> <color=orange>" + text + "</color>\n<color=#FF3111>PE 2.3.0</color>", true); } } namespace LEGACY { internal static class Assets { public static GameObject CircleSensor { get; private set; } public static GameObject MovableSensor { get; private set; } public static GameObject OBSVisual { get; private set; } public static GameObject ObjectiveMarker { get; private set; } public static GameObject EventScan { get; private set; } internal static GameObject DummyScan { get; private set; } internal static GameObject DummySensor { get; private set; } internal static GameObject AmmoStation { get; private set; } internal static GameObject MediStation { get; private set; } internal static GameObject ToolStation { get; private set; } internal static GameObject RestartPage { get; private set; } public static void Init() { CircleSensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/CircleSensor.prefab"); MovableSensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/MovableSensor.prefab"); OBSVisual = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/OBSVisual.prefab"); ObjectiveMarker = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/ObjectiveMarker.prefab"); EventScan = AssetAPI.GetLoadedAsset<GameObject>("Assets/EventObjects/EventScan.prefab"); DummyScan = AssetAPI.GetLoadedAsset<GameObject>("Assets/DummyVisual/DummyScan.prefab"); DummySensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/DummyVisual/DummySensor.prefab"); AmmoStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/AmmoStation.prefab"); MediStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/MediStation.prefab"); ToolStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/ToolStation.prefab"); RestartPage = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/CM_PageRestart_CellUI.prefab"); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("Localia.TeammatesIgnoreBullets")] [BepInIncompatibility("com.Chaxi.StrongerPrisoner")] [BepInPlugin("Inas.LEGACY", "LEGACY", "4.4.5")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas"; public const string RUNDOWN_NAME = "LEGACY"; public const string VERSION = "4.4.5"; public const bool TESTING = false; public const string TEST_STRING = "TESTING"; private Harmony m_Harmony; public override void Load() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown m_Harmony = new Harmony("LEGACY"); m_Harmony.PatchAll(); LegacyOverrideManagers.Init(); LegacyExtraEvents.Init(); LEGACY.VanillaFix.Debugger.Current.Init(); AssetAPI.OnAssetBundlesLoaded += Assets.Init; EventAPI.OnManagersSetup += delegate { AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)MainMenuGuiLayer.Current.PageRundownNew.SetupCustomTutorialButton); }; } } } 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0037: 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_0072: Invalid comparison between Unknown and I4 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected I4, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) 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; eReactorStatus val3 = status; switch (val3 - 7) { default: return; case 0: val2 = (eWardenObjectiveEventTrigger)1; break; case 1: val2 = (eWardenObjectiveEventTrigger)2; break; case 2: val2 = (eWardenObjectiveEventTrigger)3; break; } LG_LayerType layerType = __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_000e: 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_0002: 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: 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), "OnStateChange")] private static void Post_ExecuteOnNoneEventsOnDefenseStart(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState) { //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_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_0015: 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 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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); }); } } } [HarmonyPatch] internal class Patch_ReactorStartup_OverwriteGUIBehaviour { private static HashSet<uint> ForceDisableLevels; [HarmonyPrefix] [HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")] private static bool Pre_HideReactorMessageForInfiniteWave(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState) { //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_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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0023: 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_002a: Invalid comparison between Unknown and I4 //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_0033: Invalid comparison between Unknown and I4 //IL_0053: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected I4, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) if (oldState.status == newState.status) { return true; } if ((int)newState.status != 2 && (int)newState.status != 3 && (int)newState.status != 4) { return true; } if (ForceDisable()) { if (oldState.stateCount != newState.stateCount) { __instance.OnStateCountUpdate(newState.stateCount); } if (oldState.stateProgress != newState.stateProgress) { __instance.OnStateProgressUpdate(newState.stateProgress); } __instance.ReadyForVerification = false; eReactorStatus status = newState.status; eReactorStatus val = status; switch (val - 2) { case 0: { WardenObjectiveDataBlock val2 = null; if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val2) || val2 == null) { LegacyLogger.Error("Patch_ReactorStartup_OverwriteGUIBehaviour: "); LegacyLogger.Error("Failed to get warden objective datablock"); break; } __instance.m_lightCollection.SetMode(val2.LightsOnDuringIntro); __instance.m_lightCollection.ResetUpdateValues(true); __instance.lcReset = true; __instance.m_lightsBlinking = false; __instance.m_spawnEnemies = false; __instance.m_progressUpdateEnabled = true; __instance.m_alarmCountdownPlayed = false; __instance.m_currentDuration = ((!newState.verifyFailed) ? __instance.m_currentWaveData.Warmup : __instance.m_currentWaveData.WarmupFail); WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)1, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); if (__instance.m_currentWaveCount == 1) { Debug.LogError(Object.op_Implicit("Reactor IDLE START")); __instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_1_LOOP, true); __instance.m_sound.SetRTPCValue(GAME_PARAMETERS.REACTOR_POWER, 0f); } else { Debug.LogError(Object.op_Implicit("Reactor REACTOR_POWER_DOWN")); __instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_2_TO_1_TRANSITION, true); __instance.m_sound.SetRTPCValue(GAME_PARAMETERS.REACTOR_POWER, 0f); } break; } case 1: __instance.m_lightCollection.ResetUpdateValues(true); __instance.lcReset = true; __instance.m_spawnEnemies = true; __instance.m_currentEnemyWaveIndex = 0; __instance.m_alarmCountdownPlayed = false; __instance.m_progressUpdateEnabled = true; __instance.m_currentDuration = __instance.m_currentWaveData.Wave; __instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_1_TO_3_TRANSITION, true); break; case 2: __instance.m_lightCollection.ResetUpdateValues(false); __instance.lcReset = true; __instance.m_spawnEnemies = false; __instance.m_progressUpdateEnabled = true; __instance.ReadyForVerification = true; Debug.Log(Object.op_Implicit("Wait for verify! newState.verifyFailed? " + newState.verifyFailed)); __instance.m_currentDuration = ((!newState.verifyFailed) ? __instance.m_currentWaveData.Verify : __instance.m_currentWaveData.VerifyFail); WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)2, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null); break; } __instance.m_currentState = newState; return false; } return true; } private static bool ForceDisable() { return ForceDisableLevels.Contains(RundownManager.ActiveExpedition.LevelLayoutData); } static Patch_ReactorStartup_OverwriteGUIBehaviour() { ForceDisableLevels = new HashSet<uint>(); LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("Legacy_L3E2_L1"); if (block != null) { ForceDisableLevels.Add(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID); } block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("Legacy_L1E1_L1"); if (block != null) { ForceDisableLevels.Add(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID); } } } } 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_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_003c: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("LAYOUT_O4_1_L1"); if (block == null || RundownManager.ActiveExpedition.LevelLayoutData != ((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID) { return; } eLocalZoneIndex localIndex = __instance.m_zone.LocalIndex; eLocalZoneIndex val = localIndex; if ((int)val != 1) { if ((int)val == 5) { __instance.m_zonePlacementWeights.Start = 0f; __instance.m_zonePlacementWeights.Middle = 0f; __instance.m_zonePlacementWeights.End = 100000f; } return; } ePickupItemType pickupType = __instance.m_pickupType; ePickupItemType val2 = pickupType; if ((int)val2 == 1) { __instance.m_zonePlacementWeights.Start = 100000f; __instance.m_zonePlacementWeights.Middle = 0f; __instance.m_zonePlacementWeights.End = 0f; } } } } namespace LEGACY.VanillaFix { [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_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_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_000a: 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_000e: Invalid comparison between Unknown and I4 //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_0025: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 eDoorStatus status = state.status; eDoorStatus val = status; if ((val - 4 <= 1 || (int)val == 9) && (int)__instance.m_lastState.status == 6 && !isRecall) { 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] internal class Debugger { public static Debugger Current { get; private set; } = new Debugger(); public bool DEBUGGING { get; private set; } = false; private Debugger() { } internal void Init() { if (DEBUGGING) { } } private void f1(int k, out string v) { if (k < 2) { v = "2"; } v = null; } private void f2(int k, ref string v) { if (k < 2) { v = "2"; } } } } namespace LEGACY.Utils { public delegate float EasingFunction(float t, float b, float c, float d); public delegate bool BoolCheck(); internal static class CoroutineEase { [CompilerGenerated] private sealed class <DoEaseLocalPos>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Transform trans; public Vector3 sourcePos; public Vector3 targetPos; public float startTime; public float duration; public EasingFunction ease; public Action onDone; public BoolCheck checkAbort; private bool <doAbort>5__1; private float <t>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DoEaseLocalPos>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00e2: 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_0086: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <doAbort>5__1 = false; break; case 1: <>1__state = -1; break; } if (Clock.Time < startTime + duration && !<doAbort>5__1) { <doAbort>5__1 = checkAbort != null && checkAbort(); <t>5__2 = ease(Clock.Time - startTime, 0f, 1f, duration); trans.localPosition = Vector3.Lerp(sourcePos, targetPos, <t>5__2); <>2__current = null; <>1__state = 1; return true; } trans.localPosition = targetPos; if (!<doAbort>5__1 && onDone != null) { onDone(); } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DoEaseLocalRot>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Transform trans; public Vector3 sourceEuler; public Vector3 targetEuler; public float startTime; public float duration; public EasingFunction ease; public Action onDone; public BoolCheck checkAbort; private bool <doAbort>5__1; private float <t>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DoEaseLocalRot>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00e2: 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_0086: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <doAbort>5__1 = false; break; case 1: <>1__state = -1; break; } if (Clock.Time < startTime + duration && !<doAbort>5__1) { <doAbort>5__1 = checkAbort != null && checkAbort(); <t>5__2 = ease(Clock.Time - startTime, 0f, 1f, duration); trans.localEulerAngles = Vector3.Lerp(sourceEuler, targetEuler, <t>5__2); <>2__current = null; <>1__state = 1; return true; } trans.localEulerAngles = targetEuler; if (!<doAbort>5__1 && onDone != null) { onDone(); } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DoEaseLocalScale>d__0 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Transform trans; public Vector3 startScale; public Vector3 targetScale; public float startTime; public float duration; public EasingFunction ease; public Action onDone; public BoolCheck checkAbort; private bool <doAbort>5__1; private float <t>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DoEaseLocalScale>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00e2: 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_0086: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <doAbort>5__1 = false; break; case 1: <>1__state = -1; break; } if (Clock.Time < startTime + duration && !<doAbort>5__1) { <doAbort>5__1 = checkAbort != null && checkAbort(); <t>5__2 = ease(Clock.Time - startTime, 0f, 1f, duration); trans.localScale = Vector3.Lerp(startScale, targetScale, <t>5__2); <>2__current = null; <>1__state = 1; return true; } trans.localScale = targetScale; if (!<doAbort>5__1 && onDone != null) { onDone(); } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<DoEaseLocalScale>d__0))] private static IEnumerator DoEaseLocalScale(Transform trans, Vector3 startScale, Vector3 targetScale, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort) { //IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DoEaseLocalScale>d__0(0) { trans = trans, startScale = startScale, targetScale = targetScale, startTime = startTime, duration = duration, ease = ease, onDone = onDone, checkAbort = checkAbort }; } [IteratorStateMachine(typeof(<DoEaseLocalPos>d__1))] private static IEnumerator DoEaseLocalPos(Transform trans, Vector3 sourcePos, Vector3 targetPos, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort) { //IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DoEaseLocalPos>d__1(0) { trans = trans, sourcePos = sourcePos, targetPos = targetPos, startTime = startTime, duration = duration, ease = ease, onDone = onDone, checkAbort = checkAbort }; } [IteratorStateMachine(typeof(<DoEaseLocalRot>d__2))] private static IEnumerator DoEaseLocalRot(Transform trans, Vector3 sourceEuler, Vector3 targetEuler, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort) { //IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DoEaseLocalRot>d__2(0) { trans = trans, sourceEuler = sourceEuler, targetEuler = targetEuler, startTime = startTime, duration = duration, ease = ease, onDone = onDone, checkAbort = checkAbort }; } internal static Coroutine EaseLocalScale(Transform trans, Vector3 startScale, Vector3 targetScale, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null) { //IL_0015: 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) EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo); return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalScale(trans, startScale, targetScale, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null); } internal static Coroutine EaseLocalPos(Transform trans, Vector3 sourcePos, Vector3 targetPos, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null) { //IL_0015: 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) EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo); return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalPos(trans, sourcePos, targetPos, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null); } internal static Coroutine EaseLocalRot(Transform trans, Vector3 sourceEuler, Vector3 targetEuler, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null) { //IL_0015: 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) EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo); return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalRot(trans, sourceEuler, targetEuler, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null); } } public static class GOExtensions { public static GameObject GetChild(this GameObject go, string childName, bool substrSearch = false, bool recursiveSearch = true) { if (((Object)go).name.Equals(childName) || (substrSearch && ((Object)go).name.Contains(childName))) { return go; } for (int i = 0; i < go.transform.childCount; i++) { GameObject gameObject = ((Component)go.transform.GetChild(i)).gameObject; GameObject val = null; if (recursiveSearch) { val = gameObject.GetChild(childName, substrSearch); } else if (((Object)gameObject).name.Equals(childName) || (substrSearch && ((Object)gameObject).name.Contains(childName))) { val = gameObject; } if ((Object)(object)val != (Object)null) { return val; } } return null; } } public static class Helper { private static void ResetChild(iChainedPuzzleCore ICore) { CP_Bioscan_Core val = ((Il2CppObjectBase)ICore).TryCast<CP_Bioscan_Core>(); if ((Object)(object)val != (Object)null) { CP_Holopath_Spline val2 = ((Il2CppObjectBase)val.m_spline).Cast<CP_Holopath_Spline>(); CP_PlayerScanner val3 = ((Il2CppObjectBase)val.PlayerScanner).Cast<CP_PlayerScanner>(); val3.ResetScanProgression(0f); val.Deactivate(); return; } CP_Cluster_Core val4 = ((Il2CppObjectBase)ICore).TryCast<CP_Cluster_Core>(); if ((Object)(object)val4 == (Object)null) { LegacyLogger.Error("ResetChild: found iChainedPuzzleCore that is neither CP_Bioscan_Core nor CP_Cluster_Core..."); return; } CP_Holopath_Spline val5 = ((Il2CppObjectBase)val4.m_spline).Cast<CP_Holopath_Spline>(); foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)val4.m_childCores) { ResetChild(item); } val4.Deactivate(); } public static void ResetChainedPuzzle(ChainedPuzzleInstance chainedPuzzleInstance) { //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_0027: Expected O, but got Unknown //IL_006d: 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) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00be: Unknown result type (might be due to invalid IL or missing references) if (chainedPuzzleInstance.Data.DisableSurvivalWaveOnComplete) { chainedPuzzleInstance.m_sound = new CellSoundPlayer(chainedPuzzleInstance.m_parent.position); } foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)chainedPuzzleInstance.m_chainedPuzzleCores) { ResetChild(item); } if (SNet.IsMaster) { pChainedPuzzleState state = chainedPuzzleInstance.m_stateReplicator.State; pChainedPuzzleState val = default(pChainedPuzzleState); val.status = (eChainedPuzzleStatus)0; val.currentSurvivalWave_EventID = state.currentSurvivalWave_EventID; val.isSolved = false; val.isActive = false; pChainedPuzzleState val2 = val; chainedPuzzleInstance.m_stateReplicator.InteractWithState(val2, new pChainedPuzzleInteraction { type = (eChainedPuzzleInteraction)2 }); } } public static List<T> ToManagedList<T>(this List<T> il2cppList) { List<T> list = new List<T>(); Enumerator<T> enumerator = il2cppList.GetEnumerator(); while (enumerator.MoveNext()) { T current = enumerator.Current; list.Add(current); } return list; } 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_0007: 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_0013: Invalid comparison between Unknown and I4 return (int)player.Owner.Load<pGameState>().gameState == 10; } public static ChainedPuzzleInstance GetChainedPuzzleForCommandOnTerminal(LG_ComputerTerminal terminal, string command) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Invalid comparison between Unknown and I4 //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Invalid comparison between Unknown and I4 //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Invalid comparison between Unknown and I4 //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Invalid comparison between Unknown and I4 //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Invalid comparison between Unknown and I4 //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Invalid comparison between Unknown and I4 //IL_025f: Unknown result type (might be due to invalid IL or missing references) uint num = 0u; if (terminal.SpawnNode.m_dimension.IsMainDimension) { LG_LayerType layerType = terminal.SpawnNode.LayerType; LG_LayerType val = layerType; switch ((int)val) { 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> val2 = null; List<LG_ComputerTerminal> terminalsSpawnedInZone = terminal.SpawnNode.m_zone.TerminalsSpawnedInZone; int num2 = terminalsSpawnedInZone.IndexOf(terminal); ExpeditionZoneData val3 = null; Enumerator<ExpeditionZoneData> enumerator = block.Zones.GetEnumerator(); while (enumerator.MoveNext()) { ExpeditionZoneData current = enumerator.Current; if (current.LocalIndex == terminal.SpawnNode.m_zone.LocalIndex) { val3 = current; break; } } if (val3 == null) { LegacyLogger.Error("Cannot find target zone data."); return null; } if (val3.TerminalPlacements.Count != terminalsSpawnedInZone.Count) { LegacyLogger.Error("The numbers of terminal placement and spawn, skipped for the zone terminal."); return null; } val2 = val3.TerminalPlacements[num2].UniqueCommands; if (val2.Count == 0) { return null; } List<WardenObjectiveEventData> val4 = null; TERM_Command val5 = (TERM_Command)0; Enumerator<CustomTerminalCommand> enumerator2 = val2.GetEnumerator(); string text = default(string); string text2 = default(string); while (enumerator2.MoveNext()) { CustomTerminalCommand current2 = enumerator2.Current; if (current2.Command == command) { val4 = current2.CommandEvents; if (!terminal.m_command.TryGetCommand(current2.Command, ref val5, ref text, ref text2)) { LegacyLogger.Error("Cannot get TERM_COMMAND for command {0} on the specified terminal."); } break; } } if (val4 == null || (int)val5 == 0) { return null; } if ((int)val5 != 38 && (int)val5 != 39 && (int)val5 != 40 && (int)val5 != 41 && (int)val5 != 42) { return null; } ChainedPuzzleInstance val6 = null; for (int i = 0; i < val4.Count && (val4[i].ChainPuzzle == 0 || !terminal.TryGetChainPuzzleForCommand(val5, i, ref val6) || !((Object)(object)val6 != (Object)null)); i++) { } return val6; } 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_0025: 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_0031: 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_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_0034: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between I4 and Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between I4 and Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected I4, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between I4 and Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between I4 and Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected I4, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_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_0023: 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_0029: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) //IL_0077: 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; eDimensionIndex currentDimensionIndex = 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_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_000a: 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_0052: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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; } return (terminalIndex < 0) ? null : val.TerminalsSpawnedInZone[terminalIndex]; } public static AIG_NodeCluster GetNodeFromDimensionPosition(eDimensionIndex dimensionIndex, Vector3 position) { //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_0013: 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) AIG_GeomorphNodeVolume val = default(AIG_GeomorphNodeVolume); AIG_VoxelNodePillar val2 = default(AIG_VoxelNodePillar); AIG_INode val3 = default(AIG_INode); AIG_NodeCluster result = default(AIG_NodeCluster); if (!AIG_GeomorphNodeVolume.TryGetGeomorphVolume(0, dimensionIndex, position, ref val) || !((AIG_NodeVolume)val).m_voxelNodeVolume.TryGetPillar(position, ref val2) || !val2.TryGetVoxelNode(position.y, ref val3) || !AIG_NodeCluster.TryGetNodeCluster(val3.ClusterID, ref result)) { LegacyLogger.Error("TryWarpTo : Position is not valid, try again inside an area."); return null; } return result; } } internal static class Json { static Json() { } public static T Deserialize<T>(string json) { return EOSJson.Deserialize<T>(json); } public static object Deserialize(Type type, string json) { return EOSJson.Deserialize(type, json); } public static string Serialize<T>(T value) { return EOSJson.Serialize<T>(value); } public static void Load<T>(string filePath, out T config) where T : new() { config = Deserialize<T>(File.ReadAllText(filePath)); } } 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; } = (eWardenObjectiveEventTrigger)0; public int Type { get; set; } = 170; public eDimensionIndex DimensionIndex { get; set; } = (eDimensionIndex)0; public LG_LayerType Layer { get; set; } = (LG_LayerType)0; public eLocalZoneIndex LocalIndex { get; set; } = (eLocalZoneIndex)0; public string WorldEventObjectFilter { get; set; } = "RANDOM"; public uint EnemyID { get; set; } public int Count { get; set; } = 1; public float Delay { get; set; } = 0f; 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004a: 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_0067: Expected I4, but got Unknown //IL_00b0: 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; LG_AreaSize val = size; switch (val - 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_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) 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 { internal class NavMarkerManager { private Dictionary<string, GameObject> markerVisuals = new Dictionary<string, GameObject>(); private Dictionary<string, NavMarker> navMarkers = new Dictionary<string, NavMarker>(); private List<GameObject> arbitraryNavMarkers = new List<GameObject>(); public static NavMarkerManager Current { get; private set; } = new NavMarkerManager(); private GameObject InstantiateMarkerVisual() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject val = Object.Instantiate<GameObject>(Assets.ObjectiveMarker); float num = 0.16216217f; Transform transform = val.transform; transform.localPosition += Vector3.up * num; return val; } public void EnableMarkerAt(string markerName, GameObject target, float scale) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (navMarkers.ContainsKey(markerName)) { navMarkers[markerName].SetVisible(true); } else { NavMarker val = GuiManager.NavMarkerLayer.PrepareGenericMarker(target); if ((Object)(object)val != (Object)null) { val.SetColor(new Color(0.855f, 0.482f, 0.976f)); val.SetStyle((eNavMarkerStyle)14); val.SetVisible(true); navMarkers[markerName] = val; } else { LegacyLogger.Error("EnableMarkerAt: got null nav marker"); } } GameObject val2 = null; if (markerVisuals.ContainsKey(markerName)) { val2 = markerVisuals[markerName]; } else { val2 = InstantiateMarkerVisual(); val2.transform.localScale = new Vector3(scale, scale, scale); val2.transform.SetPositionAndRotation(target.transform.position, Quaternion.identity); markerVisuals[markerName] = val2; } CoroutineManager.BlinkIn(val2, 0f); LegacyLogger.Debug("EnableMarker: marker " + markerName + " enabled"); } public void EnableArbitraryMarkerAt(string markerName, Vector3 Position) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0039: 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_007a: Unknown result type (might be due to invalid IL or missing references) if (navMarkers.ContainsKey(markerName)) { navMarkers[markerName].SetVisible(true); } else { GameObject val = new GameObject(markerName); val.transform.SetPositionAndRotation(Position, Quaternion.identity); arbitraryNavMarkers.Add(val); NavMarker val2 = GuiManager.NavMarkerLayer.PrepareGenericMarker(val); if ((Object)(object)val2 != (Object)null) { val2.SetColor(new Color(0.855f, 0.482f, 0.976f)); val2.SetStyle((eNavMarkerStyle)14); val2.SetVisible(true); navMarkers[markerName] = val2; } else { LegacyLogger.Error("EnableMarkerAt: got null nav marker"); } } LegacyLogger.Debug("EnableMarker: marker " + markerName + " enabled"); } internal (GameObject markerVisual, NavMarker navMakrer) GetMarkerVisuals(string markerName) { GameObject value; NavMarker value2; return (markerVisuals.TryGetValue(markerName, out value) && navMarkers.TryGetValue(markerName, out value2)) ? (value, value2) : (null, null); } public void DisableMakrer(string markerName) { if (navMarkers.ContainsKey(markerName)) { navMarkers[markerName].SetVisible(false); } if (markerVisuals.ContainsKey(markerName)) { GameObject val = markerVisuals[markerName]; if (val.active) { CoroutineManager.BlinkOut(val, 0f); } LegacyLogger.Debug("DisableMakrer: marker " + markerName + " disabled"); } } public void Clear() { foreach (GameObject value in markerVisuals.Values) { Object.Destroy((Object)(object)value); } arbitraryNavMarkers.ForEach((Action<GameObject>)Object.Destroy); markerVisuals.Clear(); navMarkers.Clear(); arbitraryNavMarkers.Clear(); } private NavMarkerManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } } internal static class LegacyOverrideManagers { internal static readonly string LEGACY_CONFIG_PATH = Path.Combine(MTFOPathAPI.CustomPath, "LegacyOverride"); internal static void Init() { ElevatorCargoOverrideManager.Current.Init(); BigPickupFogBeaconSettingManager.Current.Init(); EnemyTaggerSettingManager.Current.Init(); ForceFailManager.Current.Init(); ((GenericExpeditionDefinitionManager<ExpeditionIntel>)ExpeditionIntelNotifier.Current).Init(); ((GenericExpeditionDefinitionManager<EventScanDefinition>)EventScanManager.Current).Init(); ((GenericExpeditionDefinitionManager<VisualGroupDefinition>)VisualManager.Current).Init(); ((GenericExpeditionDefinitionManager<MusicOverride>)MusicStateOverrider.Current).Init(); ((ZoneDefinitionManager<LevelSpawnedFogBeaconDefinition>)LevelSpawnedFogBeaconManager.Current).Init(); ((GenericExpeditionDefinitionManager<SuccessPageCustomization>)SuccessPageCustomizationManager.Current).Init(); ((GenericExpeditionDefinitionManager<ResourceStationDefinition>)ResourceStationManager.Current).Init(); } } } namespace LEGACY.LegacyOverride.Restart { public static class CM_PageRestart { internal static TextMeshPro Text { get; private set; } internal static GameObject Reconnecting { get; private set; } public static GameObject Page { get; private set; } internal static void Setup() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Assets.RestartPage == (Object)null) { return; } if ((Object)(object)Page != (Object)null) { LegacyLogger.Warning("Duplicate setup for CM_PageRestart!"); try { Object.Destroy((Object)(object)Page); } finally { Page = null; } } Transform transform = ((Component)((GuiLayer)GuiManager.Current.m_mainMenuLayer).GuiLayerBase).transform; Page = Object.Instantiate<GameObject>(Assets.RestartPage, transform.position, transform.rotation, transform); CM_PageBase component = Page.GetComponent<CM_PageBase>(); GameObject gameObject = ((Component)component.m_movingContentHolder).gameObject; Reconnecting = gameObject.GetChild("Reconnecting"); GameObject gameObject2 = ((Component)GuiManager.Current.m_mainMenuLayer.PageMap.m_mapDisconnected.transform.GetChild(0)).gameObject; gameObject2 = Object.Instantiate<GameObject>(gameObject2, Reconnecting.transform); Text = gameObject2.GetComponent<TextMeshPro>(); ((Graphic)Text).color = new Color(0f, 1f, 72f / 85f, 1f); ((TMP_Text)Text).SetText("RECONNECTING", true); ((TMP_Text)Text).ForceMeshUpdate(false, false); Page.GetComponent<CM_PageBase>().Setup(GuiManager.Current.m_mainMenuLayer); } public static void SetPageActive(bool active) { Page.GetComponent<CM_PageBase>().SetPageActive(active); } } } namespace LEGACY.LegacyOverride.ResourceStations { public sealed class ToolStation : ResourceStation { public override string ItemKey => $"Tool_Station_{base.SerialNumber}"; protected override void SetupInteraction() { base.SetupInteraction(); TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.ToolStation"); Interact.InteractionMessage = ((block == null) ? "TOOL STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID)); } protected override void Replenish(PlayerAgent player) { PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(player.Owner); PlayerAmmoStorage ammoStorage = backpack.AmmoStorage; float num = Math.Max(0f, Math.Min(def.SupplyUplimit.Tool - ammoStorage.ClassAmmo.RelInPack, def.SupplyEfficiency.Tool)); player.GiveAmmoRel((PlayerAgent)null, 0f, 0f, num); player.Sound.Post(EVENTS.AMMOPACK_APPLY, true); } public static ToolStation Instantiate(ResourceStationDefinition def) { if (def.StationType != StationType.TOOL) { LegacyLogger.Error($"Trying to instantiate MediStation with def with 'StationType': {def.StationType}!"); return null; } GameObject gO = Object.Instantiate<GameObject>(Assets.ToolStation); return new ToolStation(def, gO); } private ToolStation(ResourceStationDefinition def, GameObject GO) : base(def, GO) { } static ToolStation() { } } public sealed class MediStation : ResourceStation { public const float VANILLA_MAX_HEALTH = 25f; public override string ItemKey => $"Health_Station_{base.SerialNumber}"; protected override void SetupInteraction() { base.SetupInteraction(); TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.MediStation"); Interact.InteractionMessage = ((block == null) ? "HEALTH STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID)); } protected override void Replenish(PlayerAgent player) { float health = ((Dam_SyncedDamageBase)player.Damage).Health; float num = def.SupplyUplimit.Medi * 25f; if (!(health >= num)) { player.GiveHealth((PlayerAgent)null, Math.Min(def.SupplyEfficiency.Medi, (num - health) / 25f)); player.Sound.Post(EVENTS.MEDPACK_APPLY, true); } } public static MediStation Instantiate(ResourceStationDefinition def) { if (def.StationType != 0) { LegacyLogger.Error($"Trying to instantiate MediStation with def with 'StationType': {def.StationType}!"); return null; } GameObject gO = Object.Instantiate<GameObject>(Assets.MediStation); return new MediStation(def, gO); } private MediStation(ResourceStationDefinition def, GameObject GO) : base(def, GO) { } static MediStation() { } } public abstract class ResourceStation { [CompilerGenerated] private sealed class <BlinkMarker>d__61 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourceStation <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BlinkMarker>d__61(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } <>4__this.StationMarkerGO.SetActive(!<>4__this.StationMarkerGO.active); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const int UNLIMITED_USE_TIME = int.MaxValue; private Coroutine m_blinkMarkerCoroutine = null; public virtual GameObject GameObject { get; protected set; } public GameObject InteractGO { get { GameObject gameObject = GameObject; return ((gameObject != null) ? ((Component)gameObject.transform.GetChild(3)).gameObject : null) ?? null; } } public GameObject StationMarkerGO { get { GameObject gameObject = GameObject; return ((gameObject != null) ? ((Component)gameObject.transform.GetChild(2)).gameObject : null) ?? null; } } public virtual Interact_Timed Interact { get; protected set; } public virtual ResourceStationDefinition def { get; protected set; } public RSTimer Timer { get; protected set; } public StateReplicator<RSStateStruct> StateReplicator { get; protected set; } public RSStateStruct State => StateReplicator?.State ?? new RSStateStruct(); public LG_GenericTerminalItem TerminalItem { get; protected set; } public AIG_CourseNode SpawnNode { get { return TerminalItem.SpawnNode; } set { TerminalItem.SpawnNode = value; } } protected int SerialNumber { get; private set; } public virtual string ItemKey => $"Resource_Station_{SerialNumber}"; public bool Enabled => State.Enabled; protected virtual bool InCooldown => State.RemainingUseTime <= 0 && State.CurrentCooldownTime > 0f; public virtual bool HasUnlimitedUseTime => def.AllowedUseTimePerCooldown == int.MaxValue; public virtual void Destroy() { if (m_blinkMarkerCoroutine != null) { CoroutineManager.StopCoroutine(m_blinkMarkerCoroutine); m_blinkMarkerCoroutine = null; } Object.Destroy((Object)(object)GameObject); StateReplicator?.Unload(); Interact = null; def = null; StateReplicator = null; } protected virtual bool CanInteract() { return Enabled && !InCooldown; } protected abstract void Replenish(PlayerAgent player); protected virtual void SetInteractionText() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) string text = Text.Format(827u, (Object[])(object)new Object[1] { Object.op_Implicit(InputMapper.GetBindingName(((Interact_Base)Interact).InputAction)) }); TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.OnAdditionalInteractionText.ResourceStation"); string text2 = ((block == null) ? " TO REPLENISH" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID)); string text3 = (HasUnlimitedUseTime ? string.Empty : $"({State.RemainingUseTime}/{def.AllowedUseTimePerCooldown}) per {def.CooldownTime}s"); GuiManager.InteractionLayer.SetInteractPrompt(Interact.InteractionMessage, text + text2 + text3, (ePUIMessageStyle)0); } protected virtual void OnTriggerInteraction(PlayerAgent player) { RSStateStruct state = State; int num = (HasUnlimitedUseTime ? int.MaxValue : Math.Max(state.RemainingUseTime - 1, 0)); int num2 = player.Owner.PlayerSlotIndex(); if (num2 < 0 || num2 >= ((Il2CppArrayBase<SNet_Slot>)(object)SNet.Slots.PlayerSlots).Count) { LegacyLogger.Error($"ResourceStation_OnTriggerInteraction: player {player.PlayerName} has invalid slot index: {num2}"); } else { StateReplicator?.SetState(new RSStateStruct { LastInteractedPlayer = num2, RemainingUseTime = num, CurrentCooldownTime = ((num == 0) ? def.CooldownTime : 0f), Enabled = true }); } } protected virtual void OnInteractionSelected(PlayerAgent agent, bool selected) { if (selected) { SetInteractionText(); } } protected virtual void SetupInteraction() { Interact.InteractDuration = def.InteractDuration; Interact_Timed interact = Interact; interact.ExternalPlayerCanInteract += Func<PlayerAgent, bool>.op_Implicit((Func<PlayerAgent, bool>)((PlayerAgent _) => CanInteract())); Interact_Timed interact2 = Interact; interact2.OnInteractionSelected += Action<PlayerAgent, bool>.op_Implicit((Action<PlayerAgent, bool>)OnInteractionSelected); Interact_Timed interact3 = Interact; interact3.OnInteractionTriggered += Action<PlayerAgent>.op_Implicit((Action<PlayerAgent>)OnTriggerInteraction); } protected virtual void SetupTerminalItem() { //IL_000c: 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_0022: Unknown result type (might be due to invalid IL or missing references) LG_Zone val = default(LG_Zone); if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(((GlobalZoneIndex)def).DimensionIndex, ((GlobalZoneIndex)def).LayerType, ((GlobalZoneIndex)def).LocalIndex, ref val) || (Object)(object)val == (Object)null) { LegacyLogger.Error("ResourceStation: Cannot find spawn node!"); return; } if (def.AreaIndex < 0 || def.AreaIndex >= val.m_areas.Count) { LegacyLogger.Error("ResourceStation: Cannot find spawn node - Area index is invalid!"); return; } TerminalItem.Setup(ItemKey, val.m_areas[def.AreaIndex].m_courseNode); if (SpawnNode != null) { TerminalItem.FloorItemLocation = SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7); } TerminalItem.FloorItemStatus = (eFloorInventoryObjectStatus)0; } protected virtual void OnStateChanged(RSStateStruct oldState, RSStateStruct newState, bool isRecall) { if (isRecall) { return; } int lastInteractedPlayer = newState.LastInteractedPlayer; if (lastInteractedPlayer < 0 || lastInteractedPlayer >= ((Il2CppArrayBase<SNet_Slot>)(object)SNet.Slots.PlayerSlots).Count) { return; } if (((Interact_Base)Interact).IsSelected) { SetInteractionText(); } if (!SNet.IsMaster) { return; } LegacyLogger.Warning($"ResourceStation OnStateChanged: replenish for player {lastInteractedPlayer}, remaining use time: {newState.RemainingUseTime}"); if (oldState.RemainingUseTime > 0) { SNet_Player playerInSlot = SNet.Slots.GetPlayerInSlot(lastInteractedPlayer); if ((Object)(object)playerInSlot != (Object)null) { Replenish(((Il2CppObjectBase)playerInSlot.m_playerAgent).Cast<PlayerAgent>()); } else { LegacyLogger.Error($"playerSlot_{lastInteractedPlayer} has no player agent!"); } } if (newState.RemainingUseTime == 0) { LegacyLogger.Warning("ResourceStation OnStateChanged: cooldown timer starts!"); OnCoolDownStart(); } } protected virtual void OnCoolDownStart() { Timer.StartTimer(def.CooldownTime); if (m_blinkMarkerCoroutine == null) { m_blinkMarkerCoroutine = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(BlinkMarker()), (Action)null); } } protected virtual void OnCoolDownTimerProgress(float progress) { } protected virtual void OnCoolDownEnd() { LegacyLogger.Warning("ResourceStation OnCoolDownEnd"); if (m_blinkMarkerCoroutine != null) { CoroutineManager.StopCoroutine(m_blinkMarkerCoroutine); m_blinkMarkerCoroutine = null; StationMarkerGO.SetActive(true); } if (SNet.IsMaster) { LegacyLogger.Warning("ResourceStation OnCoolDownEnd: master reset state!"); StateReplicator.SetState(new RSStateStruct { LastInteractedPlayer = -1, RemainingUseTime = def.AllowedUseTimePerCooldown, CurrentCooldownTime = 0f, Enabled = true }); } } protected virtual void SetupReplicator() { if (StateReplicator == null) { uint num = EOSNetworking.AllotReplicatorID(); if (num == 0) { LegacyLogger.Error("ResourceStation: replicatorID depleted, cannot setup replicator!"); return; } StateReplicator = StateReplicator<RSStateStruct>.Create(num, new RSStateStruct { RemainingUseTime = def.AllowedUseTimePerCooldown, CurrentCooldownTime = -1f, Enabled = true }, (LifeTimeType)1, (IStateReplicatorHolder<RSStateStruct>)null); StateReplicator.OnStateChanged += OnStateChanged; } } protected virtual void SetupRSTimer() { if ((Object)(object)Timer == (Object)null) { Timer = RSTimer.Instantiate(OnCoolDownTimerProgress, OnCoolDownEnd); } } [IteratorStateMachine(typeof(<BlinkMarker>d__61))] private IEnumerator BlinkMarker() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BlinkMarker>d__61(0) { <>4__this = this }; } protected ResourceStation(ResourceStationDefinition def, GameObject GO) { //IL_0030: 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) this.def = def; GameObject = GO; GameObject.transform.SetPositionAndRotation(def.Position.ToVector3(), def.Rotation.ToQuaternion()); Interact = InteractGO.GetComponent<Interact_Timed>(); SerialNumber = SerialGenerator.GetUniqueSerialNo(); if ((Object)(object)Interact == (Object)null) { LegacyLogger.Error("ResourceStation: Interact Comp not found!"); } else { SetupInteraction(); } TerminalItem = GO.GetComponent<LG_GenericTerminalItem>(); if ((Object)(object)TerminalItem == (Object)null) { LegacyLogger.Error("ResourceStation: TerminalItem not found!"); } else { SetupTerminalItem(); } SetupReplicator(); SetupRSTimer(); } static ResourceStation() { } } public sealed class AmmoStation : ResourceStation { public override string ItemKey => $"Ammunition_Station_{base.SerialNumber}"; protected override void SetupInteraction() { base.SetupInteraction(); TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.AmmoStation"); Interact.InteractionMessage = ((block == null) ? "AMMUNITION STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID)); } public static AmmoStation Instantiate(ResourceStationDefinition def) { if (def.StationType != StationType.AMMO) { LegacyLogger.Error($"Trying to instantiate AmmoStation with def with 'StationType': {def.StationType}!"); return null; } GameObject gO = Object.Instantiate<GameObject>(Assets.AmmoStation); return new AmmoStation(def, gO); } protected override void Replenish(PlayerAgent player) { PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(player.Owner); PlayerAmmoStorage ammoStorage = backpack.AmmoStorage; float num = Math.Max(0f, Math.Min(def.SupplyUplimit.AmmoStandard - ammoStorage.StandardAmmo.RelInPack, def.SupplyEfficiency.AmmoStandard)); float num2 = Math.Max(0f, Math.Min(def.SupplyUplimit.AmmoSpecial - ammoStorage.SpecialAmmo.RelInPack, def.SupplyEfficiency.AmmoSpecial)); player.GiveAmmoRel((PlayerAgent)null, num, num2, 0f); player.Sound.Post(EVENTS.AMMOPACK_APPLY, true); } private AmmoStation(ResourceStationDefinition def, GameObject GO) : base(def, GO) { } static AmmoStation() { } } public enum StationType { MEDI, AMMO, TOOL } public class SupplyUplimit { public float Medi { get; set; } = 0.6f; public float AmmoStandard { get; set; } = 1f; public float AmmoSpecial { get; set; } = 1f; public float Tool { get; set; } = 0f; } public class SupplyEfficiency { public float Medi { get; set; } = 0.2f; public float AmmoStandard { get; set; } = 0.15f; public float AmmoSpecial { get; set; } = 0.15f; public float Tool { get; set; } = 0f; } public class ResourceStationDefinition : GlobalZoneIndex { public int AreaIndex { get; set; } = 0; public string WorldEventObjectFilter { get; set; } = string.Empty; public StationType StationType { get; set; } = StationType.AMMO; public Vec3 Position { get; set; } = new Vec3(); public Vec3 Rotation { get; set; } = new Vec3(); public float InteractDuration { get; set; } = 2.5f; public SupplyEfficiency SupplyEfficiency { get; set; } = new SupplyEfficiency(); public SupplyUplimit SupplyUplimit { get; set; } = new SupplyUplimit(); public int AllowedUseTimePerCooldown { get; set; } = int.MaxValue; public float CooldownTime { get; set; } = 3f; } public class ResourceStationManager : GenericExpeditionDefinitionManager<ResourceStationDefinition> { public static ResourceStationManager Current { get; private set; } protected override string DEFINITION_NAME => "ResourceStation"; private Dictionary<string, ResourceStation> Stations { get; } = new Dictionary<string, ResourceStation>(); private void Build(ResourceStationDefinition def) { if (Stations.ContainsKey(def.WorldEventObjectFilter)) { LegacyLogger.Error("ResourceStationManager: WorldEventObjectFilter '" + def.WorldEventObjectFilter + "' is already used"); return; } ResourceStation resourceStation = null; switch (def.StationType) { case StationType.MEDI: resourceStation = MediStation.Instantiate(def); break; case StationType.AMMO: resourceStation = AmmoStation.Instantiate(def); break; case StationType.TOOL: resourceStation = ToolStation.Instantiate(def); break; default: LegacyLogger.Error($"ResourceStation {def.StationType} is unimplemented"); return; } if (resourceStation != null) { Stations[def.WorldEventObjectFilter] = resourceStation; LegacyLogger.Debug("ResourceStation '" + def.WorldEventObjectFilter + "' instantiated"); } } private void BuildStations() { if (base.definitions.TryGetValue(base.CurrentMainLevelLayout, out var value)) { value.Definitions.ForEach(Build); } } private void Clear() { foreach (ResourceStation value in Stations.Values) { value.Destroy(); } Stations.Clear(); } private ResourceStationManager() { LevelAPI.OnBuildStart += delegate { Clear(); }; LevelAPI.OnLevelCleanup += Clear; LevelAPI.OnBuildDone += BuildStations; } static ResourceStationManager() { Current = new ResourceStationManager(); } } public struct RSStateStruct { public int LastInteractedPlayer; public int RemainingUseTime; public float CurrentCooldownTime; public bool Enabled; public RSStateStruct() { LastInteractedPlayer = 0; RemainingUseTime = 0; CurrentCooldownTime = 0f; Enabled = false; } } public class RSTimer : MonoBehaviour { private float startTime = 0f; private float endTime = 0f; private bool hasOnGoingTimer = false; private Action<float> OnProgress; private Action OnTimerEnd; public float RemainingTime => hasOnGoingTimer ? Math.Max(endTime - Clock.Time, 0f) : 0f; private static List<GameObject> TimerGOs { get; } private void Update() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)GameStateManager.CurrentStateName == 10 && hasOnGoingTimer) { float time = Clock.Time; if (OnProgress != null) { OnProgress((time - startTime) / (endTime - startTime)); } if (!(time < endTime)) { endTime = 0f; hasOnGoingTimer = false; OnTimerEnd?.Invoke(); } } } public void StartTimer(float time) { if (time <= 0f) { LegacyLogger.Error("StartTimer: time is not positive!"); return; } if (hasOnGoingTimer) { LegacyLogger.Error("StartTimer: this timer is yet ended!"); return; } startTime = Clock.Time; endTime = startTime + time; hasOnGoingTimer = true; } private void OnDestroy() { endTime = 0f; hasOnGoingTimer = false; OnTimerEnd = null; } public static RSTimer Instantiate(Action<float> onProgress, Action actionOnEnd) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GameObject val = new GameObject(); RSTimer rSTimer = val.AddComponent<RSTimer>(); rSTimer.OnProgress = onProgress; rSTimer.OnTimerEnd = actionOnEnd; TimerGOs.Add(val); return rSTimer; } public static void DestroyAll() { TimerGOs.ForEach((Action<GameObject>)Object.Destroy); TimerGOs.Clear(); } private RSTimer() { } static RSTimer() { TimerGOs = new List<GameObject>(); ClassInjector.RegisterTypeInIl2Cpp<RSTimer>(); LevelAPI.OnBuildStart += DestroyAll; LevelAPI.OnLevelCleanup += DestroyAll; } } } namespace LEGACY.LegacyOverride.Patches { [HarmonyPatch] internal static class ExpeditionSuccessPage { [HarmonyPostfix] [HarmonyPatch(typeof(CM_PageExpeditionSuccess), "OnEnable")] private static void Post_CM_PageExpeditionSuccess_OnEnable(CM_PageExpeditionSuccess __instance) { if (!((Object)(object)__instance == (Object)null)) { SuccessPageCustomization currentCustomization = SuccessPageCustomizationManager.Current.CurrentCustomization; if (currentCustomization != null) { ((TMP_Text)__instance.m_header).SetText(LocalizedText.op_Implicit(currentCustomization.PageHeader), true); __instance.m_overrideSuccessMusic = currentCustomization.OverrideSuccessMusic; LegacyLogger.Warning("Post_CM_PageExpeditionSuccess_OnEnable: " + ((Object)currentCustomization.PageHeader).ToString()); } } } } [HarmonyPatch] internal class GUIManager_RestartPage { [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch(typeof(GuiManager), "Setup")] private static void Post_Setup(GuiManager __instance) { LevelAPI.OnBuildStart += delegate { CM_PageRestart.Setup(); }; } } [HarmonyPatch] internal static class LevelSpawnFogBeacon_BugFix { [HarmonyPostfix] [HarmonyPatch(typeof(HeavyFogRepellerGlobalState), "AttemptInteract")] private static void Post_HeavyFogRepellerGlobalState_AttemptInteract(HeavyFogRepellerGlobalState __instance) { LevelSpawnedFogBeaconSettings lSFBDef = LevelSpawnedFogBeaconManager.Current.GetLSFBDef(__instance); if (lSFBDef != null) { __instance.m_repellerSphere.Range = lSFBDef.Range; } } } [HarmonyPatch] internal static class PouncerArenaPosition_Fix { [HarmonyPatch(typeof(LG_Floor), "CreateDimension")] [HarmonyPrefix] private static void CreateDimension_Prefix(eDimensionIndex dimensionIndex, bool arenaDimension, ref Vector3 position) { //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) //IL_0004: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_0010: 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_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_002f: Unknown result type (might be due to invalid IL or missing references) if (dimensionIndex - 17 <= 3) { position += new Vector3 { y = -500f }; } } } [HarmonyPatch] internal class RundownSelectionCustomization { [CompilerGenerated] private sealed class <reverseReveal>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CM_PageRundown_New p; public bool hosting; public Transform guixSurfaceTransform; private float <arrowScale>5__1; private float <tierMarkerDelay>5__2; private int <k>5__3; private int <m>5__4; private int <l>5__5; private int <j>5__6; private int <i>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <reverseReveal>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Expected O, but got Unknown //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_032f: Expected O, but got Unknown //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Expected O, but got Unknown //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Expected O, but got Unknown //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0696: Expected O, but got Unknown //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Expected O, but got Unknown //IL_0850: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Expected O, but got Unknown //IL_0932: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <arrowScale>5__1 = p.m_tierSpacing * 5f * p.m_tierSpaceToArrowScale; if (hosting) { CoroutineManager.BlinkIn(p.m_buttonConnect, 0f, (Transform)null); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } goto IL_0147; case 1: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.24f); <>1__state = 2; return true; case 2: <>1__state = -1; ((RectTransformComp)p.m_buttonConnect).SetVisible(false); goto IL_0147; case 3: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 4; return true; case 4: <>1__state = -1; CM_PageBase.PostSound(EVENTS.MENU_SURFACE_LEVEL_SHRINK, ""); CoroutineEase.EaseLocalScale(p.m_textRundownHeader.transform, Vector3.one, new Vector3(0.6f, 0.6f, 0.6f), 0.2f, (EasingFunction)Easing.LinearTween, (Action)null, (BoolCheck)null); <>2__current = CoroutineEase.EaseLocalScale(guixSurfaceTransform, Vector3.one, new Vector3(0.2f, 0.2f, 0.2f), 0.2f, (EasingFunction)Easing.LinearTween, (Action)null, (BoolCheck)null); <>1__state = 5; return true; case 5: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 6; return true; case 6: <>1__state = -1; CoroutineEase.EaseLocalPos(p.m_textRundownHeader.transform, p.m_textRundownHeader.transform.localPosition, p.m_rundownHeaderPos, 0.2f, (EasingFunction)Easing.LinearTween, (Action)null, (BoolCheck)null); CoroutineManager.BlinkIn(p.m_rundownIntelButton, 0f, (Transform)null); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 7; return true; case 7: <>1__state = -1; CM_PageBase.PostSound(EVENTS.MENU_SURFACE_LEVEL_TURN, ""); <>2__current = CoroutineEase.EaseLocalRot(guixSurfaceTransform, Vector3.zero, new Vector3(70f, 0f, 0f), 0.3f, (EasingFunction)Easing.LinearTween, (Action)null, (BoolCheck)null); <>1__state = 8; return true; case 8: <>1__state = -1; p.m_verticalArrow.SetActive(true); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 9; return true; case 9: <>1__state = -1; CoroutineManager.BlinkIn(((Component)p.m_tierMarkerSectorSummary).gameObject, 0f); CM_PageBase.PostSound(EVENTS.MENU_RUNDOWN_DISC_APPEAR_5, ""); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 10; return true; case 10: <>1__state = -1; CM_PageBase.PostSound(EVENTS.MENU_RUNDOWN_SPINE_START, ""); CoroutineEase.EaseLocalScale(p.m_verticalArrow.transform, new Vector3(1f, 0f, 1f), new Vector3(1f, <arrowScale>5__1, 1f), 4.3f, (EasingFunction)Easing.LinearTween, (Action)delegate { CM_PageBase.PostSound(EVENTS.MENU_RUNDOWN_SPINE_STOP, ""); }, (BoolCheck)null); <tierMarkerDelay>5__2 = 0.6f; <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 11; return true; case 11: <>1__state = -1; CM_PageBase.PostSound(EVENTS.MENU_RUNDOWN_DISC_APPEAR_3, ""); ((Component)p.m_guix_Tier3).gameObject.SetActive(true); <k>5__3 = 0; while (<k>5__3 < p.m_expIconsTier3.Count) { CoroutineManager.BlinkIn(((Component)p.m_expIconsTier3[<k>5__3]).gameObject, (float)<k>5__3 * 0.1f); <k>5__3++; } if (p.m_expIconsTier3.Count > 0) { p.m_tierMarker3.SetVisible(true, <tierMarkerDelay>5__2); } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 12; return true; case 12: <>1__state = -1; CM_PageBase.PostSound(EVENTS.MENU_RUNDOWN_DISC_APPEAR_5, ""); ((Component)p.m_guix_Tier5).gameObject.SetActive(true); <m>5__4 = 0; while (<m>5__4 < p.m_expIconsTier5.Count) { CoroutineManager.BlinkIn(((Component)p.m_expIconsTier5[<m>5__4]).gameObject, (float)<m>5__4 * 0.1f); <m>5__4++; } if (p.m_expIconsTier5.Count > 0) { p.m_tierMarker5.SetVisible(true, <tierMarkerDelay>5__2); } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 13; return true; case 13: <>1__state = -1; CM_PageBase.PostSound(EVENTS.MENU_RUNDOWN_DISC_APPEAR_4, ""); ((Component)p.m_guix_Tier4).gameObject.SetActive(true); <l>5__5 = 0; while (<l>5__5 < p.m_expIconsTier4.Count) { CoroutineManager.BlinkIn(((Component)p.m_expIconsTier4[<l>5__5]).gameObject, (float)<l>5__5 * 0.1f); <l
plugins/ProjectEternal/Custom/Oxygen.dll
Decompiled 4 days 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.3.2")] [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>__OnBuildDone; public static Action <1>__OnLevelCleanup; public static Action <2>__Setup; public static Action <3>__OnLevelCleanup; public static Action <4>__OnBuildStart; public static Action <5>__OnLevelCleanup; public static LiveEditEventHandler <6>__Listener_FileChanged1; } public const string MODNAME = "Oxygen"; public const string AUTHOR = "Inas"; public const string GUID = "Inas.Oxygen"; public const string VERSION = "1.3.2"; 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown if (!Directory.Exists(OXYGEN_CONFIG_PATH)) { Directory.CreateDirectory(OXYGEN_CONFIG_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(OXYGEN_CONFIG_PATH, "Template.json")); streamWriter.WriteLine(ConfigManager.Serialize(new OxygenConfig())); streamWriter.Flush(); streamWriter.Close(); } ClassInjector.RegisterTypeInIl2Cpp<AirManager>(); 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.<6>__Listener_FileChanged1; if (obj2 == null) { LiveEditEventHandler val = Listener_FileChanged1; <>O.<6>__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] internal class Patch_PlayerAgent { [HarmonyPrefix] [HarmonyPatch(typeof(PlayerAgent), "ReceiveModification")] public static void ReceiveModification(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; } } [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch(typeof(PlayerAgent), "Setup")] internal static void Post_Setup(PlayerAgent __instance) { if (((Agent)__instance).IsLocallyOwned) { AirManager.Setup(__instance); } } } } 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); } public static string Serialize<T>(T value) { return JsonSerializer.Serialize(value, s_SerializerOptions); } static ConfigManager() { s_SerializerOptions = new JsonSerializerOptions { AllowTrailingCommas = true, ReadCommentHandling = JsonCommentHandling.Skip, PropertyNameCaseInsensitive = true, WriteIndented = 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(PlayerAgent playerAgent) { Current = ((Component)playerAgent).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 && ((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 damageAmount = config.DamageAmount; Damage.m_nextRegen = Clock.Time + config.TimeToStartHealthRegen; if (!(health <= 1f)) { ((Dam_SyncedDamageBase)Damage).NoAirDamage(damageAmount); if (config.ShatterGlass) { glassShatterAmount += config.ShatterAmount; m_hudGlass.SetGlassShatterProgression(glassShatterAmount); } damageTick = 0f; tickUntilHealthRegenHealthStart = 0f; healthRegenAmountPerInterval = 0f; healthToRegen += damageAmount * config.HealthRegenProportion; CoughLoss += damageAmount; 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; } } } }
plugins/ProjectEternal/Custom/PortalPuzzleChanger.dll
Decompiled 4 days 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 AssetShards; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using ChainedPuzzles; using Enemies; using FX_EffectSystem; using GTFO.API; using GTFO.API.Components; using GTFO.API.JSON.Converters; using GTFO.API.Wrappers; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using LevelGeneration; using MTFO.Managers; using Microsoft.CodeAnalysis; using Player; using PortalPuzzleChanger.ConfigFiles; using PortalPuzzleChanger.GameScripts; using PortalPuzzleChanger.Plugin; using SNetwork; 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 = ".NET 6.0")] [assembly: AssemblyCompany("PortalPuzzleChanger")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PortalPuzzleChanger")] [assembly: AssemblyTitle("PortalPuzzleChanger")] [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 PortalPuzzleChanger.Plugin { [BepInPlugin("com.Breeze.PortalPuzzleChanger", "PortalPuzzleChanger", "0.0.1")] [BepInProcess("GTFO.exe")] internal class EntryPoint : BasePlugin { public static Dictionary<string, Sprite> CachedSprites; public static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, PropertyNameCaseInsensitive = true, IncludeFields = true, AllowTrailingCommas = true, WriteIndented = true }; public static ManualLogSource? LogSource { get; private set; } public static Harmony? m_Harmony { get; private set; } public override void Load() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown LogSource = ((BasePlugin)this).Log; m_Harmony = new Harmony("_PortalPuzzleChanger_"); m_Harmony.PatchAll(); SerializerOptions.Converters.Add((JsonConverter)new LocalizedTextConverter()); SerializerOptions.Converters.Add((JsonConverter)new Vector3Converter()); SerializerOptions.Converters.Add((JsonConverter)new Vector2Converter()); SerializerOptions.Converters.Add((JsonConverter)new ColorConverter()); PortalPuzzleChangerSetup.Load(); EnemyTagChangerConfigSetup.Load(); GrenadeLauncherConfigSetup.Load(); ClassInjector.RegisterTypeInIl2Cpp<GrenadeProjectile>(); AssetAPI.OnAssetBundlesLoaded += OnAssetsLoaded; } public void OnAssetsLoaded() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) List<EnemyTagChanger> list = EnemyTagChangerConfigSetup.EnabledConfigs.Values.ToList(); for (int i = 0; i < list.Count; i++) { if (!string.IsNullOrEmpty(list[i].CustomImagePath)) { Texture2D loadedAsset = AssetAPI.GetLoadedAsset<Texture2D>(list[i].CustomImagePath); Sprite val = Sprite.Create(loadedAsset, new Rect(0f, 0f, (float)((Texture)loadedAsset).width, (float)((Texture)loadedAsset).height), new Vector2(0.5f, 0.5f), 64f); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = list[i].CustomImagePath; CachedSprites.Add(((Object)val).name, val); Debug("Created a sprite from path: " + list[i].CustomImagePath); } } } public static void Debug(string message) { LogSource.LogDebug((object)("[DEBUG] " + message)); } public static void DebugWarning(string message) { LogSource.LogWarning((object)("[WARNING] " + message)); } public static void DebugError(string message) { LogSource.LogError((object)("[ERROR] " + message)); } } public class PortalPuzzleChangerSetup { public static Dictionary<uint, List<PortalEntry>> EnabledConfigs = new Dictionary<uint, List<PortalEntry>>(); private static List<PortalChangerConfig>? Configs; public static string Name { get; } = "PortalPuzzleChanger.json"; public static void Load() { string path = Path.Combine(ConfigManager.CustomPath, Name); if (File.Exists(path)) { Configs = JsonSerializer.Deserialize<List<PortalChangerConfig>>(File.ReadAllText(path), EntryPoint.SerializerOptions); EntryPoint.Debug(Name + " has loaded successfully"); } else { Configs = new List<PortalChangerConfig> { new PortalChangerConfig() }; string contents = JsonSerializer.Serialize(Configs, EntryPoint.SerializerOptions); File.WriteAllText(path, contents); EntryPoint.DebugWarning(Name + " did not exist, creating it now"); } EnabledConfigs.Clear(); int count = Configs.Count; for (int i = 0; i < count; i++) { if (Configs[i].InternalEnabled) { EnabledConfigs.Add(Configs[i].MainLevelLayoutID, Configs[i].PortalEntries); } } } } public class EnemyTagChangerConfigSetup { public static Dictionary<uint, EnemyTagChanger> EnabledConfigs = new Dictionary<uint, EnemyTagChanger>(); private static List<EnemyTagChanger>? Configs; public static string Name { get; } = "EnemyTags.json"; public static void Load() { string path = Path.Combine(ConfigManager.CustomPath, Name); if (File.Exists(path)) { Configs = JsonSerializer.Deserialize<List<EnemyTagChanger>>(File.ReadAllText(path), EntryPoint.SerializerOptions); EntryPoint.Debug(Name + " has loaded successfully"); } else { Configs = new List<EnemyTagChanger> { new EnemyTagChanger() }; string contents = JsonSerializer.Serialize(Configs, EntryPoint.SerializerOptions); File.WriteAllText(path, contents); EntryPoint.DebugWarning(Name + " did not exist, creating it now"); } EnabledConfigs.Clear(); int count = Configs.Count; for (int i = 0; i < count; i++) { if (Configs[i].internalEnabled) { EnabledConfigs.Add(Configs[i].EnemyID, Configs[i]); } } } } public class GrenadeLauncherConfigSetup { public static Dictionary<uint, GrenadeLauncherConfig> EnabledConfigs = new Dictionary<uint, GrenadeLauncherConfig>(); private static List<GrenadeLauncherConfig>? Configs; public static string Name { get; } = "GrenadeLauncher.json"; public static void Load() { string path = Path.Combine(ConfigManager.CustomPath, Name); if (File.Exists(path)) { Configs = JsonSerializer.Deserialize<List<GrenadeLauncherConfig>>(File.ReadAllText(path), EntryPoint.SerializerOptions); EntryPoint.Debug(Name + " has loaded successfully"); } else { Configs = new List<GrenadeLauncherConfig> { new GrenadeLauncherConfig() }; string contents = JsonSerializer.Serialize(Configs, EntryPoint.SerializerOptions); File.WriteAllText(path, contents); EntryPoint.DebugWarning(Name + " did not exist, creating it now"); } EnabledConfigs.Clear(); int count = Configs.Count; for (int i = 0; i < count; i++) { if (Configs[i].internalEnabled) { EnabledConfigs.Add(Configs[i].PersistentID, Configs[i]); } } } } } namespace PortalPuzzleChanger.Patches { [HarmonyPatch(typeof(LG_DimensionPortal), "Setup")] public static class DimensionPortalPatch { public static void Prefix(LG_DimensionPortal __instance) { //IL_002e: 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_0049: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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) if (!PortalPuzzleChangerSetup.EnabledConfigs.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { return; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) original = (__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex); List<PortalEntry> list = PortalPuzzleChangerSetup.EnabledConfigs[RundownManager.ActiveExpedition.LevelLayoutData]; foreach (PortalEntry item in list) { (eDimensionIndex, LG_LayerType, eLocalZoneIndex) comparingTo = (item.DimensionIndex, item.LayerType, item.ZoneIndex); if (DoesZoneMatch(original, comparingTo)) { __instance.m_targetDimension = item.TargetDimension; __instance.m_targetZone = item.TargetZoneIndex; __instance.PortalChainPuzzle = item.PortalChainedPuzzleId; EntryPoint.Debug("Changing the ChainedPuzzleID on " + __instance.PublicName); } } } public static void Postfix(LG_DimensionPortal __instance) { //IL_002e: 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_0049: 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) //IL_008a: 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_00d1: Unknown result type (might be due to invalid IL or missing references) if (!PortalPuzzleChangerSetup.EnabledConfigs.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { return; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) original = (__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex); List<PortalEntry> list = PortalPuzzleChangerSetup.EnabledConfigs[RundownManager.ActiveExpedition.LevelLayoutData]; foreach (PortalEntry item in list) { (eDimensionIndex, LG_LayerType, eLocalZoneIndex) comparingTo = (item.DimensionIndex, item.LayerType, item.ZoneIndex); if (DoesZoneMatch(original, comparingTo) && item.CreateTeamScanAsLast) { ChainedPuzzleInstance puzzleInstance = ChainedPuzzleManager.CreatePuzzleInstance(4u, __instance.SpawnNode.m_area, __instance.m_portalBioScanPoint.position, __instance.m_portalBioScanPoint); puzzleInstance.OnPuzzleSolved = __instance.m_portalChainPuzzleInstance.OnPuzzleSolved; __instance.m_portalChainPuzzleInstance.OnPuzzleSolved = Action.op_Implicit((Action)delegate { puzzleInstance.AttemptInteract((eChainedPuzzleInteraction)0); }); EntryPoint.Debug("Adding team scan on " + __instance.PublicName); } } } private static bool DoesZoneMatch((eDimensionIndex, LG_LayerType, eLocalZoneIndex) original, (eDimensionIndex, LG_LayerType, eLocalZoneIndex) comparingTo) { //IL_0006: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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) (eDimensionIndex, LG_LayerType, eLocalZoneIndex) tuple = original; (eDimensionIndex, LG_LayerType, eLocalZoneIndex) tuple2 = comparingTo; return tuple.Item1 == tuple2.Item1 && tuple.Item2 == tuple2.Item2 && tuple.Item3 == tuple2.Item3; } } [HarmonyPatch(typeof(HackingTool), "Setup")] public static class HackingToolTest { public static void Postfix(HackingTool __instance) { } } [HarmonyPatch(typeof(EnemyAgent), "SyncPlaceNavMarkerTag")] internal static class EnemyTagPatch { public static void Postfix(EnemyAgent __instance) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (EnemyTagChangerConfigSetup.EnabledConfigs.ContainsKey(__instance.EnemyDataID)) { EnemyTagChanger enemyTagChanger = EnemyTagChangerConfigSetup.EnabledConfigs[__instance.EnemyDataID]; NavMarker tagMarker = __instance.m_tagMarker; if (!string.IsNullOrEmpty(enemyTagChanger.CustomImagePath)) { SpriteRenderer component = ((Component)tagMarker.m_enemySubObj).GetComponent<SpriteRenderer>(); component.sprite = EntryPoint.CachedSprites[enemyTagChanger.CustomImagePath]; } tagMarker.SetColor(enemyTagChanger.TagColor); } } } [HarmonyPatch(typeof(GrenadeBase), "Awake")] internal static class GrenadeBase_Setup { public static void Postfix(GrenadeBase __instance) { GrenadeProjectile grenadeProjectile = ((Component)__instance).gameObject.AddComponent<GrenadeProjectile>(); ((Behaviour)grenadeProjectile).enabled = true; grenadeProjectile.GrenadeBase = __instance; } } [HarmonyPatch(typeof(GrenadeBase), "GrenadeDelay")] internal static class GrenadeBase_GrenadeDelay { public static bool Prefix() { return false; } } [HarmonyPatch(typeof(GrenadeBase), "Start")] internal static class GrenadeBase_Start { public static void Postfix(GrenadeBase __instance) { ((MonoBehaviour)__instance).CancelInvoke("GrenadeDelay"); } } [HarmonyPatch(typeof(BulletWeapon), "Fire")] internal static class BulletWeapon_Fire { public static void Prefix(BulletWeapon __instance) { if (GrenadeLauncherConfigSetup.EnabledConfigs.ContainsKey(((ItemEquippable)__instance).ArchetypeID)) { GrenadeLauncherConfig config = GrenadeLauncherConfigSetup.EnabledConfigs[((ItemEquippable)__instance).ArchetypeID]; GrenadeLauncherFire.Fire(__instance, config); } } } internal static class GrenadeLauncherFire { public static void Fire(BulletWeapon weapon, GrenadeLauncherConfig config) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0029: 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_0047: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) pItemData val = default(pItemData); val.itemID_gearCRC = 136u; Vector3 targetLookDir = ((Agent)((Item)weapon).Owner).TargetLookDir; Vector3 normalized = ((Vector3)(ref targetLookDir)).normalized; ItemReplicationManager.ThrowItem(val, (delItemCallback)null, (ItemMode)3, ((Component)((ItemEquippable)weapon).MuzzleAlign).transform.position, ((Component)((ItemEquippable)weapon).MuzzleAlign).transform.rotation, normalized * config.ShootForce, ((Component)weapon).transform.position, ((Agent)((Item)weapon).Owner).CourseNode, ((Item)weapon).Owner); ((Weapon)weapon).MaxRayDist = 0f; } } } namespace PortalPuzzleChanger.GameScripts { public class GrenadeProjectile : ConsumableInstance { public GrenadeBase GrenadeBase; private static FX_Pool explosionPool; private float damageRadiusHigh; private float damageRadiusLow; private float damageValueHigh; private float damageValueLow; private float explosionForce; private readonly int explosionTargetMask = LayerManager.MASK_EXPLOSION_TARGETS; private readonly int explosionBlockMask = LayerManager.MASK_EXPLOSION_BLOCKERS; private bool madeNoise = false; private bool collision = false; private bool addForce = false; private float decayTime; private Rigidbody rigidbody; private CellSoundPlayer cellSoundPlayer; public GrenadeProjectile(IntPtr hdl) : base(hdl) { } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown rigidbody = ((Component)this).GetComponent<Rigidbody>(); cellSoundPlayer = new CellSoundPlayer(); if (!Object.op_Implicit((Object)(object)explosionPool)) { explosionPool = FX_Manager.GetEffectPool(AssetShardManager.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/FX_Effects/FX_Tripmine.prefab", false)); } } private void Start() { GrenadeLauncherConfig grenadeLauncherConfig = GrenadeLauncherConfigSetup.EnabledConfigs[((Item)GrenadeBase).Owner.Inventory.WieldedItem.ArchetypeID]; damageRadiusHigh = grenadeLauncherConfig.MaximumDamageRange.Radius; damageRadiusLow = grenadeLauncherConfig.MinimumDamageRange.Radius; damageValueHigh = grenadeLauncherConfig.MaximumDamageRange.Damage; damageValueLow = grenadeLauncherConfig.MinimumDamageRange.Damage; explosionForce = grenadeLauncherConfig.ExplosionForce; } private void FixedUpdate() { //IL_0017: 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_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_0036: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (rigidbody.useGravity) { Vector3 val = ((Component)this).transform.position + rigidbody.velocity * Time.fixedDeltaTime; } else if (!madeNoise) { MakeNoise(); ((Component)this).transform.position = Vector3.down * 100f; madeNoise = true; } } private void Update() { //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) if (rigidbody.useGravity) { cellSoundPlayer.UpdatePosition(((Component)this).transform.position); if (collision) { DetonateSequence(); } } else if (Time.time > decayTime) { ((Item)GrenadeBase).ReplicationWrapper.Replicator.Despawn(); } } private void OnCollisionEnter() { if (rigidbody.useGravity) { DetonateSequence(); } } private void DetonateSequence() { //IL_001f: 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) Detonate(); decayTime = Time.time + 10f; rigidbody.velocity = Vector3.zero; rigidbody.angularVelocity = Vector3.zero; rigidbody.useGravity = false; } private void Detonate() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) FX_EffectBase val = (FX_EffectBase)(object)explosionPool.AquireEffect(); val.Play((FX_Trigger)null, ((Component)this).transform.position, Quaternion.LookRotation(Vector3.up)); if (SNet.IsMaster) { DamageUtil.DoExplosionDamage(((Component)this).transform.position, damageRadiusHigh, damageValueHigh, explosionTargetMask, explosionBlockMask, addForce, explosionForce); DamageUtil.DoExplosionDamage(((Component)this).transform.position, damageRadiusLow, damageValueLow, explosionTargetMask, explosionBlockMask, addForce, explosionForce); } } private void MakeNoise() { //IL_000d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown List<string> list = new List<string>(); Il2CppReferenceArray<Collider> val = Physics.OverlapSphere(((Component)this).transform.position, 50f, LayerManager.MASK_ENEMY_DAMAGABLE); foreach (Collider item in (Il2CppArrayBase<Collider>)(object)val) { Dam_EnemyDamageLimb component = ((Component)item).GetComponent<Dam_EnemyDamageLimb>(); if ((Object)(object)component == (Object)null) { continue; } EnemyAgent glueTargetEnemyAgent = component.GlueTargetEnemyAgent; if (!((Object)(object)glueTargetEnemyAgent == (Object)null) && !list.Contains(((Object)((Component)glueTargetEnemyAgent).gameObject).name)) { list.Add(((Object)((Component)glueTargetEnemyAgent).gameObject).name); if (!Physics.Linecast(((Component)this).transform.position, ((Agent)glueTargetEnemyAgent).EyePosition, LayerManager.MASK_WORLD)) { NM_NoiseData val2 = new NM_NoiseData { position = ((Agent)glueTargetEnemyAgent).EyePosition, node = ((Agent)glueTargetEnemyAgent).CourseNode, type = (NM_NoiseType)0, radiusMin = 0.01f, radiusMax = 100f, yScale = 1f, noiseMaker = null, raycastFirstNode = false, includeToNeightbourAreas = false }; NoiseManager.MakeNoise(val2); } } } cellSoundPlayer.Post(EVENTS.FRAGGRENADEEXPLODE, true); } public override void OnDespawn() { ((ItemWrapped)this).OnDespawn(); } } } namespace PortalPuzzleChanger.ConfigFiles { public class EnemyTagChanger { public bool internalEnabled { get; set; } public string internalName { get; set; } public uint EnemyID { get; set; } public Color TagColor { get; set; } public string CustomImagePath { get; set; } public EnemyTagChanger() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) internalEnabled = false; internalName = string.Empty; EnemyID = 0u; TagColor = Color.red; CustomImagePath = string.Empty; } } public class GrenadeLauncherConfig { public DamageMinMax MaximumDamageRange { get; set; } public DamageMinMax MinimumDamageRange { get; set; } public float ExplosionForce { get; set; } public float ShootForce { get; set; } public uint PersistentID { get; set; } public string internalName { get; set; } public bool internalEnabled { get; set; } public GrenadeLauncherConfig() { MaximumDamageRange = new DamageMinMax(); MinimumDamageRange = new DamageMinMax(); ExplosionForce = 1000f; PersistentID = 0u; internalName = string.Empty; internalEnabled = false; } } public class DamageMinMax { public float Radius { get; set; } public float Damage { get; set; } public DamageMinMax() { Radius = 0f; Damage = 0f; } } public class PortalChangerConfig { public uint MainLevelLayoutID { get; set; } public bool InternalEnabled { get; set; } public string? InternalName { get; set; } public List<PortalEntry> PortalEntries { get; set; } public PortalChangerConfig() { PortalEntries = new List<PortalEntry> { new PortalEntry() }; InternalEnabled = false; InternalName = "Test"; MainLevelLayoutID = 0u; } } public class PortalEntry { public eLocalZoneIndex ZoneIndex { get; set; } public LG_LayerType LayerType { get; set; } public eDimensionIndex DimensionIndex { get; set; } public eDimensionIndex TargetDimension { get; set; } public eLocalZoneIndex TargetZoneIndex { get; set; } public uint PortalChainedPuzzleId { get; set; } public bool CreateTeamScanAsLast { get; set; } public PortalEntry() { ZoneIndex = (eLocalZoneIndex)0; LayerType = (LG_LayerType)0; DimensionIndex = (eDimensionIndex)0; TargetDimension = (eDimensionIndex)1; TargetZoneIndex = (eLocalZoneIndex)0; PortalChainedPuzzleId = 4u; CreateTeamScanAsLast = false; } } }
plugins/ProjectEternal/Custom/TriggerBoxDamage.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Agents; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using GTFO.API; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Microsoft.CodeAnalysis; using Player; using SNetwork; 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 = ".NET 6.0")] [assembly: AssemblyCompany("TriggerBoxDamage")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TriggerBoxDamage")] [assembly: AssemblyTitle("TriggerBoxDamage")] [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 TriggerBoxDamage { [BepInPlugin("cris.TriggerBoxDamage", "TriggerBoxDamage", "0.0.1")] public class EntryPoint : BasePlugin { private readonly string[] TriggerBoxPrefabPaths = new string[4] { "Assets/EternalPrefabs/Mining/geo_64x64_mining_refinery_I_HA_06_ERR1.prefab", "Assets/EternalPrefabs/Mining/geo_64x64_mining_reactor_HA_02_ERR1.prefab", "Assets/EternalPrefabs/Mining/geo_64x64_mining_refinery_I_HA_03_ERR1.prefab", "Assets/EternalPrefabs/Service/geo_64x64_service_gardens_VS_01_R8A2_F.10.prefab" }; public static EntryPoint e; public override void Load() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown e = this; Harmony val = new Harmony("cris.TriggerBoxDamage"); ((BasePlugin)this).Log.LogInfo((object)"Loading TriggerBoxDamage..."); ClassInjector.RegisterTypeInIl2Cpp<CollisionTriggerDamage>(); LG_Factory.OnFactoryBuildStart += Action.op_Implicit((Action)OverrideTriggerBox); val.PatchAll(); ((BasePlugin)this).Log.LogInfo((object)"TriggerBoxDamage loaded."); } private void OverrideTriggerBox() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown string[] triggerBoxPrefabPaths = TriggerBoxPrefabPaths; bool flag = default(bool); foreach (string text in triggerBoxPrefabPaths) { GameObject loadedAsset = AssetAPI.GetLoadedAsset<GameObject>(text); if ((Object)(object)loadedAsset != (Object)null) { ManualLogSource log = ((BasePlugin)this).Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TriggerBoxDamage] Processing prefab: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } log.LogInfo(val); AddDamageComponent(loadedAsset); } else { ManualLogSource log2 = ((BasePlugin)this).Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[TriggerBoxDamage] Prefab not found at: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); } log2.LogWarning(val2); } } } private void AddDamageComponent(GameObject prefab) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown bool flag = default(bool); foreach (Transform componentsInChild in prefab.GetComponentsInChildren<Transform>(true)) { if (!((Object)componentsInChild).name.Contains("DMG") && !((Object)componentsInChild).name.Contains("INFECT") && !((Object)componentsInChild).name.Contains("HEAL")) { continue; } GameObject gameObject = ((Component)componentsInChild).gameObject; if ((Object)(object)gameObject.GetComponent<CollisionTriggerDamage>() == (Object)null) { gameObject.AddComponent<CollisionTriggerDamage>(); ManualLogSource log = ((BasePlugin)this).Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TriggerBoxDamage] Attached to: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)gameObject).name); } log.LogInfo(val); } } } } public class CollisionTriggerDamage : MonoBehaviour { private float _damageAmount; private Collider col; private const int layer = 21; private const int layerMask = 2097152; private HashSet<int> _collisions = new HashSet<int>(); private Dictionary<int, float> _playerdam = new Dictionary<int, float>(); private void Start() { //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown if (((Object)this).name.Contains("DMG_L")) { _damageAmount = 10f; } else if (((Object)this).name.Contains("DMG_M")) { _damageAmount = 4.5f; } else if (((Object)this).name.Contains("DMG_S")) { _damageAmount = 2f; } else if (((Object)this).name.Contains("DMG_XS")) { _damageAmount = 1f; } else if (((Object)this).name.Contains("F.10_DMG")) { _damageAmount = 0.0001f; } else if (((Object)this).name.Contains("F.10_INFECT")) { _damageAmount = -0.1f; } else if (((Object)this).name.Contains("F.10_DISINFECT")) { _damageAmount = -0.2f; } else if (((Object)this).name.Contains("F.10_HEAL")) { _damageAmount = -0.3f; } ManualLogSource log = ((BasePlugin)EntryPoint.e).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TriggerBoxDamage] Initialized on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)this).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" with damage "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_damageAmount); } log.LogInfo(val); ((Component)this).gameObject.layer = 21; col = ((Component)this).GetComponent<Collider>(); col.enabled = false; col.isTrigger = false; } private void FixedUpdate() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) if (!SNet.IsMaster) { return; } col.enabled = true; Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (!((Agent)current).Alive) { continue; } float num = (((int)current.Locomotion.m_currentStateEnum != 1) ? 1.85f : 0.925f); num = Mathf.Max(0f, num - 0.8f); Vector3 val = ((Component)current).transform.position + new Vector3(0f, 0.4f, 0f); int instanceID = ((Object)current).GetInstanceID(); if (!Physics.CheckSphere(val, 0.4f, 2097152)) { Ray val2 = default(Ray); ((Ray)(ref val2)).origin = val; ((Ray)(ref val2)).direction = Vector3.up; if (!Physics.SphereCast(val2, 0.4f, num, 2097152)) { _collisions.Remove(instanceID); continue; } } if (_collisions.Contains(instanceID)) { continue; } _collisions.Add(instanceID); if (!_playerdam.ContainsKey(instanceID)) { _playerdam.Add(instanceID, float.NegativeInfinity); } if (Clock.Time > _playerdam[instanceID]) { if (_damageAmount == 0.0001f) { ((Dam_SyncedDamageBase)current.Damage).NoAirDamage(_damageAmount); _playerdam[instanceID] = Clock.Time + 0.1f; } else if (_damageAmount == -0.1f) { ScreenLiquidManager.DirectApply((ScreenLiquidSettingName)11, new Vector2(0.5f, 0.5f), Vector2.zero); _playerdam[instanceID] = Clock.Time + 0.2f; } else if (_damageAmount == -0.2f) { ScreenLiquidManager.DirectApply((ScreenLiquidSettingName)5, new Vector2(0.5f, 0.5f), Vector2.zero); _playerdam[instanceID] = Clock.Time + 0.2f; } else if (_damageAmount == -0.3f) { ScreenLiquidManager.DirectApply((ScreenLiquidSettingName)9, new Vector2(0.5f, 0.5f), Vector2.zero); _playerdam[instanceID] = Clock.Time + 0.2f; } else { ((Dam_SyncedDamageBase)current.Damage).ShooterProjectileDamage(_damageAmount, ((Component)current).transform.position); _playerdam[instanceID] = Clock.Time + 0.2f; } } } col.enabled = false; } } }