Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of PSYCHOPATH v1.0.4
PSYCHOPATH.Il2CPP.dll
Decompiled 3 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using HarmonyLib; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFishNet.Managing; using Il2CppFishNet.Object; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.AvatarFramework.Animation; using Il2CppScheduleOne.AvatarFramework.Emotions; using Il2CppScheduleOne.Combat; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Dialogue; using Il2CppScheduleOne.Dragging; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.Employees; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.Graffiti; using Il2CppScheduleOne.Interaction; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Law; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.Messaging; using Il2CppScheduleOne.Money; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.NPCs.CharacterClasses; using Il2CppScheduleOne.NPCs.Relation; using Il2CppScheduleOne.NPCs.Responses; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.PlayerScripts.Health; using Il2CppScheduleOne.Police; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Compass; using Il2CppScheduleOne.UI.Phone; using Il2CppScheduleOne.UI.Phone.Map; using Il2CppScheduleOne.UI.Phone.Messages; using Il2CppScheduleOne.VoiceOver; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using PSYCHOPATH; using S1API.Entities; using S1API.Entities.Appearances.BodyLayerFields; using S1API.Entities.Appearances.CustomizationFields; using S1API.Entities.Appearances.FaceLayerFields; using S1API.Internal.Abstraction; using S1API.Quests; using S1API.Saveables; using UnityEngine; using UnityEngine.AI; 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: AssemblyTitle("PSYCHOPATH")] [assembly: AssemblyDescription("Schedule I MelonLoader Mod")] [assembly: AssemblyCompany("Virtunerd")] [assembly: AssemblyProduct("PSYCHOPATH")] [assembly: AssemblyCopyright("Copyright (c) Virtunerd 2026")] [assembly: ComVisible(false)] [assembly: Guid("6e8aa86d-a6e0-4576-9586-3d7e99bc60a6")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: MelonInfo(typeof(PSYCHOPATHMod), "PSYCHOPATH", "1.0.4", "Virtunerd", null)] [assembly: MelonGame(null, "Schedule I")] [assembly: AssemblyFileVersion("1.0.4")] [assembly: AssemblyInformationalVersion("1.0.4")] [assembly: AssemblyVersion("1.0.4.0")] namespace PSYCHOPATH; internal static class BodyDragManager { private static readonly Vector3 ZoneSize = new Vector3(2.4f, 1.4f, 2.4f); private const float HideDistance = 110f; private const float Margin = 0.5f; private const float ReEnsureEvery = 1f; private const float WaterFailSeconds = 6f; private static NPC _body; private static Vector3 _deathPos; private static bool _active; private static float _ensureTimer; private static float _unreachableTimer; private static readonly HashSet<int> _disposed = new HashSet<int>(); public static bool Active => _active; public static bool Failed { get; private set; } public static void Reset() { _active = false; Failed = false; _body = null; _ensureTimer = 0f; _unreachableTimer = 0f; _disposed.Clear(); try { HideZone.Remove(); } catch { } } public static bool IsDisposed(NPC npc) { if ((Object)(object)npc == (Object)null) { return false; } try { return _disposed.Contains(((Object)npc).GetInstanceID()); } catch { return false; } } public static bool IsActiveTarget(NPC npc) { if (!_active || (Object)(object)npc == (Object)null) { return false; } try { NPC body = _body; if ((Object)(object)body != (Object)null) { try { if (((Il2CppObjectBase)body).Pointer == ((Il2CppObjectBase)npc).Pointer) { return true; } } catch { } } return NpcIdentity.Matches(npc, PsychoState.CurrentTargetName); } catch { return false; } } public unsafe static void Begin(NPC npc, Vector3 deathPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) _body = npc; _deathPos = deathPos; _active = true; Failed = false; _unreachableTimer = 0f; _ensureTimer = 1f; EnsureDraggable(npc); PsychoState.HidePos = ChooseHideSpot(deathPos); EnsureZone(); Vector3 hidePos = PsychoState.HidePos; PPLog.Debug("Hide objective: drag the body to " + ((object)(*(Vector3*)(&hidePos))/*cast due to .constrained prefix*/).ToString()); } public static void Resume() { //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) _active = true; Failed = false; _body = null; _deathPos = PsychoState.MarkedPos; _ensureTimer = 1f; _unreachableTimer = 0f; EnsureZone(); } public static void Cancel() { _active = false; Failed = false; _body = null; try { HideZone.Remove(); } catch { } } public static bool Tick(float dt) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) if (!_active) { return false; } _ensureTimer -= dt; if (_ensureTimer <= 0f) { _ensureTimer = 1f; if (!HideZone.Active) { EnsureZone(); } EnsureDraggable(ResolveBody()); } if (!HideZone.Active) { return false; } if (!TryBodyPos(out var pos)) { return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(pos, ref val, 2.5f, -1) || pos.y < ((NavMeshHit)(ref val)).position.y - 1.5f) { _unreachableTimer += dt; if (_unreachableTimer >= 6f) { _active = false; Failed = true; PPLog.Debug("Drag body unreachable (water/void) for " + 6f + "s -> hide FAILED."); return false; } } else { _unreachableTimer = 0f; } if (HideZone.Contains(pos, 0.5f)) { DisposeBody(); HideZone.Remove(); _active = false; return true; } return false; } private static void EnsureZone() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PsychoState.HidePos; if (val == Vector3.zero) { val = (PsychoState.HidePos = ChooseHideSpot(_deathPos)); } Color color = ((PsychoState.CurrentKill == KillType.Altar) ? HideZone.AltarColor : HideZone.HideColor); HideZone.Spawn(val, ZoneSize, color); } private static NPC ResolveBody() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) NPC body = _body; try { if ((Object)(object)body != (Object)null && (Object)(object)((Component)body).gameObject != (Object)null) { return body; } } catch { } body = FindTargetDeadBody(_deathPos); if ((Object)(object)body != (Object)null) { _body = body; } return body; } private static bool TryBodyPos(out Vector3 pos) { //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) pos = Vector3.zero; NPC val = ResolveBody(); if ((Object)(object)val == (Object)null) { return false; } try { Avatar avatar = val.Avatar; if ((Object)(object)avatar != (Object)null) { pos = avatar.CenterPoint; return true; } } catch { } try { pos = ((Component)val).transform.position; return true; } catch { } return false; } private static void DisposeBody() { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) NPC val = ResolveBody(); try { Draggable val2 = (((Object)(object)val != (Object)null && (Object)(object)val.Movement != (Object)null) ? val.Movement.RagdollDraggable : null); if ((Object)(object)val2 != (Object)null) { val2.StopDragging(); } } catch { } try { DragManager instance = NetworkSingleton<DragManager>.Instance; if ((Object)(object)instance != (Object)null && instance.IsDragging) { instance.StopDragging(Vector3.zero); } } catch { } if ((Object)(object)val == (Object)null) { return; } try { _disposed.Add(((Object)val).GetInstanceID()); } catch { } if (PsychoState.CurrentKill == KillType.Altar) { try { KillRegistry.RecordDead(val, PsychoState.HidePos); } catch { } try { NotifyHelper.Banner("Left at Zahir's mark — they will be FOUND DEAD.", 5f); } catch { } PPLog.Debug("Body delivered to the altar — left (found dead)."); return; } try { val.SetVisible_Networked(false); } catch { } try { KillRegistry.RecordMissing(val, PsychoState.HidePos); } catch { } try { NotifyHelper.Banner("The body vanishes into the dark — they'll be reported MISSING.", 5f); } catch { } PPLog.Debug("Body hidden in the zone — disposed."); } private static void EnsureDraggable(NPC npc) { try { if ((Object)(object)npc == (Object)null) { return; } NPCMovement movement = npc.Movement; if ((Object)(object)movement != (Object)null) { try { movement.SetRagdollDraggable(true); } catch { } } Avatar avatar = npc.Avatar; Il2CppReferenceArray<Rigidbody> val = (((Object)(object)avatar != (Object)null) ? avatar.RagdollRBs : null); if (val == null) { return; } for (int i = 0; i < ((Il2CppArrayBase<Rigidbody>)(object)val).Length; i++) { try { if ((Object)(object)((Il2CppArrayBase<Rigidbody>)(object)val)[i] != (Object)null) { ((Il2CppArrayBase<Rigidbody>)(object)val)[i].isKinematic = false; } } catch { } } } catch (Exception ex) { PPLog.Warn("BodyDragManager.EnsureDraggable: " + ex.Message); } } private static Vector3 ChooseHideSpot(Vector3 deathPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_005e: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_00c5: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) Vector3 val = AwayDir(deathPos); float[] array = new float[4] { 110f, 88f, 66f, 44f }; float[] array2 = new float[10] { 0f, 30f, -30f, 60f, -60f, 90f, -90f, 135f, -135f, 180f }; Vector3 result = Vector3.zero; float num = -1f; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < array2.Length; j++) { Vector3 val2 = Quaternion.Euler(0f, array2[j], 0f) * val; Vector3 val3 = deathPos + val2 * array[i]; if (!GroundSnap(val3, out var hit)) { hit = val3; } if (Reachable(hit, out var onMesh) && HasNavPath(deathPos, onMesh) && !IsEnclosed(onMesh)) { Vector3 val4 = onMesh - deathPos; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude > num) { num = sqrMagnitude; result = onMesh; } } } } if (num > 0f) { return result; } Vector3 anchor = deathPos + val * 6f; if (GroundSnap(anchor, out var hit2) && Reachable(hit2, out var onMesh2)) { return onMesh2; } return deathPos; } private static Vector3 AwayDir(Vector3 deathPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b0: 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_006b: 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) Vector3 result = Vector3.forward; try { NPC val = FindNearestLivingNpc(deathPos, 30f); Vector3 val2 = Vector3.zero; bool flag = false; if ((Object)(object)val != (Object)null) { try { val2 = ((Component)val).transform.position; flag = true; } catch { } } if (!flag) { try { Player local = Player.Local; if ((Object)(object)local != (Object)null) { val2 = ((Component)local).transform.position; flag = true; } } catch { } } if (flag) { Vector3 val3 = deathPos - val2; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude > 0.01f) { result = ((Vector3)(ref val3)).normalized; } } } catch { } return result; } private static bool GroundSnap(Vector3 anchor, out Vector3 hit) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { return GroundGraffiti.TryGroundSnap(anchor, out hit); } catch { hit = anchor; return false; } } private static bool Reachable(Vector3 point, out Vector3 onMesh) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) onMesh = point; try { NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(point, ref val, 3f, -1)) { onMesh = ((NavMeshHit)(ref val)).position; return true; } } catch { } return false; } private static bool IsEnclosed(Vector3 point) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) try { if (Physics.Raycast(point + Vector3.up * 0.5f, Vector3.up, 8f, -1, (QueryTriggerInteraction)1)) { return true; } Vector3 val = point + Vector3.up * 0.6f; if (Physics.Raycast(val, Vector3.forward, 1.6f, -1, (QueryTriggerInteraction)1)) { return true; } if (Physics.Raycast(val, Vector3.back, 1.6f, -1, (QueryTriggerInteraction)1)) { return true; } if (Physics.Raycast(val, Vector3.right, 1.6f, -1, (QueryTriggerInteraction)1)) { return true; } if (Physics.Raycast(val, Vector3.left, 1.6f, -1, (QueryTriggerInteraction)1)) { return true; } } catch { } return false; } private static bool HasNavPath(Vector3 a, Vector3 b) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 try { NavMeshPath val = new NavMeshPath(); if (NavMesh.CalculatePath(a, b, -1, val)) { return (int)val.status == 0; } } catch { } return false; } private static NPC FindTargetDeadBody(Vector3 pos) { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) string currentTargetName = PsychoState.CurrentTargetName; NPC result = null; float num = float.MaxValue; try { List<NPC> nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null) { return null; } for (int i = 0; i < nPCRegistry.Count; i++) { NPC val = nPCRegistry[i]; if ((Object)(object)val == (Object)null || ZahirNPC.IsZahir(val) || IsDisposed(val)) { continue; } bool flag = false; try { flag = (Object)(object)val.Health != (Object)null && val.Health.IsDead; } catch { } if (!flag || (!string.IsNullOrEmpty(currentTargetName) && !NpcIdentity.Matches(val, currentTargetName))) { continue; } Vector3 val2; try { Avatar avatar = val.Avatar; val2 = (((Object)(object)avatar != (Object)null) ? avatar.CenterPoint : ((Component)val).transform.position); } catch { try { val2 = ((Component)val).transform.position; goto end_IL_00fb; } catch { } continue; end_IL_00fb:; } Vector3 val3 = val2 - pos; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } catch { } return result; } private static NPC FindNearestLivingNpc(Vector3 pos, float maxDist) { //IL_00a7: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) NPC result = null; float num = maxDist * maxDist; try { List<NPC> nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null) { return null; } for (int i = 0; i < nPCRegistry.Count; i++) { NPC val = nPCRegistry[i]; if ((Object)(object)val == (Object)null || ZahirNPC.IsZahir(val)) { continue; } bool flag = false; try { flag = val.IsConscious && ((Object)(object)val.Health == (Object)null || !val.Health.IsDead); } catch { } if (flag) { Vector3 position; try { position = ((Component)val).transform.position; } catch { continue; } Vector3 val2 = position - pos; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } } catch { } return result; } } internal static class BrandItem { public const string BrandId = "psychopath_brand"; private const string CloneSource = "bomb"; private static StorableItemDefinition _def; public static void Ensure() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Registry.GetItem("psychopath_brand") != (Object)null) { return; } ItemDefinition val = null; try { val = Registry.GetItem("bomb"); } catch { } StorableItemDefinition val2 = (((Object)(object)val != (Object)null) ? ((Il2CppObjectBase)val).TryCast<StorableItemDefinition>() : null); if ((Object)(object)val2 == (Object)null) { PPLog.Warn("BrandItem: clone source 'bomb' not found."); return; } StorableItemDefinition val3 = Object.Instantiate<StorableItemDefinition>(val2); Object.DontDestroyOnLoad((Object)(object)val3); ((Object)val3).hideFlags = (HideFlags)(((Object)val3).hideFlags | 0x20); ((Object)val3).name = "PSYCHOPATH_BrandItem"; try { ((BaseItemDefinition)val3).ID = "psychopath_brand"; } catch { } try { ((BaseItemDefinition)val3).Name = "Zahir's Curse"; } catch { } try { ((BaseItemDefinition)val3).Description = "A cursed mark. Press it onto the one Zahir named — and curse them."; } catch { } try { ((ItemDefinition)val3).CustomItemUI = null; } catch { } try { ((ItemDefinition)val3).Equippable = null; } catch { } try { val3.BasePurchasePrice = 0f; val3.ResellMultiplier = 0f; } catch { } try { Sprite val4 = IconLoader.Load("cursed_item.png"); if ((Object)(object)val4 != (Object)null) { ((BaseItemDefinition)val3).Icon = val4; } } catch { } try { Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)val3); } catch (Exception ex) { PPLog.Warn("BrandItem AddToRegistry: " + ex.Message); } _def = val3; PPLog.Debug("BrandItem registered ('psychopath_brand')."); } catch (Exception ex2) { PPLog.Warn("BrandItem.Ensure: " + ex2.Message); } } public static bool GiveToPlayer() { try { Ensure(); if (HasBrand()) { return true; } ItemDefinition item = Registry.GetItem("psychopath_brand"); if ((Object)(object)item == (Object)null) { return false; } PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance; if ((Object)(object)instance == (Object)null) { return false; } ItemInstance val = null; try { val = item.GetDefaultInstance(1); } catch { } if (val == null) { return false; } bool flag = false; try { flag = instance.CanItemFitInInventory(val, 1); } catch { } if (!flag) { return false; } instance.AddItemToInventory(val); LockBrandSlot(); PPLog.Debug("Gave Zahir's Brand to the player."); return true; } catch (Exception ex) { PPLog.Warn("BrandItem.GiveToPlayer: " + ex.Message); return false; } } private static void LockBrandSlot() { try { PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance; if ((Object)(object)instance == (Object)null) { return; } List<HotbarSlot> hotbarSlots = instance.hotbarSlots; if (hotbarSlots == null) { return; } for (int i = 0; i < hotbarSlots.Count; i++) { HotbarSlot val = hotbarSlots[i]; if (val == null) { continue; } ItemInstance itemInstance = ((ItemSlot)val).ItemInstance; if (itemInstance == null) { continue; } ItemDefinition definition = itemInstance.Definition; if (!((Object)(object)definition == (Object)null) && ((BaseItemDefinition)definition).ID == "psychopath_brand") { try { ((ItemSlot)val).SetIsRemovalLocked(true); } catch { } } } } catch { } } public static bool HasBrand() { return ForEachBrandSlot(remove: false); } public static void RemoveFromPlayer() { if (ForEachBrandSlot(remove: true)) { PPLog.Debug("Removed Zahir's Brand from the player."); } } private static bool ForEachBrandSlot(bool remove) { bool result = false; try { PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance; if ((Object)(object)instance == (Object)null) { return false; } List<HotbarSlot> hotbarSlots = instance.hotbarSlots; if (hotbarSlots == null) { return false; } for (int i = 0; i < hotbarSlots.Count; i++) { HotbarSlot val = hotbarSlots[i]; if (val == null) { continue; } ItemInstance itemInstance = ((ItemSlot)val).ItemInstance; if (itemInstance == null) { continue; } ItemDefinition definition = itemInstance.Definition; if (!((Object)(object)definition == (Object)null) && ((BaseItemDefinition)definition).ID == "psychopath_brand") { result = true; if (!remove) { return true; } try { ((ItemSlot)val).SetIsRemovalLocked(false); } catch { } try { ((ItemSlot)val).ClearStoredInstance(false); } catch { } } } } catch (Exception ex) { PPLog.Debug("BrandItem.ForEachBrandSlot: " + ex.Message); } return result; } } internal static class CurfewModCompat { private static bool _checked; private static bool _foreign; public static bool ForeignPatchesActive { get { if (!_checked) { Detect(); } return _foreign; } } public static void Reset() { _checked = false; _foreign = false; } private static void Detect() { _checked = true; _foreign = false; try { if (HasForeignPatch(typeof(VMSBoard), "SetText") || HasForeignPatch(typeof(CurfewManager), "OnUncappedMinPass")) { _foreign = true; } } catch { } } private static bool HasForeignPatch(Type type, string methodName) { try { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo == null || methodInfo.Name != methodName) { continue; } Patches val = null; try { val = Harmony.GetPatchInfo((MethodBase)methodInfo); } catch { } if (val != null) { int num = ((val.Prefixes != null) ? val.Prefixes.Count : 0) + ((val.Postfixes != null) ? val.Postfixes.Count : 0) + ((val.Transpilers != null) ? val.Transpilers.Count : 0); if (num > 0) { return true; } } } } catch { } return false; } } internal static class CurfewNews { private enum NewsKind { FoundDead, Missing } private struct Pending { public string Name; public NewsKind Kind; public float At; public long Seq; } private struct PanicState { public NPC Npc; public NPCMovement Mv; public float OldMul; public float Expiry; } private const float BlinkSeconds = 3f; private const float BlinkHz = 2.5f; private const float PanicRange = 25f; private const float PanicSeconds = 60f; private const float SpeedMult = 1.6f; private const string PanicLabel = "PSYCHOPATH_panic"; private static readonly Color NewsRed = new Color(1f, 0.18f, 0.18f); private static readonly Color NewsYellow = new Color(1f, 0.85f, 0.1f); public static float NewsDelay = 10f; private static bool _flashing; private static bool _contested; private static float _flashStart; private static string _flashMsg; private static Color _flashColor; private static readonly Dictionary<int, Color> _origColors = new Dictionary<int, Color>(); private static string _noticeName; private static bool _noticeFoundDead; private static bool _hasNotice; private static readonly List<Pending> _pending = new List<Pending>(); private static long _seq; private static long _lastAppliedSeq = -1L; private static readonly Dictionary<int, PanicState> _panicked = new Dictionary<int, PanicState>(); private static string _scaredEmotion; private static float _emoteReassert; public static void Reset() { _flashing = false; _contested = false; _flashMsg = null; _origColors.Clear(); _pending.Clear(); RevertAllPanic(); try { CurfewModCompat.Reset(); } catch { } } public static string PackNotice() { try { return (_hasNotice && !string.IsNullOrEmpty(_noticeName)) ? (_noticeName + "|" + (_noticeFoundDead ? "D" : "M")) : ""; } catch { return ""; } } public static void LoadNotice(string packed) { try { _hasNotice = false; _noticeName = null; _noticeFoundDead = false; if (string.IsNullOrEmpty(packed)) { return; } if (packed.IndexOf('|') >= 0) { int num = packed.LastIndexOf('|'); _noticeName = packed.Substring(0, num); _noticeFoundDead = packed.Substring(num + 1).Trim().ToUpperInvariant() .StartsWith("D"); } else { string[] array = packed.Split(';'); for (int num2 = array.Length - 1; num2 >= 0; num2--) { if (!string.IsNullOrEmpty(array[num2])) { _noticeName = array[num2]; break; } } _noticeFoundDead = false; } _hasNotice = !string.IsNullOrEmpty(_noticeName); } catch { } } public static void ClearNotice() { _hasNotice = false; _noticeName = null; _noticeFoundDead = false; _flashing = false; try { RestoreBoardColors(); } catch { } } public static void ScheduleFoundDead(string name, float delaySeconds) { try { _pending.Add(new Pending { Name = name, Kind = NewsKind.FoundDead, At = Time.time + delaySeconds, Seq = _seq++ }); } catch { } } public static void ScheduleMissing(string name, float delaySeconds) { try { _pending.Add(new Pending { Name = name, Kind = NewsKind.Missing, At = Time.time + delaySeconds, Seq = _seq++ }); } catch { } } private static void FoundDead(string name) { SetNotice(name, foundDead: true); Announce(playSfx: true); } private static void Missing(string name, bool playSfx = true) { SetNotice(name, foundDead: false); Announce(playSfx); } private static void SetNotice(string name, bool foundDead) { _noticeName = name; _noticeFoundDead = foundDead; _hasNotice = true; } private static string NoticeText() { return _noticeFoundDead ? ("<b>NEWS FLASH</b>\n" + Up(_noticeName) + "\nFOUND DEAD") : ("<b>ATTENTION:</b>\n" + Up(_noticeName) + "\nMISSING"); } private static void Announce(bool playSfx) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (_hasNotice) { string sfx = ((!playSfx) ? null : (_noticeFoundDead ? "crows-sound-effect" : "murder warning")); TriggerNews(NoticeText(), sfx, _noticeFoundDead ? NewsYellow : NewsRed); } } private static void TriggerNews(string text, string sfx, Color color) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) try { _contested = CurfewModCompat.ForeignPatchesActive; } catch { _contested = false; } CaptureBoardColors(); _flashMsg = text; _flashColor = color; _flashStart = Time.time; _flashing = true; try { ZahirVoice.PlaySfx(sfx); } catch { } PanicNearSigns(); PPLog.Debug("Curfew news: " + text.Replace("\n", " ") + (_contested ? " [contested]" : "")); } public static void Tick() { if (_pending.Count > 0) { float time = Time.time; int num = 0; for (int i = 0; i < _pending.Count; i++) { Pending value = _pending[i]; if (time >= value.At) { if (value.Seq >= _lastAppliedSeq) { _lastAppliedSeq = value.Seq; if (value.Kind == NewsKind.FoundDead) { FoundDead(value.Name); } else { Missing(value.Name); } } } else { _pending[num++] = value; } } if (num < _pending.Count) { _pending.RemoveRange(num, _pending.Count - num); } } if (_hasNotice && !_flashing && NetworkSingleton<CurfewManager>.InstanceExists) { Announce(playSfx: false); } if (_flashing) { ReassertBoards(); } if (_panicked.Count > 0) { RevertExpiredPanic(); } } public static void ReassertEarly() { if (_flashing && _contested) { ReassertBoards(); } } private static void ReassertBoards() { //IL_0046: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (_flashing) { float num = Time.time - _flashStart; SetAllBoards(color: (!(num < 3f)) ? _flashColor : (((int)(Time.time * 2.5f) % 2 == 0) ? _flashColor : Color.white), msg: _flashMsg); } } private static void SetAllBoards(string msg, Color color) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkSingleton<CurfewManager>.InstanceExists) { return; } CurfewManager instance = NetworkSingleton<CurfewManager>.Instance; Il2CppReferenceArray<VMSBoard> val = (((Object)(object)instance != (Object)null) ? instance.VMSBoards : null); if (val == null) { return; } for (int i = 0; i < ((Il2CppArrayBase<VMSBoard>)(object)val).Length; i++) { VMSBoard val2 = null; try { val2 = ((Il2CppArrayBase<VMSBoard>)(object)val)[i]; } catch { } if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.Label == (Object)null)) { try { TMP_Text val3 = ((Il2CppObjectBase)val2.Label).Cast<TMP_Text>(); val3.text = msg; ((Graphic)val3).color = color; } catch { } } } } catch (Exception ex) { PPLog.Debug("CurfewNews.SetAllBoards: " + ex.Message); } } private static void CaptureBoardColors() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) try { if (_origColors.Count > 0 || !NetworkSingleton<CurfewManager>.InstanceExists) { return; } CurfewManager instance = NetworkSingleton<CurfewManager>.Instance; Il2CppReferenceArray<VMSBoard> val = ((instance != null) ? instance.VMSBoards : null); if (val == null) { return; } for (int i = 0; i < ((Il2CppArrayBase<VMSBoard>)(object)val).Length; i++) { VMSBoard val2 = null; try { val2 = ((Il2CppArrayBase<VMSBoard>)(object)val)[i]; } catch { } if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.Label == (Object)null)) { try { _origColors[((Object)val2).GetInstanceID()] = ((Graphic)((Il2CppObjectBase)val2.Label).Cast<TMP_Text>()).color; } catch { } } } } catch { } } private static void RestoreBoardColors() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkSingleton<CurfewManager>.InstanceExists) { _origColors.Clear(); return; } CurfewManager instance = NetworkSingleton<CurfewManager>.Instance; Il2CppReferenceArray<VMSBoard> val = ((instance != null) ? instance.VMSBoards : null); if (val == null) { _origColors.Clear(); return; } for (int i = 0; i < ((Il2CppArrayBase<VMSBoard>)(object)val).Length; i++) { VMSBoard val2 = null; try { val2 = ((Il2CppArrayBase<VMSBoard>)(object)val)[i]; } catch { } if ((Object)(object)val2 == (Object)null || (Object)(object)val2.Label == (Object)null) { continue; } try { if (_origColors.TryGetValue(((Object)val2).GetInstanceID(), out var value)) { ((Graphic)((Il2CppObjectBase)val2.Label).Cast<TMP_Text>()).color = value; } } catch { } } } catch { } _origColors.Clear(); } private static List<Vector3> BoardPositions() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); try { if (!NetworkSingleton<CurfewManager>.InstanceExists) { return list; } CurfewManager instance = NetworkSingleton<CurfewManager>.Instance; Il2CppReferenceArray<VMSBoard> val = ((instance != null) ? instance.VMSBoards : null); if (val == null) { return list; } for (int i = 0; i < ((Il2CppArrayBase<VMSBoard>)(object)val).Length; i++) { VMSBoard val2 = null; try { val2 = ((Il2CppArrayBase<VMSBoard>)(object)val)[i]; } catch { } if (!((Object)(object)val2 == (Object)null)) { try { list.Add(((Component)val2).transform.position); } catch { } } } } catch { } return list; } private static void PanicNearSigns() { try { List<NPC> nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null) { return; } if (_scaredEmotion == null) { try { _scaredEmotion = DefaultEmotions.Scared; } catch { } } int count = nPCRegistry.Count; float expiry = Time.time + 60f; for (int i = 0; i < count; i++) { NPC val; try { val = nPCRegistry[i]; } catch { continue; } if ((Object)(object)val == (Object)null || ZahirNPC.IsZahir(val)) { continue; } try { if ((Object)(object)((Il2CppObjectBase)val).TryCast<Employee>() != (Object)null) { continue; } } catch { } bool flag = false; try { flag = val.IsConscious && ((Object)(object)val.Health == (Object)null || !val.Health.IsDead); } catch { } if (flag) { int instanceID; try { instanceID = ((Object)val).GetInstanceID(); } catch { continue; } if (_panicked.ContainsKey(instanceID)) { PanicState value = _panicked[instanceID]; value.Expiry = expiry; _panicked[instanceID] = value; } else { Panic(val, instanceID, expiry); } } } } catch (Exception ex) { PPLog.Debug("CurfewNews.PanicNearSigns: " + ex.Message); } } private static void Panic(NPC w, int id, float expiry) { NPCMovement val = null; float num = 1f; try { val = w.Movement; if ((Object)(object)val != (Object)null) { num = val.MoveSpeedMultiplier; val.MoveSpeedMultiplier = num * 1.6f; } } catch { } try { AvatarEmotionManager val2 = (((Object)(object)w.Avatar != (Object)null) ? w.Avatar.EmotionManager : null); if ((Object)(object)val2 != (Object)null) { val2.AddEmotionOverride("Scared", "PSYCHOPATH_panic", 60f, 10); } } catch { } _panicked[id] = new PanicState { Npc = w, Mv = val, OldMul = num, Expiry = expiry }; } private static void RevertExpiredPanic() { float time = Time.time; _emoteReassert -= Time.deltaTime; bool flag = _emoteReassert <= 0f; if (flag) { _emoteReassert = 0.5f; } List<int> list = null; foreach (KeyValuePair<int, PanicState> item in _panicked) { PanicState value = item.Value; if (time >= value.Expiry) { (list ?? (list = new List<int>())).Add(item.Key); RevertOne(value); continue; } try { if ((Object)(object)value.Mv != (Object)null) { value.Mv.MoveSpeedMultiplier = value.OldMul * 1.6f; } } catch { } if (!flag) { continue; } try { AvatarEmotionManager val = (((Object)(object)value.Npc != (Object)null && (Object)(object)value.Npc.Avatar != (Object)null) ? value.Npc.Avatar.EmotionManager : null); if ((Object)(object)val != (Object)null) { val.AddEmotionOverride("Scared", "PSYCHOPATH_panic", 60f, 10); } } catch { } } if (list != null) { for (int i = 0; i < list.Count; i++) { _panicked.Remove(list[i]); } } } private static void RevertAllPanic() { foreach (KeyValuePair<int, PanicState> item in _panicked) { RevertOne(item.Value); } _panicked.Clear(); } private static void RevertOne(PanicState s) { try { if ((Object)(object)s.Mv != (Object)null) { s.Mv.MoveSpeedMultiplier = s.OldMul; } } catch { } try { AvatarEmotionManager val = (((Object)(object)s.Npc != (Object)null && (Object)(object)s.Npc.Avatar != (Object)null) ? s.Npc.Avatar.EmotionManager : null); if ((Object)(object)val != (Object)null) { val.RemoveEmotionOverride("PSYCHOPATH_panic"); } } catch { } } private static string Up(string s) { try { return string.IsNullOrEmpty(s) ? "AN NPC" : s.ToUpperInvariant(); } catch { return s; } } } internal static class FinalEvent { private static bool _running; private static readonly Vector3 PawnShopFront = new Vector3(-67.23f, 1.01f, 55.03f); public static void Play() { if (_running) { return; } _running = true; try { MelonCoroutines.Start(Run()); } catch (Exception ex) { PPLog.Warn("FinalEvent.Play: " + ex.Message); _running = false; } } private static IEnumerator Run() { EyelidOverlay lid = SafeEyelid(); if ((Object)(object)lid != (Object)null) { try { lid.AutoUpdate = false; } catch { } try { if ((Object)(object)lid.Canvas != (Object)null) { lid.Canvas.sortingOrder = 5; } } catch { } } yield return LerpEyes(lid, GetOpen(lid), 0f, 1.2f); TeleportToPawnShop(); RestoreBody(); yield return (object)new WaitForSeconds(1.4f); yield return LerpEyes(lid, 0f, 1f, 2f); if ((Object)(object)lid != (Object)null) { try { lid.SetOpen(1f); } catch { } try { if ((Object)(object)lid.Canvas != (Object)null) { lid.Canvas.sortingOrder = -1; } } catch { } try { lid.AutoUpdate = true; } catch { } } try { ZahirVoice.Say("servant jinn"); } catch { } PPLog.Info("WIN final event done — player woke in front of the pawn shop; the contract can restart."); _running = false; } private static IEnumerator LerpEyes(EyelidOverlay lid, float from, float to, float dur) { if ((Object)(object)lid == (Object)null || dur <= 0f) { if ((Object)(object)lid != (Object)null) { try { lid.SetOpen(to); yield break; } catch { yield break; } } yield break; } float t = 0f; while (t < dur) { t += Time.deltaTime; try { lid.SetOpen(Mathf.Lerp(from, to, t / dur)); } catch { } yield return null; } try { lid.SetOpen(to); } catch { } } private static EyelidOverlay SafeEyelid() { try { return Singleton<EyelidOverlay>.Instance; } catch { return null; } } private static float GetOpen(EyelidOverlay lid) { try { return ((Object)(object)lid != (Object)null) ? lid.CurrentOpen : 1f; } catch { return 1f; } } private static void TeleportToPawnShop() { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) try { Vector3 val = PawnShopFront; try { NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(PawnShopFront, ref val2, 8f, -1)) { val = ((NavMeshHit)(ref val2)).position; } } catch { } PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance; if ((Object)(object)instance != (Object)null) { instance.Teleport(val, false); } } catch (Exception ex) { PPLog.Warn("FinalEvent.TeleportToPawnShop: " + ex.Message); } } private static void RestoreBody() { try { Player local = Player.Local; if ((Object)(object)local == (Object)null) { return; } try { if (local.IsUnconscious) { local.IsUnconscious = false; } } catch { } try { local.SetRagdolled(false); } catch { } try { PlayerHealth health = local.Health; if ((Object)(object)health != (Object)null) { health.RecoverHealth(100f); } } catch { } try { CapsuleCollider capCol = local.CapCol; if ((Object)(object)capCol != (Object)null) { ((Collider)capCol).enabled = true; } } catch { } try { PlayerCrimeData crimeData = local.CrimeData; if ((Object)(object)crimeData != (Object)null) { crimeData.SetPursuitLevel((EPursuitLevel)0); } } catch { } } catch (Exception ex) { PPLog.Warn("FinalEvent.RestoreBody: " + ex.Message); } } } internal static class HardcoreRules { public static void Tick(float dt) { } public static bool PlayerHasWeapon() { try { PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance; if ((Object)(object)instance == (Object)null) { return false; } try { Equippable equippable = instance.Equippable; if ((Object)(object)equippable != (Object)null && ((Object)(object)((Il2CppObjectBase)equippable).TryCast<Equippable_MeleeWeapon>() != (Object)null || (Object)(object)((Il2CppObjectBase)equippable).TryCast<Equippable_RangedWeapon>() != (Object)null)) { return true; } } catch { } List<HotbarSlot> hotbarSlots = instance.hotbarSlots; if (hotbarSlots == null) { return false; } for (int i = 0; i < hotbarSlots.Count; i++) { try { HotbarSlot val = hotbarSlots[i]; if (val == null) { continue; } ItemInstance itemInstance = ((ItemSlot)val).ItemInstance; if (itemInstance == null) { continue; } ItemDefinition definition = itemInstance.Definition; if ((Object)(object)definition == (Object)null) { continue; } Equippable equippable2 = definition.Equippable; if (!((Object)(object)equippable2 == (Object)null)) { if ((Object)(object)((Il2CppObjectBase)equippable2).TryCast<Equippable_MeleeWeapon>() != (Object)null) { return true; } if ((Object)(object)((Il2CppObjectBase)equippable2).TryCast<Equippable_RangedWeapon>() != (Object)null) { return true; } } } catch { } } } catch { } return false; } } internal static class HideZone { public static readonly Color AltarColor = new Color(0.15f, 0.85f, 0.25f); public static readonly Color HideColor = new Color(0.85f, 0.08f, 0.08f); private static GameObject _box; private static Vector3 _center; private static Vector3 _half; public static bool Active => (Object)(object)_box != (Object)null; public static Vector3 Center => _center; public static void Spawn(Vector3 floorCenter, Vector3 size) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Spawn(floorCenter, size, AltarColor); } public unsafe static void Spawn(Vector3 floorCenter, Vector3 size, Color color) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007e: 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_008d: 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) Remove(); try { GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val).name = "PSYCHOPATH_HideZone"; val.transform.position = new Vector3(floorCenter.x, floorCenter.y + size.y * 0.5f, floorCenter.z); val.transform.localScale = size; StripCollider(val); PropVisuals.ApplyGlass(val, color, 0.32f); _box = val; _center = floorCenter; _half = size * 0.5f; Vector3 val2 = floorCenter; PPLog.Debug("HideZone spawned at " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString()); } catch (Exception ex) { PPLog.Warn("HideZone.Spawn: " + ex.Message); } } public static bool Contains(Vector3 point, float margin) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_box == (Object)null) { return false; } float num = point.y - _center.y; if (num < 0f - margin || num > _half.y * 2f + margin) { return false; } float num2 = Mathf.Abs(point.x - _center.x); float num3 = Mathf.Abs(point.z - _center.z); return num2 <= _half.x + margin && num3 <= _half.z + margin; } public static void Remove() { if ((Object)(object)_box != (Object)null) { try { Object.Destroy((Object)(object)_box); } catch { } _box = null; } } private static void StripCollider(GameObject go) { try { Collider component = go.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { component.enabled = false; Object.Destroy((Object)(object)component); } } catch { } } } internal static class InterruptRecovery { private static bool _wasAlive = true; private static bool _wasArrested; private static bool _primed; internal static void Reset() { _wasAlive = true; _wasArrested = false; _primed = false; } internal static void Tick(float dt) { try { Player local = Player.Local; if ((Object)(object)local == (Object)null) { _primed = false; return; } bool flag = true; bool flag2 = false; try { PlayerHealth health = local.Health; if ((Object)(object)health != (Object)null) { flag = health.IsAlive; } } catch { } try { flag2 = local.IsArrested; } catch { } if (!_primed) { _wasAlive = flag; _wasArrested = flag2; _primed = true; return; } bool flag3 = _wasAlive && !flag; bool flag4 = !_wasArrested && flag2; _wasAlive = flag; _wasArrested = flag2; if (flag3 || flag4) { Recover(flag3 ? "death" : "arrest"); } } catch (Exception ex) { PPLog.Warn("InterruptRecovery.Tick: " + ex.Message); } } private static void Recover(string cause) { if (PsychoState.Phase < PsychoPhase.ContractAccepted) { return; } string text = PsychoState.CurrentTargetName ?? ""; try { TortureMechanic.Reset(); } catch (Exception ex) { PPLog.Warn("InterruptRecovery: TortureMechanic.Reset failed: " + ex.Message); } try { if (PsychoState.CurrentKill == KillType.Torture) { PsychoState.TortureDone = false; } } catch { } try { if (PsychoState.Phase == PsychoPhase.AwaitKill && PsychoState.CurrentKill == KillType.Torture && !PsychoState.OrderPendingTalk) { TortureMechanic.OnOrderRevealed(); } } catch (Exception ex2) { PPLog.Warn("InterruptRecovery: re-arm torture failed: " + ex2.Message); } try { ZahirNPC.ReanchorToPlayer(); } catch (Exception ex3) { PPLog.Warn("InterruptRecovery: reanchor failed: " + ex3.Message); } PPLog.Info("InterruptRecovery: " + cause + " during phase " + PsychoState.Phase.ToString() + " - order kept (target '" + text + "', kill " + PsychoState.CurrentKill.ToString() + ")."); try { NotifyHelper.Banner(string.IsNullOrEmpty(text) ? "Zahir waited. The order still stands." : ("Zahir waited. The order still stands - " + text + " is still yours."), 6f); } catch { } } } internal static class IntroBottle { private static GameObject _bottle; private static GameObject _smokeGo; private static InteractableObject _io; private static Action _onOpen; private static UnityAction _onOpenUnity; private static Action _openCallback; public static bool Active => (Object)(object)_bottle != (Object)null; public static void Spawn(bool whiskey, Action onOpened) { //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) Remove(); _openCallback = onOpened; try { Player local = Player.Local; if ((Object)(object)local == (Object)null || (Object)(object)((Component)local).transform == (Object)null) { PPLog.Warn("IntroBottle: no local player to place the bottle."); return; } Vector3 val = ((Component)local).transform.position + ((Component)local).transform.forward * 1f; if (!GroundGraffiti.TryGroundSnap(val, out var hit)) { hit = val; } GameObject val2 = BuildBottleVisual(hit, whiskey); if ((Object)(object)val2 == (Object)null) { return; } try { if ((Object)(object)val2.GetComponent<Collider>() == (Object)null) { BoxCollider val3 = val2.AddComponent<BoxCollider>(); val3.size = new Vector3(0.14f, 0.34f, 0.14f); val3.center = new Vector3(0f, 0.17f, 0f); } } catch { } InteractableObject val4 = val2.AddComponent<InteractableObject>(); try { val4.SetMessage("Open the bottle"); } catch { } try { val4.SetInteractionType((EInteractionType)0); } catch { } try { val4.MaxInteractionRange = 4f; } catch { } try { val4.SetInteractableState((EInteractableState)0); } catch { } _onOpen = OnOpen; _onOpenUnity = Il2CppDelegate.ToUnityAction(_onOpen); try { val4.onInteractStart.AddListener(_onOpenUnity); } catch { } _bottle = val2; _io = val4; CreateSmoke(val2.transform.position + Vector3.up * 0.2f); try { NotifyHelper.Banner(whiskey ? "The dusty whiskey bottle rests at your feet — the hard path. Open it." : "The wine bottle rests at your feet — the easy path. Open it.", 6f); } catch { } PPLog.Debug("Intro bottle spawned ~1 m in front of the player ('Open the bottle')."); } catch (Exception ex) { PPLog.Warn("IntroBottle.Spawn: " + ex.Message); } } private static GameObject BuildBottleVisual(Vector3 groundPos, bool whiskey) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: 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_00a4: 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) GameObject val = TryRealModel(groundPos, whiskey); if ((Object)(object)val != (Object)null) { return val; } GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)val2).name = "PSYCHOPATH_IntroBottle"; val2.transform.localScale = new Vector3(0.09f, 0.16f, 0.09f); val2.transform.position = groundPos + Vector3.up * val2.transform.localScale.y; try { PropVisuals.ApplyFlat(val2, whiskey ? new Color(0.5f, 0.3f, 0.08f) : new Color(0.45f, 0.05f, 0.1f)); } catch { } return val2; } private static GameObject TryRealModel(Vector3 groundPos, bool whiskey) { //IL_00bc: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) try { ItemDefinition item = Registry.GetItem("oldmanjimmys"); if ((Object)(object)item == (Object)null) { return null; } Equippable equippable = item.Equippable; if ((Object)(object)equippable == (Object)null || (Object)(object)((Component)equippable).gameObject == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(((Component)equippable).gameObject); ((Object)val).name = "PSYCHOPATH_IntroBottle"; try { Equippable component = val.GetComponent<Equippable>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } catch { } try { Rigidbody component2 = val.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } } catch { } try { val.transform.rotation = Quaternion.identity; } catch { } try { val.transform.position = groundPos; } catch { } try { if (!val.activeSelf) { val.SetActive(true); } } catch { } try { Il2CppArrayBase<Renderer> componentsInChildren = val.GetComponentsInChildren<Renderer>(true); if (componentsInChildren != null && componentsInChildren.Length > 0) { Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } float num = groundPos.y - ((Bounds)(ref bounds)).min.y + 0.01f; if (num > 0f) { Transform transform = val.transform; transform.position += Vector3.up * num; } } } catch { } if (!whiskey) { try { Il2CppArrayBase<Renderer> componentsInChildren2 = val.GetComponentsInChildren<Renderer>(true); if (componentsInChildren2 != null) { for (int j = 0; j < componentsInChildren2.Length; j++) { try { Material material = componentsInChildren2[j].material; if ((Object)(object)material != (Object)null) { material.color = new Color(0.45f, 0.05f, 0.1f); } } catch { } } } } catch { } } PPLog.Debug("Intro bottle: real 'oldmanjimmys' model seated (" + (whiskey ? "whiskey" : "wine-retint") + ")."); return val; } catch (Exception ex) { PPLog.Debug("IntroBottle.TryRealModel: " + ex.Message); return null; } } private static void OnOpen() { try { if (PsychoAuthority.IsServer) { NotifyHelper.Banner("You uncork the bottle...", 4f); Action openCallback = _openCallback; Remove(); try { openCallback?.Invoke(); } catch (Exception ex) { PPLog.Warn("IntroBottle open callback: " + ex.Message); } PPLog.Debug("Intro bottle opened -> summoning Zahir."); } } catch (Exception ex2) { PPLog.Warn("IntroBottle.OnOpen: " + ex2.Message); } } private static void CreateSmoke(Vector3 worldPos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { _smokeGo = ZahirNPC.TryCloneSmoke(worldPos, 0.36f); } catch (Exception ex) { PPLog.Debug("IntroBottle.CreateSmoke: " + ex.Message); } } public static void Remove() { try { if ((Object)(object)_io != (Object)null && (Delegate)(object)_onOpenUnity != (Delegate)null) { _io.onInteractStart.RemoveListener(_onOpenUnity); } } catch { } if ((Object)(object)_smokeGo != (Object)null) { try { Object.Destroy((Object)(object)_smokeGo); } catch { } } if ((Object)(object)_bottle != (Object)null) { try { Object.Destroy((Object)(object)_bottle); } catch { } } _bottle = null; _smokeGo = null; _io = null; _onOpen = null; _onOpenUnity = null; } } internal static class MessageCleanup { private static bool _done; private static int _attempts; private static int _totalRemoved; private static float _timer; private const int MaxAttempts = 12; private const float AttemptEvery = 3f; private static readonly string[] Snippets = new string[8] { "That is not the mark", "Now mark it", "Now hide it", "circle the body in white spray paint", "drag the body into the marked", "Mortals never learn", "I am Zahir", " must die." }; public static void Reset() { _done = false; _attempts = 0; _totalRemoved = 0; _timer = 0f; } public static void PurgeTick(float dt) { if (_done) { return; } List<NPC> nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null || nPCRegistry.Count < 10) { return; } _timer += dt; if (_timer < 3f) { return; } _timer = 0f; _totalRemoved += Scan(); _attempts++; if (_attempts >= 12) { _done = true; if (_totalRemoved > 0) { PPLog.Debug("Purged " + _totalRemoved + " leftover mod SMS (old ZahirSms history)."); } } } private static int Scan() { int num = 0; try { List<NPC> nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null) { return 0; } for (int i = 0; i < nPCRegistry.Count; i++) { NPC val = nPCRegistry[i]; if ((Object)(object)val == (Object)null) { continue; } MSGConversation val2 = null; try { val2 = val.MSGConversation; } catch { } if (val2 == null) { continue; } List<Message> messageHistory = val2.messageHistory; if (messageHistory == null) { continue; } for (int num2 = messageHistory.Count - 1; num2 >= 0; num2--) { Message val3 = null; try { val3 = messageHistory[num2]; } catch { } if (val3 != null) { string text = null; try { text = val3.text; } catch { } if (!string.IsNullOrEmpty(text) && IsModMessage(text)) { try { messageHistory.RemoveAt(num2); num++; } catch { } } } } } } catch (Exception ex) { PPLog.Warn("MessageCleanup.Scan: " + ex.Message); } return num; } private static bool IsModMessage(string text) { for (int i = 0; i < Snippets.Length; i++) { if (text.IndexOf(Snippets[i], StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } } internal static class PsychopathTeardown { public static void HellNo() { if (!PsychoAuthority.IsServer) { return; } PPLog.Info("Hell No — tearing PSYCHOPATH down to the pre-Zahir state (world normalized)."); try { ZahirVoice.Say("long laugh that turns into a cough"); } catch { } ResetCore(); try { ModConfig.SetQuestKillMode(on: false); } catch { } try { ModConfig.SetCompanionMode(on: false); } catch { } try { PsychoState.HardcoreMode = false; } catch { } try { PsychoState.ZahirIsYours = false; } catch { } try { PsychoState.Reset(); } catch { } try { NotifyHelper.Banner("You turn the bottle down. The curse lifts — everything is as it was.", 9f); } catch { } } public static void ReopenBottle() { if (!PsychoAuthority.IsServer) { return; } PPLog.Info("ReopenBottle — full reset: kill progress cleared, Zahir vanishes, the bottle returns to Mick's."); ResetCore(); try { PsychoState.HardcoreMode = false; } catch { } try { PsychoState.ZahirIsYours = false; } catch { } try { PsychoState.Reset(); } catch { } try { MickMessaging.Reset(); } catch { } try { ModConfig.SetCompanionMode(on: false); } catch { } try { ModConfig.SetQuestKillMode(on: true); } catch { } try { NotifyHelper.Banner("The bottle turns up at Mick Lubbin's again. Check your messages.", 8f); } catch { } } private static void ResetCore() { try { PsychoState.ResetPending = true; } catch { } try { KillRegistry.ReviveAllAndClear(); } catch { } try { GroundGraffiti.ClearAll(); } catch { } try { CurfewNews.ClearNotice(); } catch { } try { CurfewNews.Reset(); } catch { } try { KillQuest.Clear(); } catch { } try { KillQuestManager.ResetSessionFlags(); } catch { } try { BodyDragManager.Reset(); } catch { } try { SuspicionManager.Reset(); } catch { } try { TortureMechanic.Reset(); } catch { } try { BrandItem.RemoveFromPlayer(); } catch { } try { IntroBottle.Remove(); } catch { } try { MickMessaging.RemoveWinOffer(); } catch { } try { Player local = Player.Local; PlayerCrimeData val = (((Object)(object)local != (Object)null) ? local.CrimeData : null); if ((Object)(object)val != (Object)null) { val.SetPursuitLevel((EPursuitLevel)0); } } catch { } } } internal static class SandboxMode { private static bool _lastQuestMode = true; private static bool _lastCompanion; private static bool _haveLast; private static float _cfgReloadTimer; private static float _reopenCooldown; private static string _cfgPath; private static DateTime _cfgLastWrite; private static bool _cfgStampInit; public static void Reset() { _haveLast = false; _cfgReloadTimer = 0f; _reopenCooldown = 0f; } public static void Tick(float dt) { _cfgReloadTimer -= dt; if (_cfgReloadTimer <= 0f) { _cfgReloadTimer = 2f; try { if (_cfgPath == null) { _cfgPath = Path.Combine(MelonEnvironment.UserDataDirectory, "MelonPreferences.cfg"); } DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(_cfgPath); if (!_cfgStampInit) { _cfgStampInit = true; _cfgLastWrite = lastWriteTimeUtc; } else if (lastWriteTimeUtc != _cfgLastWrite) { _cfgLastWrite = lastWriteTimeUtc; MelonPreferences.Load(); } } catch { } } _reopenCooldown -= dt; if (ModConfig.ReopenBottle) { try { ModConfig.SetReopenBottle(on: false); } catch { } if (_reopenCooldown <= 0f) { _reopenCooldown = 10f; try { PsychopathTeardown.ReopenBottle(); } catch (Exception ex) { PPLog.Warn("ReopenBottle reset: " + ex.Message); } } } bool flag = ModConfig.QuestKillMode; bool flag2 = ModConfig.CompanionMode; if (!_haveLast) { _haveLast = true; _lastQuestMode = flag; _lastCompanion = flag2; return; } bool flag3 = flag && !_lastQuestMode; bool flag4 = flag2 && !_lastCompanion; if (flag3 && flag2) { try { ModConfig.SetCompanionMode(on: false); } catch { } flag2 = false; } else if (flag4 && flag) { try { ModConfig.SetQuestKillMode(on: false); } catch { } flag = false; } else if (flag && flag2) { try { ModConfig.SetCompanionMode(on: false); } catch { } flag2 = false; } if (PsychoState.ZahirIsYours && !flag && !flag2) { try { ModConfig.SetCompanionMode(on: true); } catch { } flag2 = true; } bool flag5 = flag != _lastQuestMode; _lastQuestMode = flag; _lastCompanion = flag2; if (!flag5) { return; } if (flag) { try { KillQuestManager.OnQuestKillModeChanged(on: true); } catch { } try { NotifyHelper.Banner("The contract resumes. Zahir expects his kills.", 6f); return; } catch { return; } } try { KillQuestManager.OnQuestKillModeChanged(on: false); } catch { } try { NotifyHelper.Banner(flag2 ? "The contract rests. Zahir walks beside you." : "The contract rests. Zahir fades into the dark.", 6f); } catch { } } } internal static class SuspicionManager { public static bool Enabled = true; public static bool RequireLineOfSight = true; public static bool ExcludeIndoor = true; public static float WitnessRange = 6f; public static float MaxBodyDist = 60f; public static float ConsequenceCooldown = 30f; public static int LosMask = 1; private const float CircleRadius = 3.5f; private const float TickEvery = 1f; private static float _timer; private static float _sinceConsequence = float.MaxValue; private static readonly HashSet<int> _reported = new HashSet<int>(); private static readonly HashSet<long> _scared = new HashSet<long>(); private static readonly HashSet<int> _contractBodies = new HashSet<int>(); public static void Reset() { _timer = 0f; _sinceConsequence = float.MaxValue; _reported.Clear(); _scared.Clear(); _contractBodies.Clear(); } private static void ApplyDifficulty() { bool flag = false; try { flag = PsychoState.HardcoreMode; } catch { } if (flag) { WitnessRange = 12f; ConsequenceCooldown = 10f; ExcludeIndoor = false; } else { WitnessRange = 6f; ConsequenceCooldown = 30f; ExcludeIndoor = true; } } public static void RegisterContractBody(NPC npc) { try { if ((Object)(object)npc != (Object)null) { _contractBodies.Add(((Object)npc).GetInstanceID()); } } catch { } } public static void Tick(float dt) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) if (!Enabled) { return; } ApplyDifficulty(); _sinceConsequence += dt; _timer -= dt; if (_timer > 0f) { return; } _timer = 1f; Vector3 position; try { Player local = Player.Local; if ((Object)(object)local == (Object)null) { return; } position = ((Component)local).transform.position; } catch { return; } List<NPC> nPCRegistry; try { nPCRegistry = NPCManager.NPCRegistry; } catch { return; } if (nPCRegistry == null) { return; } int count = nPCRegistry.Count; float num = MaxBodyDist * MaxBodyDist; for (int i = 0; i < count; i++) { NPC val; try { val = nPCRegistry[i]; } catch { continue; } if ((Object)(object)val == (Object)null || ZahirNPC.IsZahir(val)) { continue; } bool flag = false; try { flag = (Object)(object)val.Health != (Object)null && val.Health.IsDead; } catch { } if (!flag || BodyDragManager.IsDisposed(val)) { continue; } int instanceID; try { instanceID = ((Object)val).GetInstanceID(); } catch { continue; } if (_contractBodies.Contains(instanceID)) { Vector3 val2 = BodyPos(val); Vector3 val3 = val2 - position; if (!(((Vector3)(ref val3)).sqrMagnitude > num)) { ProcessBody(nPCRegistry, count, val, val2); } } } } private static void ProcessBody(List<NPC> reg, int count, NPC body, Vector3 bodyPos) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0105: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) int instanceID; try { instanceID = ((Object)body).GetInstanceID(); } catch { return; } float num = WitnessRange * WitnessRange; bool? flag = null; bool flag2 = false; NPC val = null; for (int i = 0; i < count; i++) { NPC val2; try { val2 = reg[i]; } catch { continue; } if ((Object)(object)val2 == (Object)null) { continue; } try { if (((Il2CppObjectBase)val2).Pointer == ((Il2CppObjectBase)body).Pointer) { continue; } } catch { continue; } if (ZahirNPC.IsZahir(val2)) { continue; } bool flag3 = false; try { flag3 = val2.IsConscious && ((Object)(object)val2.Health == (Object)null || !val2.Health.IsDead); } catch { } if (!flag3) { continue; } Vector3 position; try { position = ((Component)val2).transform.position; } catch { continue; } Vector3 val3 = position - bodyPos; if (((Vector3)(ref val3)).sqrMagnitude > num) { continue; } if (ExcludeIndoor) { bool flag4 = false; try { flag4 = val2.isInBuilding; } catch { } if (flag4) { continue; } } if (RequireLineOfSight && !CanSee(position, bodyPos)) { continue; } if (!flag.HasValue) { try { flag = GroundGraffiti.RitualCircleNear(bodyPos, 3.5f); } catch { flag = false; } } if (flag.Value) { int instanceID2; try { instanceID2 = ((Object)val2).GetInstanceID(); } catch { continue; } long item = ((long)instanceID << 32) ^ (uint)instanceID2; if (_scared.Add(item)) { FearControl.MakeFlee(val2, bodyPos); } continue; } flag2 = true; val = val2; break; } if (flag2 && _sinceConsequence >= ConsequenceCooldown) { _sinceConsequence = 0f; try { WantedControl.RaiseWanted(); } catch { } try { NotifyHelper.Banner("A witness saw the body — the police are investigating.", 5f); } catch { } try { ZahirVoice.Say("rejecting my offer"); } catch { } string text = "?"; try { text = (((Object)(object)val != (Object)null) ? val.FullName : "?"); } catch { } PPLog.Debug("Uncircled body discovered by witness '" + text + "' -> investigation."); } } private static Vector3 BodyPos(NPC body) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) try { Avatar avatar = body.Avatar; if ((Object)(object)avatar != (Object)null) { return avatar.CenterPoint; } } catch { } try { return ((Component)body).transform.position; } catch { return Vector3.zero; } } private static bool CanSee(Vector3 witnessPos, Vector3 bodyPos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) try { Vector3 val = witnessPos + Vector3.up * 1.6f; Vector3 val2 = bodyPos + Vector3.up * 0.4f; Vector3 val3 = val2 - val; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude <= 1f) { return true; } val3 /= magnitude; Vector3 val4 = val + val3 * 0.4f; Vector3 val5 = val2 - val3 * 0.6f; return !Physics.Linecast(val4, val5, LosMask, (QueryTriggerInteraction)1); } catch { return true; } } } internal static class TortureMechanic { private const int HitsToWin = 3; private const float MiniTimeLimit = 11f; private const float GreenHalf = 0.07f; private const float NearDist = 4f; private static NPC _victim; private static InteractableObject _intObj; private static DialogueController _intDc; private static bool _intWired; private static Action _onCurse; private static UnityAction _onCurseUnity; private static bool _miniActive; private static float _miniMarker; private static float _miniMult; private static float _miniTime; private static float _missFlash; private static int _miniDir = 1; private static int _miniHits; private static Vector3 _freezePos; private static bool _frozen; private static bool _brandPending; private static float _brandBannerTimer; private static bool _playerLocked; private static bool _dying; private static float _dyingTimer; private static bool _skinBlackened; private const float DeathSeconds = 9f; private const float SkinBlackAt = 2.5f; public static bool MinigameActive => _miniActive; public static bool Busy => _miniActive || _dying; public static void Reset() { UnlockPlayer(); UnwireInteraction(); if (_frozen && (Object)(object)_victim != (Object)null) { try { ReleaseVictim(_victim); } catch { } } _victim = null; _miniActive = false; _frozen = false; _miniHits = 0; _brandPending = false; _brandBannerTimer = 0f; _dying = false; _skinBlackened = false; } public static void OnOrderRevealed() { Reset(); bool flag = false; try { flag = BrandItem.GiveToPlayer(); } catch { } _brandPending = !flag; } public static void Tick(float dt) { try { if (_dying) { TickDying(dt); return; } if (_brandPending && !_miniActive) { if (!BrandItem.HasBrand() && !BrandItem.GiveToPlayer()) { _brandBannerTimer -= dt; if (_brandBannerTimer <= 0f) { _brandBannerTimer = 4f; NotifyHelper.Banner("Free an inventory slot to receive Zahir's Curse.", 4f); } return; } _brandPending = false; } if (_miniActive) { TickMinigame(dt); HoldVictim(); return; } ResolveVictim(); if (!((Object)(object)_victim == (Object)null)) { KeepInvincible(_victim); EnsureInteraction(); } } catch (Exception ex) { PPLog.Debug("TortureMechanic.Tick: " + ex.Message); } } private static void ResolveVictim() { try { if ((Object)(object)_victim != (Object)null && (Object)(object)((Component)_victim).gameObject != (Object)null && NpcIdentity.Matches(_victim, PsychoState.CurrentTargetName)) { return; } } catch { _victim = null; } _victim = null; _intWired = false; _intObj = null; try { List<NPC> nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null) { return; } for (int i = 0; i < nPCRegistry.Count; i++) { NPC val = nPCRegistry[i]; if (!((Object)(object)val == (Object)null) && NpcIdentity.Matches(val, PsychoState.CurrentTargetName)) { _victim = val; break; } } } catch { } } private static void KeepInvincible(NPC npc) { try { NPCHealth health = npc.Health; if ((Object)(object)health != (Object)null && !health.npc.NPCData.Health.Invincible) { health.npc.NPCData.Health.Invincible = true; } } catch { } } private static void EnsureInteraction() { if (_intWired && (Object)(object)_intObj != (Object)null) { return; } try { NPC victim = _victim; if ((Object)(object)victim == (Object)null) { return; } DialogueController val = null; try { val = ((Component)victim).gameObject.GetComponentInChildren<DialogueController>(true); } catch { } InteractableObject val2 = null; if ((Object)(object)val != (Object)null) { try { val2 = val.IntObj; } catch { } } if ((Object)(object)val2 == (Object)null) { try { Il2CppArrayBase<InteractableObject> componentsInChildren = ((Component)victim).gameObject.GetComponentsInChildren<InteractableObject>(true); if (componentsInChildren != null && componentsInChildren.Length > 0) { val2 = componentsInChildren[0]; } } catch { } } if ((Object)(object)val2 == (Object)null) { return; } try { ((UnityEventBase)val2.onInteractStart).RemoveAllListeners(); } catch { } try { ((UnityEventBase)val2.onHovered).RemoveAllListeners(); } catch { } if ((Object)(object)val != (Object)null) { try { ((Behaviour)val).enabled = false; } catch { } } try { val2.SetMessage("Curse your victim"); } catch { } try { val2.SetInteractionType((EInteractionType)0); } catch { } try { val2.MaxInteractionRange = 4f; } catch { } try { val2.SetInteractableState((EInteractableState)0); } catch { } _onCurse = OnCurseTrigger; _onCurseUnity = Il2CppDelegate.ToUnityAction(_onCurse); try { val2.onInteractStart.AddListener(_onCurseUnity); } catch { } _intObj = val2; _intDc = val; _intWired = true; PPLog.Debug("Torture interaction wired on '" + PsychoState.CurrentTargetName + "'."); } catch (Exception ex) { PPLog.Debug("TortureMechanic.EnsureInteraction: " + ex.Message); } } private static void UnwireInteraction() { try { InteractableObject intObj = _intObj; if ((Object)(object)intObj != (Object)null) { try { if ((Delegate)(object)_onCurseUnity != (Delegate)null) { intObj.onInteractStart.RemoveListener(_onCurseUnity); } } catch { } try { intObj.SetMessage(""); } catch { } } DialogueController intDc = _intDc; if ((Object)(object)intDc != (Object)null) { try { ((Behaviour)intDc).enabled = true; } catch { } } } catch { } _intObj = null; _intDc = null; _intWired = false; _onCurse = null; _onCurseUnity = null; } private static void OnCurseTrigger() { try { if (!PsychoAuthority.IsServer || _miniActive || (Object)(object)_victim == (Object)null) { return; } if (!BrandItem.HasBrand()) { NotifyHelper.Banner("You need Zahir's Curse to curse them."); return; } FreezeVictim(_victim); _miniActive = true; _miniMarker = 0f; _miniDir = 1; _miniMult = 1f; _miniHits = 0; _miniTime = 11f; LockPlayer(); try { ZahirVoice.PlaySfx("torture_minigame"); } catch { } NotifyHelper.Banner("Curse them — stop the marker on GREEN (SPACE).", 4f); PPLog.Debug("Curse minigame started on '" + PsychoState.CurrentTargetName + "'."); } catch (Exception ex) { PPLog.Warn("TortureMechanic.OnCurseTrigger: " + ex.Message); } } private static void TickMinigame(float dt) { try { PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance; if ((Object)(object)instance != (Object)null) { if (instance.CanMove) { instance.CanMove = false; } if (instance.CanJump) { instance.CanJump = false; } } } catch { } _miniTime -= dt; if (_miniTime <= 0f) { CurseFail(); return; } _miniMult = Mathf.Clamp(_miniMult + dt / 18f, 1f, 2.2f); _miniMarker = Mathf.Clamp01(_miniMarker + (float)_miniDir * dt * _miniMult); if (_miniMarker >= 1f) { _miniDir = -1; } else if (_miniMarker <= 0f) { _miniDir = 1; } bool flag = false; try { flag = !GameInput.IsTyping && GameInput.GetButtonDown((ButtonCode)7); } catch { } if (!flag) { return; } if (Mathf.Abs(_miniMarker - 0.5f) <= 0.08f) { _miniHits++; if (_miniHits >= 3) { CurseSuccess(); } } else { _missFlash = Time.time + 0.25f; } } private static void CurseSuccess() { NPC victim = _victim; _miniActive = false; UnlockPlayer(); NotifyHelper.Banner("The curse takes hold — the lethal mark spreads through them.", 5f); try { BrandItem.RemoveFromPlayer(); } catch { } if ((Object)(object)victim != (Object)null) { ApplyDrugEffect(victim); try { NPCHealth health = victim.Health; if ((Object)(object)health != (Object)null) { health.npc.NPCData.Health.Invincible = false; } } catch { } } _dying = true; _dyingTimer = 9f; PPLog.Debug("Curse SUCCESS — victim afflicted by the lethal effect; dying over " + 9f + "s."); } private static void TickDying(float dt) { NPC victim = _victim; if ((Object)(object)victim == (Object)null) { _dying = false; return; } bool flag = false; try { flag = (Object)(object)victim.Health != (Object)null && victim.Health.IsDead; } catch { } if (flag) { _dying = false; ReleaseVictim(victim); PPLog.Debug("Curse: victim succumbed to the lethal effect."); return; } HoldVictim(); try { Avatar avatar = victim.Avatar; if ((Object)(object)avatar != (Object)null) { avatar.Effects.TriggerSick(true); } } catch { } _dyingTimer -= dt; if (!_skinBlackened && _dyingTimer <= 6.5f) { _skinBlackened = true; BlackenSkin(victim); NotifyHelper.Banner("Their skin blackens as the curse devours them.", 4f); } if (!(_dyingTimer <= 0f)) { return; } ReleaseForDeath(victim); EvictFromBuilding(victim); UnwireInteraction(); try { NPCHealth health = victim.Health; if ((Object)(object)health != (Object)null) { health.npc.NPCData.Health.Invincible = false; try { health.npc.NPCData.Health.CanRevive = false; } catch { } health.Die(); } } catch { } _dying = false; PPLog.Debug("Curse: the lethal effect finished the victim."); } private static void CurseFail() { //IL_0082: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) NPC victim = _victim; _miniActive = false; UnlockPlayer(); NotifyHelper.Banner("The curse broke — they tear free and run. The police are hunting you.", 7f); try { BrandItem.RemoveFromPlayer(); } catch { } if ((Object)(object)victim != (Object)null) { ReleaseVictim(victim); try { NPCHealth health = victim.Health; if ((Object)(object)health != (Object)null) { health.npc.NPCData.Health.Invincible = false; } } catch { } try { Vector3 position = ((Component)victim).transform.position; Player local = Player.Local; if ((Object)(object)local != (Object)null && (Object)(object)((Component)local).transform != (Object)null) { position = ((Component)local).transform.position; } FearControl.MakeFlee(victim, position); } catch { } try { Avatar avatar = victim.Avatar; if ((Object)(object)avatar != (Object)null) { avatar.EmotionManager.AddEmotionOverride("Scared", "PSYCHOPATH_torturefail", 30f, 10); } } catch { } } try { WantedControl.RaiseWanted(); } catch { } try { KillQuestManager.FailTorture(); } catch { } PPLog.Debug("Curse FAILED — victim flees, player wanted, order failed."); } private static void LockPlayer() { try { PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance; if ((Object)(object)instance != (Object)null) { instance.CanMove = false; instance.CanJump = false; _playerLocked = true; } } catch { } } private static void UnlockPlayer() { if (!_playerLocked) { return; } try { PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance; if ((Object)(object)instance != (Object)null) { instance.CanMove = true; instance.CanJump = true; _playerLocked = false; } } catch { } } private static void FreezeVictim(NPC npc) { //IL_0008: Unknown result typ