Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RespawnPaceControl v0.7.9
plugins/RespawnPaceControl.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RespawnPaceControl { [BepInPlugin("com.respawnpacecontrol.mod", "Respawn Pace Control", "0.7.9")] public class Plugin : BaseUnityPlugin { private sealed class TimerSample { internal float Previous; internal bool ObservedChange; internal float LastObservedAt; } private enum EnemyHudPhase { Spawned, WaitingForSpawn, DespawnedAlive, Countdown, Unknown } private sealed class EnemyHudState { internal EnemyHudPhase Phase = EnemyHudPhase.Countdown; } private readonly struct EnemyHudRow { internal readonly int Id; internal readonly string Name; internal readonly EnemyHudPhase Phase; internal readonly float Seconds; internal EnemyHudRow(int id, string name, EnemyHudPhase phase, float seconds) { Id = id; Name = name; Phase = phase; Seconds = seconds; } } [HarmonyPatch(typeof(EnemyParent), "Spawn")] private static class ObserveHudSpawnPatch { private static void Postfix(EnemyParent __instance) { EnemyHudStates.GetValue(__instance, (EnemyParent _) => new EnemyHudState()).Phase = ((!IsSpawned(__instance)) ? EnemyHudPhase.WaitingForSpawn : EnemyHudPhase.Spawned); } } [HarmonyPatch(typeof(EnemyParent), "Despawn")] private static class ObserveHudDespawnPatch { private static void Postfix(EnemyParent __instance) { if (EnemyHudStates.TryGetValue(__instance, out var value) && value.Phase == EnemyHudPhase.Spawned && !IsSpawned(__instance)) { value.Phase = (IsDyingOrDead(__instance, isClient: false) ? EnemyHudPhase.Countdown : EnemyHudPhase.DespawnedAlive); } } } [HarmonyPatch(typeof(HurtCollider), "EnemyHurt")] private static class ColliderDamagePatch { private static void ApplyColliderDamage(EnemyHealth health, int damage, Vector3 direction, HurtCollider collider) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) bool fromPlayer = !collider.deathPit && !Object.op_Implicit((Object)(object)collider.enemyHost) && Object.op_Implicit((Object)/*isinst with value type is only supported in some contexts*/); ApplyDamage(health, damage, direction, fromPlayer); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return ReplaceInstruction(instructions, HurtMethod, AccessTools.Method(typeof(ColliderDamagePatch), "ApplyColliderDamage", (Type[])null, (Type[])null), passInstance: true, "HurtCollider.EnemyHurt"); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnCollisionStay")] private static class ObjectDamagePatch { private static void ApplyObjectDamage(EnemyHealth health, int damage, Vector3 direction, PhysGrabObjectImpactDetector detector) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) object? obj = ImpactObjectField?.GetValue(detector); PhysGrabObject val = (PhysGrabObject)((obj is PhysGrabObject) ? obj : null); bool fromPlayer = Object.op_Implicit((Object)(object)val) && (Object.op_Implicit((Object)/*isinst with value type is only supported in some contexts*/) || Object.op_Implicit((Object)(object)ItemVehicle.GetSeatedDriverForPhysObject(val))); ApplyDamage(health, damage, direction, fromPlayer); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return ReplaceInstruction(instructions, HurtMethod, AccessTools.Method(typeof(ObjectDamagePatch), "ApplyObjectDamage", (Type[])null, (Type[])null), passInstance: true, "PhysGrabObjectImpactDetector.OnCollisionStay"); } } [HarmonyPatch] private static class HeldEnemyDamagePatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyHealth), "LightImpact", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyHealth), "MediumImpact", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyHealth), "HeavyImpact", (Type[])null, (Type[])null); } private static void ApplyHeldEnemyDamage(EnemyHealth health, int damage, Vector3 direction, EnemyHealth impactedHealth) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) object? obj = HealthEnemyField?.GetValue(impactedHealth); Enemy val = (Enemy)((obj is Enemy) ? obj : null); EnemyRigidbody val2 = (EnemyRigidbody)(Object.op_Implicit((Object)(object)val) ? /*isinst with value type is only supported in some contexts*/: null); PhysGrabObject val3 = (PhysGrabObject)(Object.op_Implicit((Object)(object)val2) ? /*isinst with value type is only supported in some contexts*/: null); bool fromPlayer = Object.op_Implicit((Object)(object)val3) && val3.grabbed && Object.op_Implicit((Object)/*isinst with value type is only supported in some contexts*/); ApplyDamage(health, damage, direction, fromPlayer); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod) { return ReplaceInstruction(instructions, HurtMethod, AccessTools.Method(typeof(HeldEnemyDamagePatch), "ApplyHeldEnemyDamage", (Type[])null, (Type[])null), passInstance: true, __originalMethod.Name); } } [HarmonyPatch(typeof(EnemyHealth), "Death")] private static class RecordPlayerKillPatch { private static void Prefix(EnemyHealth __instance) { if (playerDamageTarget != __instance || IsClient()) { return; } EnemyParent enemyParent = GetEnemyParent(__instance); if (Object.op_Implicit((Object)(object)enemyParent)) { PlayerKills.GetValue(enemyParent, (EnemyParent _) => PlayerKillMarker); } } } [HarmonyPatch(typeof(EnemyHealth), "OnSpawn")] private static class ResetPlayerKillPatch { private static void Prefix(EnemyHealth __instance) { EnemyParent enemyParent = GetEnemyParent(__instance); if (Object.op_Implicit((Object)(object)enemyParent)) { PlayerKills.Remove(enemyParent); } } } private sealed class RespawnAcceleration { internal double CumulativeReduction; } [HarmonyPatch(typeof(EnemyDirector), "Update")] private static class TrackRespawnAccelerationPatch { private static float RecordDecrease(EnemyDirector director) { float despawnedDecreasePercent = director.despawnedDecreasePercent; RespawnAccelerationByDirector.GetValue(director, (EnemyDirector _) => new RespawnAcceleration()).CumulativeReduction += despawnedDecreasePercent; return despawnedDecreasePercent; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return ReplaceInstruction(instructions, AccessTools.Field(typeof(EnemyDirector), "despawnedDecreasePercent"), AccessTools.Method(typeof(TrackRespawnAccelerationPatch), "RecordDecrease", (Type[])null, (Type[])null), passInstance: false, "EnemyDirector.Update"); } } [HarmonyPatch(typeof(EnemyParent), "Despawn")] private static class EnemyParentDespawnPatch { private static float GetRespawnMultiplier(EnemyDirector director, EnemyParent enemy) { float result = (float)DecreaseMultiplierField.GetValue(director); float value = ReductionScale.Value; if (!(value >= 0f) || !(value < 1f) || !PlayerKills.TryGetValue(enemy, out var _) || !CanAdjustRespawn() || !RespawnAccelerationByDirector.TryGetValue(director, out var value3)) { return result; } return Mathf.Max(0f, (float)(1.0 - value3.CumulativeReduction * (double)value)); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return ReplaceInstruction(instructions, DecreaseMultiplierField, AccessTools.Method(typeof(EnemyParentDespawnPatch), "GetRespawnMultiplier", (Type[])null, (Type[])null), passInstance: true, "EnemyParent.Despawn"); } private static void Postfix(EnemyParent __instance) { if (EnableMinimumRespawn.Value && !(MinimumRespawnSeconds.Value <= 0f) && PlayerKills.TryGetValue(__instance, out var _) && CanAdjustRespawn()) { __instance.DespawnedTimer = Mathf.Max(__instance.DespawnedTimer, MinimumRespawnSeconds.Value); } } } [HarmonyPatch(typeof(EnemyDirector), "SetInvestigate")] private static class InvestigateNoisePatch { private static void ApplyScaledDecrease(EnemyParent enemy, float seconds) { float value = NoiseReductionScale.Value; if (!(value >= 0f) || !(value < 1f) || !PlayerKills.TryGetValue(enemy, out var _) || !CanAdjustRespawn()) { enemy.DisableDecrease(seconds); } else if (value > 0f) { enemy.DisableDecrease(seconds * value); } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return ReplaceInstruction(instructions, AccessTools.Method(typeof(EnemyParent), "DisableDecrease", (Type[])null, (Type[])null), AccessTools.Method(typeof(InvestigateNoisePatch), "ApplyScaledDecrease", (Type[])null, (Type[])null), passInstance: false, "EnemyDirector.SetInvestigate"); } } internal static ConfigEntry<float> ReductionScale; internal static ConfigEntry<float> MinimumRespawnSeconds; internal static ConfigEntry<bool> EnableMinimumRespawn; internal static ConfigEntry<float> NoiseReductionScale; internal static ConfigEntry<bool> ShowRespawnTimer; private ConfigEntry<KeyboardShortcut> toggleTimerList; private Harmony harmony; private const int CollapsedRows = 4; private const int MaxDisplayedEnemies = 24; private const float HudWidth = 246f; private const float HudHeaderHeight = 28f; private const float HudRowHeight = 22f; private const float HudFooterHeight = 22f; private EnemyDirector hudDirector; private bool hudExpanded; private float nextTimerRefresh; private float nextHudRefresh; private EnemyParent[] cachedEnemies = (EnemyParent[])(object)new EnemyParent[0]; private readonly List<EnemyHudRow> hudRows = new List<EnemyHudRow>(); private readonly Dictionary<int, TimerSample> timerSamples = new Dictionary<int, TimerSample>(); private static readonly ConditionalWeakTable<EnemyParent, EnemyHudState> EnemyHudStates = new ConditionalWeakTable<EnemyParent, EnemyHudState>(); private GUIStyle timerTitleStyle; private GUIStyle timerLineStyle; private GUIStyle timerStatusStyle; private GUIStyle timerHintStyle; private static readonly Dictionary<string, string> KoreanEnemyNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "CeilingEye", "천장 눈알" }, { "ThinMan", "그림자 아이" }, { "Gnome", "노움" }, { "Duck", "오리" }, { "SlowMouth", "역류성 식도염" }, { "ValuableThrower", "갓난 아기" }, { "Animal", "우당탕 거미" }, { "Upscream", "넉백 거미" }, { "Hidden", "투명인간" }, { "Tumbler", "개구리" }, { "Bowtie", "눈사람" }, { "Floater", "띄우는 외계인" }, { "Bang", "해골 폭탄" }, { "BangDirector", "해골 폭탄" }, { "Head", "헤드맨" }, { "Robe", "가오나시" }, { "Hunter", "장님" }, { "Runner", "리퍼" }, { "Beamer", "광대" }, { "SlowWalker", "대장장이" }, { "Tricycle", "벨라" }, { "BirthdayBoy", "파티 보이" }, { "BombThrower", "폭탄마" }, { "Elsa", "엘사" }, { "Spinny", "룰렛 외계인" }, { "HeadGrabber", "도깨비" }, { "HeartHugger", "하트 허거" }, { "Shadow", "수녀" }, { "Oogly", "그린 랜턴" }, { "Tick", "진드기" }, { "Pony", "말" }, { "Snatcher", "말" } }; private static readonly FieldInfo SpawnedField = AccessTools.Field(typeof(EnemyParent), "Spawned"); private static readonly FieldInfo ParentEnemyField = AccessTools.Field(typeof(EnemyParent), "Enemy"); private static readonly FieldInfo EnemyHealthField = AccessTools.Field(typeof(Enemy), "Health"); private static readonly FieldInfo HealthCurrentField = AccessTools.Field(typeof(EnemyHealth), "healthCurrent"); private static readonly FieldInfo HealthDeadField = AccessTools.Field(typeof(EnemyHealth), "dead"); private static readonly FieldInfo HealthDyingField = AccessTools.Field(typeof(EnemyHealth), "deadImpulse"); private static readonly FieldInfo ExtractionField = AccessTools.Field(typeof(RoundDirector), "allExtractionPointsCompleted"); private static readonly ConditionalWeakTable<EnemyParent, object> PlayerKills = new ConditionalWeakTable<EnemyParent, object>(); private static readonly object PlayerKillMarker = new object(); private static readonly FieldInfo HealthEnemyField = AccessTools.Field(typeof(EnemyHealth), "enemy"); private static readonly FieldInfo EnemyParentField = AccessTools.Field(typeof(Enemy), "EnemyParent"); private static readonly FieldInfo EnemyBodyField = AccessTools.Field(typeof(Enemy), "Rigidbody"); private static readonly FieldInfo EnemyBodyObjectField = AccessTools.Field(typeof(EnemyRigidbody), "physGrabObject"); private static readonly FieldInfo ImpactObjectField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "physGrabObject"); private static readonly FieldInfo LastGrabberField = AccessTools.Field(typeof(PhysGrabObject), "lastPlayerGrabbing"); private static readonly FieldInfo HurtPlayerField = AccessTools.Field(typeof(HurtCollider), "playerCausingHurt"); private static readonly MethodInfo HurtMethod = AccessTools.Method(typeof(EnemyHealth), "Hurt", (Type[])null, (Type[])null); [ThreadStatic] private static EnemyHealth playerDamageTarget; private static readonly ConditionalWeakTable<EnemyDirector, RespawnAcceleration> RespawnAccelerationByDirector = new ConditionalWeakTable<EnemyDirector, RespawnAcceleration>(); private static readonly FieldInfo DecreaseMultiplierField = AccessTools.Field(typeof(EnemyDirector), "despawnedDecreaseMultiplier"); private static string NormalizeEnemyName(string rawName) { if (string.IsNullOrEmpty(rawName)) { return string.Empty; } string text = rawName.Trim(); if (text.StartsWith("Enemy - ", StringComparison.OrdinalIgnoreCase)) { text = text.Substring(8); } if (text.EndsWith("(Clone)", StringComparison.OrdinalIgnoreCase)) { text = text.Substring(0, text.Length - 7); } text = text.Trim(); return text.Replace(" ", "").Replace("_", "").Replace("-", ""); } private static string GetDisplayEnemyName(string rawName) { string key = NormalizeEnemyName(rawName); if (KoreanEnemyNames.TryGetValue(key, out var value)) { return value; } if (string.IsNullOrEmpty(rawName)) { return "알 수 없는 몬스터"; } string text = rawName.Trim(); if (text.StartsWith("Enemy - ", StringComparison.OrdinalIgnoreCase)) { text = text.Substring(8); } if (text.EndsWith("(Clone)", StringComparison.OrdinalIgnoreCase)) { text = text.Substring(0, text.Length - 7); } return text.Trim(); } private static bool IsSpawned(EnemyParent enemy) { if (SpawnedField != null) { return (bool)SpawnedField.GetValue(enemy); } return false; } private static bool IsDyingOrDead(EnemyParent parent, bool isClient) { object? obj = ParentEnemyField?.GetValue(parent); Enemy val = (Enemy)((obj is Enemy) ? obj : null); EnemyHealth val2 = (EnemyHealth)(Object.op_Implicit((Object)(object)val) ? /*isinst with value type is only supported in some contexts*/: null); if (Object.op_Implicit((Object)(object)val2)) { object obj2 = HealthDeadField?.GetValue(val2); if (!(obj2 is bool) || !(bool)obj2) { obj2 = HealthDyingField?.GetValue(val2); if (!(obj2 is bool) || !(bool)obj2) { if (!isClient && HealthCurrentField?.GetValue(val2) is int num) { return num <= 0; } return false; } } return true; } return false; } private static bool CanAdjustRespawn() { if (!IsClient() && (Object)(object)RoundDirector.instance != (Object)null && ExtractionField != null) { return !(bool)ExtractionField.GetValue(RoundDirector.instance); } return false; } private string ReadLegacy(string key) { if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { return null; } bool flag = false; string[] array = File.ReadAllLines(((BaseUnityPlugin)this).Config.ConfigFilePath); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.StartsWith("[")) { flag = text == "[General]"; } else if (flag && !text.StartsWith("#")) { int num = text.IndexOf('='); if (num >= 0 && text.Substring(0, num).Trim() == key) { return text.Substring(num + 1).Trim(); } } } return null; } private float LegacyFloat(string key, float fallback, float min, float max) { if (!float.TryParse(ReadLegacy(key), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return fallback; } return Mathf.Clamp(result, min, max); } private void Awake() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown float num = LegacyFloat("리젠 가속 비율 (0: 가속 없음 / 1: 기본 가속)", LegacyFloat("ReductionScale", 0.5f, 0f, 1f), 0f, 1f); string text = ReadLegacy("Mode"); if (text == "KeepInitial") { num = 0f; } else if (text == "Vanilla") { num = 1f; } ReductionScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "리젠 가속 비율", num, new ConfigDescription("플레이어가 처치한 몬스터의 시간 경과 리젠 가속 비율입니다. 0이면 시간에 따른 가속이 없고, 0.5이면 원래 가속량의 절반, 1이면 원래 게임과 같습니다.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); EnableMinimumRespawn = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "최소 리젠 대기시간 사용", true, "켜짐: 플레이어가 처치한 몬스터에 최소 리젠 대기시간을 적용합니다. 꺼짐: 최소시간을 적용하지 않습니다. 기본값은 켜짐입니다."); MinimumRespawnSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "최소 리젠 대기시간", LegacyFloat("최소 리젠 대기시간 (0: 기본값 / 초 단위)", LegacyFloat("MinimumRespawnSeconds", 0f, 0f, 1800f), 0f, 1800f), new ConfigDescription("플레이어가 처치한 몬스터에 처음 지정하는 최소 리젠 대기시간(초)입니다. 0이면 제한하지 않습니다. 이후 소음이나 게임 이벤트로 더 짧아질 수 있습니다.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1800f), Array.Empty<object>())); NoiseReductionScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "소음 리젠 단축 비율", LegacyFloat("소음 리젠 단축 비율 (0: 단축 없음 / 1: 기본 단축)", 1f, 0f, 1f), new ConfigDescription("플레이어가 처치한 몬스터의 남은 리젠 대기시간을 소음 조사로 줄이는 비율입니다. 0이면 해당 단축을 막고, 0.5이면 절반만 줄고, 1이면 원래 게임과 같습니다.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); ShowRespawnTimer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "리젠 타이머 표시", false, "화면 왼쪽 위에 몬스터의 리젠 상태와 대기시간을 표시합니다. 비방장에서는 로컬에서 확인할 수 있는 상태와 시간만 표시합니다."); toggleTimerList = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "리젠 타이머 펼치기 키", new KeyboardShortcut((KeyCode)93, Array.Empty<KeyCode>()), "리젠 타이머가 켜져 있을 때 목록을 펼치거나 접는 단축키입니다."); harmony = new Harmony("com.respawnpacecontrol.mod"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Respawn Pace Control v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded (player kills only)."); } private void Update() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) EnemyDirector instance = EnemyDirector.instance; if (!ShowRespawnTimer.Value || !Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)GameManager.instance)) { hudDirector = null; hudExpanded = false; hudRows.Clear(); return; } float unscaledTime = Time.unscaledTime; if ((Object)(object)hudDirector != (Object)(object)instance) { hudDirector = instance; hudExpanded = false; nextTimerRefresh = unscaledTime; nextHudRefresh = unscaledTime; timerSamples.Clear(); } bool isClient = IsClient(); if (unscaledTime >= nextTimerRefresh) { nextTimerRefresh = unscaledTime + 1f; cachedEnemies = Object.FindObjectsByType<EnemyParent>((FindObjectsSortMode)0); ObserveClientTimers(isClient, unscaledTime); } if (unscaledTime >= nextHudRefresh) { nextHudRefresh = unscaledTime + 0.1f; RefreshHudRows(isClient, unscaledTime); } if (hudRows.Count > 4) { KeyboardShortcut value = toggleTimerList.Value; if (((KeyboardShortcut)(ref value)).IsDown() && SemiFunc.NoTextInputsActive()) { hudExpanded = !hudExpanded; } } } private static bool IsClient() { if (GameManager.Multiplayer()) { return !PhotonNetwork.IsMasterClient; } return false; } private void ObserveClientTimers(bool isClient, float now) { if (!isClient) { timerSamples.Clear(); return; } HashSet<int> hashSet = new HashSet<int>(); EnemyParent[] array = cachedEnemies; foreach (EnemyParent val in array) { if ((Object)(object)val == (Object)null) { continue; } int instanceID = ((Object)val).GetInstanceID(); hashSet.Add(instanceID); if (IsSpawned(val)) { timerSamples.Remove(instanceID); continue; } float despawnedTimer = val.DespawnedTimer; if (float.IsNaN(despawnedTimer) || float.IsInfinity(despawnedTimer) || despawnedTimer <= 0f) { timerSamples.Remove(instanceID); continue; } if (!timerSamples.TryGetValue(instanceID, out var value)) { timerSamples[instanceID] = new TimerSample { Previous = despawnedTimer }; continue; } if (despawnedTimer < value.Previous - 0.01f) { value.ObservedChange = true; value.LastObservedAt = now; } else if (despawnedTimer > value.Previous + 0.01f) { value.ObservedChange = false; } value.Previous = despawnedTimer; } List<int> list = new List<int>(); foreach (KeyValuePair<int, TimerSample> timerSample in timerSamples) { if (!hashSet.Contains(timerSample.Key)) { list.Add(timerSample.Key); } } foreach (int item in list) { timerSamples.Remove(item); } } private void RefreshHudRows(bool isClient, float now) { hudRows.Clear(); EnemyParent[] array = cachedEnemies; foreach (EnemyParent val in array) { if (Object.op_Implicit((Object)(object)val)) { float seconds; EnemyHudPhase hudPhase = GetHudPhase(val, isClient, now, out seconds); hudRows.Add(new EnemyHudRow(((Object)val).GetInstanceID(), GetDisplayEnemyName(((Object)val).name), hudPhase, seconds)); } } hudRows.Sort(CompareHudRows); } private static int CompareHudRows(EnemyHudRow left, EnemyHudRow right) { int phase = (int)left.Phase; int num = phase.CompareTo((int)right.Phase); if (num != 0) { return num; } if (left.Phase == EnemyHudPhase.Countdown) { int num2 = left.Seconds.CompareTo(right.Seconds); if (num2 != 0) { return num2; } } return left.Id.CompareTo(right.Id); } private EnemyHudPhase GetHudPhase(EnemyParent enemy, bool isClient, float now, out float seconds) { seconds = 0f; if (SpawnedField == null) { return EnemyHudPhase.Unknown; } if (IsSpawned(enemy)) { if (!Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !LevelGenerator.Instance.Generated || !Object.op_Implicit((Object)(object)enemy.EnableObject) || !enemy.EnableObject.activeInHierarchy || IsDyingOrDead(enemy, isClient)) { return EnemyHudPhase.Unknown; } return EnemyHudPhase.Spawned; } seconds = enemy.DespawnedTimer; if (float.IsNaN(seconds) || float.IsInfinity(seconds)) { return EnemyHudPhase.Unknown; } if (isClient) { if (seconds <= 0f || !timerSamples.TryGetValue(((Object)enemy).GetInstanceID(), out var value) || !value.ObservedChange || now - value.LastObservedAt > 2.5f) { return EnemyHudPhase.Unknown; } } else { EnemyHudStates.TryGetValue(enemy, out var value2); if (seconds <= 0f || (value2 != null && value2.Phase == EnemyHudPhase.WaitingForSpawn)) { return EnemyHudPhase.WaitingForSpawn; } if (value2 != null && value2.Phase == EnemyHudPhase.DespawnedAlive) { return EnemyHudPhase.DespawnedAlive; } } return EnemyHudPhase.Countdown; } private static string FormatRespawnStatus(EnemyHudRow row) { switch (row.Phase) { case EnemyHudPhase.Spawned: return "리젠 완료"; case EnemyHudPhase.WaitingForSpawn: return "리젠 대기 중"; case EnemyHudPhase.DespawnedAlive: return "디스폰 중"; case EnemyHudPhase.Countdown: { int num = Mathf.CeilToInt(row.Seconds); return (num / 60).ToString("00") + ":" + (num % 60).ToString("00"); } default: return "--:--"; } } private static Color HudStatusColor(EnemyHudPhase phase) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) return (Color)(phase switch { EnemyHudPhase.Spawned => Color32.op_Implicit(new Color32((byte)171, (byte)224, (byte)186, byte.MaxValue)), EnemyHudPhase.WaitingForSpawn => Color32.op_Implicit(new Color32((byte)237, (byte)201, (byte)131, byte.MaxValue)), EnemyHudPhase.DespawnedAlive => Color32.op_Implicit(new Color32((byte)185, (byte)194, (byte)200, byte.MaxValue)), EnemyHudPhase.Countdown => Color32.op_Implicit(new Color32((byte)232, (byte)241, (byte)245, byte.MaxValue)), _ => Color32.op_Implicit(new Color32((byte)153, (byte)166, (byte)174, byte.MaxValue)), }); } private void OnGUI() { //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_009b: 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_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: Expected O, but got Unknown //IL_00c9: 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_00da: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) if (!ShowRespawnTimer.Value || !Object.op_Implicit((Object)(object)hudDirector) || (Object)(object)hudDirector != (Object)(object)EnemyDirector.instance || hudRows.Count == 0 || (int)Event.current.type != 7) { return; } if (timerTitleStyle == null) { timerLineStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, alignment = (TextAnchor)3, clipping = (TextClipping)1 }; timerLineStyle.normal.textColor = Color32.op_Implicit(new Color32((byte)235, (byte)239, (byte)239, byte.MaxValue)); timerTitleStyle = new GUIStyle(timerLineStyle) { fontStyle = (FontStyle)1 }; timerStatusStyle = new GUIStyle(timerLineStyle) { alignment = (TextAnchor)5 }; timerHintStyle = new GUIStyle(timerStatusStyle) { fontSize = 11 }; timerHintStyle.normal.textColor = Color32.op_Implicit(new Color32((byte)174, (byte)188, (byte)194, byte.MaxValue)); } float num = Mathf.Min((float)Screen.width / 1920f, (float)Screen.height / 1080f); float num2 = 140f * num; float num3 = 320f * num; float num4 = 578f; float num5 = Mathf.Min(Mathf.Max(num, 0.82f), ((float)Screen.height - num3 - 10f) / num4); Matrix4x4 matrix = GUI.matrix; try { GUI.matrix = matrix * Matrix4x4.TRS(new Vector3(num2, num3, 0f), Quaternion.identity, new Vector3(num5, num5, 1f)); DrawHudList(); } finally { GUI.matrix = matrix; } } private unsafe void DrawHudList() { //IL_005a: 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_0077: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Min(hudRows.Count, hudExpanded ? 24 : 4); int num2 = hudRows.Count - num; Rect val = new Rect(0f, 0f, 246f, 28f + 22f * (float)num + ((num2 > 0) ? 22f : 8f)); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, Color32.op_Implicit(new Color32((byte)13, (byte)23, (byte)28, (byte)202)), 0f, 6f); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, Color32.op_Implicit(new Color32((byte)154, (byte)179, (byte)188, (byte)58)), 1f, 6f); float num3 = 226f; GUI.Label(new Rect(10f, 3f, 94f, 23f), "리젠 타이머", timerTitleStyle); KeyboardShortcut value = toggleTimerList.Value; if (hudRows.Count > 4 && (int)((KeyboardShortcut)(ref value)).MainKey != 0) { string text = (hudExpanded ? "접기" : "펼치기"); string text2 = ((object)(*(KeyboardShortcut*)(&value))/*cast due to .constrained prefix*/).ToString().Replace("RightBracket", "]").Replace("LeftBracket", "["); GUI.Label(new Rect(104f, 3f, num3 - 94f, 23f), text2 + " " + text, timerHintStyle); } float num4 = 28f; GUI.DrawTexture(new Rect(10f, num4 - 1f, num3, 1f), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, Color32.op_Implicit(new Color32((byte)154, (byte)179, (byte)188, (byte)52)), 0f, 0f); for (int i = 0; i < num; i++) { EnemyHudRow row = hudRows[i]; GUI.Label(new Rect(10f, num4, num3 - 91f, 22f), row.Name, timerLineStyle); timerStatusStyle.normal.textColor = HudStatusColor(row.Phase); GUI.Label(new Rect(10f + num3 - 87f, num4, 87f, 22f), FormatRespawnStatus(row), timerStatusStyle); num4 += 22f; } if (num2 > 0) { GUI.Label(new Rect(10f, num4, num3, 19f), $"+ {num2}개", timerHintStyle); } } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } } private static EnemyParent GetEnemyParent(EnemyHealth health) { object? obj = HealthEnemyField?.GetValue(health); Enemy val = (Enemy)((obj is Enemy) ? obj : null); if (!Object.op_Implicit((Object)(object)val)) { return null; } object? obj2 = EnemyParentField?.GetValue(val); return (EnemyParent)((obj2 is EnemyParent) ? obj2 : null); } private static void ApplyDamage(EnemyHealth health, int damage, Vector3 direction, bool fromPlayer) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) EnemyHealth val = playerDamageTarget; playerDamageTarget = (fromPlayer ? health : null); try { health.Hurt(damage, direction); } finally { playerDamageTarget = val; } } private static IEnumerable<CodeInstruction> ReplaceInstruction(IEnumerable<CodeInstruction> instructions, MemberInfo original, MethodInfo replacement, bool passInstance, string target) { bool matched = false; foreach (CodeInstruction instruction in instructions) { bool flag = ((original is FieldInfo) ? (instruction.opcode == OpCodes.Ldfld) : (instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt)); if (original != null && replacement != null && flag && object.Equals(instruction.operand, original)) { if (passInstance) { CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null); CodeInstructionExtensions.MoveLabelsTo(instruction, val); val.blocks.AddRange(instruction.blocks.FindAll((ExceptionBlock block) => (int)block.blockType != 5)); instruction.blocks.RemoveAll((ExceptionBlock block) => (int)block.blockType != 5); yield return val; } instruction.opcode = OpCodes.Call; instruction.operand = replacement; matched = true; } yield return instruction; } if (!matched) { Logger.CreateLogSource("Respawn Pace Control").LogWarning((object)(target + ": expected instruction not found in this game version.")); } } } }