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 TMPro;
using ULTRAKILL.Cheats;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Events;
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.DebugInfo($"{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;
[SerializeField]
private Collider[] _colliders = null;
[SerializeField]
private List<MonoBehaviour> _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<Collider> Colliders => _colliders;
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<T>(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<EnemyIdentifier>();
Enemy = ((Component)this).GetComponent<Enemy>();
Assert.IsNotNull((Object)(object)Eid);
_isEnemyCompInitializer = true;
_hasDoneSetup = true;
_enemyRootMono = GameObjectExtensions.GetOrAddComponent<EnemyRoot>(RootGameObject);
CreateMods();
Eid.ForceGetHealth();
InitialHealth = Health;
UpdateHighestHealth();
_colliders = ((Component)this).GetComponentsInChildren<Collider>(true);
PrefabStore?.StorePrefab();
}
}
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<Collider>();
}
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<MonoBehaviour>(MonoRegistrar.RegisteredTypes.Count);
foreach (Type registeredType in MonoRegistrar.RegisteredTypes)
{
_monoBehaviours.Add((MonoBehaviour)((Component)this).gameObject.AddComponent(registeredType));
}
if (!Options.DontCreateEnemyRadianceComp.Value)
{
Radiance = GameObjectExtensions.GetOrAddComponent<EnemyRadiance>(((Component)this).gameObject);
}
if (!Options.DontCreateEnemyPrefabComp.Value)
{
PrefabStore = ((Component)this).gameObject.AddComponent<EnemyPrefabStore>();
}
}
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;
}
}
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<PrefsManager>.Instance != (Object)null)
{
Log.ExpectedInfo("Had to get PrefsManager via PrefsManager.Instance (then cached the value)");
_manager = MonoSingleton<PrefsManager>.Instance;
}
return _manager;
}
}
}
public static class LevelQuickLoader
{
private enum LevelQuickLoadState
{
Needed,
AwaitingLoad,
WaitingToReturn,
Returning,
Done
}
private static Dictionary<string, LevelQuickLoadState> _quickLoadStates = new Dictionary<string, LevelQuickLoadState>();
private static bool _quickLoading = false;
private static bool _currentLevelIsFromQuickLoad = false;
private static string _quickLoadLevel = null;
private static string _preQuickLoadLevel = null;
public static void AddQuickLoadLevel(string levelName)
{
_quickLoadStates.TryAdd(levelName, LevelQuickLoadState.Needed);
}
internal static void Initialize()
{
if (Options.DisableQuickLoad.Value)
{
_quickLoadStates.Clear();
Log.Message("Clearing _quickLoadStates due to DisableQuickLoad being true...");
}
UpdateEvents.OnUpdate += Update;
}
private static bool TryFindQuickLoadLevel()
{
if (SceneHelper.PendingScene == null && !_quickLoading)
{
_quickLoadLevel = null;
foreach (KeyValuePair<string, LevelQuickLoadState> 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 static void Update()
{
TryFindQuickLoadLevel();
if (!(SceneHelper.CurrentScene == _quickLoadLevel) || SceneHelper.PendingScene != null)
{
return;
}
if (_quickLoadStates[_quickLoadLevel] == LevelQuickLoadState.AwaitingLoad)
{
_quickLoadStates[_quickLoadLevel] = LevelQuickLoadState.WaitingToReturn;
}
else if (_quickLoadStates[_quickLoadLevel] == LevelQuickLoadState.WaitingToReturn)
{
Log.TraceExpectedInfo(_quickLoadLevel + " quick load done!");
_quickLoadStates[_quickLoadLevel] = LevelQuickLoadState.Done;
_quickLoadLevel = null;
_quickLoading = false;
if (!TryFindQuickLoadLevel())
{
SceneHelper.LoadScene(_preQuickLoadLevel, false);
_preQuickLoadLevel = null;
_currentLevelIsFromQuickLoad = false;
}
}
}
}
public class ToggleCheat : ICheat
{
public Action<ToggleCheat> OnDisable = null;
public Action<ToggleCheat, CheatsManager> OnEnable = null;
private static Dictionary<string, bool> ToggleCheatStateStore = new Dictionary<string, bool>();
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<ToggleCheat> onDisable, Action<ToggleCheat, CheatsManager> 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<T> where T : class, new()
{
public Func<T> ConstructObject = null;
public Action<T> PrepareObject = delegate
{
};
public Action<T> UnprepareObject = delegate
{
};
public Action<T> DestructObject = delegate
{
};
private Stack<int> _FreeList = new Stack<int>();
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<T> constructObject, Action<T> 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<T> Take()
{
return new PoolObject<T>(this, TakeUnsafe());
}
public void Return((T, int) element)
{
UnprepareObject?.Invoke(element.Item1);
_FreeList.Push(element.Item2);
}
public void Return(PoolObject<T> obj)
{
obj.Dispose();
}
~ObjPool()
{
Clear();
}
}
public class PoolObject<T> : IDisposable where T : class, new()
{
private ObjPool<T> Pool;
private (T, int) Element;
public T Obj => Element.Item1;
public T Value => Obj;
public bool IsValid => Pool != null;
internal PoolObject(ObjPool<T> 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<bool> RegisterAction { private get; set; } = null;
public Func<bool> UnregisterAction { private get; set; } = null;
public bool Registered
{
get
{
return _Registered;
}
private set
{
_Registered = value;
}
}
public RegistrationTracker(Func<bool> registerAction, Func<bool> 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<T>(this IList<T> 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<T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
{
private struct ReserveListElem
{
public T Obj;
public bool Free;
public ReserveListElem(T obj, bool free)
{
Obj = obj;
Free = free;
}
}
private List<ReserveListElem> _List;
private Stack<int> _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<ReserveListElem>();
_FreeList = new Stack<int>();
}
public ReserveList(int capacity)
{
_List = new List<ReserveListElem>(capacity);
_FreeList = new Stack<int>(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<T> 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
{
private static List<Func<bool>> _assetPickers = new List<Func<bool>>(64);
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;
private static GameObject FleshPrisonPrefab { get; set; } = null;
private static GameObject FleshPanopticonPrefab { get; set; } = null;
public static void EnableExplosionsPicking()
{
LevelQuickLoader.AddQuickLoadLevel("uk_construct");
}
public static void EnableProjectilePicking()
{
LevelQuickLoader.AddQuickLoadLevel("Endless");
}
public static void AddAssetPicker<ObjectType>(Func<ObjectType, bool> pickerFunc) where ObjectType : Object
{
Func<bool> item = delegate
{
ObjectType val = Object.FindAnyObjectByType<ObjectType>((FindObjectsInactive)1);
return !((Object)(object)val == (Object)null) && pickerFunc(val);
};
_assetPickers.Add(item);
}
private static void OnSceneWasLoaded(Scene scene, string levelName, string unitySceneName)
{
for (int i = 0; i < _assetPickers.Count; i++)
{
Func<bool> func = _assetPickers[i];
try
{
if (func())
{
_assetPickers.RemoveAt(i);
i--;
}
}
catch (Exception ex)
{
Log.Error($"Caught {ex.GetType()} whilst trying to execute an asset picker!\n{ex}\n");
}
}
if ((Object)(object)LabelPrefab == (Object)null)
{
HeatResistance val = Object.FindAnyObjectByType<HeatResistance>((FindObjectsInactive)1);
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI val2 = null;
TextMeshProUGUI[] componentsInChildren = ((Component)val).gameObject.GetComponentsInChildren<TextMeshProUGUI>(true);
TextMeshProUGUI[] array = componentsInChildren;
foreach (TextMeshProUGUI val3 in array)
{
if (((TMP_Text)val3).text.Contains("COMPROMISED"))
{
val2 = val3;
break;
}
}
Assert.IsNotNull((Object)(object)val2);
LabelPrefab = Object.Instantiate<GameObject>(((Component)val2).gameObject);
LabelPrefab.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)LabelPrefab);
((TMP_Text)LabelPrefab.GetComponent<TextMeshProUGUI>()).text = "UKAIW-Label!";
}
}
if ((Object)(object)RocketPrefab == (Object)null)
{
Grenade[] array2 = Object.FindObjectsByType<Grenade>((FindObjectsInactive)1, (FindObjectsSortMode)0);
Grenade[] array3 = array2;
foreach (Grenade val4 in array3)
{
if (val4.rocket)
{
RocketPrefab = Object.Instantiate<GameObject>(((Component)val4).gameObject);
Object.DontDestroyOnLoad((Object)(object)RocketPrefab);
RocketPrefab.SetActive(false);
}
if ((Object)(object)HarmlessExplosionPrefab == (Object)null && (Object)(object)val4.harmlessExplosion != (Object)null)
{
HarmlessExplosionPrefab = Object.Instantiate<GameObject>(val4.harmlessExplosion);
Object.DontDestroyOnLoad((Object)(object)HarmlessExplosionPrefab);
HarmlessExplosionPrefab.SetActive(false);
GameObjectExtensions.GetOrAddComponent<ExplosionAdditions>(HarmlessExplosionPrefab);
}
if ((Object)(object)ExplosionPrefab == (Object)null && (Object)(object)val4.explosion != (Object)null)
{
ExplosionPrefab = Object.Instantiate<GameObject>(val4.explosion);
Object.DontDestroyOnLoad((Object)(object)ExplosionPrefab);
ExplosionPrefab.SetActive(false);
GameObjectExtensions.GetOrAddComponent<ExplosionAdditions>(ExplosionPrefab);
}
if ((Object)(object)SuperExplosionPrefab == (Object)null && (Object)(object)val4.superExplosion != (Object)null)
{
SuperExplosionPrefab = Object.Instantiate<GameObject>(val4.superExplosion);
Object.DontDestroyOnLoad((Object)(object)SuperExplosionPrefab);
SuperExplosionPrefab.SetActive(false);
GameObjectExtensions.GetOrAddComponent<ExplosionAdditions>(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 val5 = Object.FindAnyObjectByType<Mass>((FindObjectsInactive)1);
if ((Object)(object)val5 != (Object)null)
{
MortarPrefab = Object.Instantiate<GameObject>(val5.explosiveProjectile);
Object.DontDestroyOnLoad((Object)(object)MortarPrefab);
MortarPrefab.SetActive(false);
ExplosionPrefab = Object.Instantiate<GameObject>(MortarPrefab.GetComponent<Projectile>().explosionEffect);
Object.DontDestroyOnLoad((Object)(object)ExplosionPrefab);
ExplosionPrefab.SetActive(false);
GameObjectExtensions.GetOrAddComponent<ExplosionAdditions>(ExplosionPrefab);
HomingProjectilePrefab = Object.Instantiate<GameObject>(val5.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!");
}
}
if (!((Object)(object)FleshPrisonPrefab == (Object)null) && !((Object)(object)FleshPanopticonPrefab == (Object)null))
{
return;
}
FleshPrison val6 = Object.FindAnyObjectByType<FleshPrison>((FindObjectsInactive)1);
if ((Object)(object)val6 != (Object)null)
{
if (val6.altVersion)
{
FleshPanopticonPrefab = Object.Instantiate<GameObject>(((Component)val6).gameObject);
Object.DontDestroyOnLoad((Object)(object)FleshPanopticonPrefab);
}
else
{
FleshPrisonPrefab = Object.Instantiate<GameObject>(((Component)val6).gameObject);
Object.DontDestroyOnLoad((Object)(object)FleshPrisonPrefab);
}
}
else
{
Log.ExpectedInfo("We'd like a flesh prison in order to yoink it as a prefab, but this scene \"" + SceneHelper.CurrentScene + "\" didn't have it yet!");
}
}
internal static void Initialize()
{
ScenesEvents.OnSceneWasLoaded += OnSceneWasLoaded;
LevelQuickLoader.AddQuickLoadLevel("Level 0-E");
}
}
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<PlayerActivator>();
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<CheatsManager>.Instance != (Object)null)
{
Log.ExpectedInfo("Had to get CheatsManager via CheatsManager.Instance (then cached the value)");
_manager = MonoSingleton<CheatsManager>.Instance;
}
return _manager;
}
}
public static bool Enabled => (MonoSingleton<CheatsController>.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 = true;
}
}
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<ActivateNextWave>().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<EndlessGrid>.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<IEnrage>();
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<IEnrage>();
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<Gutterman>();
if (component4 != null)
{
component4.Enrage();
}
return true;
}
return false;
case 7:
{
SwordsMachine component10 = ((Component)eid).GetComponent<SwordsMachine>();
if (component10 != null)
{
component10.Enrage();
}
return true;
}
case 0:
{
StatueBoss component7 = ((Component)eid).GetComponent<StatueBoss>();
if (component7 != null)
{
component7.Enrage();
}
return true;
}
case 1:
case 9:
{
Drone component3 = ((Component)eid).GetComponent<Drone>();
if (component3 != null)
{
component3.Enrage();
}
return true;
}
case 8:
{
V2 component8 = ((Component)eid).GetComponent<V2>();
if (component8 != null)
{
component8.Enrage();
}
return true;
}
case 5:
{
Mindflayer component9 = ((Component)eid).GetComponent<Mindflayer>();
if (component9 != null)
{
component9.Enrage();
}
return true;
}
case 2:
{
Mass component5 = ((Component)eid).GetComponent<Mass>();
if (!((component5 == null) ? null : ((Component)component5).GetComponentInChildren<EnemySimplifier>()?.enraged).GetValueOrDefault(true))
{
Mass component6 = ((Component)eid).GetComponent<Mass>();
if (component6 != null)
{
component6.Enrage();
}
return true;
}
return false;
}
case 4:
{
SpiderBody component2 = ((Component)eid).GetComponent<SpiderBody>();
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<Gutterman>();
if (component2 != null)
{
component2.UnEnrage();
}
return true;
}
return false;
case 7:
{
SwordsMachine component5 = ((Component)eid).GetComponent<SwordsMachine>();
if (component5 != null)
{
component5.UnEnrage();
}
return true;
}
case 0:
{
StatueBoss component3 = ((Component)eid).GetComponent<StatueBoss>();
if (component3 != null)
{
component3.UnEnrage();
}
return true;
}
case 1:
case 9:
{
Drone component6 = ((Component)eid).GetComponent<Drone>();
if (component6 != null)
{
component6.UnEnrage();
}
return true;
}
case 8:
{
V2 component7 = ((Component)eid).GetComponent<V2>();
if (component7 != null)
{
component7.UnEnrage();
}
return true;
}
case 5:
{
Mindflayer component4 = ((Component)eid).GetComponent<Mindflayer>();
if (component4 != null)
{
component4.UnEnrage();
}
return true;
}
case 4:
{
SpiderBody component = ((Component)eid).GetComponent<SpiderBody>();
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>();
Collider[] array = CollectionExtensions.AddRangeToArray<Collider>(enemyGo.GetComponents<Collider>(), enemyGo.GetComponentsInChildren<Collider>());
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<EnemyComponents>(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<EnemyComponents>());
});
}
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<EnemyComponents>();
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<EnemyIdentifier>(), instakill: false, typeof(SpiderDiePatch), _cancellationTracker);
}
public static void Postfix(SpiderBody __instance)
{
EidDeathPatch.PostDeath(((Component)__instance).gameObject.GetComponent<EnemyIdentifier>(), 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<EnemyIdentifier>(), instakill: false, typeof(DroneDeathPatch), _cancellationTracker);
}
public static void Postfix(Drone __instance, bool fromExplosion)
{
EidDeathPatch.PostDeath(((Component)__instance).gameObject.GetComponent<EnemyIdentifier>(), 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<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.TryCallPreDeath(_cancellationTracker.GetCanceler(), instakill: true, typeof(EnemyIdentifierInstakill));
_cancellationTracker.TryInvokeReimplementation();
return _cancellationTracker.ShouldRunMethod;
}
public static void Postfix(EnemyIdentifier __instance)
{
EnemyComponents component = ((Component)__instance).GetComponent<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.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<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.TryCallPreDeath(_cancellationTracker.GetCanceler(), instakill: true, typeof(EnemyIdentifierExplodePatch));
_cancellationTracker.TryInvokeReimplementation();
return _cancellationTracker.ShouldRunMethod;
}
public static void Postfix(EnemyIdentifier __instance)
{
EnemyComponents component = ((Component)__instance).GetComponent<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.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<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.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<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.TryCallPostDeath(cancellationTracker.GetCancelInfo(), callerObj);
}
public static bool Prefix(EnemyIdentifier __instance, bool fromExplosion)
{
_cancellationTracker.Reset();
EnemyComponents component = ((Component)__instance).GetComponent<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.TryCallPreDeath(_cancellationTracker.GetCanceler(), instakill: false, typeof(EidDeathPatch));
_cancellationTracker.TryInvokeReimplementation();
component.NullInvalid<EnemyComponents>()?.TryCallDeath();
return _cancellationTracker.ShouldRunMethod;
}
public static void Postfix(EnemyIdentifier __instance, bool fromExplosion)
{
EnemyComponents component = ((Component)__instance).GetComponent<EnemyComponents>();
component.NullInvalid<EnemyComponents>()?.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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(StatueBoss __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreUnEnrage(_cancellationTracker);
}
public static void Postfix(StatueBoss __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(SwordsMachine __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreUnEnrage(_cancellationTracker);
}
public static void Postfix(SwordsMachine __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(Drone __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreUnEnrage(_cancellationTracker);
}
public static void Postfix(Drone __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(V2 __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreUnEnrage(_cancellationTracker);
}
public static void Postfix(V2 __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(Mindflayer __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreUnEnrage(_cancellationTracker);
}
public static void Postfix(Mindflayer __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(SpiderBody __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreUnEnrage(_cancellationTracker);
}
public static void Postfix(SpiderBody __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(Gutterman __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreUnEnrage(_cancellationTracker);
}
public static void Postfix(Gutterman __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().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<EnemyComponents>().CallPreEnrage(_cancellationTracker);
}
public static void Postfix(Mass __instance)
{
((Component)__instance).GetComponent<EnemyComponents>().CallPostEnrage(_cancellationTracker);
}
}
public static class EnemyEvents
{
public static Action<EnemyComponents> PreStart;
public static Action<EnemyComponents> PostStart;
public static Action<EnemyComponents> PreDisabled;
public static Action<EnemyComponents> PreDestroy;
public static Action<EnemyComponents, bool> PreDeath;
public static Action<EnemyComponents, bool> PostDeath;
public static Action<EnemyComponents> 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<EnemyComponents>();
_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<EnemyComponents>();
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<EnemyComponents>();
_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<EnemyComponents>();
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<EnemyComponents>();
_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<EnemyComponents>();
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<EnemyComponents>();
_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<EnemyComponents>();
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<EnemyComponents>();
_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<EnemyComponents>();
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<EnemyComponents>();
_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<EnemyComponents>();
component.NotifyOfPostHurt(_cancellationTracker.GetCancelInfo(), ((Component)__instance).gameObject, force, null, multiplier, 1f, sourceWeapon, tryForExplode: false, ignoreTotalDamageTakenMultiplier: false, fromExplosion, typeof(DroneHurtPatch));
}
}
public static class EnemyPrefabManager
{
private static int InstanceStoreTickIdx = 0;
private static ReserveList<EnemyPrefabStore.InstanceStore> InstanceStores = new ReserveList<EnemyPrefabStore.InstanceStore>(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<EnemyIdentifier>(true);
EnemyIdentifier[] array2 = array;
foreach (EnemyIdentifier val in array2)
{
EnemyComponents orAddComponent = ComponentExtensions.GetOrAddComponent<EnemyComponents>((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<GameObject> Instances = new Stack<GameObject>();
private HashSet<EnemyPrefabStore> RegisteredStores = new HashSet<EnemyPrefabStore>(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<GameObject>(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<GameObject>(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<EnemyComponents>();
component.PreDeath += delegate
{
instGo.GetComponent<Stalker>().SandExplode(1);
};
component.PostDeath += delegate
{
instGo.GetComponent<EnemyComponents>().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.