using System; using System.Collections; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameConsole; using HarmonyLib; using Nyxpiri.Collections.Generic; using Nyxpiri.ULTRAKILL.NyxLib; using Nyxpiri.ULTRAKILL.NyxLib.Diagnostics.Debug; using Nyxpiri.ULTRAKILL.NyxLib.EnemyTypes; using TMPro; using ULTRAKILL.Cheats; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Assertions; using UnityEngine.Events; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceProviders; using UnityEngine.SceneManagement; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] public static class StackDebug { public static string GetStackString() { StackTrace arg = new StackTrace(1, fNeedFileInfo: false); return $"{arg}"; } public static void PrintStack() { StackTrace arg = new StackTrace(1, fNeedFileInfo: false); Log.Message($"Stack debug! {arg}"); } } public class EnemyModifier : MonoBehaviour { } public class EnemyComponents : MonoBehaviour { public delegate void PreHurtEventHandler(EventMethodCanceler canceler, GameObject target, Vector3 force, Vector3? hitPoint, float multiplier, bool tryForExplode, float critMultiplier, GameObject sourceWeapon, bool ignoreTotalDamageTakenMultiplier, bool fromExplosion); public delegate void PostHurtEventHandler(EventMethodCancelInfo cancelInfo, GameObject target, Vector3 force, Vector3? hitPoint, float multiplier, bool tryForExplode, float critMultiplier, GameObject sourceWeapon, bool ignoreTotalDamageTakenMultiplier, bool fromExplosion); public delegate void PreAnyEnemyHurtEventHandler(EventMethodCanceler canceler, EnemyComponents enemy, GameObject target, Vector3 force, Vector3? hitPoint, float multiplier, bool tryForExplode, float critMultiplier, GameObject sourceWeapon, bool ignoreTotalDamageTakenMultiplier, bool fromExplosion); public delegate void PostAnyEnemyHurtEventHandler(EventMethodCancelInfo cancelInfo, EnemyComponents enemy, GameObject target, Vector3 force, Vector3? hitPoint, float multiplier, bool tryForExplode, float critMultiplier, GameObject sourceWeapon, bool ignoreTotalDamageTakenMultiplier, bool fromExplosion); public delegate void PreEnrageEventHandler(EventMethodCanceler canceler); public delegate void PostEnrageEventHandler(EventMethodCancelInfo cancelInfo); public delegate void PreUnEnrageEventHandler(EventMethodCanceler canceler); public delegate void PostUnEnrageEventHandler(EventMethodCancelInfo cancelInfo); public delegate void PreDeathEventHandler(EventMethodCanceler canceler, bool instakill); public delegate void PostDeathEventHandler(EventMethodCancelInfo cancelInfo, bool instakill); public static MonoRegistrar MonoRegistrar = new MonoRegistrar(); [SerializeField] private EnemyPrefabStore _PrefabStore = null; [SerializeField] private EnemyRadiance _Radiance = null; [SerializeField] private bool _hasDoneSetup = false; [SerializeField] private EnemyRoot _enemyRootMono; public bool AvoidHealthBasedSlowDown = false; [NonSerialized] public bool QueuedForDestruction = false; public EnemyIdentifier Eid = null; public Enemy Enemy = null; [NonSerialized] public bool IsMarkedDontDestroyOnLoad = false; public static FieldAccess OverrideFullNameFA; [SerializeField] private Collider[] _colliders = null; [SerializeField] private List _monoBehaviours = null; private bool _isEnemyCompInitializer = false; private object DeathPatchCallerObject = null; private bool PreDeathCalled = false; private bool PostDeathCalled = false; private bool DeathCalled = false; private bool InTheProcessOfHurting = false; private object HurtPatchCallerObject = null; public EnemyPrefabStore PrefabStore { get { return _PrefabStore; } private set { _PrefabStore = value; } } public EnemyRadiance Radiance { get { return _Radiance; } private set { _Radiance = value; } } public EnemyRoot EnemyRootMono => _enemyRootMono; public bool HasDoneSetup => _hasDoneSetup; public bool UniquelySolo { get; private set; } = false; public bool IsEnemyCompInitializer => _isEnemyCompInitializer; public bool EidStarted { get; internal set; } = false; [SerializeField] public float InitialHealth { get; private set; } = -1f; [SerializeField] public float HighestHealth { get; private set; } = -1f; public float Health { get { if ((Object)(object)Enemy != (Object)null) { return Enemy.health; } return Eid.health; } set { if ((Object)(object)Enemy != (Object)null) { Enemy.health = value; } else { Eid.health = value; } } } public GameObject RootGameObject => ((int)Eid.enemyType == 4) ? ((Component)((Component)this).transform.parent).gameObject : ((Component)this).gameObject; public bool InstaKilled { get; private set; } = false; public IReadOnlyList Colliders => _colliders; public string OverrideFullName { get { return OverrideFullNameFA.GetValue(Eid); } set { OverrideFullNameFA.SetValue(Eid, value); } } public event PreHurtEventHandler PreHurt; public event PostHurtEventHandler PostHurt; public static event PreAnyEnemyHurtEventHandler PreAnyEnemyHurt; public static event PostAnyEnemyHurtEventHandler PostAnyEnemyHurt; public event PreEnrageEventHandler PreEnrage = null; public event PostEnrageEventHandler PostEnrage = null; public event PreUnEnrageEventHandler PreUnEnrage = null; public event PostUnEnrageEventHandler PostUnEnrage = null; public event PreDeathEventHandler PreDeath; public event PostDeathEventHandler PostDeath; public T GetMonoByIndex(int idx) where T : MonoBehaviour { if (idx < 0) { throw new IndexOutOfRangeException($"Index {idx} was less than 0"); } if (idx > _monoBehaviours.Count) { return default(T); } MonoBehaviour obj = _monoBehaviours[idx]; return (T)(object)((obj is T) ? obj : null); } public void MarkAsUniquelySolo() { UniquelySolo = true; } public void InstaDestroy() { Object.Destroy((Object)(object)RootGameObject); } private void Awake() { Log.TraceExpectedInfo($"EnemyComponents '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' awakens..."); Setup(); EnemyRootMono.Enemy = this; } internal void Setup() { if (!HasDoneSetup) { Log.TraceExpectedInfo($"EnemyComponents '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' is setting up..."); Eid = ((Component)this).GetComponent(); Enemy = ((Component)this).GetComponent(); Assert.IsNotNull((Object)(object)Eid); _isEnemyCompInitializer = true; _hasDoneSetup = true; _enemyRootMono = GameObjectExtensions.GetOrAddComponent(RootGameObject); CreateMods(); Eid.ForceGetHealth(); InitialHealth = Health; UpdateHighestHealth(); _colliders = ((Component)this).GetComponentsInChildren(true); PrefabStore?.StorePrefab(); } } public void ResetHealthInfo() { Eid.ForceGetHealth(); InitialHealth = Health; HighestHealth = -100f; UpdateHighestHealth(); } private void UpdateHighestHealth() { if (Health > HighestHealth) { HighestHealth = Health; } } private void Start() { Log.TraceExpectedInfo($"enemy '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' starts..."); if (_isEnemyCompInitializer) { _colliders = ((Component)this).GetComponentsInChildren(); } if (InitialHealth <= 0f) { Eid.ForceGetHealth(); InitialHealth = Health; } PrefabStore?.StorePrefab(); UpdateHighestHealth(); } private void OnDestroy() { Log.TraceExpectedInfo($"enemy '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' gets instantaneously obliterated (destroyed)..."); } protected void Update() { if (QueuedForDestruction) { Log.TraceExpectedInfo($"enemy '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' was queued for destruction, so its time has come."); Object.Destroy((Object)(object)RootGameObject); } if (InTheProcessOfHurting) { InTheProcessOfHurting = false; Log.UnexpectedInfo(((Object)this).name + ": InTheProcessOfHurting had to be set to false by Update"); } } protected void FixedUpdate() { UpdateHighestHealth(); } private void OnDisable() { Log.TraceExpectedInfo($"enemy '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' gets disabled..."); if (QueuedForDestruction) { Log.TraceExpectedInfo($"enemy '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' was queued for destruction, so its time has come."); Object.Destroy((Object)(object)RootGameObject); } } private void OnEnable() { Log.TraceExpectedInfo($"enemy '{((Object)this).name}:{((Object)((Component)this).gameObject).GetInstanceID()}' gets enabled..."); } private void CreateMods() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown Log.TraceExpectedInfo(((Object)this).name + ".EnemyAdditions is creating new modules..."); _monoBehaviours = new List(MonoRegistrar.RegisteredTypes.Count); foreach (Type registeredType in MonoRegistrar.RegisteredTypes) { _monoBehaviours.Add((MonoBehaviour)((Component)this).gameObject.AddComponent(registeredType)); } if (!Options.DontCreateEnemyRadianceComp.Value) { Radiance = GameObjectExtensions.GetOrAddComponent(((Component)this).gameObject); } if (!Options.DontCreateEnemyPrefabComp.Value) { PrefabStore = ((Component)this).gameObject.AddComponent(); } } internal void TryCallPreDeath(EventMethodCanceler canceler, bool instakill, object patchCallerObject) { if (!PreDeathCalled) { DeathPatchCallerObject = patchCallerObject; PreDeathCalled = true; InstaKilled = instakill; this.PreDeath?.Invoke(canceler, InstaKilled); EnemyEvents.PreDeath?.Invoke(this, InstaKilled); } } internal void TryCallPostDeath(EventMethodCancelInfo cancelInfo, object patchCallerObject) { if (!PostDeathCalled && DeathPatchCallerObject == patchCallerObject) { PostDeathCalled = true; this.PostDeath?.Invoke(cancelInfo, InstaKilled); EnemyEvents.PostDeath?.Invoke(this, InstaKilled); } } internal void TryCallDeath() { if (!DeathCalled) { DeathCalled = true; EnemyEvents.Death?.Invoke(this); } } internal void NotifyOfPreHurt(EventMethodCanceler canceler, GameObject target, Vector3 force, Vector3? hitPoint, float multiplier, float critMultiplier, GameObject sourceWeapon, bool tryForExplode, bool ignoreTotalDamageTakenMultiplier, bool fromExplosion, object hurtPatchCallerObject) { //IL_005c: 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 (InTheProcessOfHurting) { if (HurtPatchCallerObject == hurtPatchCallerObject) { Log.TraceExpectedInfo(((Object)this).name + ": had NotifyOfPreHurt called by the same hurtPatchCallerObject when we were in the process of hurting already? ignoring"); } else { Log.TraceExpectedInfo(((Object)this).name + ": had NotifyOfPreHurt called by differing hurtPatchCallerObject when we were in the process of hurting already, ignoring"); } } else { this.PreHurt?.Invoke(canceler, target, force, hitPoint, multiplier, tryForExplode, critMultiplier, sourceWeapon, ignoreTotalDamageTakenMultiplier, fromExplosion); EnemyComponents.PreAnyEnemyHurt?.Invoke(canceler, this, target, force, hitPoint, multiplier, tryForExplode, critMultiplier, sourceWeapon, ignoreTotalDamageTakenMultiplier, fromExplosion); HurtPatchCallerObject = hurtPatchCallerObject; InTheProcessOfHurting = true; } } internal void NotifyOfPostHurt(EventMethodCancelInfo cancellationInfo, GameObject target, Vector3 force, Vector3? hitPoint, float multiplier, float critMultiplier, GameObject sourceWeapon, bool tryForExplode, bool ignoreTotalDamageTakenMultiplier, bool fromExplosion, object hurtPatchCallerObject) { //IL_005f: 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 (!InTheProcessOfHurting) { Log.TraceExpectedInfo(((Object)this).name + ": had NotifyOfPostHurt called when we were NOT in the process of hurting already, ignoring"); return; } if (HurtPatchCallerObject != hurtPatchCallerObject) { Log.TraceExpectedInfo(((Object)this).name + ": had NotifyOfPostHurt called when we were in the process of hurting already BUT the hurtPatchCallerObject did not match, ignoring"); return; } this.PostHurt?.Invoke(cancellationInfo, target, force, hitPoint, multiplier, tryForExplode, critMultiplier, sourceWeapon, ignoreTotalDamageTakenMultiplier, fromExplosion); EnemyComponents.PostAnyEnemyHurt?.Invoke(cancellationInfo, this, target, force, hitPoint, multiplier, tryForExplode, critMultiplier, sourceWeapon, ignoreTotalDamageTakenMultiplier, fromExplosion); HurtPatchCallerObject = null; InTheProcessOfHurting = false; } internal bool CallPreEnrage(EventMethodCancellationTracker cancellationTracker) { cancellationTracker.Reset(); this.PreEnrage?.Invoke(cancellationTracker.GetCanceler()); cancellationTracker.TryInvokeReimplementation(); return cancellationTracker.ShouldRunMethod; } internal void CallPostEnrage(EventMethodCancellationTracker cancellationTracker) { this.PostEnrage?.Invoke(cancellationTracker.GetCancelInfo()); } internal bool CallPreUnEnrage(EventMethodCancellationTracker cancellationTracker) { cancellationTracker.Reset(); this.PreUnEnrage?.Invoke(cancellationTracker.GetCanceler()); cancellationTracker.TryInvokeReimplementation(); return cancellationTracker.ShouldRunMethod; } internal void CallPostUnEnrage(EventMethodCancellationTracker cancellationTracker) { this.PostUnEnrage?.Invoke(cancellationTracker.GetCancelInfo()); } static EnemyComponents() { EnemyComponents.PreAnyEnemyHurt = null; EnemyComponents.PostAnyEnemyHurt = null; OverrideFullNameFA = new FieldAccess("overrideFullName"); } } public class EnemyRoot : MonoBehaviour { public EnemyComponents Enemy { get; internal set; } = null; protected void Awake() { } } public static class GamePrefs { [HarmonyPatch(typeof(PrefsManager), "Awake", new Type[] { })] private static class PrefsManagerAwakePatch { public static void Prefix(PrefsManager __instance) { } public static void Postfix(PrefsManager __instance) { _manager = __instance; } } private static PrefsManager _manager; public static PrefsManager Manager { get { if ((Object)(object)_manager == (Object)null && (Object)(object)MonoSingleton.Instance != (Object)null) { Log.ExpectedInfo("Had to get PrefsManager via PrefsManager.Instance (then cached the value)"); _manager = MonoSingleton.Instance; } return _manager; } } } public class ToggleCheat : ICheat { public Action OnDisable = null; public Action OnEnable = null; private static Dictionary ToggleCheatStateStore = new Dictionary(); public string LongName { get; private set; } = "Unnamed ToggleCheat"; public string Identifier { get; private set; } = "ukaiw.unnamed-toggle-cheat"; public string ButtonEnabledOverride { get; set; } = null; public string ButtonDisabledOverride { get; set; } = null; public string Icon => null; public bool DefaultState { get; private set; } = false; public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1; public bool IsActive => ToggleCheatStateStore.GetValueOrDefault(Identifier, defaultValue: false); public ToggleCheat(string longName, string identifier, Action onDisable, Action onEnable) { LongName = longName; Identifier = identifier; DefaultState = ToggleCheatStateStore.GetValueOrDefault(Identifier, defaultValue: false); OnDisable = onDisable; OnEnable = onEnable; } public void Disable() { ToggleCheatStateStore[Identifier] = false; OnDisable?.Invoke(this); } public void Enable(CheatsManager manager) { ToggleCheatStateStore[Identifier] = true; OnEnable?.Invoke(this, manager); } } namespace NyxpiriOS { public class Shaker2D { public float _MinScale = 0f; public float _MaxScale = 1f; private float _MinDistance = 1f; public float _Rate = 50f; public float MinScale { get { return _MinScale; } set { _MinScale = value; } } public float MaxScale { get { return _MaxScale; } set { _MaxScale = value; } } public float MinDistance { get { return _MinDistance; } set { _MinDistance = value; } } public float Rate { get { return _Rate; } set { _Rate = Mathf.Max(0f, value); } } public Vector2 PositionA { get; private set; } = Vector2.zero; public Vector2 PositionB { get; private set; } = Vector2.zero; public float Alpha { get; private set; } = 0f; public Vector2 Position { get { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0074: 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) float alpha = Alpha; alpha = Mathf.Sin((alpha + 0.5f) * MathF.PI); alpha = ((!(Alpha < 0.5f)) ? (0.5f + Mathf.Abs(alpha) * 0.5f) : ((1f - alpha) * 0.5f)); return Vector2.op_Implicit(Vector3.Lerp(Vector2.op_Implicit(PositionA), Vector2.op_Implicit(PositionB), alpha)); } } public void NextPosition() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0034: 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_0039: 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_004d: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b1: 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_00c2: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) PositionA = PositionB; for (int i = 0; (i < 10 && Vector3.Distance(Vector2.op_Implicit(PositionB), Vector2.op_Implicit(PositionA)) < MinDistance) || i < 1; i++) { Vector2 val = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref val)).normalized; normalized = ((normalized == Vector2.zero) ? Vector2.right : normalized); PositionB = normalized * Random.Range(MinScale, MaxScale); if (!(Vector2.Distance(PositionB, PositionA) < MinDistance)) { continue; } Vector2 positionB = PositionB; val = PositionB - PositionA; PositionB = positionB + ((Vector2)(ref val)).normalized * (MinDistance - Vector2.Distance(PositionB, PositionA)); val = PositionB; if (!(((Vector2)(ref val)).magnitude > MaxScale)) { val = PositionB; if (!(((Vector2)(ref val)).magnitude < MinScale)) { break; } } PositionB = Vector2.zero; } } public void Process(float delta) { Alpha += delta * Rate; if (Alpha > 1f) { Alpha %= 1f; NextPosition(); } } } } namespace Nyxpiri { public class ObjPool where T : class, new() { public Func ConstructObject = null; public Action PrepareObject = delegate { }; public Action UnprepareObject = delegate { }; public Action DestructObject = delegate { }; private Stack _FreeList = new Stack(); private T[] Array = new T[0]; public int Size => Array.Length; public int NumFree => _FreeList.Count; public int NumTaken => Array.Length - _FreeList.Count; public ObjPool(Func constructObject, Action destructObject) { Assert.IsNotNull((object)constructObject, ""); DestructObject = destructObject; ConstructObject = constructObject; } public void Clear() { T[] array = Array; foreach (T obj in array) { DestructObject(obj); } Array = new T[0]; _FreeList.Clear(); } public void EnsureSize(int size) { if (Array.Length < size) { T[] array = Array; Array = new T[size]; for (int i = 0; i < array.Length; i++) { Array[i] = array[i]; } for (int j = array.Length; j < Array.Length; j++) { Array[j] = ConstructObject(); _FreeList.Push(j); Assert.IsNotNull((object)Array[j], ""); } } } public (T, int) TakeUnsafe() { if (_FreeList.Count == 0) { EnsureSize(Size * 2); } int num = _FreeList.Pop(); T val = Array[num]; PrepareObject?.Invoke(val); return (val, num); } public PoolObject Take() { return new PoolObject(this, TakeUnsafe()); } public void Return((T, int) element) { UnprepareObject?.Invoke(element.Item1); _FreeList.Push(element.Item2); } public void Return(PoolObject obj) { obj.Dispose(); } ~ObjPool() { Clear(); } } public class PoolObject : IDisposable where T : class, new() { private ObjPool Pool; private (T, int) Element; public T Obj => Element.Item1; public T Value => Obj; public bool IsValid => Pool != null; internal PoolObject(ObjPool pool, (T, int) element) { Pool = pool; Element = element; } public void Dispose() { if (IsValid) { Pool.Return(Element); Element = (null, -1); Pool = null; } } ~PoolObject() { Dispose(); } } public class RegistrationTracker { private bool _Registered = false; public Func RegisterAction { private get; set; } = null; public Func UnregisterAction { private get; set; } = null; public bool Registered { get { return _Registered; } private set { _Registered = value; } } public RegistrationTracker(Func registerAction, Func unregisterAction) { RegisterAction = registerAction; UnregisterAction = unregisterAction; } public void Register() { if (!Registered && (RegisterAction?.Invoke()).GetValueOrDefault(false)) { _Registered = true; } } public void Unregister() { if (Registered && (UnregisterAction?.Invoke()).GetValueOrDefault(false)) { _Registered = false; } } } } namespace Nyxpiri.Unity.Collections { public static class CollectionSorting { public static void Shuffle(this IList list) { for (int i = 0; i < list.Count; i++) { int index = Random.Range(0, list.Count - 1); T item = list[i]; list.RemoveAt(i); list.Insert(index, item); } } } } namespace Nyxpiri.Collections.Generic { public class ReserveList : IReadOnlyCollection, IEnumerable, IEnumerable { private struct ReserveListElem { public T Obj; public bool Free; public ReserveListElem(T obj, bool free) { Obj = obj; Free = free; } } private List _List; private Stack _FreeList; public int Count { get; private set; } = 0; public int SoftCapacity => _List.Count; public int Capacity => _List.Capacity; public T this[int index] { get { if (_List[index].Free) { throw new IndexOutOfRangeException("Attempt to access an index that was in the _FreeList"); } return _List[index].Obj; } set { if (_List[index].Free) { throw new IndexOutOfRangeException("Attempt to access an index that was in the _FreeList"); } ReserveListElem value2 = _List[index]; value2.Obj = value; _List[index] = value2; } } ~ReserveList() { } public ReserveList() { _List = new List(); _FreeList = new Stack(); } public ReserveList(int capacity) { _List = new List(capacity); _FreeList = new Stack(capacity); } public int Add(T elem) { Count++; int count; if (_FreeList.Count == 0) { count = _List.Count; _List.Add(new ReserveListElem(elem, free: false)); return count; } count = _FreeList.Pop(); _List[count] = new ReserveListElem(elem, free: false); return count; } public void RemoveAt(int idx) { if (_List[idx].Free) { throw new IndexOutOfRangeException("Attempt to free already freed index"); } Count--; _List[idx] = new ReserveListElem(default(T), free: true); _FreeList.Push(idx); } public bool IsIndexValid(int idx) { if (idx < 0) { return false; } if (_List.Count <= idx) { return false; } if (_List[idx].Free) { return false; } return true; } public IEnumerator GetEnumerator() { foreach (ReserveListElem elem in _List) { if (!elem.Free) { yield return elem.Obj; } } } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } } namespace Nyxpiri.ULTRAKILL.NyxLib { public static class Assets { public static class HookPoints { public static GameObject HealingHookPoint { get; internal set; } public static GameObject SlingshotHookPoint { get; internal set; } public static GameObject NormalHookPoint { get; internal set; } } private static List> _assetPickers = new List>(64); private static FieldAccess spawnableObjectsDbFA = new FieldAccess("objects"); private static bool _spawnMenuPrefabsGotten = false; private static GameObject _prefabHolder = null; public static GameObject LabelPrefab { get; private set; } = null; public static GameObject HarmlessExplosionPrefab { get; private set; } = null; public static GameObject ExplosionPrefab { get; private set; } = null; public static GameObject SuperExplosionPrefab { get; private set; } = null; public static GameObject RocketPrefab { get; private set; } = null; public static GameObject MortarPrefab { get; private set; } = null; public static GameObject HomingProjectilePrefab { get; private set; } = null; public static GameObject PrefabHolder { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown if ((Object)(object)_prefabHolder == (Object)null) { _prefabHolder = new GameObject(); Object.DontDestroyOnLoad((Object)(object)_prefabHolder); _prefabHolder.SetActive(false); } return _prefabHolder; } } public static void AddAssetPicker(Func pickerFunc) where ObjectType : Object { Func item = delegate(Scene scene) { ObjectType[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); List list = new List(); if (typeof(ObjectType).IsSubclassOf(typeof(Component)) || typeof(ObjectType) == typeof(Component)) { GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); GameObject[] array2 = rootGameObjects; foreach (GameObject val in array2) { list.AddRange(val.GetComponentsInChildren()); } } if (list != null) { foreach (ObjectType item2 in list) { if (pickerFunc(item2)) { return true; } } } if (array != null) { ObjectType[] array3 = array; foreach (ObjectType arg in array3) { if (pickerFunc(arg)) { return true; } } } return false; }; _assetPickers.Add(item); } public static SpawnMenu TryGetSpawnMenu() { if ((Object)(object)MonoSingleton.Instance == (Object)null) { return null; } return ((Component)MonoSingleton.Instance).GetComponentInChildren(true); } public static SpawnableObjectsDatabase TryGetSpawnableObjectsDb() { SpawnMenu val = TryGetSpawnMenu(); if ((Object)(object)val == (Object)null) { return null; } return spawnableObjectsDbFA.GetValue(val); } private static void OnNewScene(Scene scene) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _assetPickers.Count; i++) { Func func = _assetPickers[i]; try { if (func(scene)) { _assetPickers.RemoveAt(i); i--; } } catch (Exception ex) { Log.Error($"Caught {ex.GetType()} whilst trying to execute an asset picker!\n{ex}\n"); } } if (_assetPickers.Count == 0) { Log.TraceExpectedInfo("[Assets] Success! It seems! All asset pickers seem to be satisfied."); } if ((Object)(object)LabelPrefab == (Object)null) { HudController instance = HudController.Instance; if ((Object)(object)instance != (Object)null) { TextMeshProUGUI textMesh = instance.speedometer.textMesh; LabelPrefab = Object.Instantiate(((Component)textMesh).gameObject, PrefabHolder.transform); LabelPrefab.SetActive(false); Object.DontDestroyOnLoad((Object)(object)LabelPrefab); ((TMP_Text)LabelPrefab.GetComponent()).text = "UKAIW-Label!"; } } if ((Object)(object)RocketPrefab == (Object)null) { Grenade[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); Grenade[] array2 = array; foreach (Grenade val in array2) { if (val.rocket) { RocketPrefab = Object.Instantiate(((Component)val).gameObject); Object.DontDestroyOnLoad((Object)(object)RocketPrefab); RocketPrefab.SetActive(false); } if ((Object)(object)HarmlessExplosionPrefab == (Object)null && (Object)(object)val.harmlessExplosion != (Object)null) { HarmlessExplosionPrefab = Object.Instantiate(val.harmlessExplosion); Object.DontDestroyOnLoad((Object)(object)HarmlessExplosionPrefab); HarmlessExplosionPrefab.SetActive(false); GameObjectExtensions.GetOrAddComponent(HarmlessExplosionPrefab); } if ((Object)(object)ExplosionPrefab == (Object)null && (Object)(object)val.explosion != (Object)null) { ExplosionPrefab = Object.Instantiate(val.explosion); Object.DontDestroyOnLoad((Object)(object)ExplosionPrefab); ExplosionPrefab.SetActive(false); GameObjectExtensions.GetOrAddComponent(ExplosionPrefab); } if ((Object)(object)SuperExplosionPrefab == (Object)null && (Object)(object)val.superExplosion != (Object)null) { SuperExplosionPrefab = Object.Instantiate(val.superExplosion); Object.DontDestroyOnLoad((Object)(object)SuperExplosionPrefab); SuperExplosionPrefab.SetActive(false); GameObjectExtensions.GetOrAddComponent(SuperExplosionPrefab); } if ((Object)(object)SuperExplosionPrefab != (Object)null && (Object)(object)ExplosionPrefab != (Object)null && (Object)(object)HarmlessExplosionPrefab != (Object)null && (Object)(object)RocketPrefab != (Object)null) { break; } } } if ((Object)(object)MortarPrefab == (Object)null) { Mass val2 = Object.FindAnyObjectByType((FindObjectsInactive)1); if ((Object)(object)val2 != (Object)null) { MortarPrefab = Object.Instantiate(val2.explosiveProjectile); Object.DontDestroyOnLoad((Object)(object)MortarPrefab); MortarPrefab.SetActive(false); ExplosionPrefab = Object.Instantiate(MortarPrefab.GetComponent().explosionEffect); Object.DontDestroyOnLoad((Object)(object)ExplosionPrefab); ExplosionPrefab.SetActive(false); GameObjectExtensions.GetOrAddComponent(ExplosionPrefab); HomingProjectilePrefab = Object.Instantiate(val2.homingProjectile); Object.DontDestroyOnLoad((Object)(object)HomingProjectilePrefab); HomingProjectilePrefab.SetActive(false); } else { Log.ExpectedInfo("We'd like a a hideous mass in order to yoink it's projectile prefabs, but this scene \"" + SceneHelper.CurrentScene + "\" didn't have it yet!"); } } TryGetSpawnMenuPrefabs(); } private static void TryGetSpawnMenuPrefabs() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0073: Expected I4, but got Unknown SpawnableObjectsDatabase val = TryGetSpawnableObjectsDb(); if ((Object)(object)val == (Object)null) { return; } _spawnMenuPrefabsGotten = true; SpawnableObject[] sandboxObjects = val.sandboxObjects; foreach (SpawnableObject val2 in sandboxObjects) { HookPoint componentInChildren = val2.gameObject.GetComponentInChildren(); if (!((Object)(object)componentInChildren != (Object)null)) { continue; } hookPointType type = componentInChildren.type; hookPointType val3 = type; switch ((int)val3) { case 0: HookPoints.NormalHookPoint = Object.Instantiate(val2.gameObject, PrefabHolder.transform); HookPoints.NormalHookPoint.SetActive(false); break; case 1: if (componentInChildren.healPlayer) { HookPoints.HealingHookPoint = Object.Instantiate(val2.gameObject, PrefabHolder.transform); HookPoints.HealingHookPoint.SetActive(false); } else { HookPoints.SlingshotHookPoint = Object.Instantiate(val2.gameObject, PrefabHolder.transform); HookPoints.SlingshotHookPoint.SetActive(false); } break; } } } internal static void Initialize() { ScenesEvents.OnSceneWasLoaded += OnSceneWasLoaded; LevelQuickLoader.OnQuickLoad += OnNewScene; } private static void OnSceneWasLoaded(Scene scene, string levelName, string unitySceneName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) OnNewScene(scene); } } public static class Cheats { public delegate void ReadyForCheatRegistrationEventHandler(CheatsManager cheatsManager); [HarmonyPatch(typeof(CheatsManager), "Start", new Type[] { })] private static class CheatsManagerStartPatch { public static void Prefix(CheatsManager __instance) { _manager = __instance; } public static void Postfix(CheatsManager __instance) { } } [HarmonyPatch(typeof(TeleportCheat), "Teleport")] private static class TeleportCheatTeleportPatch { public static void Prefix(TeleportCheat __instance, Transform target) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (Enabled) { PlayerActivator val = Object.FindAnyObjectByType(); if ((Object)(object)val != (Object)null) { ((Component)val).transform.position = target.position; } } } public static void Postfix(TeleportCheat __instance, Transform target) { } } [HarmonyPatch(typeof(HeatResistance), "Awake")] private static class APatch { public static void Prefix(HeatResistance __instance) { } public static void Postfix(HeatResistance __instance) { } } private static CheatsManager _manager; public const string RadiantAllEnemies = "nyxpiri.radiant-all-enemies"; public const string SandAllEnemies = "nyxpiri.sand-all-enemies"; public const string OverrideCybergrindStartingWave = "nyxpiri.override-cybergrind-starting-wave"; public const string DisableStops = "nyxpiri.disable-stops"; public const string DisableSlowdown = "nyxpiri.disable-slowdown"; public const string UltraStop = "nyxpiri.ultra-stop"; public const string ShortHitStop = "nyxpiri.short-hit-stop"; public const string PlayCleanMusicWithBattle = "nyxpiri.clean-music-with-battle"; public const string AlwaysBattleMusic = "nyxpiri.always-battle-music"; public const string LogEIDInfo = "nyxpiri.dev.log-eid-info"; private static bool WaitingForCheatRegistration; public static CheatsManager Manager { get { if ((Object)(object)_manager == (Object)null && (Object)(object)MonoSingleton.Instance != (Object)null) { Log.ExpectedInfo("Had to get CheatsManager via CheatsManager.Instance (then cached the value)"); _manager = MonoSingleton.Instance; } return _manager; } } public static bool Enabled => (MonoSingleton.Instance?.cheatsEnabled).GetValueOrDefault(false); public static event ReadyForCheatRegistrationEventHandler ReadyForCheatRegistration; public static bool IsCheatEnabled(string cheatID) { if (!Enabled) { return false; } return Manager.GetCheatState(cheatID); } public static bool IsCheatDisabled(string cheatID) { return !IsCheatEnabled(cheatID); } public static void Initialize() { ScenesEvents.OnSceneWasLoaded += OnSceneWasLoaded; UpdateEvents.OnUpdate += LateUpdate; } private static void LateUpdate() { if (WaitingForCheatRegistration && !((Object)(object)Manager == (Object)null)) { if (Manager.GetCheatState("nyxpiri.radiant-all-enemies")) { OptionsManager.forceRadiance = true; } if (Manager.GetCheatState("nyxpiri.sand-all-enemies")) { OptionsManager.forceSand = true; } RegisterCheats(); WaitingForCheatRegistration = false; } } private static void OnSceneWasLoaded(Scene scene, string levelName, string unitySceneName) { if (!((Object)(object)Manager == (Object)null)) { WaitingForCheatRegistration = Manager.GetCheatInstance() == null; } } private static void RegisterCheats() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if (Options.RegisterHideCheatsStatusCheat.Value) { Manager.RegisterCheat((ICheat)new HideCheatsStatus(), "meta"); } if (Options.RegisterForceNextWaveCheat.Value) { Manager.RegisterCheat((ICheat)(object)new ToggleCheat("Force Next Wave", "nyxpiri.force-next-cybergrind-wave", delegate { }, delegate { Manager.DisableCheat("nyxpiri.force-next-cybergrind-wave"); if (Cybergrind.IsActive && Cybergrind.IsInCybergrindLevel) { ((Component)Cybergrind.EndlessGrid).GetComponent().deadEnemies = 99999; } }), "CYBERGRIND"); } if (Options.RegisterOverrideCybergrindStartingWaveCheat.Value) { Manager.RegisterCheat((ICheat)(object)new ToggleCheat("Override Starting Wave", "nyxpiri.override-cybergrind-starting-wave", delegate { }, delegate { }), "CYBERGRIND"); } Manager.RegisterCheat((ICheat)(object)new ToggleCheat("Radiant All Enemies", "nyxpiri.radiant-all-enemies", delegate { }, delegate { }), "SELF SABOTAGE"); if (Options.RegisterSandAllEnemiesCheat.Value) { Manager.RegisterCheat((ICheat)(object)new ToggleCheat("Sand All Enemies", "nyxpiri.sand-all-enemies", delegate { OptionsManager.forceSand = false; }, delegate { OptionsManager.forceSand = true; }), "SELF SABOTAGE"); } Cheats.ReadyForCheatRegistration?.Invoke(Manager); Manager.RebuildMenu(); } } [HarmonyPatch(typeof(CheckPoint), "ActivateCheckPoint", new Type[] { })] internal static class CheckpointGetPatch { public static void Prefix(CheckPoint __instance) { } public static void Postfix(CheckPoint __instance) { } } public static class Cybergrind { public delegate void CybergrindPreBeginEventHandler(EventMethodCanceler canceler, EndlessGrid endlessGrid); public delegate void CybergrindPostBeginEventHandler(EventMethodCancelInfo cancelInfo, EndlessGrid endlessGrid); public delegate void CybergrindPreNextWaveEventHandler(EventMethodCanceler canceler, EndlessGrid endlessGrid); public delegate void CybergrindPostNextWaveEventHandler(EventMethodCancelInfo cancelInfo, EndlessGrid endlessGrid); [HarmonyPatch(typeof(EndlessGrid), "OnTriggerEnter", new Type[] { typeof(Collider) })] private static class CybergrindStartPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(EndlessGrid __instance, Collider other) { if (!((Component)other).CompareTag("Player")) { return true; } _cancellationTracker.Reset(); Cybergrind.PreCybergrindBegin?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(EndlessGrid __instance, Collider other) { if (((Component)other).CompareTag("Player")) { Cybergrind.PostCybergrindBegin?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); IsActive = true; } } } [HarmonyPatch(typeof(EndlessGrid), "Start")] private static class EndlessGridStartPatch { public static void Prefix(EndlessGrid __instance) { } public static void Postfix(EndlessGrid __instance) { EndlessGrid = __instance; } } [HarmonyPatch(typeof(EndlessGrid), "NextWave", null)] private static class EndlessGridNextWavePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(EndlessGrid __instance) { _cancellationTracker.Reset(); Cybergrind.PreCybergrindNextWave?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(EndlessGrid __instance) { Cybergrind.PostCybergrindNextWave?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } private static EndlessGrid _endlessGrid; public static EndlessGrid EndlessGrid { get { if ((Object)(object)_endlessGrid != (Object)null) { return _endlessGrid; } _endlessGrid = MonoSingleton.Instance; return _endlessGrid; } set { _endlessGrid = value; } } public static bool IsActive { get; private set; } public static bool IsInCybergrindLevel => (Object)(object)EndlessGrid != (Object)null; public static event CybergrindPreBeginEventHandler PreCybergrindBegin; public static event CybergrindPostBeginEventHandler PostCybergrindBegin; public static event CybergrindPreNextWaveEventHandler PreCybergrindNextWave; public static event CybergrindPostNextWaveEventHandler PostCybergrindNextWave; public static void Initialize() { UpdateEvents.OnFixedUpdate += OnFixedUpdate; ScenesEvents.OnSceneWasLoaded += OnSceneWasLoaded; ScenesEvents.OnSceneWasUnloaded += OnSceneWasUnloaded; PreCybergrindBegin += PreBegin; } private static void PreBegin(EventMethodCanceler canceler, EndlessGrid endlessGrid) { if (Cheats.Enabled && Cheats.IsCheatEnabled("nyxpiri.override-cybergrind-starting-wave")) { endlessGrid.startWave = Options.CybergrindStartingWaveOverride.Value; } } private static void OnSceneWasUnloaded(Scene scene, string levelName, string unitySceneName) { IsActive = false; } private static void OnSceneWasLoaded(Scene scene, string levelName, string unitySceneName) { IsActive = false; } private static void OnFixedUpdate() { } } public static class Assert { public static void IsTrue(bool condition, string additionalMsg = "") { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!condition) { throw new AssertionException("Assertion Failed: Condition was false :c; " + additionalMsg, "Assertion Failed: Condition was false :c; " + additionalMsg); } } public static void IsFalse(bool condition, string additionalMsg = "") { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (condition) { throw new AssertionException("Assertion Failed: Condition was false :c; " + additionalMsg, "Assertion Failed: Condition was false :c; " + additionalMsg); } } public static void IsNotNull(object obj, string additionalMsg = "") { //IL_0045: 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) if (obj == null) { if (obj == null) { throw new AssertionException("Assertion Failed: Object was null :c; " + additionalMsg, "Assertion Failed: Object was null :c; " + additionalMsg); } throw new AssertionException("Assertion Failed: Object equals null but *'is' not* null :c; " + additionalMsg, "Assertion Failed: Object was null :c; " + additionalMsg); } } public static void IsNull(object obj, string additionalMsg = "") { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (obj != null) { throw new AssertionException("Assertion Failed: Object is not null :c; " + additionalMsg, "Assertion Failed: Object is not null :c; " + additionalMsg); } } public static void IsNotNull(Object obj, string additionalMsg = "") { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (obj == (Object)null) { if (obj == null) { throw new AssertionException("Assertion Failed: Object was null :c; " + additionalMsg, "Assertion Failed: Object was null :c; " + additionalMsg); } throw new AssertionException("Assertion Failed: Object equals null but *'is' not* null :c; " + additionalMsg, "Assertion Failed: Object was null :c; " + additionalMsg); } } } public static class TryLog { public static void Action(Action action) { try { action(); } catch (Exception arg) { Log.Error($"Exception caught! :c\n{arg}"); throw; } } } [HarmonyPatch(typeof(ActivateNextWave), "AddDeadEnemy")] internal static class CybergrindStartPatch { public static void Prefix() { } public static void Postfix() { } } public enum EnemyGameplayRank { Normal, Miniboss, Boss, Ultraboss } public enum EnemySpeciesType { Husk, Machine, Demon, Angel, Soul, OrganicMachine, Puppet, Unknown, UltraUnknown } public enum EnemySpeciesRank { NotApplicable, Lesser, Greater, Supreme, Prime } public static class EnemyUtils { public static int NumGameplayRanks = 4; public static bool IsEnraged(this EnemyIdentifier eid) { if (eid.Dead) { return false; } IEnrage component = ((Component)eid).GetComponent(); return ((component != null) ? new bool?(component.isEnraged) : null).GetValueOrDefault(false); } public static bool TryEnrage(this EnemyIdentifier eid) { //IL_0064: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected I4, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 if (eid.Dead) { return false; } IEnrage component = ((Component)eid).GetComponent(); if (((component != null) ? new bool?(component.isEnraged) : null).GetValueOrDefault(false)) { return false; } if (component != null) { component.Enrage(); return true; } EnemyType enemyType = eid.enemyType; EnemyType val = enemyType; switch ((int)val) { default: if ((int)val != 33) { break; } if (!eid.dead) { Gutterman component4 = ((Component)eid).GetComponent(); if (component4 != null) { component4.Enrage(); } return true; } return false; case 7: { SwordsMachine component10 = ((Component)eid).GetComponent(); if (component10 != null) { component10.Enrage(); } return true; } case 0: { StatueBoss component7 = ((Component)eid).GetComponent(); if (component7 != null) { component7.Enrage(); } return true; } case 1: case 9: { Drone component3 = ((Component)eid).GetComponent(); if (component3 != null) { component3.Enrage(); } return true; } case 8: { V2 component8 = ((Component)eid).GetComponent(); if (component8 != null) { component8.Enrage(); } return true; } case 5: { Mindflayer component9 = ((Component)eid).GetComponent(); if (component9 != null) { component9.Enrage(); } return true; } case 2: { Mass component5 = ((Component)eid).GetComponent(); if (!((component5 == null) ? null : ((Component)component5).GetComponentInChildren()?.enraged).GetValueOrDefault(true)) { Mass component6 = ((Component)eid).GetComponent(); if (component6 != null) { component6.Enrage(); } return true; } return false; } case 4: { SpiderBody component2 = ((Component)eid).GetComponent(); if (component2 != null) { component2.Enrage(); } return true; } case 3: case 6: break; } return false; } public static bool TryUnenrage(this EnemyIdentifier eid) { //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_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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected I4, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 if (eid.Dead) { return false; } EnemyType enemyType = eid.enemyType; EnemyType val = enemyType; switch ((int)val) { default: if ((int)val != 33) { break; } if (!eid.dead) { Gutterman component2 = ((Component)eid).GetComponent(); if (component2 != null) { component2.UnEnrage(); } return true; } return false; case 7: { SwordsMachine component5 = ((Component)eid).GetComponent(); if (component5 != null) { component5.UnEnrage(); } return true; } case 0: { StatueBoss component3 = ((Component)eid).GetComponent(); if (component3 != null) { component3.UnEnrage(); } return true; } case 1: case 9: { Drone component6 = ((Component)eid).GetComponent(); if (component6 != null) { component6.UnEnrage(); } return true; } case 8: { V2 component7 = ((Component)eid).GetComponent(); if (component7 != null) { component7.UnEnrage(); } return true; } case 5: { Mindflayer component4 = ((Component)eid).GetComponent(); if (component4 != null) { component4.UnEnrage(); } return true; } case 4: { SpiderBody component = ((Component)eid).GetComponent(); if (component != null) { component.UnEnrage(); } return true; } case 2: case 3: case 6: break; } return false; } public static void ApplyDamage(this EnemyIdentifier eid, Vector3 force, Vector3 hitPoint, float multiplier, float critMultiplier, GameObject sourceWeapon, bool fromExplosion) { //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) eid.DeliverDamage(((Component)eid).gameObject, force, hitPoint, multiplier, false, critMultiplier, sourceWeapon, false, fromExplosion); } public static EnemyGameplayRank GetEnemyGameplayRank(this EnemyIdentifier eid) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected I4, but got Unknown EnemyType enemyType = eid.enemyType; if (1 == 0) { } EnemyGameplayRank result = (int)enemyType switch { 37 => EnemyGameplayRank.Ultraboss, 23 => EnemyGameplayRank.Normal, 35 => EnemyGameplayRank.Boss, 0 => eid.isBoss ? EnemyGameplayRank.Boss : EnemyGameplayRank.Normal, 1 => EnemyGameplayRank.Normal, 26 => EnemyGameplayRank.Miniboss, 3 => EnemyGameplayRank.Normal, 30 => EnemyGameplayRank.Ultraboss, 17 => EnemyGameplayRank.Ultraboss, 16 => EnemyGameplayRank.Boss, 28 => EnemyGameplayRank.Boss, 33 => EnemyGameplayRank.Normal, 34 => EnemyGameplayRank.Normal, 2 => (!eid.isBoss) ? EnemyGameplayRank.Miniboss : EnemyGameplayRank.Boss, 21 => EnemyGameplayRank.Normal, 27 => EnemyGameplayRank.Boss, 4 => eid.isBoss ? EnemyGameplayRank.Boss : EnemyGameplayRank.Normal, 25 => EnemyGameplayRank.Ultraboss, 31 => EnemyGameplayRank.Normal, 5 => (!eid.isBoss) ? EnemyGameplayRank.Miniboss : EnemyGameplayRank.Boss, 11 => EnemyGameplayRank.Ultraboss, 18 => EnemyGameplayRank.Ultraboss, 32 => EnemyGameplayRank.Boss, 36 => EnemyGameplayRank.Normal, 14 => EnemyGameplayRank.Normal, 19 => EnemyGameplayRank.Miniboss, 29 => EnemyGameplayRank.Ultraboss, 15 => EnemyGameplayRank.Normal, 12 => EnemyGameplayRank.Normal, 13 => EnemyGameplayRank.Normal, 6 => EnemyGameplayRank.Normal, 7 => (!eid.isBoss) ? EnemyGameplayRank.Miniboss : EnemyGameplayRank.Boss, 20 => EnemyGameplayRank.Normal, 8 => EnemyGameplayRank.Boss, 22 => EnemyGameplayRank.Boss, 24 => EnemyGameplayRank.Boss, 9 => EnemyGameplayRank.Normal, 10 => EnemyGameplayRank.Ultraboss, 38 => EnemyGameplayRank.Normal, 40 => EnemyGameplayRank.Normal, 41 => EnemyGameplayRank.Miniboss, 42 => EnemyGameplayRank.Boss, 39 => EnemyGameplayRank.Normal, _ => throw new NotImplementedException(), }; if (1 == 0) { } return result; } public static EnemySpeciesType GetSpeciesType(this EnemyType enemyType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected I4, but got Unknown if (1 == 0) { } EnemySpeciesType result = (int)enemyType switch { 3 => EnemySpeciesType.Husk, 37 => EnemySpeciesType.UltraUnknown, 23 => EnemySpeciesType.UltraUnknown, 35 => EnemySpeciesType.Machine, 0 => EnemySpeciesType.Demon, 1 => EnemySpeciesType.Machine, 26 => EnemySpeciesType.Husk, 30 => EnemySpeciesType.OrganicMachine, 17 => EnemySpeciesType.OrganicMachine, 16 => EnemySpeciesType.Angel, 28 => EnemySpeciesType.Angel, 33 => EnemySpeciesType.Machine, 34 => EnemySpeciesType.Machine, 2 => EnemySpeciesType.Demon, 21 => EnemySpeciesType.Demon, 27 => EnemySpeciesType.Demon, 4 => EnemySpeciesType.Demon, 25 => EnemySpeciesType.UltraUnknown, 31 => EnemySpeciesType.Demon, 5 => EnemySpeciesType.Machine, 11 => EnemySpeciesType.Husk, 18 => EnemySpeciesType.Soul, 32 => EnemySpeciesType.Demon, 36 => EnemySpeciesType.Puppet, 14 => EnemySpeciesType.Husk, 19 => EnemySpeciesType.Husk, 29 => EnemySpeciesType.Soul, 15 => EnemySpeciesType.Husk, 12 => EnemySpeciesType.Husk, 13 => EnemySpeciesType.Husk, 6 => EnemySpeciesType.Machine, 7 => EnemySpeciesType.Machine, 20 => EnemySpeciesType.Machine, 8 => EnemySpeciesType.Machine, 22 => EnemySpeciesType.Machine, 24 => EnemySpeciesType.UltraUnknown, 9 => EnemySpeciesType.Angel, 38 => EnemySpeciesType.Angel, 40 => EnemySpeciesType.Angel, 41 => EnemySpeciesType.Husk, 42 => EnemySpeciesType.Demon, 39 => EnemySpeciesType.Demon, 10 => EnemySpeciesType.Unknown, _ => throw new NotImplementedException(), }; if (1 == 0) { } return result; } public static EnemySpeciesRank GetSpeciesRank(this EnemyType enemyType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected I4, but got Unknown if (1 == 0) { } EnemySpeciesRank result = (int)enemyType switch { 37 => EnemySpeciesRank.NotApplicable, 23 => EnemySpeciesRank.Supreme, 35 => EnemySpeciesRank.Supreme, 0 => EnemySpeciesRank.Lesser, 1 => EnemySpeciesRank.Lesser, 26 => EnemySpeciesRank.Supreme, 3 => EnemySpeciesRank.Lesser, 30 => EnemySpeciesRank.Greater, 17 => EnemySpeciesRank.Lesser, 16 => EnemySpeciesRank.Supreme, 28 => EnemySpeciesRank.Supreme, 33 => EnemySpeciesRank.Greater, 34 => EnemySpeciesRank.Greater, 2 => EnemySpeciesRank.Greater, 21 => EnemySpeciesRank.Lesser, 27 => EnemySpeciesRank.Supreme, 4 => EnemySpeciesRank.Lesser, 25 => EnemySpeciesRank.NotApplicable, 31 => EnemySpeciesRank.Lesser, 5 => EnemySpeciesRank.Greater, 11 => EnemySpeciesRank.Supreme, 18 => EnemySpeciesRank.Prime, 32 => EnemySpeciesRank.Supreme, 36 => EnemySpeciesRank.NotApplicable, 14 => EnemySpeciesRank.Greater, 19 => EnemySpeciesRank.Supreme, 29 => EnemySpeciesRank.Prime, 15 => EnemySpeciesRank.Greater, 12 => EnemySpeciesRank.Lesser, 13 => EnemySpeciesRank.Lesser, 6 => EnemySpeciesRank.Lesser, 7 => EnemySpeciesRank.Greater, 20 => EnemySpeciesRank.Greater, 8 => EnemySpeciesRank.Supreme, 22 => EnemySpeciesRank.Supreme, 24 => EnemySpeciesRank.Prime, 9 => EnemySpeciesRank.Lesser, 41 => EnemySpeciesRank.Supreme, 39 => EnemySpeciesRank.Lesser, 42 => EnemySpeciesRank.Supreme, 38 => EnemySpeciesRank.Lesser, 40 => EnemySpeciesRank.Greater, 10 => EnemySpeciesRank.NotApplicable, _ => throw new NotImplementedException(), }; if (1 == 0) { } return result; } public static EnemySpeciesRank GetSpeciesRank(this EnemyIdentifier eid) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return eid.enemyType.GetSpeciesRank(); } public static EnemySpeciesType GetSpeciesType(this EnemyIdentifier eid) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return eid.enemyType.GetSpeciesType(); } public static Bounds SolveEnemyBounds(this EnemyComponents enemy) { //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_000f: Unknown result type (might be due to invalid IL or missing references) return ((Component)enemy).gameObject.SolveEnemyBounds(); } public static Bounds SolveEnemyBounds(this GameObject enemyGo) { //IL_0003: 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_003d: 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_0034: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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) //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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: 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_01fb: 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) Bounds result = default(Bounds); Collider component = enemyGo.GetComponent(); Collider[] array = CollectionExtensions.AddRangeToArray(enemyGo.GetComponents(), enemyGo.GetComponentsInChildren()); if ((Object)(object)component != (Object)null) { result = component.bounds; } Vector3 extents = ((Bounds)(ref result)).extents; if (((Vector3)(ref extents)).magnitude > 2f) { return result; } Collider[] array2 = array; foreach (Collider val in array2) { Vector3 min = ((Bounds)(ref result)).min; Vector3 max = ((Bounds)(ref result)).max; float x = min.x; Bounds bounds = val.bounds; if (x > ((Bounds)(ref bounds)).min.x) { bounds = val.bounds; min.x = ((Bounds)(ref bounds)).min.x; } float y = min.y; bounds = val.bounds; if (y > ((Bounds)(ref bounds)).min.y) { bounds = val.bounds; min.y = ((Bounds)(ref bounds)).min.y; } float z = min.z; bounds = val.bounds; if (z > ((Bounds)(ref bounds)).min.z) { bounds = val.bounds; min.z = ((Bounds)(ref bounds)).min.z; } float x2 = max.x; bounds = val.bounds; if (x2 < ((Bounds)(ref bounds)).max.x) { bounds = val.bounds; max.x = ((Bounds)(ref bounds)).max.x; } float y2 = max.y; bounds = val.bounds; if (y2 < ((Bounds)(ref bounds)).max.y) { bounds = val.bounds; max.y = ((Bounds)(ref bounds)).max.y; } float z2 = max.z; bounds = val.bounds; if (z2 < ((Bounds)(ref bounds)).max.z) { bounds = val.bounds; max.z = ((Bounds)(ref bounds)).max.z; } ((Bounds)(ref result)).SetMinMax(min, max); } return result; } } [HarmonyPatch(typeof(EnemyIdentifier), "Awake")] internal static class EnemyPreSpawnPatch { public static void Prefix(EnemyIdentifier __instance) { GameObject gameObject = ((Component)__instance).gameObject; try { EnemyComponents orAddComponent = GameObjectExtensions.GetOrAddComponent(gameObject); } catch (Exception arg) { Log.Error($"{arg}"); } } public static void Postfix(EnemyIdentifier __instance) { GameObject gameObject = ((Component)__instance).gameObject; } } [HarmonyPatch(typeof(EnemyIdentifier), "Start")] internal static class EnemyStartPatch { public static void Prefix(EnemyIdentifier __instance) { GameObject gameObject = ((Component)__instance).gameObject; TryLog.Action(delegate { EnemyEvents.PreStart?.Invoke(((Component)__instance).GetComponent()); }); } public static void Postfix(EnemyIdentifier __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)__instance).gameObject; EnemyComponents ec = ((Component)__instance).GetComponent(); TryLog.Action(delegate { EnemyEvents.PostStart?.Invoke(ec); }); if (Cheats.IsCheatEnabled("nyxpiri.dev.log-eid-info")) { ec.RootGameObject.DebugPrintChildren(); } ec.EidStarted = true; if (Options.LogEnemyTypeOnStart.Value) { Log.Message($"{((Object)gameObject).name}: enemy type is: {__instance.enemyType}"); } } } [HarmonyPatch(typeof(EnemyComponents), "OnDisable")] internal static class EnemyDisablePatch { public static void Prefix(EnemyComponents __instance) { EnemyComponents enemyComponents = __instance; GameObject gameObject = ((Component)enemyComponents).gameObject; TryLog.Action(delegate { EnemyEvents.PreDisabled?.Invoke(__instance); }); } public static void Postfix(EnemyComponents __instance) { GameObject gameObject = ((Component)__instance).gameObject; } } [HarmonyPatch(typeof(EnemyComponents), "OnDestroy")] internal static class EnemyDestroyPatch { public static void Prefix(EnemyComponents __instance) { EnemyComponents enemyComponents = __instance; GameObject gameObject = ((Component)enemyComponents).gameObject; TryLog.Action(delegate { EnemyEvents.PreDestroy?.Invoke(__instance); }); } public static void Postfix(EnemyComponents __instance) { GameObject gameObject = ((Component)__instance).gameObject; } } [HarmonyPatch(typeof(SpiderBody), "Die", new Type[] { })] internal static class SpiderDiePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(SpiderBody __instance) { return EidDeathPatch.PreDeath(((Component)__instance).gameObject.GetComponent(), instakill: false, typeof(SpiderDiePatch), _cancellationTracker); } public static void Postfix(SpiderBody __instance) { EidDeathPatch.PostDeath(((Component)__instance).gameObject.GetComponent(), typeof(SpiderDiePatch), _cancellationTracker); } } [HarmonyPatch(typeof(Enemy), "GoLimp", new Type[] { typeof(bool) })] internal static class EnemyLimpPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Enemy __instance, bool fromExplosion) { return EidDeathPatch.PreDeath(__instance.EID, instakill: false, typeof(EnemyLimpPatch), _cancellationTracker); } public static void Postfix(Enemy __instance, bool fromExplosion) { EidDeathPatch.PostDeath(__instance.EID, typeof(EnemyLimpPatch), _cancellationTracker); } } [HarmonyPatch(typeof(Drone), "Death", new Type[] { typeof(bool) })] internal static class DroneDeathPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Drone __instance, bool fromExplosion) { return EidDeathPatch.PreDeath(((Component)__instance).gameObject.GetComponent(), instakill: false, typeof(DroneDeathPatch), _cancellationTracker); } public static void Postfix(Drone __instance, bool fromExplosion) { EidDeathPatch.PostDeath(((Component)__instance).gameObject.GetComponent(), typeof(DroneDeathPatch), _cancellationTracker); } } [HarmonyPatch(typeof(EnemyIdentifier), "InstaKill")] internal static class EnemyIdentifierInstakill { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(EnemyIdentifier __instance) { _cancellationTracker.Reset(); EnemyComponents component = ((Component)__instance).GetComponent(); component.NullInvalid()?.TryCallPreDeath(_cancellationTracker.GetCanceler(), instakill: true, typeof(EnemyIdentifierInstakill)); _cancellationTracker.TryInvokeReimplementation(); return _cancellationTracker.ShouldRunMethod; } public static void Postfix(EnemyIdentifier __instance) { EnemyComponents component = ((Component)__instance).GetComponent(); component.NullInvalid()?.TryCallPostDeath(_cancellationTracker.GetCancelInfo(), typeof(EnemyIdentifierInstakill)); } } [HarmonyPatch(typeof(EnemyIdentifier), "Explode")] internal static class EnemyIdentifierExplodePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(EnemyIdentifier __instance) { _cancellationTracker.Reset(); EnemyComponents component = ((Component)__instance).GetComponent(); component.NullInvalid()?.TryCallPreDeath(_cancellationTracker.GetCanceler(), instakill: true, typeof(EnemyIdentifierExplodePatch)); _cancellationTracker.TryInvokeReimplementation(); return _cancellationTracker.ShouldRunMethod; } public static void Postfix(EnemyIdentifier __instance) { EnemyComponents component = ((Component)__instance).GetComponent(); component.NullInvalid()?.TryCallPostDeath(_cancellationTracker.GetCancelInfo(), typeof(EnemyIdentifierExplodePatch)); } } [HarmonyPatch(typeof(EnemyIdentifier), "ProcessDeath", new Type[] { typeof(bool) })] internal static class EidDeathPatch { public static GameObject[] ActivateOnDeath; public static bool CalledPreDeath = false; private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool PreDeath(EnemyIdentifier eid, bool instakill, object callerObj, EventMethodCancellationTracker cancellationTracker) { cancellationTracker.Reset(); EnemyComponents component = ((Component)eid).GetComponent(); component.NullInvalid()?.TryCallPreDeath(cancellationTracker.GetCanceler(), instakill, callerObj); cancellationTracker.TryInvokeReimplementation(); return cancellationTracker.ShouldRunMethod; } public static void PostDeath(EnemyIdentifier eid, object callerObj, EventMethodCancellationTracker cancellationTracker) { EnemyComponents component = ((Component)eid).GetComponent(); component.NullInvalid()?.TryCallPostDeath(cancellationTracker.GetCancelInfo(), callerObj); } public static bool Prefix(EnemyIdentifier __instance, bool fromExplosion) { _cancellationTracker.Reset(); EnemyComponents component = ((Component)__instance).GetComponent(); component.NullInvalid()?.TryCallPreDeath(_cancellationTracker.GetCanceler(), instakill: false, typeof(EidDeathPatch)); _cancellationTracker.TryInvokeReimplementation(); component.NullInvalid()?.TryCallDeath(); return _cancellationTracker.ShouldRunMethod; } public static void Postfix(EnemyIdentifier __instance, bool fromExplosion) { EnemyComponents component = ((Component)__instance).GetComponent(); component.NullInvalid()?.TryCallPostDeath(_cancellationTracker.GetCancelInfo(), typeof(EidDeathPatch)); } } [HarmonyPatch(typeof(StatueBoss), "Enrage")] internal static class StatueEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(StatueBoss __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(StatueBoss __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(StatueBoss), "UnEnrage")] internal static class StatueBossUnEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(StatueBoss __instance) { ((Component)__instance).GetComponent().CallPreUnEnrage(_cancellationTracker); } public static void Postfix(StatueBoss __instance) { ((Component)__instance).GetComponent().CallPostUnEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(SwordsMachine), "Enrage")] internal static class SwordsMachineEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(SwordsMachine __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(SwordsMachine __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(SwordsMachine), "UnEnrage")] internal static class SwordsMachineUnEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(SwordsMachine __instance) { ((Component)__instance).GetComponent().CallPreUnEnrage(_cancellationTracker); } public static void Postfix(SwordsMachine __instance) { ((Component)__instance).GetComponent().CallPostUnEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(Drone), "Enrage")] internal static class DroneEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(Drone __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(Drone __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(Drone), "UnEnrage")] internal static class DroneUnEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(Drone __instance) { ((Component)__instance).GetComponent().CallPreUnEnrage(_cancellationTracker); } public static void Postfix(Drone __instance) { ((Component)__instance).GetComponent().CallPostUnEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(V2), "Enrage", new Type[] { typeof(string) })] internal static class V2EnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(V2 __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(V2 __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(V2), "UnEnrage")] internal static class V2UnEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(V2 __instance) { ((Component)__instance).GetComponent().CallPreUnEnrage(_cancellationTracker); } public static void Postfix(V2 __instance) { ((Component)__instance).GetComponent().CallPostUnEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(Mindflayer), "Enrage")] internal static class MindflayerEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(Mindflayer __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(Mindflayer __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(Mindflayer), "UnEnrage")] internal static class MindflayerUnEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(Mindflayer __instance) { ((Component)__instance).GetComponent().CallPreUnEnrage(_cancellationTracker); } public static void Postfix(Mindflayer __instance) { ((Component)__instance).GetComponent().CallPostUnEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(SpiderBody), "Enrage")] internal static class SpiderBodyEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(SpiderBody __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(SpiderBody __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(SpiderBody), "UnEnrage")] internal static class SpiderBodyUnEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(SpiderBody __instance) { ((Component)__instance).GetComponent().CallPreUnEnrage(_cancellationTracker); } public static void Postfix(SpiderBody __instance) { ((Component)__instance).GetComponent().CallPostUnEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(Gutterman), "Enrage")] internal static class GuttermanEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(Gutterman __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(Gutterman __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(Gutterman), "UnEnrage")] internal static class GuttermanUnEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(Gutterman __instance) { ((Component)__instance).GetComponent().CallPreUnEnrage(_cancellationTracker); } public static void Postfix(Gutterman __instance) { ((Component)__instance).GetComponent().CallPostUnEnrage(_cancellationTracker); } } [HarmonyPatch(typeof(Mass), "Enrage")] internal static class MassEnragePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static void Prefix(Mass __instance) { ((Component)__instance).GetComponent().CallPreEnrage(_cancellationTracker); } public static void Postfix(Mass __instance) { ((Component)__instance).GetComponent().CallPostEnrage(_cancellationTracker); } } public static class EnemyEvents { public static Action PreStart; public static Action PostStart; public static Action PreDisabled; public static Action PreDestroy; public static Action PreDeath; public static Action PostDeath; public static Action Death; } [HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")] internal static class EidDeliverDamagePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(EnemyIdentifier __instance, GameObject target, Vector3 force, Vector3 hitPoint, float multiplier, bool tryForExplode, float critMultiplier = 0f, GameObject sourceWeapon = null, bool ignoreTotalDamageTakenMultiplier = false, bool fromExplosion = false) { //IL_001f: 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) EnemyComponents component = ((Component)__instance).GetComponent(); _cancellationTracker.Reset(); component.NotifyOfPreHurt(_cancellationTracker.GetCanceler(), target, force, hitPoint, multiplier, critMultiplier, sourceWeapon, tryForExplode, ignoreTotalDamageTakenMultiplier, fromExplosion, typeof(EidDeliverDamagePatch)); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(EnemyIdentifier __instance, GameObject target, Vector3 force, Vector3 hitPoint, float multiplier, bool tryForExplode, float critMultiplier = 0f, GameObject sourceWeapon = null, bool ignoreTotalDamageTakenMultiplier = false, bool fromExplosion = false) { //IL_0014: 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) EnemyComponents component = ((Component)__instance).GetComponent(); component.NotifyOfPostHurt(_cancellationTracker.GetCancelInfo(), target, force, hitPoint, multiplier, critMultiplier, sourceWeapon, tryForExplode, ignoreTotalDamageTakenMultiplier, fromExplosion, typeof(EidDeliverDamagePatch)); } } [HarmonyPatch(typeof(Zombie), "GetHurt")] internal static class ZombieHurtPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Zombie __instance, GameObject target, Vector3 force, float multiplier, float critMultiplier, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); _cancellationTracker.Reset(); component.NotifyOfPreHurt(_cancellationTracker.GetCanceler(), target, force, null, multiplier, critMultiplier, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(ZombieHurtPatch)); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Zombie __instance, GameObject target, Vector3 force, float multiplier, float critMultiplier, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); component.NotifyOfPostHurt(_cancellationTracker.GetCancelInfo(), target, force, null, multiplier, critMultiplier, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(ZombieHurtPatch)); } } [HarmonyPatch(typeof(Machine), "GetHurt")] internal static class MachineHurtPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Machine __instance, GameObject target, Vector3 force, float multiplier, float critMultiplier, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); _cancellationTracker.Reset(); component.NotifyOfPreHurt(_cancellationTracker.GetCanceler(), target, force, null, multiplier, critMultiplier, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(MachineHurtPatch)); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Machine __instance, GameObject target, Vector3 force, float multiplier, float critMultiplier, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); component.NotifyOfPostHurt(_cancellationTracker.GetCancelInfo(), target, force, null, multiplier, critMultiplier, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(MachineHurtPatch)); } } [HarmonyPatch(typeof(SpiderBody), "GetHurt")] internal static class SpiderBodyHurtPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(SpiderBody __instance, GameObject target, Vector3 force, Vector3 hitPoint, float multiplier, GameObject sourceWeapon) { //IL_001f: 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) EnemyComponents component = ((Component)__instance).GetComponent(); _cancellationTracker.Reset(); component.NotifyOfPreHurt(_cancellationTracker.GetCanceler(), target, force, hitPoint, multiplier, 1f, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion: false, typeof(SpiderBodyHurtPatch)); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(SpiderBody __instance, GameObject target, Vector3 force, Vector3 hitPoint, float multiplier, GameObject sourceWeapon) { //IL_0014: 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) EnemyComponents component = ((Component)__instance).GetComponent(); component.NotifyOfPostHurt(_cancellationTracker.GetCancelInfo(), target, force, hitPoint, multiplier, 1f, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion: false, typeof(SpiderBodyHurtPatch)); } } [HarmonyPatch(typeof(Statue), "GetHurt")] internal static class StatueHurtPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Statue __instance, GameObject target, Vector3 force, float multiplier, float critMultiplier, Vector3 hurtPos, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); _cancellationTracker.Reset(); component.NotifyOfPreHurt(_cancellationTracker.GetCanceler(), target, force, null, multiplier, critMultiplier, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(StatueHurtPatch)); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Statue __instance, GameObject target, Vector3 force, float multiplier, float critMultiplier, Vector3 hurtPos, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); component.NotifyOfPostHurt(_cancellationTracker.GetCancelInfo(), target, force, null, multiplier, critMultiplier, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(StatueHurtPatch)); } } [HarmonyPatch(typeof(Drone), "GetHurt")] internal static class DroneHurtPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Drone __instance, Vector3 force, float multiplier, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); _cancellationTracker.Reset(); component.NotifyOfPreHurt(_cancellationTracker.GetCanceler(), ((Component)__instance).gameObject, force, null, multiplier, 1f, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(DroneHurtPatch)); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Drone __instance, Vector3 force, float multiplier, GameObject sourceWeapon = null, bool fromExplosion = false) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) EnemyComponents component = ((Component)__instance).GetComponent(); component.NotifyOfPostHurt(_cancellationTracker.GetCancelInfo(), ((Component)__instance).gameObject, force, null, multiplier, 1f, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(DroneHurtPatch)); } } public class EnemyPrefabDatabase : MonoBehaviour { private FieldAccess spawnableObjectsDbFA = new FieldAccess("objects"); private bool SpawnMenuBasedInitializationFinished = false; private GameObject PrefabHolder = null; private Dictionary prefabs = new Dictionary(); public static EnemyPrefabDatabase Instance { get; private set; } public static GameObject GetPrefab(AEnemyType enemyType) { return Instance.prefabs.GetValueOrDefault(enemyType, null); } public static GameObject GetPrefab(EnemyType enemyType) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return Instance.prefabs.GetValueOrDefault(MonoSingleton.Instance.GetVanillaType(enemyType), null); } public static GameObject TrySpawnAt(EnemyType enemyType, Vector3 position, Quaternion rotation, Transform parent, bool autoActivate) { //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_000d: Unknown result type (might be due to invalid IL or missing references) return TrySpawnAt(MonoSingleton.Instance.GetVanillaType(enemyType), position, rotation, parent, autoActivate); } public static GameObject TrySpawnAt(AEnemyType enemyType, Vector3 position, Quaternion rotation, Transform parent, bool autoActivate) { //IL_0016: 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) GameObject prefab = GetPrefab(enemyType); GameObject val = Object.Instantiate(prefab, parent); val.transform.position = position; val.transform.rotation = rotation; val.SetActive(autoActivate); return val; } public void RegisterPrefab(AEnemyType enemyType, GameObject prefab) { prefabs[enemyType] = prefab; } internal void SpawnMenuBasedInitialize() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00e7: 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) if (SpawnMenuBasedInitializationFinished || (Object)(object)MonoSingleton.Instance == (Object)null) { return; } SpawnMenu componentInChildren = ((Component)MonoSingleton.Instance).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { return; } SpawnableObjectsDatabase value = spawnableObjectsDbFA.GetValue(componentInChildren); if ((Object)(object)value == (Object)null) { return; } SpawnMenuBasedInitializationFinished = true; if ((Object)(object)PrefabHolder == (Object)null) { PrefabHolder = new GameObject("EnemyPrefabsHolder"); PrefabHolder.SetActive(false); PrefabHolder.transform.parent = ((Component)this).transform; Object.DontDestroyOnLoad((Object)(object)PrefabHolder); } foreach (object value2 in Enum.GetValues(typeof(EnemyType))) { FindAndAddEnemyViaDb(value, (EnemyType)value2); Log.TraceExpectedInfo($"Trying to add enemy of type {(object)(EnemyType)value2} prefab from the spawnableObjectsDb"); } SpawnMenuBasedInitializationFinished = true; Log.TraceExpectedInfo("Finished(?) adding enemy prefabs from the spawnableObjectsDb"); } private void FindAndAddEnemyViaDb(SpawnableObjectsDatabase spawnableObjectsDb, EnemyType enemyType) { //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_005b: Unknown result type (might be due to invalid IL or missing references) GameObject val = ((IEnumerable)spawnableObjectsDb.enemies).FirstOrDefault((Func)((SpawnableObject obj) => obj.enemyType == enemyType))?.gameObject; if (!((Object)(object)val == (Object)null)) { GameObject val2 = Object.Instantiate(val, PrefabHolder.transform); RegisterPrefab(MonoSingleton.Instance.GetVanillaType(enemyType), val2); EnemyIdentifier componentInChildren = val2.GetComponentInChildren(); EnemyComponents orAddComponent = ComponentExtensions.GetOrAddComponent((Component)(object)componentInChildren); GroundCheckEnemy componentInChildren2 = val2.GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.cols.Clear(); } orAddComponent.IsMarkedDontDestroyOnLoad = true; Object.DontDestroyOnLoad((Object)(object)val2); orAddComponent.Setup(); } } protected void OnEnable() { if ((Object)(object)Instance == (Object)null || !((Behaviour)Instance).enabled) { Instance = this; } } protected void Start() { UpdateEvents.OnLateUpdate += delegate { }; PlayerEvents.PreStart += delegate { SpawnMenuBasedInitialize(); }; } } public static class EnemyPrefabManager { private static int InstanceStoreTickIdx = 0; private static ReserveList InstanceStores = new ReserveList(256); private static int _findEidsFrameCountdown; public static bool TickSkipInstantiation { get; private set; } = false; public static void Initialize() { UpdateEvents.OnLateUpdate += LateUpdate; ScenesEvents.OnSceneWasLoaded += delegate { FindEIDs(); _findEidsFrameCountdown = 5; }; } private static void FindEIDs() { EnemyIdentifier[] array = Object.FindObjectsOfType(true); EnemyIdentifier[] array2 = array; foreach (EnemyIdentifier val in array2) { EnemyComponents orAddComponent = ComponentExtensions.GetOrAddComponent((Component)(object)val); if (!orAddComponent.HasDoneSetup) { Log.TraceExpectedInfo($"FindEIDs search is setting up an enemycomps on {((Component)val).gameObject}!"); } orAddComponent.Setup(); } } public static void LateUpdate() { if (Options.SkipPrefabManagerTicks.Value || !Cheats.Enabled) { return; } if (_findEidsFrameCountdown >= 0) { if (_findEidsFrameCountdown == 0) { FindEIDs(); } _findEidsFrameCountdown--; } if (TickSkipInstantiation) { TickSkipInstantiation = false; } else { if (InstanceStores.Count <= 0) { return; } int i = 0; int num = 0; for (; i < 50; i++) { if (num >= 1) { break; } InstanceStoreTickIdx = (InstanceStoreTickIdx + 1) % InstanceStores.SoftCapacity; if (InstanceStores.IsIndexValid(InstanceStoreTickIdx)) { EnemyPrefabStore.InstanceStore instanceStore = InstanceStores[InstanceStoreTickIdx]; if (!instanceStore.IsFull) { Assert.IsNotNull((Object)(object)instanceStore); instanceStore.InstantiateAndStore(); num++; } } } } } public static int RegisterInstanceStore(EnemyPrefabStore.InstanceStore instanceStore) { TickSkipInstantiation = true; return InstanceStores.Add(instanceStore); } public static void UnregisterInstanceStore(int idx) { InstanceStores.RemoveAt(idx); } } public class EnemyPrefabStore : EnemyModifier { public class InstanceStore : ScriptableObject { public GameObject Prefab = null; public GameObject PrefabParent = null; private string _debugName = "UNNAMED"; private Stack Instances = new Stack(); private HashSet RegisteredStores = new HashSet(32); private RegistrationTracker RegistrationTracker = null; private int RegistrationIdx = -1; public EnemyComponents PrefabEadd { get; private set; } public bool IsFull => Instances.Count >= InstanceStoreCapacity; public void Initialize(GameObject prefab, GameObject prefabParent, EnemyComponents prefabEadd, string debugName) { Prefab = prefab; PrefabParent = prefabParent; PrefabEadd = prefabEadd; _debugName = debugName; Log.TraceExpectedInfo($"New instance store by the name of {debugName} being created with prefab {Prefab}"); if (Cheats.Enabled) { Assert.IsNotNull((Object)(object)Prefab); } RegistrationTracker = new RegistrationTracker(delegate { Log.TraceExpectedInfo(_debugName + ": Registering to prefab manager"); if (Cheats.Enabled) { Assert.IsNotNull((Object)(object)Prefab); } RegistrationIdx = EnemyPrefabManager.RegisterInstanceStore(this); return true; }, delegate { Log.TraceExpectedInfo(_debugName + ": Unregistering from prefab manager"); if (Cheats.Enabled) { Assert.IsNotNull((Object)(object)Prefab); } EnemyPrefabManager.UnregisterInstanceStore(RegistrationIdx); RegistrationIdx = -1; return true; }); } public void InstantiateAndStore() { if ((Object)(object)Prefab == (Object)null) { RegistrationTracker.Unregister(); Log.Error(_debugName + ": InstanceStore had instantiate and store called despite prefab being null, and thus destroyed."); } else if ((Object)(object)PrefabParent == (Object)null) { RegistrationTracker.Unregister(); Log.Error(_debugName + ": InstanceStore had instantiate and store called despite prefab parent being null, and thus destroyed."); } else if (!IsFull) { GameObject val = Object.Instantiate(Prefab); Log.TraceExpectedInfo($"{_debugName}: Instantiating and storing for prefab {Prefab}"); Instances.Push(val); val.SetActive(false); } } public void RegisterStore(EnemyPrefabStore store) { RegisteredStores.Add(store); if (RegisteredStores.Count == 1) { RegistrationTracker.Register(); } Assert.IsNotNull((Object)(object)Prefab); } public void UnregisterStore(EnemyPrefabStore store) { RegisteredStores.Remove(store); if (RegisteredStores.Count == 0) { RegistrationTracker.Unregister(); } Assert.IsNotNull((Object)(object)Prefab); } public GameObject GetNewInstance() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 Assert.IsNotNull((Object)(object)Prefab); GameObject instGo = null; if (Instances.Count > 0) { instGo = Instances.Pop(); } if (instGo == null) { instGo = Object.Instantiate(Prefab); } Transform transform = instGo.transform; GameObject prefabParent = PrefabParent; transform.SetParent((prefabParent != null) ? prefabParent.transform : null); if ((int)PrefabEadd.Eid.enemyType == 12) { EnemyComponents component = instGo.GetComponent(); component.PreDeath += delegate { instGo.GetComponent().SandExplode(1); }; component.PostDeath += delegate { instGo.GetComponent().InstaDestroy(); }; } return instGo; } } private RegistrationTracker InstancesRegistrator = null; [SerializeField] private InstanceStore _instances = null; [SerializeField] private GameObject _prefabParent = null; [SerializeField] private GameObject _prefab = null; [SerializeField] private EnemyIdentifier _eid = null; [SerializeField] private EnemyComponents _enemy = null; private static bool IsStoringPrefab; public static int InstanceStoreCapacity => Mathf.Min(InstanceStoreCapacityModsAdditional, Options.EnemyPrefabInstanceStoreCapacityMax.Value); public static int InstanceStoreCapacityModsAdditional { get; private set; } public InstanceStore Instances => _instances; public GameObject PrefabDirectGameObject => _prefab; public GameObject PrefabParent => _prefabParent ?? null; private bool IsPrefab { get; set; } = false; public static void RequestInstanceStoreCapacity(int requestedCapacity) { InstanceStoreCapacityModsAdditional = Math.Max(InstanceStoreCapacity, requestedCapacity); } public EnemyPrefabStore() { InstancesRegistrator = new RegistrationTracker(delegate { if ((Object)(object)_instances == (Object)null) { return false; } Log.TraceExpectedInfo($"{((Component)this).gameObject} (EnemyPrefabStore): Registering self to InstanceStore"); _instances.RegisterStore(this); return true; }, delegate { if ((Object)(object)_instances == (Object)null) { return false; } Log.TraceExpectedInfo($"{((Component)this).gameObject} (EnemyPrefabStore): Unregistering self to InstanceStore"); _instances.UnregisterStore(this); return true; }); } public void StorePrefab(bool force = false) { try { StorePrefabUnsafe(force); } catch (Exception) { IsStoringPrefab = false; throw; } } protected void Awake() { GetComps(); if ((Object)(object)_prefab != (Object)null && (Object)(object)_prefabParent == (Object)null) { Transform parent = _enemy.RootGameObject.transform.parent; _prefabParent = ((parent != null) ? ((Component)parent).gameObject : null); } } protected void Start() { InstancesRegistrator.Register(); } protected void OnEnable() { InstancesRegistrator.Register(); } protected void OnDisable() { InstancesRegistrator.Unregister(); } private void OnDestroy() { if (!IsPrefab) { } } private void Update() { if (Cheats.Enabled && (Object)(object)_prefab == (Object)null) { StorePrefab(); } } private void StorePrefabUnsafe(bool force = false) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Invalid comparison between Unknown and I4 if (IsStoringPrefab) { Log.UnexpectedInfo("EnemyPrefabStore tried to store a prefab whilst we were storing a prefab"); return; } if ((Object)(object)_prefab != (Object)null && !force) { Log.TraceExpectedInfo("EnemyPrefabMod found that " + ((Object)this).name + " already had a prefab, and force is false, no need to make a new one"); return; } if ((Object)(object)_prefab != (Object)null && force) { Log.TraceExpectedInfo("EnemyPrefabMod found that " + ((Object)this).name + " already had a prefab, but force is true, need to make a new one"); } else if ((Object)(object)_prefab == (Object)null) { Log.TraceExpectedInfo("EnemyPrefabMod found that " + ((Object)this).name + " did not have a prefab, need to make a new one"); } if (!Cheats.Enabled) { return; } GetComps(); GameObject rootGameObject = _enemy.RootGameObject; IsStoringPrefab = true; bool activeSelf = rootGameObject.activeSelf; GameObject val = new GameObject(); val.SetActive(false); if (activeSelf) { } _prefab = Object.Instantiate(rootGameObject, val.transform); if (_enemy.IsMarkedDontDestroyOnLoad) { Object.DontDestroyOnLoad((Object)(object)_prefab); Object.DontDestroyOnLoad((Object)(object)val); } if (activeSelf) { } _prefab.SetActive(false); Assert.IsNotNull((Object)(object)rootGameObject); Assert.IsNotNull((Object)(object)rootGameObject.transform); Transform parent = rootGameObject.transform.parent; _prefabParent = ((parent != null) ? ((Component)parent).gameObject : null); EnemyComponents enemyComponents = _prefab.GetComponent() ?? _prefab.GetComponentInChildren(true); EnemyIdentifier eid = enemyComponents.Eid; if ((Object)(object)_instances == (Object)null) { _instances = ScriptableObject.CreateInstance(); _instances.Initialize(_prefab, _prefabParent, enemyComponents, $"InstanceStore For '{((Component)this).gameObject}'"); if (((Behaviour)this).isActiveAndEnabled) { InstancesRegistrator.Register(); } } _instances.Prefab = _prefab; _instances.PrefabParent = _prefabParent; enemyComponents.PrefabStore.IsPrefab = true; eid.activateOnDeath = (GameObject[])(object)new GameObject[0]; eid.drillers = new List(); eid.stuckMagnets = new List(); eid.blessed = false; eid.destroyOnDeath = new List(); eid.onDeath = new UnityEvent(); EventOnDestroy component = ((Component)eid).GetComponent(); if ((Object)(object)component != (Object)null) { component.stuff = new UnityEvent(); } if ((Object)(object)eid.machine != (Object)null) { eid.machine.musicRequested = false; } if ((Object)(object)eid.zombie != (Object)null) { eid.zombie.musicRequested = false; } if ((Object)(object)eid.statue != (Object)null) { eid.statue.musicRequested = false; } enemyComponents.PrefabStore._instances = _instances; enemyComponents.PrefabStore._prefab = _prefab; if ((int)eid.enemyType == 7) { SwordsMachine component2 = ((Component)eid).GetComponent(); component2.secondPhasePosTarget = null; component2.firstPhase = false; ((Component)component2).GetComponent().spawnIn = true; component2.inAction = false; component2.inSemiAction = false; component2.moveAtTarget = false; } IsStoringPrefab = false; } private void GetComps() { if ((Object)(object)_enemy == (Object)null) { _enemy = ((Component)this).GetComponent(); } if ((Object)(object)_eid == (Object)null) { _eid = ((Component)this).GetComponent(); } } } public class EnemyRadiance : EnemyModifier { public class Modifier { public bool BaseEnabled = false; public bool SpeedEnabled = false; public bool HealthEnabled = false; public bool DamageEnabled = false; public bool Multiplier = false; public float BaseMod = 0f; public float SpeedMod = 0f; public float DamageMod = 0f; public float HealthMod = 0f; public bool Additive { get { return !Multiplier; } set { Multiplier = !value; } } } [HarmonyPatch(typeof(EnemyIdentifier), "BuffAll", new Type[] { })] private static class EidAllBuffPatch { public static void Prefix(EnemyIdentifier __instance) { if (Cheats.Enabled) { } } public static void Postfix(EnemyIdentifier __instance) { if (Cheats.Enabled && !_expectingBuffCalls) { } } } [HarmonyPatch(typeof(EnemyIdentifier), "HealthBuff", new Type[] { typeof(float) })] private static class EidHealthBuffPatch { public static void Prefix(EnemyIdentifier __instance, float modifier) { if (Cheats.Enabled) { } } public static void Postfix(EnemyIdentifier __instance, float modifier) { if (Cheats.Enabled && !_expectingBuffCalls) { EnemyRadiance component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && component._hasBuffedHealthBefore) { PossiblyWarnOfCurrentMethod(); component._externalHealthBuff = modifier; __instance.healthBuffModifier = component._prevHealthBuff; } } } } [HarmonyPatch(typeof(EnemyIdentifier), "SpeedBuff", new Type[] { typeof(float) })] private static class EidSpeedBuffPatch { public static void Prefix(EnemyIdentifier __instance, float modifier) { if (Cheats.Enabled) { } } public static void Postfix(EnemyIdentifier __instance, float modifier) { if (Cheats.Enabled && !_expectingBuffCalls) { EnemyRadiance component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && component._hasBuffedSpeedBefore) { PossiblyWarnOfCurrentMethod(); component._externalSpeedBuff = modifier; __instance.speedBuffModifier = component._prevSpeedBuff; } } } } [HarmonyPatch(typeof(EnemyIdentifier), "DamageBuff", new Type[] { typeof(float) })] private static class EidDamageBuffPatch { public static void Prefix(EnemyIdentifier __instance, float modifier) { if (Cheats.Enabled) { } } public static void Postfix(EnemyIdentifier __instance, float modifier) { if (Cheats.Enabled && !_expectingBuffCalls) { EnemyRadiance component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && component._hasBuffedDamageBefore) { PossiblyWarnOfCurrentMethod(); component._externalHealthBuff = modifier; __instance.damageBuffModifier = component._prevDamageBuff; } } } } private EnemyIdentifier Eid = null; private EnemyComponents Enemy = null; private static bool _expectingBuffCalls; [SerializeField] private bool _hasBuffedBefore = false; [SerializeField] private bool _hasBuffedSpeedBefore = false; [SerializeField] private bool _hasBuffedHealthBefore = false; [SerializeField] private bool _hasBuffedDamageBefore = false; [SerializeField] private bool _requestedSpeedBuff = false; [SerializeField] private bool _requestedHealthBuff = false; [SerializeField] private bool _requestedDamageBuff = false; [SerializeField] private bool _buffsBase = false; [SerializeField] private bool _buffsSpeed = false; [SerializeField] private bool _buffsDamage = false; [SerializeField] private bool _buffsHealth = false; [SerializeField] private float _addedBase = 0f; [SerializeField] private float _addedSpeed = 0f; [SerializeField] private float _addedDamage = 0f; [SerializeField] private float _addedHealth = 0f; [SerializeField] private float _prevBaseBuff = 1f; [SerializeField] private float _prevHealthBuff = 1f; [SerializeField] private float _prevDamageBuff = 1f; [SerializeField] private float _prevSpeedBuff = 1f; [SerializeField] private float _externalBaseBuff = -1f; [SerializeField] private float _externalHealthBuff = -1f; [SerializeField] private float _externalDamageBuff = -1f; [SerializeField] private float _externalSpeedBuff = -1f; public HashSet Modifiers = new HashSet(8); private Modifier RadiantAllModifier = new Modifier(); private Modifier ExternalBuffModifier = new Modifier(); private bool _excluded = false; private bool _started = false; public bool BuffsBase => _buffsBase; public bool BuffsSpeed => _buffsSpeed; public bool BuffsDamage => _buffsDamage; public bool BuffsHealth => _buffsHealth; public float AddedBase { get { return _addedBase; } private set { _addedBase = value; } } public float AddedSpeed { get { return _addedSpeed; } private set { _addedSpeed = value; } } public float AddedDamage { get { return _addedDamage; } private set { _addedDamage = value; } } public float AddedHealth { get { return _addedHealth; } private set { _addedHealth = value; } } public bool IsActive => !Eid.Dead && Cheats.Enabled && !_excluded && _started && (Enemy?.EidStarted).GetValueOrDefault(false); public bool BuffsAny => BuffsHealth || BuffsDamage || BuffsSpeed || BuffsBase; public int ExpectedSpeedBuffRequests => _requestedSpeedBuff ? 1 : 0; public int ExpectedHealthBuffRequests => _requestedHealthBuff ? 1 : 0; public int ExpectedDamageBuffRequests => _requestedDamageBuff ? 1 : 0; public bool IsExternallySpeedBuffed => Eid.speedBuffRequests - ExpectedSpeedBuffRequests > 0; public bool IsExternallyDamageBuffed => Eid.damageBuffRequests - ExpectedDamageBuffRequests > 0; public bool IsExternallyHealthBuffed => Eid.healthBuffRequests - ExpectedHealthBuffRequests > 0; public bool IsExternallyBuffed => IsExternallySpeedBuffed || IsExternallyDamageBuffed || IsExternallyHealthBuffed; public void AddModifier(Modifier modifier) { Modifiers.Add(modifier); } protected void FixedUpdate() { if (!Cheats.Enabled || !IsActive) { return; } if (Cheats.IsCheatEnabled("nyxpiri.radiant-all-enemies")) { RadiantAllModifier.SpeedEnabled = Options.RadianceAllSpeedTier >= 0f; RadiantAllModifier.DamageEnabled = Options.RadianceAllDamageTier >= 0f; RadiantAllModifier.HealthEnabled = Options.RadianceAllHealthTier >= 0f; RadiantAllModifier.BaseEnabled = Options.RadianceAllTier >= 0f; RadiantAllModifier.BaseMod = Options.RadianceAllTier - 1f; RadiantAllModifier.SpeedMod = Options.RadianceAllSpeedTier - 1f; RadiantAllModifier.HealthMod = Options.RadianceAllHealthTier - 1f; RadiantAllModifier.DamageMod = Options.RadianceAllDamageTier - 1f; } else { RadiantAllModifier.BaseEnabled = false; RadiantAllModifier.SpeedEnabled = false; RadiantAllModifier.DamageEnabled = false; RadiantAllModifier.HealthEnabled = false; } float num = 1f; float num2 = 1f; float num3 = 1f; float num4 = 1f; _buffsDamage = false; _buffsHealth = false; _buffsSpeed = false; _buffsBase = false; DisableExternalBuffMod(); for (int i = 0; i < 3; i++) { bool flag = i == 0; bool flag2 = i == 1; bool flag3 = i == 2; foreach (Modifier modifier in Modifiers) { if (flag || flag2) { _buffsDamage = BuffsDamage || modifier.DamageEnabled; _buffsHealth = BuffsHealth || modifier.HealthEnabled; _buffsSpeed = BuffsSpeed || modifier.SpeedEnabled; _buffsBase = BuffsBase || modifier.BaseEnabled; } if (!((modifier.Multiplier && !flag3) || (modifier.Additive && !flag2) || flag)) { if (modifier.BaseEnabled) { num = (modifier.Multiplier ? (num * modifier.BaseMod) : (num + modifier.BaseMod)); } if (modifier.HealthEnabled) { num2 = (modifier.Multiplier ? (num2 * modifier.HealthMod) : (num2 + modifier.HealthMod)); } if (modifier.SpeedEnabled) { num3 = (modifier.Multiplier ? (num3 * modifier.SpeedMod) : (num3 + modifier.SpeedMod)); } if (modifier.DamageEnabled) { num4 = (modifier.Multiplier ? (num4 * modifier.DamageMod) : (num4 + modifier.DamageMod)); } } } if (!BuffsAny && !_hasBuffedBefore) { return; } if (flag) { HandleExternalBuffs(); } } if (BuffsBase) { AddBase(0f - AddedBase); AddBase(num - 1f); } else if (AddedBase != 0f) { AddBase(0f - AddedSpeed); } if (BuffsSpeed) { AddSpeed(0f - AddedSpeed); RequestSpeedBuff(); AddSpeed(num3 - 1f); } else { AddSpeed(0f - AddedSpeed); UnrequestSpeedBuff(); } if (BuffsDamage) { AddDamage(0f - AddedDamage); RequestDamageBuff(); AddDamage(num4 - 1f); } else { AddDamage(0f - AddedDamage); UnrequestDamageBuff(); } if (BuffsHealth) { AddHealth(0f - AddedHealth); RequestHealthBuff(); AddHealth(num2 - 1f); } else { AddHealth(0f - AddedHealth); UnrequestHealthBuff(); } if (Eid.radianceTier != _prevBaseBuff || Eid.speedBuffModifier != _prevSpeedBuff || Eid.damageBuffModifier != _prevDamageBuff || Eid.damageBuffModifier != _prevDamageBuff) { Eid.UpdateBuffs(false, true); if (Options.LogEnemyRadianceUpdates.Value && (!Options.LogEnemyRadianceUpdatesOnlyIfExternallyBuffed.Value || IsExternallyBuffed)) { Log.Message($"{this} updated radiance! radiance info: \nradianceTier: {Eid.radianceTier}" + $"\nspeedBuff: {Eid.speedBuffModifier}\nhealthBuff: {Eid.healthBuffModifier}" + $"\ndamageBuff: {Eid.damageBuffModifier}\nAddedBase: {AddedBase}" + $"\nAddedSpeed: {AddedSpeed}\nspeedValue: {num3}\nAddedDamage: {AddedDamage}" + $"\ndamageValue: {num4}\nAddedHealth: {AddedHealth}\nhealthValue: {num2}" + $"\nIsExternallyBuffed: {IsExternallyBuffed}\n" + $"IsExternallySpeedBuffed: {IsExternallySpeedBuffed}\n" + $"_externalSpeedBuff: {_externalSpeedBuff}\n" + $"IsExternallyDamageBuffed: {IsExternallyDamageBuffed}\n" + $"_externalDamageBuff: {_externalDamageBuff}\n" + $"IsExternallyHealthBuffed: {IsExternallyHealthBuffed}\n" + $"_externalHealthBuff: {_externalHealthBuff}\n" + $"ExpectedSpeedBuffRequests: {ExpectedSpeedBuffRequests}\n" + $"ExpectedDamageBuffRequests: {ExpectedDamageBuffRequests}\n" + $"ExpectedHealthBuffRequests: {ExpectedHealthBuffRequests}\n" + $"HealthBuffRequests: {Eid.healthBuffRequests}\n" + $"DamageBuffRequests: {Eid.damageBuffRequests}\n" + $"SpeedBuffRequests: {Eid.speedBuffRequests}\n" + $"ExternalBuffModifier.BaseEnabled: {ExternalBuffModifier.BaseEnabled}\n" + $"ExternalBuffModifier.BaseMod: {ExternalBuffModifier.BaseMod}\n" + $"ExternalBuffModifier.SpeedEnabled: {ExternalBuffModifier.SpeedEnabled}\n" + $"ExternalBuffModifier.SpeedMod: {ExternalBuffModifier.SpeedMod}\n" + $"ExternalBuffModifier.DamageEnabled: {ExternalBuffModifier.DamageEnabled}\n" + $"ExternalBuffModifier.DamageMod: {ExternalBuffModifier.DamageMod}\n" + $"ExternalBuffModifier.HealthEnabled: {ExternalBuffModifier.HealthEnabled}\n" + $"ExternalBuffModifier.HealthMod: {ExternalBuffModifier.HealthMod}\n"); } } _prevBaseBuff = Eid.radianceTier; _prevDamageBuff = Eid.damageBuffModifier; _prevHealthBuff = Eid.healthBuffModifier; _prevSpeedBuff = Eid.speedBuffModifier; } private void DisableExternalBuffMod() { ExternalBuffModifier.BaseEnabled = false; ExternalBuffModifier.DamageEnabled = false; ExternalBuffModifier.HealthEnabled = false; ExternalBuffModifier.DamageEnabled = false; } private void HandleExternalBuffs() { if (!Cheats.Enabled) { return; } if (BuffsAny && (Eid.radianceTier == 0f || !_hasBuffedBefore)) { _hasBuffedBefore = true; _externalBaseBuff = Eid.radianceTier; if (_externalBaseBuff == 0f && !_hasBuffedBefore) { _externalBaseBuff = 1f; } Eid.radianceTier = 1f; if (!_hasBuffedHealthBefore) { PossiblyWarnOfCurrentMethod(); _externalHealthBuff = Eid.healthBuffModifier; Eid.healthBuffModifier = 1f; } if (!_hasBuffedDamageBefore) { PossiblyWarnOfCurrentMethod(); _externalDamageBuff = Eid.damageBuffModifier; Eid.damageBuffModifier = 1f; } if (!_hasBuffedSpeedBefore) { PossiblyWarnOfCurrentMethod(); _externalSpeedBuff = Eid.speedBuffModifier; Eid.speedBuffModifier = 1f; } } if (BuffsHealth) { } if (BuffsDamage) { } if (BuffsSpeed) { } ExternalBuffModifier.BaseMod = _externalBaseBuff - 1f; if (IsExternallyBuffed) { ExternalBuffModifier.BaseEnabled = true; } if (IsExternallyHealthBuffed) { ExternalBuffModifier.HealthEnabled = true; ExternalBuffModifier.HealthMod = _externalHealthBuff - 1f; } if (IsExternallyDamageBuffed) { ExternalBuffModifier.DamageEnabled = true; ExternalBuffModifier.DamageMod = _externalDamageBuff - 1f; } if (IsExternallySpeedBuffed) { ExternalBuffModifier.SpeedEnabled = true; ExternalBuffModifier.SpeedMod = _externalSpeedBuff - 1f; } } private void RequestHealthBuff() { if (!_requestedHealthBuff) { PossiblyWarnOfCurrentMethod(); _hasBuffedHealthBefore = true; _expectingBuffCalls = true; LogBuffRequest("health", Eid.healthBuffRequests); Eid.HealthBuff(); _expectingBuffCalls = false; _requestedHealthBuff = true; } } private void UnrequestHealthBuff() { if (_requestedHealthBuff) { PossiblyWarnOfCurrentMethod(); LogBuffUnrequest("health"); Eid.HealthUnbuff(); _requestedHealthBuff = false; } } private void RequestSpeedBuff() { if (!_requestedSpeedBuff) { PossiblyWarnOfCurrentMethod(); _hasBuffedSpeedBefore = true; _expectingBuffCalls = true; LogBuffRequest("speed", Eid.speedBuffRequests); Eid.SpeedBuff(); _expectingBuffCalls = false; _requestedSpeedBuff = true; } } private void UnrequestSpeedBuff() { if (_requestedSpeedBuff) { PossiblyWarnOfCurrentMethod(); LogBuffUnrequest("speed"); Eid.SpeedUnbuff(); _requestedSpeedBuff = false; } } private void RequestDamageBuff() { if (!_requestedDamageBuff) { PossiblyWarnOfCurrentMethod(); _hasBuffedDamageBefore = true; _expectingBuffCalls = true; LogBuffRequest("damage", Eid.damageBuffRequests); Eid.DamageBuff(); _expectingBuffCalls = false; _requestedDamageBuff = true; } } private void UnrequestDamageBuff() { if (_requestedDamageBuff) { PossiblyWarnOfCurrentMethod(); Eid.DamageUnbuff(); LogBuffUnrequest("damage"); _requestedDamageBuff = false; } } private void AddSpeed(float amount) { PossiblyWarnOfCurrentMethod(); EnemyIdentifier eid = Eid; eid.speedBuffModifier += amount; AddedSpeed += amount; } private void AddDamage(float amount) { PossiblyWarnOfCurrentMethod(); EnemyIdentifier eid = Eid; eid.damageBuffModifier += amount; AddedDamage += amount; } private void AddHealth(float amount) { PossiblyWarnOfCurrentMethod(); EnemyIdentifier eid = Eid; eid.healthBuffModifier += amount; AddedHealth += amount; } private void AddBase(float amount) { PossiblyWarnOfCurrentMethod(); EnemyIdentifier eid = Eid; eid.radianceTier += amount; AddedBase += amount; } private void LogBuffRequest(string type, int buffRequests) { if (Options.LogEnemyRadianceBuffRequests.Value) { Log.Message($"{((Object)this).name} is about to request a {type} buff! current have {buffRequests} requests!"); } } private void LogBuffUnrequest(string type) { if (Options.LogEnemyRadianceBuffRequests.Value) { Log.Message(((Object)this).name + " UNREQUESTED a " + type + " buff!"); } } private void Awake() { Eid = ((Component)this).GetComponent(); Enemy = ((Component)this).GetComponent(); if (Cheats.Enabled) { } } private void Start() { RadiantAllModifier = new Modifier(); ExternalBuffModifier = new Modifier(); AddModifier(RadiantAllModifier); AddModifier(ExternalBuffModifier); _started = true; if (Cheats.Enabled) { if (_requestedHealthBuff && Eid.healthBuff) { EnemyIdentifier eid = Eid; eid.healthBuffRequests--; } if (_requestedSpeedBuff && Eid.speedBuff) { EnemyIdentifier eid2 = Eid; eid2.speedBuffRequests--; } if (_requestedDamageBuff && Eid.damageBuff) { EnemyIdentifier eid3 = Eid; eid3.damageBuffRequests--; } } } private static void PossiblyWarnOfCurrentMethod() { if (Options.WarnOfEnemyRadianceUpdates.Value) { Log.Warning("Enemy Radiance Method Seemingly Called!\n Stack:\n" + StackDebug.GetStackString()); } } } public abstract class AEnemyType { public abstract string ReadableName { get; } public abstract string Name { get; } public abstract string UniqueName { get; } public abstract EnemyType? VanillaEnumValue { get; } public abstract bool IsVanilla { get; } public override string ToString() { return Name; } public override bool Equals(object obj) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (obj is EnemyType val && VanillaEnumValue == (EnemyType?)val) { return true; } return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } } public class EnemyTypeDB : MonoSingleton { private AEnemyType[] types = new AEnemyType[0]; private HashSet hashTypes = new HashSet(); private Dictionary dictTypes = new Dictionary(); private Dictionary vanillaTypeDict = new Dictionary(); public void RegisterType(AEnemyType enemyType) { //IL_0062: 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) dictTypes.Add(enemyType.UniqueName, enemyType); hashTypes.Add(enemyType); types = hashTypes.ToArray(); Log.TraceExpectedInfo($"[EnemyTypeDB]: Registered AEnemyType {enemyType}"); if (enemyType.VanillaEnumValue.HasValue && !vanillaTypeDict.ContainsKey(enemyType.VanillaEnumValue.Value)) { vanillaTypeDict.Add(enemyType.VanillaEnumValue.Value, enemyType); } } public IReadOnlyList GetValues() { return types; } public AEnemyType GetVanillaType(EnemyType vanillaEnumType) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return vanillaTypeDict[vanillaEnumType]; } protected void OnEnable() { Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } } [HarmonyPatch(typeof(MinosPrime), "Death")] internal static class MinosPrimeDeathPatch { private static MinosPrime _minosPrime; private static void SlowDownReplacement(TimeController tc, float amount) { EnemyComponents component = ((Component)_minosPrime).GetComponent(); Action action = delegate { tc.SlowDown(amount); }; if ((Object)(object)component == (Object)null) { action(); } else if (!component.AvoidHealthBasedSlowDown) { action(); } } private static void Prefix(MinosPrime __instance) { _minosPrime = __instance; } private static IEnumerable Transpiler(IEnumerable instructions) { foreach (CodeInstruction instr in instructions) { if (CodeInstructionExtensions.Calls(instr, typeof(TimeController).GetMethod("SlowDown"))) { instr.operand = typeof(MinosPrimeDeathPatch).GetMethod("SlowDownReplacement", BindingFlags.Static | BindingFlags.NonPublic); } yield return instr; } } } [HarmonyPatch(typeof(SisyphusPrime), "Death")] internal static class SisyphusPrimeDeathPatch { private static SisyphusPrime _sisyphusPrime; private static void SlowDownReplacement(TimeController tc, float amount) { EnemyComponents component = ((Component)_sisyphusPrime).GetComponent(); Action action = delegate { tc.SlowDown(amount); }; if ((Object)(object)component == (Object)null) { action(); } else if (!component.AvoidHealthBasedSlowDown) { action(); } } private static void Prefix(SisyphusPrime __instance) { _sisyphusPrime = __instance; } private static IEnumerable Transpiler(IEnumerable instructions) { foreach (CodeInstruction instr in instructions) { if (CodeInstructionExtensions.Calls(instr, typeof(TimeController).GetMethod("SlowDown"))) { instr.operand = typeof(SisyphusPrimeDeathPatch).GetMethod("SlowDownReplacement", BindingFlags.Static | BindingFlags.NonPublic); } yield return instr; } } } public static class CannonballEvents { public delegate void PreCannonballStartEventHandler(EventMethodCanceler canceler, Cannonball cannonball); public delegate void PostCannonballStartEventHandler(EventMethodCancelInfo cancelInfo, Cannonball cannonball); public delegate void PreCannonballCollideEventHandler(EventMethodCanceler canceler, Cannonball cannonball, Collider other); public delegate void PostCannonballCollideEventHandler(EventMethodCancelInfo cancelInfo, Cannonball cannonball, Collider other); public delegate void PreCannonballLaunchEventHandler(EventMethodCanceler canceler, Cannonball cannonball); public delegate void PostCannonballLaunchEventHandler(EventMethodCancelInfo cancelInfo, Cannonball cannonball); public delegate void PreCannonballExplodeEventHandler(EventMethodCanceler canceler, Cannonball cannonball); public delegate void PostCannonballExplodeEventHandler(EventMethodCancelInfo cancelInfo, Cannonball cannonball); [HarmonyPatch(typeof(Cannonball), "Start")] private static class CannonballStartPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Cannonball __instance) { _cancellationTracker.Reset(); CannonballEvents.PreCannonballStart?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Cannonball __instance) { CannonballEvents.PostCannonballStart?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } [HarmonyPatch(typeof(Cannonball), "Collide")] private static class CannonballCollidePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Cannonball __instance, Collider other) { _cancellationTracker.Reset(); CannonballEvents.PreCannonballCollide?.Invoke(_cancellationTracker.GetCanceler(), __instance, other); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Cannonball __instance, Collider other) { CannonballEvents.PostCannonballCollide?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, other); } } [HarmonyPatch(typeof(Cannonball), "Launch")] private static class CannonballLaunchPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Cannonball __instance) { _cancellationTracker.Reset(); CannonballEvents.PreCannonballLaunch?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Cannonball __instance) { CannonballEvents.PostCannonballLaunch?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } [HarmonyPatch(typeof(Cannonball), "Explode")] private static class CannonballExplodePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Cannonball __instance) { _cancellationTracker.Reset(); CannonballEvents.PreCannonballExplode?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Cannonball __instance) { CannonballEvents.PostCannonballExplode?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } public static event PreCannonballStartEventHandler PreCannonballStart; public static event PostCannonballStartEventHandler PostCannonballStart; public static event PreCannonballCollideEventHandler PreCannonballCollide; public static event PostCannonballCollideEventHandler PostCannonballCollide; public static event PreCannonballLaunchEventHandler PreCannonballLaunch; public static event PostCannonballLaunchEventHandler PostCannonballLaunch; public static event PreCannonballExplodeEventHandler PreCannonballExplode; public static event PostCannonballExplodeEventHandler PostCannonballExplode; } public static class CoinEvents { public delegate void PreCoinAwakeEventHandler(EventMethodCanceler canceler, Coin coin); public delegate void PostCoinAwakeEventHandler(EventMethodCancelInfo cancelInfo, Coin coin); public delegate void PreCoinPunchflectionEventHandler(EventMethodCanceler canceler, Coin coin); public delegate void PostCoinPunchflectionEventHandler(EventMethodCancelInfo cancelInfo, Coin coin); public delegate void PreCoinReflectRevolverEventHandler(EventMethodCanceler canceler, Coin coin); public delegate void PostCoinReflectRevolverEventHandler(EventMethodCancelInfo cancelInfo, Coin coin); [HarmonyPatch(typeof(Coin), "Awake")] private static class CoinAwakePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Coin __instance) { _cancellationTracker.Reset(); CoinEvents.PreCoinAwake?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Coin __instance) { CoinEvents.PostCoinAwake?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } [HarmonyPatch(typeof(Coin), "ReflectRevolver")] private static class CoinReflectRevolverPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Coin __instance) { _cancellationTracker.Reset(); CoinEvents.PreCoinReflectRevolver?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Coin __instance) { CoinEvents.PostCoinReflectRevolver?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } [HarmonyPatch(typeof(Coin), "Punchflection")] private static class CoinPunchflectionPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Coin __instance) { _cancellationTracker.Reset(); CoinEvents.PreCoinPunchflection?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Coin __instance) { CoinEvents.PostCoinPunchflection?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } public static event PreCoinAwakeEventHandler PreCoinAwake; public static event PostCoinAwakeEventHandler PostCoinAwake; public static event PreCoinPunchflectionEventHandler PreCoinPunchflection; public static event PostCoinPunchflectionEventHandler PostCoinPunchflection; public static event PreCoinReflectRevolverEventHandler PreCoinReflectRevolver; public static event PostCoinReflectRevolverEventHandler PostCoinReflectRevolver; } public static class ExplosionEvents { } public class ExplosionAdditions : MonoBehaviour { public class ManagedExplosion { public Explosion Explosion = null; public float BaseMaxSize = 0f; public float BasePushScale = 0f; public float BaseSpeed = 0f; public float BaseEnemyDamageMultiplier = 0f; public int BasePlayerDamageOverride = 0; public int BaseDamage = 0; } private ManagedExplosion[] _Explosions = null; [SerializeField] private float _baseDamageOverride = -1f; [SerializeField] private sbyte _harmless = -1; public float ExplosionScale = 1f; public float ExplosionSpeedScale = 1f; public float ExplosionDamageScale = 1f; public float ExplosionEnemyDamageMultiplierScale = 1f; public float ExplosionPushScale = 1f; public bool ForceElectric = false; public IReadOnlyCollection Explosions => (IReadOnlyCollection)(object)_Explosions; public IEnumerable Audios { get; private set; } public float? BaseDamageOverride { get { if (_baseDamageOverride >= 0f) { return _baseDamageOverride; } return null; } set { _baseDamageOverride = value.GetValueOrDefault(-1f); } } public bool? Harmless { get { if (_harmless >= 0) { return _harmless > 0; } return null; } set { _harmless = (sbyte)((!value.HasValue) ? (-1) : (value.Value ? 1 : 0)); } } protected void Awake() { Explosion[] componentsInChildren = ((Component)this).GetComponentsInChildren(); _Explosions = new ManagedExplosion[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { Explosion val = componentsInChildren[i]; ManagedExplosion managedExplosion = new ManagedExplosion(); managedExplosion.Explosion = val; managedExplosion.BaseSpeed = val.speed; managedExplosion.BaseMaxSize = val.maxSize; managedExplosion.BaseDamage = val.damage; managedExplosion.BasePushScale = val.pushForceMultiplier; managedExplosion.BaseEnemyDamageMultiplier = val.enemyDamageMultiplier; managedExplosion.BasePlayerDamageOverride = val.playerDamageOverride; _Explosions[i] = managedExplosion; } Audios = ((Component)this).GetComponentsInChildren().Concat(((Component)this).GetComponents()); } protected void Start() { ApplyValues(); foreach (AudioSource audio in Audios) { if (!audio.loop) { audio.Play(); } } } public void ApplyValues() { ManagedExplosion[] explosions = _Explosions; foreach (ManagedExplosion managedExplosion in explosions) { managedExplosion.Explosion.maxSize = managedExplosion.BaseMaxSize * ExplosionScale; managedExplosion.Explosion.speed = managedExplosion.BaseSpeed * ExplosionSpeedScale; managedExplosion.Explosion.damage = Mathf.RoundToInt(BaseDamageOverride.GetValueOrDefault(managedExplosion.BaseDamage) * ExplosionDamageScale); managedExplosion.Explosion.enemyDamageMultiplier = managedExplosion.BaseEnemyDamageMultiplier * ExplosionEnemyDamageMultiplierScale; managedExplosion.Explosion.playerDamageOverride = Mathf.RoundToInt((float)managedExplosion.BasePlayerDamageOverride * ExplosionDamageScale); managedExplosion.Explosion.electric = managedExplosion.Explosion.electric || ForceElectric; managedExplosion.Explosion.harmless = Harmless.GetValueOrDefault(managedExplosion.Explosion.harmless); managedExplosion.Explosion.pushForceMultiplier = managedExplosion.BasePushScale * ExplosionPushScale; } } } public static class GrenadeExtensions { private static FieldInfo _explodedFi = typeof(Grenade).GetField("exploded", BindingFlags.Instance | BindingFlags.NonPublic); public static bool IsExploded(this Grenade self) { return (bool)_explodedFi.GetValue(self); } } public static class GrenadeEvents { public delegate void PreGrenadeStartEventHandler(EventMethodCanceler canceler, Grenade grenade); public delegate void PostGrenadeStartEventHandler(EventMethodCancelInfo cancelInfo, Grenade grenade); public delegate void PreGrenadeBeamEventHandler(EventMethodCanceler canceler, Grenade grenade, Vector3 targetPoint, GameObject newSourceWeapon = null); public delegate void PostGrenadeBeamEventHandler(EventMethodCancelInfo cancelInfo, Grenade grenade, Vector3 targetPoint, GameObject newSourceWeapon = null); public delegate void PreGrenadeCollisionEventHandler(EventMethodCanceler canceler, Grenade grenade, Collider other, Vector3 velocity); public delegate void PostGrenadeCollisionEventHandler(EventMethodCancelInfo cancelInfo, Grenade grenade, Collider other, Vector3 velocity); public delegate void PreGrenadeExplodeEventHandler(EventMethodCanceler canceler, Grenade grenade, bool big, bool harmless, bool super, float sizeMultiplier, bool ultrabooster, GameObject exploderWeapon, bool fup); public delegate void PostGrenadeExplodeEventHandler(EventMethodCancelInfo cancelInfo, Grenade grenade, bool big, bool harmless, bool super, float sizeMultiplier, bool ultrabooster, GameObject exploderWeapon, bool fup); [HarmonyPatch(typeof(Grenade), "Start")] private static class GrenadeStartPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Grenade __instance) { _cancellationTracker.Reset(); GrenadeEvents.PreGrenadeStart?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Grenade __instance) { GrenadeEvents.PostGrenadeStart?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } [HarmonyPatch(typeof(Grenade), "Explode", new Type[] { typeof(bool), typeof(bool), typeof(bool), typeof(float), typeof(bool), typeof(GameObject), typeof(bool) })] private static class GrenadeExplodePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Grenade __instance, bool big = false, bool harmless = false, bool super = false, float sizeMultiplier = 1f, bool ultrabooster = false, GameObject exploderWeapon = null, bool fup = false) { _cancellationTracker.Reset(); GrenadeEvents.PreGrenadeExplode?.Invoke(_cancellationTracker.GetCanceler(), __instance, big, harmless, super, sizeMultiplier, ultrabooster, exploderWeapon, fup); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Grenade __instance, bool big = false, bool harmless = false, bool super = false, float sizeMultiplier = 1f, bool ultrabooster = false, GameObject exploderWeapon = null, bool fup = false) { GrenadeEvents.PostGrenadeExplode?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, big, harmless, super, sizeMultiplier, ultrabooster, exploderWeapon, fup); } } [HarmonyPatch(typeof(Grenade), "GrenadeBeam")] private static class GrenadeBeamPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Grenade __instance, Vector3 targetPoint, GameObject newSourceWeapon = null) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { Log.Warning("Congratulations! You triggered a bug that's in the base game, which I thusly cannot fix. You hit the Grenade object within 0.01 seconds before it exploded, and the ShotgunHammer has a 0.01 second delay before it converts a grenade into a beam. So, just before it converted into a beam, the Grenade exploded, and was thus destroyed."); return true; } _cancellationTracker.Reset(); GrenadeEvents.PreGrenadeBeam?.Invoke(_cancellationTracker.GetCanceler(), __instance, targetPoint, newSourceWeapon); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Grenade __instance, Vector3 targetPoint, GameObject newSourceWeapon = null) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null)) { GrenadeEvents.PostGrenadeBeam?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, targetPoint, newSourceWeapon); } } } [HarmonyPatch(typeof(Grenade), "Collision", new Type[] { typeof(Collider), typeof(Vector3) })] private static class GrenadeCollisionPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Grenade __instance, Collider other, Vector3 velocity) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) _cancellationTracker.Reset(); GrenadeEvents.PreGrenadeCollision?.Invoke(_cancellationTracker.GetCanceler(), __instance, other, velocity); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Grenade __instance, Collider other, Vector3 velocity) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) GrenadeEvents.PostGrenadeCollision?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, other, velocity); } } public static event PreGrenadeStartEventHandler PreGrenadeStart; public static event PostGrenadeStartEventHandler PostGrenadeStart; public static event PreGrenadeBeamEventHandler PreGrenadeBeam; public static event PostGrenadeBeamEventHandler PostGrenadeBeam; public static event PreGrenadeCollisionEventHandler PreGrenadeCollision; public static event PostGrenadeCollisionEventHandler PostGrenadeCollision; public static event PreGrenadeExplodeEventHandler PreGrenadeExplode; public static event PostGrenadeExplodeEventHandler PostGrenadeExplode; } public static class NailEvents { public delegate void PreNailStartEventHandler(EventMethodCanceler canceler, Nail nail); public delegate void PostNailStartEventHandler(EventMethodCancelInfo cancelInfo, Nail nail); public delegate void PreNailHitEnemyEventHandler(EventMethodCanceler canceler, Nail nail, Transform other, EnemyIdentifierIdentifier eidid); public delegate void PostNailHitEnemyEventHandler(EventMethodCancelInfo cancelInfo, Nail nail, Transform other, EnemyIdentifierIdentifier eidid); public delegate void PreNailTouchEnemyEventHandler(EventMethodCanceler canceler, Nail nail, Transform other); public delegate void PostNailTouchEnemyEventHandler(EventMethodCancelInfo cancelInfo, Nail nail, Transform other); [HarmonyPatch(typeof(Nail), "Start")] private static class NailStartPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Nail __instance) { _cancellationTracker.Reset(); NailEvents.PreNailStart?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Nail __instance) { NailEvents.PostNailStart?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } [HarmonyPatch(typeof(Nail), "TouchEnemy")] public static class NailTouchEnemyPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Nail __instance, Transform other) { _cancellationTracker.Reset(); NailEvents.PreNailTouchEnemy?.Invoke(_cancellationTracker.GetCanceler(), __instance, other); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Nail __instance, Transform other) { NailEvents.PostNailTouchEnemy?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, other); } } [HarmonyPatch(typeof(Nail), "HitEnemy")] private static class NailHitEnemyPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Nail __instance, Transform other, EnemyIdentifierIdentifier eidid = null) { _cancellationTracker.Reset(); NailEvents.PreNailHitEnemy?.Invoke(_cancellationTracker.GetCanceler(), __instance, other, eidid); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Nail __instance, Transform other, EnemyIdentifierIdentifier eidid = null) { NailEvents.PostNailHitEnemy?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, other, eidid); } } public static event PreNailStartEventHandler PreNailStart; public static event PostNailStartEventHandler PostNailStart; public static event PreNailHitEnemyEventHandler PreNailHitEnemy; public static event PostNailHitEnemyEventHandler PostNailHitEnemy; public static event PreNailTouchEnemyEventHandler PreNailTouchEnemy; public static event PostNailTouchEnemyEventHandler PostNailTouchEnemy; } public class ProjectileParryGainsModifier : MonoBehaviour { public float ParryHealthGain = 100f; public float ParryStaminaGain = 300f; public float ParryPunchStaminaGain = 0f; private Projectile _projectile; protected void Awake() { _projectile = ((Component)this).GetComponent(); } protected void OnEnable() { PlayerPunchEvents.PreParryProjectile += PreParryProjectile; } protected void OnDisable() { PlayerPunchEvents.PreParryProjectile -= PreParryProjectile; } private void PreParryProjectile(EventMethodCanceler canceler, Punch punch, Projectile proj) { if (Cheats.Enabled && !((Object)(object)proj != (Object)(object)_projectile)) { proj.playerBullet = true; NewMovement instance = MonoSingleton.Instance; instance.GetHealth((int)ParryHealthGain, false, false, true); MonoSingleton.Instance.punchStamina = Mathf.Min(MonoSingleton.Instance.punchStamina + ParryPunchStaminaGain, Mathf.Max(2f, MonoSingleton.Instance.punchStamina)); if (instance.boostCharge + ParryStaminaGain >= 300f) { instance.FullStamina(); } else { instance.boostCharge += ParryStaminaGain; } } } } public static class ProjectileEvents { public delegate void PreProjectileAwakeEventHandler(EventMethodCanceler canceler, Projectile projectile); public delegate void PostProjectileAwakeEventHandler(EventMethodCancelInfo cancelInfo, Projectile projectile); public delegate void PreProjectileCollidedEventHandler(EventMethodCanceler canceler, Projectile projectile, Collider other); public delegate void PostProjectileCollidedEventHandler(EventMethodCancelInfo cancelInfo, Projectile projectile, Collider other); [HarmonyPatch(typeof(Projectile), "Awake")] private static class ProjectileAwakePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Projectile __instance) { _cancellationTracker.Reset(); ProjectileEvents.PreProjectileAwake?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Projectile __instance) { ProjectileEvents.PostProjectileAwake?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); GameObjectExtensions.GetOrAddComponent(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(Projectile), "Collided")] private static class ProjectileCollidedPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Projectile __instance, Collider other) { _cancellationTracker.Reset(); ProjectileEvents.PreProjectileCollided?.Invoke(_cancellationTracker.GetCanceler(), __instance, other); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Projectile __instance, Collider other) { ProjectileEvents.PostProjectileCollided?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, other); } } [HarmonyPatch(typeof(Projectile), "Explode")] private static class ProjectileExplodePatch { public static void Prefix(Projectile __instance) { ProjectileAdditions component = ((Component)__instance).GetComponent(); component.InvokePreExplode(viaCreateFromExplosion: false); } public static void Postfix(Projectile __instance) { ProjectileAdditions component = ((Component)__instance).GetComponent(); component.InvokePostExplode(viaCreateFromExplosion: false); } } [HarmonyPatch(typeof(Projectile), "CreateExplosionEffect")] private static class ProjectileCreateExplosionEffectPatch { public static void Prefix(Projectile __instance) { ProjectileAdditions component = ((Component)__instance).GetComponent(); component.InvokePreExplode(viaCreateFromExplosion: true); } public static void Postfix(Projectile __instance) { ProjectileAdditions component = ((Component)__instance).GetComponent(); component.InvokePostExplode(viaCreateFromExplosion: true); } } public static event PreProjectileAwakeEventHandler PreProjectileAwake; public static event PostProjectileAwakeEventHandler PostProjectileAwake; public static event PreProjectileCollidedEventHandler PreProjectileCollided; public static event PostProjectileCollidedEventHandler PostProjectileCollided; } public class ProjectileAdditions : MonoBehaviour { private Action PreExplode = null; private Action PostExplode = null; internal void InvokePreExplode(bool viaCreateFromExplosion) { PreExplode?.Invoke(viaCreateFromExplosion); } internal void InvokePostExplode(bool viaCreateFromExplosion) { PostExplode?.Invoke(viaCreateFromExplosion); } } public static class RevolverBeamEvents { public delegate void PreRevolverBeamStartEventHandler(EventMethodCanceler canceler, RevolverBeam revolverBeam); public delegate void PostRevolverBeamStartEventHandler(EventMethodCancelInfo cancelInfo, RevolverBeam revolverBeam); public delegate void PreRevolverBeamHitSomethingEventHandler(EventMethodCanceler canceler, RevolverBeam revolverBeam, PhysicsCastResult hit); public delegate void PostRevolverBeamHitSomethingEventHandler(EventMethodCancelInfo cancelInfo, RevolverBeam revolverBeam, PhysicsCastResult hit); public delegate void PreRevolverBeamPiercingShotCheckEventHandler(EventMethodCanceler canceler, RevolverBeam revolverBeam); public delegate void PostRevolverBeamPiercingShotCheckEventHandler(EventMethodCancelInfo cancelInfo, RevolverBeam revolverBeam); [HarmonyPatch(typeof(RevolverBeam), "Start")] private static class RevolverBeamStartPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(RevolverBeam __instance) { _cancellationTracker.Reset(); RevolverBeamEvents.PreRevolverBeamStart?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(RevolverBeam __instance) { RevolverBeamEvents.PostRevolverBeamStart?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } [HarmonyPatch(typeof(RevolverBeam), "HitSomething")] private static class RevolverBeamHitSomethingPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(RevolverBeam __instance, PhysicsCastResult hit) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) _cancellationTracker.Reset(); RevolverBeamEvents.PreRevolverBeamHitSomething?.Invoke(_cancellationTracker.GetCanceler(), __instance, hit); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(RevolverBeam __instance, PhysicsCastResult hit) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) RevolverBeamEvents.PostRevolverBeamHitSomething?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, hit); } } [HarmonyPatch(typeof(RevolverBeam), "PiercingShotCheck")] private static class RevolverBeamPiercingShotCheckPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(RevolverBeam __instance) { _cancellationTracker.Reset(); RevolverBeamEvents.PreRevolverBeamPiercingShotCheck?.Invoke(_cancellationTracker.GetCanceler(), __instance); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(RevolverBeam __instance) { RevolverBeamEvents.PostRevolverBeamPiercingShotCheck?.Invoke(_cancellationTracker.GetCancelInfo(), __instance); } } public static event PreRevolverBeamStartEventHandler PreRevolverBeamStart; public static event PostRevolverBeamStartEventHandler PostRevolverBeamStart; public static event PreRevolverBeamHitSomethingEventHandler PreRevolverBeamHitSomething; public static event PostRevolverBeamHitSomethingEventHandler PostRevolverBeamHitSomething; public static event PreRevolverBeamPiercingShotCheckEventHandler PreRevolverBeamPiercingShotCheck; public static event PostRevolverBeamPiercingShotCheckEventHandler PostRevolverBeamPiercingShotCheck; } public struct EventMethodCanceler { private EventMethodCancellationTracker _tracker; public bool Cancelled => _tracker.Cancelled; public EventMethodCanceler(EventMethodCancellationTracker tracker) { _tracker = tracker; } public void CancelMethod() { _tracker.CancelMethod(); } public bool CancelMethodForReimplementation(Action reimplementationAction) { return _tracker.CancelForReimplementation(reimplementationAction); } public bool CancelMethodForReplicatingReimplementation(Action reimplementationAction) { return _tracker.CancelForReplicatingReimplementation(reimplementationAction); } } public struct EventMethodCancelInfo { private bool _cancelled; private EventMethodCancelReason _cancelReason; public bool Cancelled => _cancelled; public EventMethodCancelReason? Reason { get { if (Cancelled) { return _cancelReason; } return null; } } internal EventMethodCancelInfo(bool cancelled, EventMethodCancelReason? reason) { _cancelled = cancelled; _cancelReason = reason.GetValueOrDefault(EventMethodCancelReason.CancelAction); } } public enum EventMethodCancelReason : byte { CancelAction = 8, SoftCancelAction = 9, Reimplement = 16, ReimplementAndReplicate = 32 } public class EventMethodCancellationTracker { private bool _cancelled = false; private EventMethodCancelReason _cancelReason = EventMethodCancelReason.CancelAction; private Action _reimplementationAction = null; public bool ShouldRunMethod => !_cancelled; public bool Cancelled => _cancelled; public EventMethodCancelReason? Reason { get { if (Cancelled) { return _cancelReason; } return null; } } public bool TryInvokeReimplementation() { if (_reimplementationAction == null) { return false; } _reimplementationAction(); _reimplementationAction = null; return true; } public EventMethodCancelInfo GetCancelInfo() { return new EventMethodCancelInfo(Cancelled, Reason); } public void CancelMethod() { if (Cancelled && (_cancelReason == EventMethodCancelReason.Reimplement || _cancelReason == EventMethodCancelReason.ReimplementAndReplicate)) { _reimplementationAction = null; } _cancelReason = EventMethodCancelReason.CancelAction; _cancelled = true; } public void SoftlyCancelMethod() { if (Cancelled && _cancelReason == EventMethodCancelReason.ReimplementAndReplicate) { _reimplementationAction = null; } _cancelReason = EventMethodCancelReason.SoftCancelAction; _cancelled = true; } public bool CancelForReimplementation(Action reimplementationAction) { if ((Cancelled && _cancelReason == EventMethodCancelReason.CancelAction) || _reimplementationAction != null) { return false; } _cancelReason = EventMethodCancelReason.Reimplement; _cancelled = true; _reimplementationAction = reimplementationAction; return true; } public bool CancelForReplicatingReimplementation(Action reimplementationAction) { if ((Cancelled && (_cancelReason == EventMethodCancelReason.SoftCancelAction || _cancelReason == EventMethodCancelReason.CancelAction)) || _reimplementationAction != null) { return false; } _cancelReason = EventMethodCancelReason.ReimplementAndReplicate; _cancelled = true; _reimplementationAction = reimplementationAction; return true; } public void Reset() { _cancelled = false; _reimplementationAction = null; } public EventMethodCanceler GetCanceler() { return new EventMethodCanceler(this); } } public class FieldPublisher where IT : class { private FieldInfo Fi = null; private IT Instance = null; public VT Value { get { return (VT)Fi.GetValue(Instance); } set { Fi.SetValue(Instance, value); } } public FieldPublisher(IT instance, string fieldName) { Instance = instance; Fi = typeof(IT).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); } } public struct FieldAccess { private FieldInfo Fi; public FieldAccess(string fieldName, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic) { Fi = typeof(ObjectType).GetField(fieldName, bindingFlags); } public FieldType GetValue(ObjectType objectType) { return (FieldType)Fi.GetValue(objectType); } public void SetValue(ObjectType objectType, FieldType value) { Fi.SetValue(objectType, value); } } public static class GameObjectUtils { public static void DebugPrintChildren(this GameObject go, bool forceLog = true, bool includeComponents = true) { Action action = (forceLog ? ((Action)delegate(string str) { Log.Message(str); }) : ((Action)delegate(string str) { Log.TraceExpectedInfo(str); })); action("----- Debug Print for " + ((Object)go).name + " start! -----"); DebugPrintChildren(go, action, includeComponents, 0uL); action("----- Debug Print for " + ((Object)go).name + " end! -----"); } private static void DebugPrintChildren(GameObject go, Action logFunc, bool includeComponents, ulong depth) { string text = ""; for (ulong num = 0uL; num < depth; num++) { text += " "; } logFunc(text + "GO::" + ((Object)go).name + ":"); if (includeComponents) { Component[] components = go.GetComponents(); logFunc(text + "COMPONENTS:"); Component[] array = components; foreach (Component val in array) { logFunc($"{text}COMP::{((object)val).GetType()}"); } } logFunc(text + "CHILDREN:"); for (int j = 0; j < go.transform.childCount; j++) { DebugPrintChildren(((Component)go.transform.GetChild(j)).gameObject, logFunc, includeComponents, depth + 1); } if (go.transform.childCount == 0) { logFunc(text + " ![NO CHILDREN]!"); } } } public class MonoRegistrar { private List _registeredTypes = new List(32); public IReadOnlyList RegisteredTypes => _registeredTypes; public int Register() where T : MonoBehaviour { if (_registeredTypes.Contains(typeof(T))) { throw new ArgumentException("Type '" + typeof(T).FullName + "' was already registered in this MonoRegistrar"); } int count = _registeredTypes.Count; _registeredTypes.Add(typeof(T)); return count; } } public class QuickMsg : MonoBehaviour { public Vector3 Velocity = Vector3.zero; public float Duration = 0f; public GlobalTimeStamp EnableTimestamp; public TextMeshProUGUI TextMesh = null; public RectTransform RectTransform { get; private set; } public bool FlashEnabled { get; internal set; } public float FlashDelay { get; internal set; } public float FlashFadeTime { get; internal set; } public Color FlashColor { get; internal set; } protected void Update() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0028: 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_0038: 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) Velocity = NyxMath.EaseInterpTo(Velocity, Vector3.zero, 3f, Time.deltaTime); RectTransform rectTransform = RectTransform; rectTransform.anchoredPosition3D += Velocity * Time.deltaTime; } protected void OnEnable() { EnableTimestamp.UpdateToNow(); RectTransform = ((Component)this).GetComponent(); TextMesh = ((Component)this).GetComponent(); } protected void OnDisable() { } } public static class QuickMsgPool { private static ObjPool Pool = null; private static List<(PoolObject, QuickMsg)> ActiveQuickMsgs = new List<(PoolObject, QuickMsg)>(32); public static void Initialize() { ScenesEvents.OnSceneWasLoaded += OnSceneLoaded; UpdateEvents.OnUpdate += OnUpdate; Pool = new ObjPool(delegate { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(Assets.LabelPrefab, ((Component)MonoSingleton.Instance).gameObject.transform); val.AddComponent(); TextMeshProUGUI component = val.GetComponent(); RectTransform component2 = val.GetComponent(); ((TMP_Text)component).text = "UKAIW QuickMsg default"; ((Graphic)component).color = Color.white; ((TMP_Text)component).fontSize = 24f; ((TMP_Text)component).horizontalAlignment = (HorizontalAlignmentOptions)2; component2.pivot = new Vector2(0.5f, 0.5f); component2.anchorMin = new Vector2(0.5f, 1f); component2.anchorMax = new Vector2(0.5f, 1f); component2.SetSizeWithCurrentAnchors((Axis)0, 1000f); return val; }, delegate(GameObject go) { Object.Destroy((Object)(object)go); }); Pool.PrepareObject = delegate { }; ObjPool pool = Pool; pool.UnprepareObject = (Action)Delegate.Combine(pool.UnprepareObject, (Action)delegate(GameObject go) { go.SetActive(false); }); } private static void OnUpdate() { for (int i = 0; i < ActiveQuickMsgs.Count; i++) { var (poolObject, quickMsg) = ActiveQuickMsgs[i]; if (quickMsg.EnableTimestamp.TimeSince > (double)quickMsg.Duration) { ActiveQuickMsgs.RemoveAt(i); i--; poolObject.Dispose(); } else { ((TMP_Text)quickMsg.TextMesh).alpha = NyxMath.InverseNormalizeToRange((float)quickMsg.EnableTimestamp.TimeSince, 0f, quickMsg.Duration); } } } private static void OnSceneLoaded(Scene scene, string levelName, string unitySceneName) { Pool?.Clear(); ActiveQuickMsgs?.Clear(); if ((Object)(object)Assets.LabelPrefab != (Object)null) { CanvasController obj = MonoSingleton.Instance.NullInvalid(); if ((Object)(object)((obj != null) ? ((Component)obj).gameObject : null) != (Object)null) { Pool.EnsureSize(32); } } } public static void DisplayQuickMsg(string text, Color color, float duration, Vector3 velocity, float fontSize, bool flashing = false) { //IL_002b: 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_009c: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) PoolObject poolObject = Pool.Take(); GameObject value = poolObject.Value; value.SetActive(true); value.GetComponent().anchoredPosition = new Vector2(0f, 0f); TextMeshProUGUI component = value.GetComponent(); ((TMP_Text)component).text = text; ((Graphic)component).color = color; ((TMP_Text)component).fontSize = fontSize; ((TMP_Text)component).outlineWidth = 0.1f; ((TMP_Text)component).outlineColor = Color32.op_Implicit(new Color((1f - ((Color)(ref color)).grayscale) * 5f, (1f - ((Color)(ref color)).grayscale) * 5f, (1f - ((Color)(ref color)).grayscale) * 5f)); QuickMsg component2 = value.GetComponent(); component2.Duration = duration; component2.Velocity = velocity; component2.FlashEnabled = flashing; component2.FlashDelay = 0.25f; component2.FlashFadeTime = 0.25f; component2.FlashColor = Color.white; ActiveQuickMsgs.Add((poolObject, component2)); } } public static class TextMeshProUGUIEvents { [HarmonyPatch(typeof(TextMeshProUGUI), "OnEnable")] private static class TextMeshProUGUIEnablePatch { public static void Prefix(TextMeshProUGUI __instance) { PreEnable?.Invoke(__instance); } public static void Postfix(TextMeshProUGUI __instance) { PostEnable?.Invoke(__instance); } } [HarmonyPatch(typeof(TextMeshProUGUI), "OnDisable")] private static class TextMeshProUGUIDisablePatch { public static void Prefix(TextMeshProUGUI __instance) { PreDisable?.Invoke(__instance); } public static void Postfix(TextMeshProUGUI __instance) { PostDisable?.Invoke(__instance); } } public static Action PreEnable; public static Action PostEnable; public static Action PreDisable; public static Action PostDisable; } public class Heck : MonoBehaviour { public static Heck Itself = null; public static MonoRegistrar MonoRegistrar = new MonoRegistrar(); private List _monoBehaviours = null; public GameObject PainMeterGo { get; private set; } = null; public T GetMonoByIndex(int idx) where T : MonoBehaviour { if (idx < 0) { throw new IndexOutOfRangeException($"Index {idx} was less than 0"); } if (idx > _monoBehaviours.Count) { return default(T); } MonoBehaviour obj = _monoBehaviours[idx]; return (T)(object)((obj is T) ? obj : null); } protected void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown Itself = this; _monoBehaviours = new List(MonoRegistrar.RegisteredTypes.Count); foreach (Type registeredType in MonoRegistrar.RegisteredTypes) { _monoBehaviours.Add((MonoBehaviour)((Component)this).gameObject.AddComponent(registeredType)); } } protected void Start() { } protected void Update() { } protected void FixedUpdate() { } protected void OnDestroy() { } protected void OnEnable() { } protected void OnDisable() { } internal static void Initialize() { ScenesEvents.OnSceneWasLoaded += delegate { CreateHeck(); }; } private static void CreateHeck() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (!((Object)(object)Itself != (Object)null)) { GameObject val = new GameObject(); val.AddComponent(); } } } public abstract class LevelAdditions { internal abstract void OnSceneLoad(); internal abstract void OnSceneUnload(); } public static class LevelAdditionsManager { private static Dictionary> LevelAdditionsCtorDict = new Dictionary>(); private static LevelAdditions CurrentAdditions = null; public static void Initialize() { ScenesEvents.OnSceneWasLoaded += OnSceneLoad; ScenesEvents.OnSceneWasUnloaded += OnSceneUnload; } private static void OnSceneLoad(Scene scene, string levelName, string unitySceneName) { levelName = SceneHelper.CurrentScene; CurrentAdditions = null; Func value = null; LevelAdditionsCtorDict.TryGetValue(levelName, out value); Log.TraceExpectedInfo("Level Additions OnSceneLoad called with sceneName " + levelName + ", trying to find valid constructor..."); if (value != null) { CurrentAdditions = value(); Log.ExpectedInfo($"Loading New LevelAdditions of type {CurrentAdditions.GetType()}!"); CurrentAdditions.OnSceneLoad(); } else { Log.ExpectedInfo("No constructor for Level Additions found!"); } } private static void OnSceneUnload(Scene scene, string levelName, string unitySceneName) { CurrentAdditions?.OnSceneUnload(); CurrentAdditions = null; } } public static class Music { [HarmonyPatch(typeof(MusicManager), "OnEnable", new Type[] { })] private static class MusicManagerAwakePatch { public static void Prefix(MusicManager __instance) { } public static void Postfix(MusicManager __instance) { _manager = __instance; } } private static MusicManager _manager; private static int _playBattleWithCleanVotes; private static bool HasVotedForBattleMusic; private static bool WasPlayCleanWithBattle; public static MusicManager Manager { get { if ((Object)(object)_manager == (Object)null && (Object)(object)MonoSingleton.Instance != (Object)null) { Log.ExpectedInfo("Had to get MusicManager via MusicManager.Instance (then cached the value)"); _manager = MonoSingleton.Instance; } return _manager; } } public static int PlayCleanWithBattleVotes => _playBattleWithCleanVotes + (Options.ForcePlayCleanMusicWithBattleMusic.Value ? 1 : 0); public static void AddPlayCleanWithBattleVote() { _playBattleWithCleanVotes++; } public static void SubtractPlayCleanWithBattleVote() { _playBattleWithCleanVotes--; if (_playBattleWithCleanVotes < 0) { Log.Error($"_playBattleWithCleanVotes is {_playBattleWithCleanVotes}, which is considered such it should be impossible! :c\nI don't know what caused this. Here's the current stack which may not be relevant. {StackDebug.GetStackString()}"); } } internal static void Initialize() { ScenesEvents.OnSceneWasLoaded += OnSceneLoad; UpdateEvents.OnUpdate += Update; } private static void OnSceneLoad(Scene scene, string levelName, string unitySceneName) { _playBattleWithCleanVotes = 0; HasVotedForBattleMusic = false; } private static void VoteForBattleMusic() { if ((Object)(object)Manager.battleTheme != (Object)null) { Manager.PlayBattleMusic(); HasVotedForBattleMusic = true; } } private static void UnvoteForBattleMusic() { if (HasVotedForBattleMusic) { Manager.PlayCleanMusic(); HasVotedForBattleMusic = false; } } private static void Update() { if ((Object)(object)Cheats.Manager == (Object)null) { return; } if (Cheats.IsCheatEnabled("nyxpiri.always-battle-music")) { VoteForBattleMusic(); } else { UnvoteForBattleMusic(); } bool flag = Cheats.IsCheatEnabled("nyxpiri.clean-music-with-battle") || PlayCleanWithBattleVotes > 0; if ((Object)(object)Manager.battleTheme == (Object)null || (Object)(object)Manager.cleanTheme == (Object)null) { return; } if (flag) { if ((Object)(object)Manager.targetTheme == (Object)(object)Manager.bossTheme) { Manager.cleanTheme.volume = Mathf.Max(Manager.battleTheme.volume, Manager.cleanTheme.volume); } else if ((Object)(object)Manager.targetTheme == (Object)(object)Manager.battleTheme) { Manager.cleanTheme.volume = Mathf.Max(Manager.battleTheme.volume, Manager.cleanTheme.volume); if (Mathf.Abs(Manager.cleanTheme.time - Manager.battleTheme.time) > 0.1f) { Manager.cleanTheme.time = Manager.battleTheme.time; if (!Manager.cleanTheme.isPlaying) { Manager.cleanTheme.Play(); } } } else if ((Object)(object)Manager.targetTheme == (Object)(object)Manager.cleanTheme) { Manager.battleTheme.volume = Mathf.MoveTowards(Manager.battleTheme.volume, 0f, Manager.fadeSpeed * Time.deltaTime); } } else if (Manager.off || Manager.targetTheme.volume == Manager.volume) { if ((Object)(object)Manager.targetTheme == (Object)(object)Manager.bossTheme) { Manager.cleanTheme.volume = Mathf.MoveTowards(Manager.cleanTheme.volume, 0f, Manager.fadeSpeed * Time.deltaTime); } else if ((Object)(object)Manager.targetTheme == (Object)(object)Manager.battleTheme) { Manager.cleanTheme.volume = Mathf.MoveTowards(Manager.cleanTheme.volume, 0f, Manager.fadeSpeed * Time.deltaTime); } else if ((Object)(object)Manager.targetTheme == (Object)(object)Manager.cleanTheme) { Manager.battleTheme.volume = Mathf.MoveTowards(Manager.battleTheme.volume, 0f, Manager.fadeSpeed * Time.deltaTime); } } WasPlayCleanWithBattle = flag; } } [BepInPlugin("nyxpiri.ultrakill.nyxlib", "NyxLib", "0.2.0")] [BepInProcess("ULTRAKILL.exe")] public class NyxLib : BaseUnityPlugin { private string _prevScene = SceneHelper.CurrentScene; protected void Awake() { Harmony.CreateAndPatchAll(Assembly.GetAssembly(typeof(NyxLib)), (string)null); Log.Logger = ((BaseUnityPlugin)this).Logger; Options.Config = ((BaseUnityPlugin)this).Config; Options.Initialize(); if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { ((BaseUnityPlugin)this).Config.Save(); } Log.TraceExpectedInfo("Awake called!"); ((Component)MonoSingleton.Instance).transform.parent = ((Component)this).transform; VanillaEnemyType.Initialize(); ((Component)this).gameObject.AddComponent(); Assets.Initialize(); Cheats.Initialize(); Log.TraceExpectedInfo("Awake finished!"); } protected void OnDestroy() { } protected void Start() { Log.TraceExpectedInfo("Start called!"); Music.Initialize(); LevelAdditionsManager.Initialize(); Cybergrind.Initialize(); QuickMsgPool.Initialize(); Heck.Initialize(); EnemyPrefabManager.Initialize(); LevelQuickLoader.Initialize(); Console instance = MonoSingleton.Instance; instance.onError = (Action)Delegate.Combine(instance.onError, (Action)delegate { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) if (Options.ShowErrorNotification.Value) { QuickMsgPool.DisplayQuickMsg("AN ERROR HAS OCCURRED!", Color.red, 3f, Vector3.down * 100f, 42f); QuickMsgPool.DisplayQuickMsg($"TIME: {DateTime.Now.Hour}:{DateTime.Now.Minute}", Color.red, 3f, Vector3.down * 200f, 32f); } }); SceneManager.sceneLoaded += OnSceneWasLoaded; SceneManager.sceneUnloaded += OnSceneWasUnloaded; Log.TraceExpectedInfo("Start finished!"); } public void OnSceneWasLoaded(Scene scene, LoadSceneMode loadSceneMode) { //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) Log.TraceExpectedInfo("------------- New Scene Loaded '" + SceneHelper.CurrentScene + "' -------------"); TryLog.Action(delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ScenesEvents.NotifySceneWasLoaded(scene, SceneHelper.CurrentScene, ((Scene)(ref scene)).name); }); } public void OnSceneWasUnloaded(Scene scene) { //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) Log.TraceExpectedInfo("------------- Scene Unloaded '" + _prevScene + "' -------------"); TryLog.Action(delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ScenesEvents.NotifySceneWasUnloaded(scene, _prevScene, ((Scene)(ref scene)).name); }); _prevScene = SceneHelper.CurrentScene; } protected void OnApplicationFocus(bool hasFocus) { if (hasFocus) { ((BaseUnityPlugin)this).Config.Reload(); } } protected void Update() { TryLog.Action(delegate { UpdateEvents.NotifyUpdate(); }); } protected void FixedUpdate() { TryLog.Action(delegate { UpdateEvents.NotifyFixedUpdate(); }); } protected void LateUpdate() { TryLog.Action(delegate { UpdateEvents.NotifyLateUpdate(); }); } } public static class NyxMath { public static float NormalizeToRange(float a, float minimum, float maximum) { if (maximum == minimum) { return 1f; } a -= minimum; a /= maximum - minimum; return a; } public static float InverseNormalizeToRange(float a, float minimum, float maximum) { if (maximum == minimum) { return 0f; } a -= maximum; a /= minimum - maximum; return a; } public static float EaseInterpTo(float a, float b, float decay, float delta) { return b + (a - b) * Mathf.Exp((0f - decay) * delta); } public static Vector2 EaseInterpTo(Vector2 a, Vector2 b, float decay, float delta) { //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_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_001c: 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) return b + (a - b) * Mathf.Exp((0f - decay) * delta); } public static Vector3 EaseInterpTo(Vector3 a, Vector3 b, float decay, float delta) { //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_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_001c: 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) return b + (a - b) * Mathf.Exp((0f - decay) * delta); } public static double EaseInterpTo(double a, double b, double decay, double delta) { return b + (a - b) * Math.Exp((0.0 - decay) * delta); } } public class ConfigFileManager : MonoBehaviour { public Action OnReload; private ConfigFile Config = null; public void Initialize(ConfigFile config) { Assert.IsNotNull((object)config, ""); Config = config; } protected void Start() { Assert.IsNotNull((object)Config, "Config should not be null when ConfigFIleManager Start is called, please call Initialize with a valid ConfigFile"); if (!File.Exists(Config.ConfigFilePath)) { Config.Save(); } } protected void OnApplicationFocus(bool hasFocus) { if (hasFocus) { Config.Reload(); OnReload?.Invoke(); } } } public static class Options { public enum LevelQuickLoaderTypes { Default, Simple, Additive } internal static ConfigFile Config; private static ConfigEntry IncludePerformanceLogsEntry; private static ConfigEntry IncludeTraceExpectedLogsEntry; private static ConfigEntry IncludeExpectedLogsEntry; private static ConfigEntry IncludeLikelyLogsEntry; private static ConfigEntry IncludeUnlikelyLogsEntry; private static ConfigEntry IncludeUnexpectedLogsEntry; public static ConfigEntry ShowErrorNotification; public static ConfigEntry LogEnemyRadianceUpdatesOnlyIfExternallyBuffed; public static ConfigEntry LogEnemyRadianceBuffRequests; public static ConfigEntry LogEnemyRadianceUpdates; public static ConfigEntry WarnOfEnemyRadianceUpdates; public static ConfigEntry LogEnemyTypeOnStart; public static ConfigEntry DisableQuickLoad; public static ConfigEntry DontCreateEnemyPrefabComp; public static ConfigEntry DontCreateEnemyRadianceComp; public static ConfigEntry LevelQuickLoaderType; private static ConfigEntry RadianceAllTierEntry; private static ConfigEntry RadianceAllSpeedTierEntry; private static ConfigEntry RadianceAllDamageTierEntry; private static ConfigEntry RadianceAllHealthTierEntry; private const string DebugCat = "Debug"; private const string DevCat = "Development"; private const string ExtrasCat = "Extras"; private const string CheatsCat = "Cheats"; private const string RadianceAllCat = "RadianceAll"; public static ConfigEntry SkipPrefabManagerTicks { get; private set; } public static ConfigEntry EnemyPrefabInstanceStoreCapacityMax { get; private set; } public static bool IncludePerformanceLogs => IncludePerformanceLogsEntry.Value; public static bool IncludeTraceExpectedLogs => IncludeTraceExpectedLogsEntry.Value; public static bool IncludeExpectedLogs => IncludeExpectedLogsEntry.Value; public static bool IncludeLikelyLogs => IncludeLikelyLogsEntry.Value; public static bool IncludeUnlikelyLogs => IncludeUnlikelyLogsEntry.Value; public static bool IncludeUnexpectedLogs => IncludeUnexpectedLogsEntry.Value; public static float RadianceAllTier => RadianceAllTierEntry.Value; public static float RadianceAllSpeedTier => RadianceAllSpeedTierEntry.Value; public static float RadianceAllDamageTier => RadianceAllDamageTierEntry.Value; public static float RadianceAllHealthTier => RadianceAllHealthTierEntry.Value; public static ConfigEntry RegisterHideCheatsStatusCheat { get; private set; } public static ConfigEntry RegisterSandAllEnemiesCheat { get; private set; } public static ConfigEntry RegisterForceNextWaveCheat { get; private set; } public static ConfigEntry RegisterOverrideCybergrindStartingWaveCheat { get; private set; } public static ConfigEntry CybergrindStartingWaveOverride { get; private set; } public static ConfigEntry ForcePlayCleanMusicWithBattleMusic { get; private set; } public static void Initialize() { ShowErrorNotification = Config.Bind("Debug", "ShowErrorNotification", false, "Shows text saying An Error has Occured! At the top of your screen as a 'QuickMsg', with a timestamp (using your locally set timezone!)"); IncludePerformanceLogsEntry = Config.Bind("Debug", "IncludePerformanceLogs", false, (ConfigDescription)null); IncludeTraceExpectedLogsEntry = Config.Bind("Debug", "IncludeTraceExpectedLogs", false, (ConfigDescription)null); IncludeExpectedLogsEntry = Config.Bind("Debug", "IncludeExpectedLogs", false, (ConfigDescription)null); IncludeLikelyLogsEntry = Config.Bind("Debug", "IncludeLikelyLogs", false, (ConfigDescription)null); IncludeUnlikelyLogsEntry = Config.Bind("Debug", "IncludeUnlikelyLogs", true, (ConfigDescription)null); IncludeUnexpectedLogsEntry = Config.Bind("Debug", "IncludeUnexpectedLogs", true, (ConfigDescription)null); LogEnemyTypeOnStart = Config.Bind("Debug.Development", "LogEnemyTypeOnEnemyStart", false, (ConfigDescription)null); DontCreateEnemyPrefabComp = Config.Bind("Debug.Development", "DontCreateEnemyPrefabComp", false, (ConfigDescription)null); DontCreateEnemyRadianceComp = Config.Bind("Debug.Development", "DontCreateEnemyRadianceComp", false, (ConfigDescription)null); SkipPrefabManagerTicks = Config.Bind("Debug.Development", "SkipPrefabManagerTicks", false, (ConfigDescription)null); LogEnemyRadianceBuffRequests = Config.Bind("Debug", "LogEnemyRadianceBuffRequests", false, (ConfigDescription)null); LogEnemyRadianceUpdates = Config.Bind("Debug", "LogEnemyRadianceUpdates", false, (ConfigDescription)null); LogEnemyRadianceUpdatesOnlyIfExternallyBuffed = Config.Bind("Debug", "LogEnemyRadianceUpdatesOnlyIfExternallyBuffed", false, (ConfigDescription)null); WarnOfEnemyRadianceUpdates = Config.Bind("Debug", "WarnOfEnemyRadianceUpdates", false, "Logs method calls which modify enemy radiance when they happen relating to Nyxpiri.ULTRAKILL.EnemyRadiance, as warnings. Mostly intended for ensuring enemy radiance isn't tampering when it shouldn't be."); RadianceAllTierEntry = Config.Bind("Cheats.RadianceAll", "RadianceAllTier", 1f, (ConfigDescription)null); RadianceAllSpeedTierEntry = Config.Bind("Cheats.RadianceAll", "RadianceAllSpeedTier", 1.25f, (ConfigDescription)null); RadianceAllDamageTierEntry = Config.Bind("Cheats.RadianceAll", "RadianceAllDamageTier", 1.1f, (ConfigDescription)null); RadianceAllHealthTierEntry = Config.Bind("Cheats.RadianceAll", "RadianceAllHealthTier", 1.25f, (ConfigDescription)null); EnemyPrefabInstanceStoreCapacityMax = Config.Bind("Performance", "EnemyPrefabInstanceStoreCapacityMax", 5, (ConfigDescription)null); RegisterHideCheatsStatusCheat = Config.Bind("Cheats", "RegisterHideCheatsStatusCheat", false, (ConfigDescription)null); RegisterSandAllEnemiesCheat = Config.Bind("Cheats", "RegisterSandAllEnemiesCheat", true, (ConfigDescription)null); RegisterForceNextWaveCheat = Config.Bind("Cheats", "RegisterForceNextWaveCheat", true, (ConfigDescription)null); RegisterOverrideCybergrindStartingWaveCheat = Config.Bind("Cheats", "RegisterOverrideCybergrindStartingWaveCheat", false, (ConfigDescription)null); CybergrindStartingWaveOverride = Config.Bind("Cheats", "CybergrindStartingWaveOverride", 0, "Overrides cybergrind starting wave to this number, only works if cheats are enabled and the OverrideCybergrindStartingWave cheat is active."); ForcePlayCleanMusicWithBattleMusic = Config.Bind("Extras", "ForcePlayCleanMusicWithBattleMusic", false, (ConfigDescription)null); DisableQuickLoad = Config.Bind("Misc.LevelQuickLoader", "DisableGameInitLevelQuickLoad", false, (ConfigDescription)null); LevelQuickLoaderType = Config.Bind("Misc.LevelQuickLoader", "LevelQuickLoaderType", LevelQuickLoaderTypes.Default, "Changes the class used as the 'LevelQuickLoader' the default value of 'default' picks whichever one is recommended at the time and is *highly recommended*, it currenty uses the simple quick loader. The Additive quick loader is outright effectively non-functional and not at all recommended to be used as it might not even let your game start."); } } public class PlayerComponents : MonoBehaviour { public delegate void PreStartEventHandler(EventMethodCanceler canceler, PlayerComponents player); public delegate void PostStartEventHandler(EventMethodCancelInfo canceler, PlayerComponents player); public static MonoRegistrar MonoRegistrar; private List _monoBehaviours = null; public NewMovement NewMovement { get; private set; } = null; public static PlayerComponents Instance { get; private set; } public static event PreStartEventHandler PreStart; public static event PostStartEventHandler PostStart; public T GetMonoByIndex(int idx) where T : MonoBehaviour { if (idx < 0) { throw new IndexOutOfRangeException($"Index {idx} was less than 0"); } if (idx > _monoBehaviours.Count) { return default(T); } MonoBehaviour obj = _monoBehaviours[idx]; return (T)(object)((obj is T) ? obj : null); } protected void Awake() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown NewMovement = ((Component)this).gameObject.GetComponent(); _monoBehaviours = new List(MonoRegistrar.RegisteredTypes.Count); foreach (Type registeredType in MonoRegistrar.RegisteredTypes) { _monoBehaviours.Add((MonoBehaviour)GameObjectExtensions.GetOrAddComponent(((Component)this).gameObject, registeredType)); } Instance = this; } protected void Start() { EventMethodCancellationTracker eventMethodCancellationTracker = new EventMethodCancellationTracker(); PlayerComponents.PreStart?.Invoke(eventMethodCancellationTracker.GetCanceler(), this); if (eventMethodCancellationTracker.ShouldRunMethod) { } PlayerComponents.PostStart?.Invoke(eventMethodCancellationTracker.GetCancelInfo(), this); } static PlayerComponents() { PlayerComponents.PreStart = null; PlayerComponents.PostStart = null; MonoRegistrar = new MonoRegistrar(); Instance = null; } } public static class PlayerEvents { public delegate void PreUpdateEventHandler(EventMethodCanceler canceler, PlayerComponents player); public delegate void PostUpdateEventHandler(EventMethodCancelInfo cancelInfo, PlayerComponents player); public delegate void PreStartEventHandler(EventMethodCanceler canceler, PlayerComponents player); public delegate void PostStartEventHandler(EventMethodCancelInfo cancelInfo, PlayerComponents player); public delegate void PreFullStaminaEventHandler(EventMethodCanceler canceler, PlayerComponents player); public delegate void PostFullStaminaEventHandler(EventMethodCancelInfo cancelInfo, PlayerComponents player); public delegate void PredictedDeathEventHandler(EventMethodCanceler canceler, PlayerComponents player, int damage); public delegate void PreHurtEventHandler(EventMethodCanceler canceler, PlayerComponents player, int unprocessedDamage, int processedDamage, bool invincible, float scoreLossMultiplier, bool explosion, bool instablack, float hardDamageMultiplier, bool ignoreInvincibility); public delegate void PostHurtEventHandler(EventMethodCancelInfo cancelInfo, PlayerComponents player, int unprocessedDamage, int processedDamage, bool invincible, float scoreLossMultiplier, bool explosion, bool instablack, float hardDamageMultiplier, bool ignoreInvincibility); [HarmonyPatch(typeof(NewMovement), "Awake", new Type[] { })] private static class NewMovementAwakePatch { public static void Prefix(NewMovement __instance) { } public static void Postfix(NewMovement __instance) { ((Component)__instance).gameObject.AddComponent(); } } [HarmonyPatch(typeof(NewMovement), "Start", new Type[] { })] private static class NewMovementStartPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(NewMovement __instance) { _cancellationTracker.Reset(); PlayerEvents.PreStart?.Invoke(_cancellationTracker.GetCanceler(), PlayerComponents.Instance); _cancellationTracker.TryInvokeReimplementation(); return _cancellationTracker.ShouldRunMethod; } public static void Postfix(NewMovement __instance) { PlayerEvents.PostStart?.Invoke(_cancellationTracker.GetCancelInfo(), PlayerComponents.Instance); } } [HarmonyPatch(typeof(NewMovement), "GetHurt", new Type[] { typeof(int), typeof(bool), typeof(float), typeof(bool), typeof(bool), typeof(float), typeof(bool) })] private static class PlayerHurtPatch { private static bool WasPreHurtCalled = false; private static int ProcessedDamage = 0; private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(NewMovement __instance, int damage, bool invincible, float scoreLossMultiplier = 1f, bool explosion = false, bool instablack = false, float hardDamageMultiplier = 0.35f, bool ignoreInvincibility = false) { _cancellationTracker.Reset(); if (__instance.dead || __instance.levelOver || !(!invincible || ((Component)__instance).gameObject.layer != 15 || ignoreInvincibility) || damage <= 0) { return true; } ProcessedDamage = damage; AssistController instance = MonoSingleton.Instance; if (instance.majorEnabled) { ProcessedDamage = Mathf.RoundToInt((float)ProcessedDamage * instance.damageTaken); } if (Invincibility.Enabled) { ProcessedDamage = 0; } PlayerComponents component = ((Component)__instance).GetComponent(); PlayerEvents.PreHurt?.Invoke(_cancellationTracker.GetCanceler(), component, damage, ProcessedDamage, invincible, scoreLossMultiplier, explosion, instablack, hardDamageMultiplier, ignoreInvincibility); WasPreHurtCalled = true; bool flag = !Invincibility.Enabled; if (__instance.hp - ProcessedDamage <= 0 && flag) { PlayerEvents.PredictedDeath?.Invoke(_cancellationTracker.GetCanceler(), component, ProcessedDamage); } _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(NewMovement __instance, int damage, bool invincible, float scoreLossMultiplier = 1f, bool explosion = false, bool instablack = false, float hardDamageMultiplier = 0.35f, bool ignoreInvincibility = false) { if (WasPreHurtCalled) { PlayerEvents.PostHurt?.Invoke(_cancellationTracker.GetCancelInfo(), ((Component)__instance).GetComponent(), damage, ProcessedDamage, invincible, scoreLossMultiplier, explosion, instablack, hardDamageMultiplier, ignoreInvincibility); } } } [HarmonyPatch(typeof(NewMovement), "FullStamina")] private static class PlayerFullStaminaPatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(NewMovement __instance) { _cancellationTracker.Reset(); PlayerEvents.PreFullRefillStamina?.Invoke(_cancellationTracker.GetCanceler(), PlayerComponents.Instance); _cancellationTracker.TryInvokeReimplementation(); return _cancellationTracker.ShouldRunMethod; } public static void Postfix(NewMovement __instance) { PlayerEvents.PostFullRefillStamina?.Invoke(_cancellationTracker.GetCancelInfo(), PlayerComponents.Instance); } } [HarmonyPatch(typeof(NewMovement), "Update")] private static class PlayerUpdatePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(NewMovement __instance) { _cancellationTracker.Reset(); PlayerEvents.PreUpdate?.Invoke(_cancellationTracker.GetCanceler(), PlayerComponents.Instance); _cancellationTracker.TryInvokeReimplementation(); return _cancellationTracker.ShouldRunMethod; } public static void Postfix(NewMovement __instance) { PlayerEvents.PostUpdate?.Invoke(_cancellationTracker.GetCancelInfo(), PlayerComponents.Instance); } } public static event PreUpdateEventHandler PreUpdate; public static event PostUpdateEventHandler PostUpdate; public static event PreStartEventHandler PreStart; public static event PostStartEventHandler PostStart; public static event PreFullStaminaEventHandler PreFullRefillStamina; public static event PostFullStaminaEventHandler PostFullRefillStamina; public static event PredictedDeathEventHandler PredictedDeath; public static event PreHurtEventHandler PreHurt; public static event PostHurtEventHandler PostHurt; } [HarmonyPatch(typeof(ShotgunHammer), "HitNade")] internal static class PistonDeviceHitNadePatch { public static void Prefix(ShotgunHammer __instance) { } public static void Postfix(ShotgunHammer __instance) { } } public static class PlayerPunchEvents { public delegate void PreParryProjectileEventHandler(EventMethodCanceler canceler, Punch punch, Projectile projectile); public delegate void PostParryProjectileEventHandler(EventMethodCancelInfo cancelInfo, Punch punch, Projectile projectile); [HarmonyPatch(typeof(Punch), "ParryProjectile")] private static class PunchParryProjectilePatch { private static EventMethodCancellationTracker _cancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(Punch __instance, Projectile proj) { _cancellationTracker.Reset(); PlayerPunchEvents.PreParryProjectile?.Invoke(_cancellationTracker.GetCanceler(), __instance, proj); _cancellationTracker.TryInvokeReimplementation(); return !_cancellationTracker.Cancelled; } public static void Postfix(Punch __instance, Projectile proj) { PlayerPunchEvents.PostParryProjectile?.Invoke(_cancellationTracker.GetCancelInfo(), __instance, proj); } } public static event PreParryProjectileEventHandler PreParryProjectile; public static event PostParryProjectileEventHandler PostParryProjectile; } public class PropertyPublisher where IT : class { private PropertyInfo Fi = null; private IT Instance = null; public VT Value { get { return (VT)Fi.GetValue(Instance); } set { Fi.SetValue(Instance, value); } } public PropertyPublisher(IT instance, string fieldName) { Instance = instance; Fi = typeof(IT).GetProperty(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); } } public class AdditiveLevelQuickLoader : ILevelQuickLoader { public class LevelLoader { public bool AutoActivate = false; public bool WaitingForActivation = false; public bool Activating = false; public bool Success = false; public bool Finished = false; private string _levelName; private AsyncOperationHandle _handle; private SceneInstance _currentSceneInst; private AsyncOperation _activationHandle; public event Action OnFinished; public event Action OnWaitForActivation; public event Action OnSceneActivated; public void QuickLoadLevel(string levelName) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Log.Message("LevelQuickLoader loading level " + levelName); _levelName = levelName; _handle = Addressables.LoadSceneAsync((object)levelName, (LoadSceneMode)1, false, 10000); _handle.Completed += OnSceneLoaded; } public void AllowWaitForCompletion() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) try { if (!_handle.IsDone) { _handle.WaitForCompletion(); } } catch (Exception arg) { Log.Warning($"Exception whilst waiting for LevelQuickLoad completion {arg}"); throw; } } private void OnSceneLoaded(AsyncOperationHandle handle) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_0039: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if ((int)handle.Status == 2) { Log.Error($"Error trying to quick load level {_levelName}, {handle.OperationException}"); Finish(success: false); return; } SceneInstance result = handle.Result; Scene scene = ((SceneInstance)(ref result)).Scene; Log.Message("LevelQuickLoader level loaded " + _levelName); _currentSceneInst = handle.Result; if (AutoActivate) { Activate(); return; } WaitingForActivation = true; this.OnWaitForActivation?.Invoke(this); } public void Activate() { WaitingForActivation = false; Activating = true; _activationHandle = ((SceneInstance)(ref _currentSceneInst)).ActivateAsync(); _activationHandle.completed += SceneActivated; } private void Finish(bool success) { Success = success; this.OnFinished?.Invoke(this); } private void SceneActivated(AsyncOperation operation) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_005a: Unknown result type (might be due to invalid IL or missing references) if (!operation.isDone) { Finish(success: false); return; } Scene scene = ((SceneInstance)(ref _currentSceneInst)).Scene; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); this.OnSceneActivated?.Invoke(this, scene); GameObject[] array = rootGameObjects; foreach (GameObject val in array) { if (!(val.scene != scene)) { val.SetActive(false); } } Activating = false; Log.Message("LevelQuickLoader level activated " + _levelName); Unload(); Finish(success: true); } private void Unload() { //IL_0002: 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_000d: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle val = Addressables.UnloadSceneAsync(_currentSceneInst, true); val.Completed += OnSceneUnloaded; } private void OnSceneUnloaded(AsyncOperationHandle handle) { Log.Message("LevelQuickLoader level unloaded " + _levelName); } internal void Retry() { QuickLoadLevel(_levelName); } } private List _levelLoaders = new List(); private Queue _activationQueue = new Queue(); private Queue _queue = new Queue(); private LevelLoader _activatingLoader = null; public bool QueueActivation = false; public LevelLoader ActivatingLoader { get { if (_activatingLoader == null) { return null; } if (!_activatingLoader.Activating) { return null; } return _activatingLoader; } set { _activatingLoader = value; } } event ILevelQuickLoader.OnQuickLoadEventHandler ILevelQuickLoader.OnQuickLoad { add { OnQuickLoad += value; } remove { OnQuickLoad -= value; } } public event ILevelQuickLoader.OnQuickLoadEventHandler OnQuickLoad; public void QuickLoadLevel(string levelName) { if (Options.DisableQuickLoad.Value) { Log.Warning("AddQuickLoadLevel called for " + levelName + " when DisableQuickLoad == true"); } else { _queue.Enqueue(levelName); } } private LevelLoader SetupNewLoader(string levelName) { Assert.IsFalse(Options.DisableQuickLoad.Value); LevelLoader levelLoader = new LevelLoader(); _levelLoaders.Add(levelLoader); levelLoader.OnFinished += delegate(LevelLoader finishedLoader) { if (finishedLoader.Success) { _levelLoaders.Remove(finishedLoader); } }; levelLoader.OnWaitForActivation += delegate(LevelLoader waitingLoader) { if (QueueActivation) { if (ActivatingLoader != null) { _activationQueue.Enqueue(waitingLoader); } else { ActivateLoader(waitingLoader); } } else { waitingLoader.Activate(); } }; levelLoader.OnSceneActivated += delegate(LevelLoader loader, Scene scene) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) this.OnQuickLoad?.Invoke(scene); }; levelLoader.AutoActivate = !QueueActivation; levelLoader.QuickLoadLevel(levelName); return levelLoader; } private void ActivateLoader(LevelLoader loader) { ActivatingLoader = loader; loader.Activate(); } public AdditiveLevelQuickLoader() { Log.Warning("Using experimental AdditiveLevelQuickLoader"); Log.Error("AdditiveLevelQuickLoader is specifically known to *not* be functional at the moment, and is not recommended at all!"); } public void Flush() { UpdateEvents.OnLateUpdate += LateUpdate; if (Options.DisableQuickLoad.Value) { return; } List list = new List(); foreach (string item2 in _queue) { try { LevelLoader item = SetupNewLoader(item2); list.Add(item); } catch (Exception arg) { Log.Warning($"LevelQuickLoader error = {arg}"); } } _queue.Clear(); foreach (LevelLoader item3 in list) { item3.AllowWaitForCompletion(); } } private void LateUpdate() { Flush(); foreach (LevelLoader levelLoader in _levelLoaders) { if (!levelLoader.Success && levelLoader.Finished) { levelLoader.Retry(); } } if (ActivatingLoader == null && _activationQueue.Count > 0) { LevelLoader loader = _activationQueue.Dequeue(); ActivateLoader(loader); } } void ILevelQuickLoader.PreInitQueueAdded() { Flush(); } } public static class LevelQuickLoader { private static ILevelQuickLoader _instance = null; private static Queue _preInitQueue = new Queue(); public static event ILevelQuickLoader.OnQuickLoadEventHandler OnQuickLoad; public static void AddQuickLoadLevel(string levelName) { if (_instance == null) { _preInitQueue.Enqueue(levelName); } else { _instance.QuickLoadLevel(levelName); } } internal static void Initialize() { if (Options.DisableQuickLoad.Value) { Log.Warning("LevelQuickLoader disabled due to DisableGameInitLevelQuickLoad in config file being true..."); return; } Log.DebugInfo("LevelQuickLoader constructing ILevelQuickLoader based on options..."); switch (Options.LevelQuickLoaderType.Value) { case Options.LevelQuickLoaderTypes.Default: _instance = new SimpleLevelQuickLoader(); break; case Options.LevelQuickLoaderTypes.Simple: _instance = new SimpleLevelQuickLoader(); break; case Options.LevelQuickLoaderTypes.Additive: _instance = new AdditiveLevelQuickLoader(); break; } foreach (string item in _preInitQueue) { AddQuickLoadLevel(item); } _preInitQueue = null; _instance.PreInitQueueAdded(); _instance.OnQuickLoad += LevelQuickLoader.OnQuickLoad; } } public interface ILevelQuickLoader { public delegate void OnQuickLoadEventHandler(Scene scene); event OnQuickLoadEventHandler OnQuickLoad; void QuickLoadLevel(string levelName); internal void PreInitQueueAdded(); } public class SimpleLevelQuickLoader : ILevelQuickLoader { private enum LevelQuickLoadState { Needed, AwaitingLoad, WaitingToReturn, Returning, Done } private Dictionary _quickLoadStates = new Dictionary(); private bool _quickLoading = false; private bool _currentLevelIsFromQuickLoad = false; private string _quickLoadLevel = null; private string _preQuickLoadLevel = null; public event ILevelQuickLoader.OnQuickLoadEventHandler OnQuickLoad; void ILevelQuickLoader.QuickLoadLevel(string levelName) { _quickLoadStates.TryAdd(levelName, LevelQuickLoadState.Needed); } internal SimpleLevelQuickLoader() { if (Options.DisableQuickLoad.Value) { _quickLoadStates.Clear(); Log.Message("Clearing _quickLoadStates due to DisableQuickLoad being true..."); } UpdateEvents.OnUpdate += Update; } private bool TryFindQuickLoadLevel() { if (SceneHelper.PendingScene == null && !_quickLoading) { _quickLoadLevel = null; foreach (KeyValuePair quickLoadState in _quickLoadStates) { if (quickLoadState.Value == LevelQuickLoadState.Needed) { _quickLoadLevel = quickLoadState.Key; break; } } if (_quickLoadLevel != null) { if (!_currentLevelIsFromQuickLoad) { _preQuickLoadLevel = SceneHelper.CurrentScene; } Log.TraceExpectedInfo("Quickloading " + _quickLoadLevel); SceneHelper.LoadScene(_quickLoadLevel, false); _currentLevelIsFromQuickLoad = true; _quickLoadStates[_quickLoadLevel] = LevelQuickLoadState.AwaitingLoad; _quickLoading = true; return true; } } return false; } private void Update() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) TryFindQuickLoadLevel(); if (!(SceneHelper.CurrentScene == _quickLoadLevel) || SceneHelper.PendingScene != null) { return; } if (_quickLoadStates[_quickLoadLevel] == LevelQuickLoadState.AwaitingLoad) { _quickLoadStates[_quickLoadLevel] = LevelQuickLoadState.WaitingToReturn; } else if (_quickLoadStates[_quickLoadLevel] == LevelQuickLoadState.WaitingToReturn) { this.OnQuickLoad?.Invoke(SceneManager.GetActiveScene()); Log.TraceExpectedInfo(_quickLoadLevel + " quick load done!"); _quickLoadStates[_quickLoadLevel] = LevelQuickLoadState.Done; _quickLoadLevel = null; _quickLoading = false; if (!TryFindQuickLoadLevel()) { SceneHelper.LoadScene(_preQuickLoadLevel, false); _preQuickLoadLevel = null; _currentLevelIsFromQuickLoad = false; } } } void ILevelQuickLoader.PreInitQueueAdded() { } } public static class ScenesEvents { public delegate void OnSceneWasLoadedEventHandler(Scene scene, string levelName, string unitySceneName); public delegate void OnSceneWasUnloadedEventHandler(Scene scene, string levelName, string unitySceneName); public static event OnSceneWasLoadedEventHandler OnSceneWasLoaded; public static event OnSceneWasUnloadedEventHandler OnSceneWasUnloaded; internal static void NotifySceneWasLoaded(Scene scene, string levelName, string unitySceneName) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) ScenesEvents.OnSceneWasLoaded?.Invoke(scene, levelName, unitySceneName); } internal static void NotifySceneWasUnloaded(Scene scene, string levelName, string unitySceneName) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) ScenesEvents.OnSceneWasLoaded?.Invoke(scene, levelName, unitySceneName); } } public enum StyleRanks { Null = -1, Destructive, Chaotic, Brutal, Anarchic, Supreme, SSadistic, SSSensoredStorm, ULTRAKILL } public static class Style { public delegate void PreAddPointsEventHandler(EventMethodCanceler canceler, StyleHUD shud, int points, string pointID, GameObject sourceWeapon = null, EnemyIdentifier eid = null, int count = -1, string prefix = "", string postfix = ""); public delegate void PostAddPointsEventHandler(EventMethodCancelInfo cancelled, StyleHUD shud, int points, string pointID, GameObject sourceWeapon = null, EnemyIdentifier eid = null, int count = -1, string prefix = "", string postfix = ""); public delegate void PreRemovePointsEventHandler(EventMethodCanceler canceler, StyleHUD shud, int points); public delegate void PostRemovePointsEventHandler(EventMethodCancelInfo cancelled, StyleHUD shud, int points); public delegate void PreShudUpdateEventHandler(EventMethodCanceler canceler, StyleHUD shud); public delegate void PostShudUpdateEventHandler(EventMethodCancelInfo cancelled, StyleHUD shud); [HarmonyPatch(typeof(StyleHUD), "AddPoints")] private static class AddPointsPatch { private static EventMethodCancellationTracker CancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(StyleHUD __instance, int points, string pointID, GameObject sourceWeapon = null, EnemyIdentifier eid = null, int count = -1, string prefix = "", string postfix = "") { CancellationTracker.Reset(); Style.PreAddPoints?.Invoke(CancellationTracker.GetCanceler(), __instance, points, pointID, sourceWeapon, eid, count, prefix, postfix); CancellationTracker.TryInvokeReimplementation(); return !CancellationTracker.Cancelled; } public static void Postfix(StyleHUD __instance, int points, string pointID, GameObject sourceWeapon = null, EnemyIdentifier eid = null, int count = -1, string prefix = "", string postfix = "") { Style.PostAddPoints?.Invoke(CancellationTracker.GetCancelInfo(), __instance, points, pointID, sourceWeapon, eid, count, prefix, postfix); } } [HarmonyPatch(typeof(StyleHUD), "RemovePoints")] private static class RemovePointsPatch { private static EventMethodCancellationTracker CancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(StyleHUD __instance, int points) { CancellationTracker.Reset(); Style.PreRemovePoints?.Invoke(CancellationTracker.GetCanceler(), __instance, points); CancellationTracker.TryInvokeReimplementation(); return !CancellationTracker.Cancelled; } public static void Postfix(StyleHUD __instance, int points) { Style.PostRemovePoints?.Invoke(CancellationTracker.GetCancelInfo(), __instance, points); } } [HarmonyPatch(typeof(StyleHUD), "AscendRank")] private static class AscendRankPatch { public static void Prefix(StyleHUD __instance) { } public static void Postfix(StyleHUD __instance) { } } [HarmonyPatch(typeof(StyleHUD), "DescendRank")] private static class DescendRankPatch { public static void Prefix(StyleHUD __instance) { } public static void Postfix(StyleHUD __instance) { } } [HarmonyPatch(typeof(StyleHUD), "Update")] private static class StyleUpdatePatch { private static EventMethodCancellationTracker CancellationTracker = new EventMethodCancellationTracker(); public static bool Prefix(StyleHUD __instance) { CancellationTracker.Reset(); Style.PreShudUpdate?.Invoke(CancellationTracker.GetCanceler(), __instance); CancellationTracker.TryInvokeReimplementation(); return !CancellationTracker.Cancelled; } public static void Postfix(StyleHUD __instance) { Style.PostShudUpdate?.Invoke(CancellationTracker.GetCancelInfo(), __instance); } } public static int NumStyleRanks = 8; public static event PreAddPointsEventHandler PreAddPoints; public static event PostAddPointsEventHandler PostAddPoints; public static event PreRemovePointsEventHandler PreRemovePoints; public static event PostRemovePointsEventHandler PostRemovePoints; public static event PreShudUpdateEventHandler PreShudUpdate; public static event PostShudUpdateEventHandler PostShudUpdate; public static StyleRanks GetStyleRank(this StyleHUD self) { return (StyleRanks)self.rankIndex; } } public struct SceneTimeStamp { public double? TimeStamp { get; set; } public readonly double TimeSince => Time.timeSinceLevelLoadAsDouble - TimeStamp.GetValueOrDefault(0.0); public void UpdateToNow() { TimeStamp = Time.timeSinceLevelLoadAsDouble; } } [Serializable] public struct FixedTimeStamp { [SerializeField] public double TimeStamp; public readonly double TimeSince => (double)Time.fixedTime - TimeStamp; public void UpdateToNow() { TimeStamp = Time.fixedTime; } } public struct GlobalTimeStamp { public double? TimeStamp { get; set; } public readonly double TimeSince => Time.timeAsDouble - TimeStamp.GetValueOrDefault(0.0); public void UpdateToNow() { TimeStamp = Time.timeAsDouble; } } public static class TimeScale { [HarmonyPatch(typeof(TimeController), "Awake", new Type[] { })] private static class TimeControllerAwakePatch { public static void Prefix(TimeController __instance) { } public static void Postfix(TimeController __instance) { _controller = __instance; } } private static TimeController _controller; public static bool ModDisableHitstop; public static TimeController Controller { get { if ((Object)(object)_controller == (Object)null && (Object)(object)MonoSingleton.Instance != (Object)null) { Log.ExpectedInfo("Had to get TimeController via TimeController.Instance (then cached the value)"); _controller = MonoSingleton.Instance; } return _controller; } } } [HarmonyPatch(typeof(TimeController), "TrueStop")] internal static class TrueStopPatch { public static void Prefix(TimeController __instance, float length) { if (Cheats.IsCheatEnabled("nyxpiri.disable-stops") || TimeScale.ModDisableHitstop) { FieldInfo field = ((object)__instance).GetType().GetField("currentStop", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, length + 100f); } } public static void Postfix(TimeController __instance, float length) { if (Cheats.IsCheatEnabled("nyxpiri.disable-stops") || TimeScale.ModDisableHitstop) { FieldInfo field = ((object)__instance).GetType().GetField("currentStop", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, 0f); } } } [HarmonyPatch(typeof(TimeController), "HitStop")] internal static class HitStopPatch { public static void Prefix(TimeController __instance, float length) { if (Cheats.IsCheatEnabled("nyxpiri.disable-stops") || TimeScale.ModDisableHitstop) { FieldInfo field = ((object)__instance).GetType().GetField("currentStop", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, length + 100f); } } public static void Postfix(TimeController __instance, float length) { if (Cheats.IsCheatEnabled("nyxpiri.disable-stops") || TimeScale.ModDisableHitstop) { FieldInfo field = ((object)__instance).GetType().GetField("currentStop", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, 0f); } } } [HarmonyPatch(typeof(TimeController), "SlowDown")] internal static class SlowDownPatch { public static void Prefix(TimeController __instance, float amount) { } public static void Postfix(TimeController __instance, float amount) { if (Cheats.IsCheatEnabled("nyxpiri.disable-slowdown")) { FieldInfo field = ((object)__instance).GetType().GetField("slowDown", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, 1f); } } } [HarmonyPatch(typeof(TimeController), "ParryFlash")] internal static class ParryFlashPatch { public static bool ModShortenHitStop; public static void Prefix(TimeController __instance) { } public static void Postfix(TimeController __instance) { if (Cheats.IsCheatEnabled("nyxpiri.short-hit-stop") || ModShortenHitStop) { UpdatePatch.RemainingStopTime = 0.125f; } } } [HarmonyPatch(typeof(TimeController), "Update")] internal static class UpdatePatch { public static float RemainingStopTime = -1f; public static void Prefix(TimeController __instance) { if (RemainingStopTime >= 0f) { RemainingStopTime -= Time.unscaledDeltaTime; if (RemainingStopTime <= 0f) { RemainingStopTime = -1f; __instance.RestoreTime(); } } } public static void Postfix(TimeController __instance) { } } [HarmonyPatch(typeof(AudioSource), "Play", new Type[] { })] internal static class AudioPlayPatch { public static bool Disabled; public static void Prefix(AudioSource __instance) { } public static void Postfix(AudioSource __instance) { if (Cheats.IsCheatEnabled("nyxpiri.ultra-stop") && !Disabled) { Disabled = true; TimeScale.Controller.ParryFlash(); Disabled = false; } } } [HarmonyPatch(typeof(AudioSource), "Play", new Type[] { typeof(float) })] internal static class AudioPlayDFPatch { public static void Prefix(AudioSource __instance, float delay) { } public static void Postfix(AudioSource __instance, float delay) { if (Cheats.IsCheatEnabled("nyxpiri.ultra-stop") && !AudioPlayPatch.Disabled) { AudioPlayPatch.Disabled = true; TimeScale.Controller.ParryFlash(); AudioPlayPatch.Disabled = false; } } } [HarmonyPatch(typeof(AudioSource), "Play", new Type[] { typeof(ulong) })] internal static class AudioPlayDUPatch { public static void Prefix(AudioSource __instance, ulong delay) { } public static void Postfix(AudioSource __instance, ulong delay) { if (Cheats.IsCheatEnabled("nyxpiri.ultra-stop") && !AudioPlayPatch.Disabled) { AudioPlayPatch.Disabled = true; TimeScale.Controller.ParryFlash(); AudioPlayPatch.Disabled = false; } } } [HarmonyPatch(typeof(AudioSource), "PlayDelayed", new Type[] { typeof(float) })] internal static class AudioPlayDDFPatch { public static void Prefix(AudioSource __instance, float delay) { } public static void Postfix(AudioSource __instance, float delay) { if (Cheats.IsCheatEnabled("nyxpiri.ultra-stop") && !AudioPlayPatch.Disabled) { AudioPlayPatch.Disabled = true; TimeScale.Controller.ParryFlash(); AudioPlayPatch.Disabled = false; } } } [HarmonyPatch(typeof(AudioSource), "PlayScheduled", new Type[] { typeof(double) })] internal static class AudioPlaySDPatch { public static void Prefix(AudioSource __instance, double time) { } public static void Postfix(AudioSource __instance, double time) { if (Cheats.IsCheatEnabled("nyxpiri.ultra-stop") && !AudioPlayPatch.Disabled) { AudioPlayPatch.Disabled = true; TimeScale.Controller.ParryFlash(); AudioPlayPatch.Disabled = false; } } } [HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })] internal static class AudioPlayDOSPatch { public static void Prefix(AudioSource __instance, AudioClip clip) { } public static void Postfix(AudioSource __instance, AudioClip clip) { if (Cheats.IsCheatEnabled("nyxpiri.ultra-stop") && !AudioPlayPatch.Disabled) { AudioPlayPatch.Disabled = true; TimeScale.Controller.ParryFlash(); AudioPlayPatch.Disabled = false; } } } public static class UnityEngineObjectExtensions { public static T NullInvalid(this T self) where T : Object { if ((Object)(object)self == (Object)null) { return default(T); } return self; } } public static class UpdateEvents { public delegate void OnUpdateEventHandler(); public delegate void OnFixedUpdateEventHandler(); public delegate void OnLateUpdateEventHandler(); public static event OnUpdateEventHandler OnUpdate; public static event OnFixedUpdateEventHandler OnFixedUpdate; public static event OnLateUpdateEventHandler OnLateUpdate; internal static void NotifyLateUpdate() { UpdateEvents.OnLateUpdate?.Invoke(); } internal static void NotifyFixedUpdate() { UpdateEvents.OnFixedUpdate?.Invoke(); } internal static void NotifyUpdate() { UpdateEvents.OnUpdate?.Invoke(); } } } namespace Nyxpiri.ULTRAKILL.NyxLib.EnemyTypes { public class VanillaEnemyType : AEnemyType { private string readableName = "???"; private string name = "???"; private string uniqueName = "???"; private EnemyType? vanillaEnumValue = null; public override string ReadableName => readableName; public override string Name => name; public override string UniqueName => uniqueName; public override EnemyType? VanillaEnumValue => vanillaEnumValue; public override bool IsVanilla => true; public static AEnemyType BigJohnator { get; private set; } public static AEnemyType CancerousRodent { get; private set; } public static AEnemyType Centaur { get; private set; } public static AEnemyType Cerberus { get; private set; } public static AEnemyType Deathcatcher { get; private set; } public static AEnemyType Drone { get; private set; } public static AEnemyType Ferryman { get; private set; } public static AEnemyType Filth { get; private set; } public static AEnemyType FleshPanopticon { get; private set; } public static AEnemyType Gabriel { get; private set; } public static AEnemyType FleshPrison { get; private set; } public static AEnemyType GabrielSecond { get; private set; } public static AEnemyType Geryon { get; private set; } public static AEnemyType Gutterman { get; private set; } public static AEnemyType Guttertank { get; private set; } public static AEnemyType HideousMass { get; private set; } public static AEnemyType Idol { get; private set; } public static AEnemyType Leviathan { get; private set; } public static AEnemyType MaliciousFace { get; private set; } public static AEnemyType Mandalore { get; private set; } public static AEnemyType Mannequin { get; private set; } public static AEnemyType Mindflayer { get; private set; } public static AEnemyType Minos { get; private set; } public static AEnemyType MinosPrime { get; private set; } public static AEnemyType Minotaur { get; private set; } public static AEnemyType MirrorReaper { get; private set; } public static AEnemyType Power { get; private set; } public static AEnemyType Providence { get; private set; } public static AEnemyType Puppet { get; private set; } public static AEnemyType Schism { get; private set; } public static AEnemyType Sisyphus { get; private set; } public static AEnemyType SisyphusPrime { get; private set; } public static AEnemyType Soldier { get; private set; } public static AEnemyType Stalker { get; private set; } public static AEnemyType Stray { get; private set; } public static AEnemyType Streetcleaner { get; private set; } public static AEnemyType Swordsmachine { get; private set; } public static AEnemyType Turret { get; private set; } public static AEnemyType V2 { get; private set; } public static AEnemyType V2Second { get; private set; } public static AEnemyType VeryCancerousRodent { get; private set; } public static AEnemyType Virtue { get; private set; } public static AEnemyType Wicked { get; private set; } public VanillaEnemyType(string friendlyName, string name) { readableName = friendlyName; this.name = name; uniqueName = "nyxlib.vanilla-ultrakill." + name; } public VanillaEnemyType(string friendlyName, string name, EnemyType vanillaEnumValue) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) readableName = friendlyName; this.name = name; uniqueName = "NyxLib.Vanilla.ULTRAKILL." + name; this.vanillaEnumValue = vanillaEnumValue; } public VanillaEnemyType(string friendlyName, string name, string uniqueName, EnemyType vanillaEnumValue) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) readableName = friendlyName; this.name = name; this.uniqueName = uniqueName; this.vanillaEnumValue = vanillaEnumValue; } internal static void Initialize() { //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_0034: 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_0037: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected I4, but got Unknown EnemyTypeDB instance = MonoSingleton.Instance; foreach (object value in Enum.GetValues(typeof(EnemyType))) { EnemyType val = (EnemyType)value; AEnemyType enemyType = null; EnemyType val2 = val; EnemyType val3 = val2; switch ((int)val3) { case 37: enemyType = (BigJohnator = new VanillaEnemyType("Big Johninator", "BigJohnator", (EnemyType)37)); break; case 23: enemyType = (CancerousRodent = new VanillaEnemyType("Cancerous Rodent", "CancerousRodent", (EnemyType)23)); break; case 35: enemyType = (Centaur = new VanillaEnemyType("Earth Mover", "Centaur", (EnemyType)35)); break; case 0: enemyType = (Cerberus = new VanillaEnemyType("Cerberus", "Cerberus", (EnemyType)0)); break; case 39: enemyType = (Deathcatcher = new VanillaEnemyType("Deathcatcher", "Deathcatcher", (EnemyType)39)); break; case 1: enemyType = (Drone = new VanillaEnemyType("Drone", "Drone", (EnemyType)1)); break; case 26: enemyType = (Ferryman = new VanillaEnemyType("Ferryman", "Ferryman", (EnemyType)26)); break; case 3: enemyType = (Filth = new VanillaEnemyType("Filth", "Filth", (EnemyType)3)); break; case 30: enemyType = (FleshPanopticon = new VanillaEnemyType("Flesh Panopticon", "FleshPanopticon", (EnemyType)30)); break; case 17: enemyType = (FleshPrison = new VanillaEnemyType("Flesh Prison", "FleshPrison", (EnemyType)17)); break; case 16: enemyType = (Gabriel = new VanillaEnemyType("Gabrie - Judge of Hell", "Gabriel", (EnemyType)16)); break; case 28: enemyType = (GabrielSecond = new VanillaEnemyType("Gabriel - Apostate of Hate", "GabrielSecond", (EnemyType)28)); break; case 42: enemyType = (Geryon = new VanillaEnemyType("Geryon", "Geryon", (EnemyType)42)); break; case 33: enemyType = (Gutterman = new VanillaEnemyType("Gutterman", "Gutterman", (EnemyType)33)); break; case 34: enemyType = (Guttertank = new VanillaEnemyType("Guttertank", "Guttertank", (EnemyType)34)); break; case 2: enemyType = (HideousMass = new VanillaEnemyType("Hideous Mass", "HideousMass", (EnemyType)2)); break; case 21: enemyType = (Idol = new VanillaEnemyType("Idol", "Idol", (EnemyType)21)); break; case 27: enemyType = (Leviathan = new VanillaEnemyType("Leviathan", "Leviathan", (EnemyType)27)); break; case 4: enemyType = (MaliciousFace = new VanillaEnemyType("Malicious Face", "MaliciousFace", (EnemyType)4)); break; case 25: enemyType = (Mandalore = new VanillaEnemyType("Mandalore", "Mandalore", (EnemyType)25)); break; case 31: enemyType = (Mannequin = new VanillaEnemyType("Mannequin", "Mannequin", (EnemyType)31)); break; case 5: enemyType = (Mindflayer = new VanillaEnemyType("Mindflayer", "Mindflayer", (EnemyType)5)); break; case 11: enemyType = (Minos = new VanillaEnemyType("Corpse of King Minos", "Minos", (EnemyType)11)); break; case 18: enemyType = (MinosPrime = new VanillaEnemyType("Minos Prime", "MinosPrime", (EnemyType)18)); break; case 32: enemyType = (Minotaur = new VanillaEnemyType("Minotaur", "Minotaur", (EnemyType)32)); break; case 41: enemyType = (MirrorReaper = new VanillaEnemyType("Mirror Reaper", "MirrorReaper", (EnemyType)41)); break; case 40: enemyType = (Power = new VanillaEnemyType("Power", "Power", (EnemyType)40)); break; case 38: enemyType = (Providence = new VanillaEnemyType("Providence", "Providence", (EnemyType)38)); break; case 36: enemyType = (Puppet = new VanillaEnemyType("Puppet", "Puppet", (EnemyType)36)); break; case 14: enemyType = (Schism = new VanillaEnemyType("Schism", "Schism", (EnemyType)14)); break; case 19: enemyType = (Sisyphus = new VanillaEnemyType("Sisyphus", "Sisyphus", (EnemyType)19)); break; case 29: enemyType = (SisyphusPrime = new VanillaEnemyType("Sisyphus Prime", "SisyphusPrime", (EnemyType)29)); break; case 15: enemyType = (Soldier = new VanillaEnemyType("Soldier", "Soldier", (EnemyType)15)); break; case 12: enemyType = (Stalker = new VanillaEnemyType("Stalker", "Stalker", (EnemyType)12)); break; case 13: enemyType = (Stray = new VanillaEnemyType("Stray", "Stray", (EnemyType)13)); break; case 6: enemyType = (Streetcleaner = new VanillaEnemyType("Street Cleaner", "Streetcleaner", (EnemyType)6)); break; case 7: enemyType = (Swordsmachine = new VanillaEnemyType("Swords Machine", "Swordsmachine", (EnemyType)7)); break; case 20: enemyType = (Turret = new VanillaEnemyType("Turret", "Turret", (EnemyType)20)); break; case 8: enemyType = (V2 = new VanillaEnemyType("V2", "V2", (EnemyType)8)); break; case 22: enemyType = (V2Second = new VanillaEnemyType("V2... 2!", "V2Second", (EnemyType)22)); break; case 24: enemyType = (VeryCancerousRodent = new VanillaEnemyType("Very Cancerous Rodent", "VeryCancerousRodent", (EnemyType)24)); break; case 9: enemyType = (Virtue = new VanillaEnemyType("Virtue", "Virtue", (EnemyType)9)); break; case 10: enemyType = (Wicked = new VanillaEnemyType("Something Wicked", "Wicked", (EnemyType)10)); break; } instance.RegisterType(enemyType); } } } } namespace Nyxpiri.ULTRAKILL.NyxLib.Diagnostics.Debug { internal static class Log { internal static ManualLogSource Logger; public static void Warning(string message) { Logger.LogWarning((object)message); } public static void Error(string message) { Logger.LogError((object)message); } public static void PerformanceInfo(string message) { if (Options.IncludePerformanceLogs) { Logger.LogDebug((object)message); } } public static void TraceExpectedInfo(string message) { if (Options.IncludeTraceExpectedLogs) { Logger.LogDebug((object)message); } } public static void DebugInfo(string message) { if (Options.IncludeTraceExpectedLogs) { Logger.LogDebug((object)message); } } public static void ExpectedInfo(string message) { Logger.LogDebug((object)message); } public static void LikelyInfo(string message) { Logger.LogInfo((object)message); } public static void UnlikelyInfo(string message) { Logger.LogInfo((object)message); } public static void UnexpectedInfo(string message) { Logger.LogMessage((object)message); } public static void Message(string message) { Logger.LogMessage((object)message); } } }