using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Pix.Paranoia.Creatures; using Pix.Paranoia.Hallucinations; using Pix.Paranoia.Infection; using Pix.Paranoia.Nausea; using Pix.Paranoia.Relics; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace Pix.Paranoia { [BepInPlugin("Pix.Paranoia", "Paranoia", "0.8.9")] public sealed class ParanoiaPlugin : BaseUnityPlugin { private sealed class CreatureSfxIndex { public readonly List Foreshadow = new List(); public readonly List Displacement = new List(); public readonly List Violation = new List(); } public const string PluginGuid = "Pix.Paranoia"; public const string PluginName = "Paranoia"; public const string PluginVersion = "0.8.9"; private const string RpcParanoidinDamage = "PX_ParanoidinDamage"; private Harmony _harmony; private Harmony _criticalHarmony; private static ParanoiaPlugin _self; internal static ConfigEntry Enabled; internal static ConfigEntry DebugLogging; internal static ConfigEntry UseSleepDeprivation; internal static ConfigEntry DaysWithoutSleepThreshold; internal static ConfigEntry TickIntervalSeconds; internal static ConfigEntry BaseEventChancePerTick; internal static ConfigEntry NightChanceMultiplier; internal static ConfigEntry GlobalCooldownSeconds; internal static ConfigEntry ForeshadowCooldownSeconds; internal static ConfigEntry DisplacementCooldownSeconds; internal static ConfigEntry ViolationCooldownSeconds; internal static ConfigEntry ViolationForeignBiomeChance; internal static ConfigEntry SameSoundRepeatBlockSeconds; internal static ConfigEntry EnableEatTrigger; internal static ConfigEntry EatTriggerChance; internal static ConfigEntry DisplacementMinDistance; internal static ConfigEntry DisplacementMaxDistance; internal static ConfigEntry ForeshadowDistance; internal static ConfigEntry ViolationDistance; internal static ConfigEntry DisableDuringActiveEvent; internal static ConfigEntry ForcePlayAudioSources; internal static ConfigEntry ForcedNearSpawnDistance; internal static ConfigEntry SleepTest_DaySeconds; internal static ConfigEntry Meadows_Foreshadow; internal static ConfigEntry Meadows_Displacement; internal static ConfigEntry Meadows_Violation; internal static ConfigEntry BlackForest_Foreshadow; internal static ConfigEntry BlackForest_Displacement; internal static ConfigEntry BlackForest_Violation; internal static ConfigEntry Swamp_Foreshadow; internal static ConfigEntry Swamp_Displacement; internal static ConfigEntry Swamp_Violation; internal static ConfigEntry Mountains_Foreshadow; internal static ConfigEntry Mountains_Displacement; internal static ConfigEntry Mountains_Violation; internal static ConfigEntry Plains_Foreshadow; internal static ConfigEntry Plains_Displacement; internal static ConfigEntry Plains_Violation; internal static ConfigEntry Mistlands_Foreshadow; internal static ConfigEntry Mistlands_Displacement; internal static ConfigEntry Mistlands_Violation; internal static ConfigEntry Ocean_Foreshadow; internal static ConfigEntry Ocean_Displacement; internal static ConfigEntry Ocean_Violation; internal static ConfigEntry AshLands_Foreshadow; internal static ConfigEntry AshLands_Displacement; internal static ConfigEntry AshLands_Violation; internal static ConfigEntry EnableParanoidin; internal static ConfigEntry ParanoidinChancePerTickSevere; internal static ConfigEntry ParanoidinCooldownSeconds; internal static ConfigEntry ParanoidinEnvironmentEnabled; internal static ConfigEntry DisableParanoiaTickDuringRespawnLockout; internal static ConfigEntry RespawnLockoutSeconds; internal static ConfigEntry ParanoidinChancePerTickModerate; internal static ConfigEntry ParanoidinChancePerTickMild; internal static ConfigEntry ParanoidinMinTier; internal static ConfigEntry ParanoidinPrefabNames; internal static ConfigEntry ParanoidinUseSafeVisuals = null; internal static ConfigEntry ParanoidinSpawnVisualGhost = null; internal static ConfigEntry ParanoidinFarShowDistance; internal static ConfigEntry ParanoidinFarShowSeconds; internal static ConfigEntry ParanoidinStartDistance; internal static ConfigEntry ParanoidinMinDistance; internal static ConfigEntry ParanoidinTeleportStep; internal static ConfigEntry ParanoidinTeleportCooldown; internal static ConfigEntry ParanoidinDespawnDistance; internal static ConfigEntry ParanoidinHoldSeconds; internal static ConfigEntry ParanoidinAttackRange; internal static ConfigEntry ParanoidinAttackWindupSeconds; internal static ConfigEntry ParanoidinAttackDamage; internal static ConfigEntry ParanoidinDamageRequiresServer; internal static ConfigEntry ParanoidinDebugAllowClientDamage; internal static ConfigEntry ParanoidinWarningSfx; internal static ConfigEntry ParanoidinStepSfx; internal static ConfigEntry ParanoidinAttackSfx; internal static ConfigEntry ParanoidinHauntSfx; internal static ConfigEntry CfgHallucinationEnabled; internal static ConfigEntry CfgHallucinationWarningTimeSeconds; internal static ConfigEntry CfgHallucinationTriggerTimeSeconds; internal static ConfigEntry CfgHallucinationDurationSeconds; internal static ConfigEntry CfgHallucinationGlobalCooldownSeconds; internal static ConfigEntry CfgHallucinationWarningMessage; internal static ConfigEntry CfgHallucinationTriggerMessage; internal static ConfigEntry CfgHallucinationRainbowEnabled; internal static ConfigEntry CfgHallucinationRainbowDistance; internal static ConfigEntry CfgHallucinationMaxFakeCreatures; internal static ConfigEntry CfgHallucinationFakeCreatureSpawnInterval; internal static ConfigEntry CfgHallucinationFakeCreatureMinDistance; internal static ConfigEntry CfgHallucinationFakeCreatureMaxDistance; internal static ConfigEntry CfgHallucinationFakeCreatureBiomeOnly; internal static ConfigEntry CfgHallucinationFakeCreatureChaotic; internal static ConfigEntry CfgHallucinationBlurStrength; internal static ConfigEntry CfgHallucinationBlurIterations; internal static ConfigEntry CfgHallucinationBlurDownsample; internal static ConfigEntry CfgHallucinationEdgeWidth; internal static ConfigEntry CfgHallucinationEdgeSoftness; internal static ConfigEntry CfgHallucinationPulseSpeed; internal static ConfigEntry CfgHallucinationPulseAmplitude; internal static ConfigEntry CfgHallucinationOnsetBurialChambers; internal static ConfigEntry CfgHallucinationOnsetTrollCave; internal static ConfigEntry CfgHallucinationOnsetSunkenCrypt; internal static ConfigEntry CfgHallucinationOnsetFrostCave; internal static ConfigEntry CfgHallucinationOnsetSealedTower; internal static ConfigEntry CfgHallucinationOnsetInfestedMine; internal static ConfigEntry CfgHallucinationOnsetPutridHole; internal static ConfigEntry CfgHallucinationOnsetSmoulderingTomb; internal static ConfigEntry CfgWhisperingGreydwarfEnabled; internal static ConfigEntry CfgWhisperingGreydwarfChance; private static bool _sfxIndexBuilt; private static readonly object _sfxIndexLock = new object(); private static readonly HashSet _availableSfxNames = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary _sfxByCreatureKey = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary _creaturesByBiome = new Dictionary { { (Biome)1, new string[5] { "deer", "boar", "neck", "greyling", "seagal" } }, { (Biome)8, new string[6] { "greydwarf", "troll", "skeleton", "ghost", "rancidremains", "crow" } }, { (Biome)256, new string[3] { "serpent", "seagal", "leviathan" } }, { (Biome)2, new string[7] { "draugr", "blob", "blobelite", "leech", "wraith", "abomination", "surtling" } }, { (Biome)4, new string[6] { "wolf", "hatchling", "fenring", "stonegolem", "ulv", "bat" } }, { (Biome)16, new string[6] { "goblin", "goblinbrute", "goblinshaman", "lox", "deathsquito", "blobtar" } }, { (Biome)512, new string[8] { "seeker", "seekerbrute", "seekerbrood", "gjall", "tick", "dverger", "dvergermage", "hare" } }, { (Biome)32, new string[6] { "charred", "volture", "asksvin", "bloblava", "bonemawserpent", "fallenvalkyrie" } } }; private static bool _paranoidinRpcRegistered; private static void EnsureSfxIndexBuilt() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown if (_sfxIndexBuilt) { return; } lock (_sfxIndexLock) { if (_sfxIndexBuilt) { return; } _availableSfxNames.Clear(); _sfxByCreatureKey.Clear(); try { if ((Object)ZNetScene.instance != (Object)null && ZNetScene.instance.m_prefabs != null) { foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)prefab == (Object)null) { continue; } string name = ((Object)prefab).name; if (string.IsNullOrEmpty(name) || !name.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase)) { continue; } _availableSfxNames.Add(name); string text = ExtractCreatureKey(name); if (!string.IsNullOrEmpty(text)) { if (!_sfxByCreatureKey.TryGetValue(text, out var value)) { value = new CreatureSfxIndex(); _sfxByCreatureKey[text] = value; } ClassifyAndAdd(value, name); } } } } catch (Exception ex) { LogWarn("SFX AUTO indexing failed (will fall back to config-only pools): " + ex.Message); } _sfxIndexBuilt = true; if (DebugLogging.Value) { LogInfo($"SFX AUTO index built: {_availableSfxNames.Count} sfx prefabs, {_sfxByCreatureKey.Count} creature keys."); } } } private static string ExtractCreatureKey(string sfxPrefabName) { if (string.IsNullOrEmpty(sfxPrefabName)) { return null; } string text = sfxPrefabName; if (text.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase)) { text = text.Substring(4); } string[] array = text.Split(new char[3] { '_', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { return null; } return array[0].Trim().ToLowerInvariant(); } private static void ClassifyAndAdd(CreatureSfxIndex idx, string sfxPrefabName) { if (idx != null && !string.IsNullOrEmpty(sfxPrefabName)) { string text = sfxPrefabName.ToLowerInvariant(); bool flag = text.Contains("_idle") || text.Contains("_footstep") || text.Contains("_random") || text.Contains("_creak") || text.Contains("_greet") || text.Contains("_laugh") || text.Contains("_yea"); bool flag2 = text.Contains("_alert") || text.Contains("_alerted") || text.Contains("_scream") || text.Contains("_howl") || text.Contains("_taunt") || text.Contains("_roar") || text.Contains("_shout"); bool flag3 = text.Contains("_death") || text.Contains("_hurt") || text.Contains("_hit") || text.Contains("_attack") || text.Contains("_bite") || text.Contains("_slam") || text.Contains("_claw") || text.Contains("_spit"); if (!flag && !flag2 && !flag3) { flag = true; } if (flag) { idx.Foreshadow.Add(sfxPrefabName); } if (flag2) { idx.Displacement.Add(sfxPrefabName); } if (flag3) { idx.Violation.Add(sfxPrefabName); } } } internal static List GetAutoPool(Biome biome, ParanoiaCategory cat) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) EnsureSfxIndexBuilt(); if (!_sfxIndexBuilt || _availableSfxNames.Count == 0) { return new List(); } if (!_creaturesByBiome.TryGetValue(biome, out var value) || value == null || value.Length == 0) { value = null; } List list = new List(64); if (value != null) { foreach (string text in value) { if (!string.IsNullOrEmpty(text) && _sfxByCreatureKey.TryGetValue(text, out var value2)) { switch (cat) { case ParanoiaCategory.Foreshadow: list.AddRange(value2.Foreshadow); break; case ParanoiaCategory.Displacement: list.AddRange(value2.Displacement); break; case ParanoiaCategory.Violation: list.AddRange(value2.Violation); break; } } } } if (list.Count == 0) { foreach (KeyValuePair item in _sfxByCreatureKey) { CreatureSfxIndex value3 = item.Value; if (value3 != null) { switch (cat) { case ParanoiaCategory.Foreshadow: list.AddRange(value3.Foreshadow); break; case ParanoiaCategory.Displacement: list.AddRange(value3.Displacement); break; case ParanoiaCategory.Violation: list.AddRange(value3.Violation); break; } } } } if (list.Count > 1) { HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); List list2 = new List(list.Count); for (int j = 0; j < list.Count; j++) { string text2 = list[j]; if (!string.IsNullOrEmpty(text2) && hashSet.Add(text2)) { list2.Add(text2); } } list = list2; } return list; } internal static bool IsSfxAvailable(string sfxPrefabName) { if (string.IsNullOrEmpty(sfxPrefabName)) { return false; } EnsureSfxIndexBuilt(); if (_availableSfxNames.Count == 0) { return true; } return _availableSfxNames.Contains(sfxPrefabName); } private void Awake() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown _self = this; BindConfig(); ParanoiaRelics.Init(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); TryExtractEmbeddedResources(); TryRegisterParanoidinRpc(); if ((Object)(object)ParanoiaEngine.Instance == (Object)null) { ((Component)this).gameObject.AddComponent(); } if ((Object)(object)HallucinationManager.Instance == (Object)null) { ((Component)this).gameObject.AddComponent(); } ParanoiaConsole.TryRegister(); _harmony = new Harmony("Pix.Paranoia"); try { _harmony.PatchAll(typeof(ParanoiaPlugin).Assembly); } catch (Exception arg) { Debug.LogError((object)$"[Paranoia] PatchAll failed: {arg}"); } _criticalHarmony = new Harmony("Pix.Paranoia.critical"); ParanoiaRelics.ApplyPatches(_criticalHarmony); ParanoiaSerpent.Init(_criticalHarmony, ((BaseUnityPlugin)this).Logger); ParanoiaGreydwarfs.Init(_harmony); ParanoiaNausea.Init(_harmony, ((BaseUnityPlugin)this).Config); ParanoiaInfection.Init(_criticalHarmony, ((BaseUnityPlugin)this).Logger, ((BaseUnityPlugin)this).Config); } private void OnDestroy() { try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } try { Harmony criticalHarmony = _criticalHarmony; if (criticalHarmony != null) { criticalHarmony.UnpatchSelf(); } } catch { } } private void BindConfig() { //IL_0a87: Unknown result type (might be due to invalid IL or missing references) //IL_0a91: Expected O, but got Unknown //IL_0ac4: Unknown result type (might be due to invalid IL or missing references) //IL_0ace: Expected O, but got Unknown //IL_0b01: Unknown result type (might be due to invalid IL or missing references) //IL_0b0b: Expected O, but got Unknown //IL_0b3e: Unknown result type (might be due to invalid IL or missing references) //IL_0b48: Expected O, but got Unknown //IL_0be3: Unknown result type (might be due to invalid IL or missing references) //IL_0bed: Expected O, but got Unknown //IL_0c15: Unknown result type (might be due to invalid IL or missing references) //IL_0c1f: Expected O, but got Unknown //IL_0c52: Unknown result type (might be due to invalid IL or missing references) //IL_0c5c: Expected O, but got Unknown //IL_0c8f: Unknown result type (might be due to invalid IL or missing references) //IL_0c99: Expected O, but got Unknown //IL_0ccc: Unknown result type (might be due to invalid IL or missing references) //IL_0cd6: Expected O, but got Unknown //IL_0d49: Unknown result type (might be due to invalid IL or missing references) //IL_0d53: Expected O, but got Unknown //IL_0d7a: Unknown result type (might be due to invalid IL or missing references) //IL_0d84: Expected O, but got Unknown //IL_0dab: Unknown result type (might be due to invalid IL or missing references) //IL_0db5: Expected O, but got Unknown //IL_0de8: Unknown result type (might be due to invalid IL or missing references) //IL_0df2: Expected O, but got Unknown //IL_0e25: Unknown result type (might be due to invalid IL or missing references) //IL_0e2f: Expected O, but got Unknown //IL_0e62: Unknown result type (might be due to invalid IL or missing references) //IL_0e6c: Expected O, but got Unknown //IL_0e9f: Unknown result type (might be due to invalid IL or missing references) //IL_0ea9: Expected O, but got Unknown //IL_0edc: Unknown result type (might be due to invalid IL or missing references) //IL_0ee6: Expected O, but got Unknown //IL_0f19: Unknown result type (might be due to invalid IL or missing references) //IL_0f23: Expected O, but got Unknown //IL_0f56: Unknown result type (might be due to invalid IL or missing references) //IL_0f60: Expected O, but got Unknown //IL_0f93: Unknown result type (might be due to invalid IL or missing references) //IL_0f9d: Expected O, but got Unknown //IL_0fd0: Unknown result type (might be due to invalid IL or missing references) //IL_0fda: Expected O, but got Unknown //IL_100d: Unknown result type (might be due to invalid IL or missing references) //IL_1017: Expected O, but got Unknown //IL_104a: Unknown result type (might be due to invalid IL or missing references) //IL_1054: Expected O, but got Unknown //IL_1087: Unknown result type (might be due to invalid IL or missing references) //IL_1091: Expected O, but got Unknown //IL_10e4: Unknown result type (might be due to invalid IL or missing references) //IL_10ee: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable/disable Pix.Paranoia."); DebugLogging = ((BaseUnityPlugin)this).Config.Bind("General", "DebugLogging", false, "Enable debug logs."); UseSleepDeprivation = ((BaseUnityPlugin)this).Config.Bind("Sleep", "UseSleepDeprivation", true, "If true, paranoia ramps based on days without sleep."); DaysWithoutSleepThreshold = ((BaseUnityPlugin)this).Config.Bind("Sleep", "DaysWithoutSleepThreshold", 1, "Days without sleep before paranoia begins (Default: 1)."); TickIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind("Balance", "TickIntervalSeconds", 1.25f, "How often the engine checks to fire a paranoia event."); BaseEventChancePerTick = ((BaseUnityPlugin)this).Config.Bind("Balance", "BaseEventChancePerTick", 0.035f, "Base chance per tick to attempt an event (tiers multiply)."); NightChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind("Bias", "NightChanceMultiplier", 1.6f, "Multiplier to event chance at night."); GlobalCooldownSeconds = ((BaseUnityPlugin)this).Config.Bind("Cooldowns", "GlobalCooldownSeconds", 120f, "Global cooldown after any paranoia event."); ForeshadowCooldownSeconds = ((BaseUnityPlugin)this).Config.Bind("Cooldowns", "ForeshadowCooldownSeconds", 45f, "Cooldown for Foreshadowing events."); DisplacementCooldownSeconds = ((BaseUnityPlugin)this).Config.Bind("Cooldowns", "DisplacementCooldownSeconds", 90f, "Cooldown for Displacement events."); ViolationCooldownSeconds = ((BaseUnityPlugin)this).Config.Bind("Cooldowns", "ViolationCooldownSeconds", 220f, "Cooldown for Violation events."); ViolationForeignBiomeChance = ((BaseUnityPlugin)this).Config.Bind("Biome", "ViolationForeignBiomeChance", 0.08f, "When a VIOLATION event fires, chance (0-1) to pick the pool from a DIFFERENT biome (rare cross-biome \"wrong sound\" moments). This does not change how often Violation events occur; it only affects which biome pool is used once a Violation is chosen. Set to 0 for biome-pure."); SameSoundRepeatBlockSeconds = ((BaseUnityPlugin)this).Config.Bind("Cooldowns", "SameSoundRepeatBlockSeconds", 300f, "Block repeating the exact same sound for this many seconds."); EnableEatTrigger = ((BaseUnityPlugin)this).Config.Bind("Triggers", "EnableEatTrigger", true, "If true, eating can (rarely) trigger a paranoia sound."); EatTriggerChance = ((BaseUnityPlugin)this).Config.Bind("Triggers", "EatTriggerChance", 0.06f, "Chance for an eat-triggered paranoia attempt (still respects cooldowns/safety)."); DisplacementMinDistance = ((BaseUnityPlugin)this).Config.Bind("Spatial", "DisplacementMinDistance", 18f, "Min distance for displacement sounds (distant)."); DisplacementMaxDistance = ((BaseUnityPlugin)this).Config.Bind("Spatial", "DisplacementMaxDistance", 45f, "Max distance for displacement sounds (distant)."); ForeshadowDistance = ((BaseUnityPlugin)this).Config.Bind("Spatial", "ForeshadowDistance", 7f, "Distance for foreshadow sounds (near)."); ViolationDistance = ((BaseUnityPlugin)this).Config.Bind("Spatial", "ViolationDistance", 5f, "Distance for violation sounds (very near)."); DisableDuringActiveEvent = ((BaseUnityPlugin)this).Config.Bind("Safety", "DisableDuringActiveEvent", true, "If true, paranoia won't fire during raids/random events."); ForcePlayAudioSources = ((BaseUnityPlugin)this).Config.Bind("Testing", "ForcePlayAudioSources", true, "If true, spawned sfx will force-play any AudioSource components found (helps testing)."); ForcedNearSpawnDistance = ((BaseUnityPlugin)this).Config.Bind("Testing", "ForcedNearSpawnDistance", 2.5f, "Distance used when pn_fire spawns an explicit prefab name (keeps it close)."); SleepTest_DaySeconds = ((BaseUnityPlugin)this).Config.Bind("Testing", "SleepTest_DaySeconds", 1800f, "Seconds per 'day' for Paranoia sleep-deprivation."); Meadows_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - Meadows", "Foreshadow", "AUTO", "CSV list of sfx prefab names."); Meadows_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - Meadows", "Displacement", "AUTO", "CSV list of sfx prefab names."); Meadows_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - Meadows", "Violation", "AUTO", "CSV list of sfx prefab names."); BlackForest_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - BlackForest", "Foreshadow", "AUTO", "CSV list."); BlackForest_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - BlackForest", "Displacement", "AUTO", "CSV list."); BlackForest_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - BlackForest", "Violation", "AUTO", "CSV list."); Swamp_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - Swamp", "Foreshadow", "AUTO", "CSV list."); Swamp_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - Swamp", "Displacement", "AUTO", "CSV list."); Swamp_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - Swamp", "Violation", "AUTO", "CSV list."); Mountains_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - Mountains", "Foreshadow", "AUTO", "CSV list."); Mountains_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - Mountains", "Displacement", "AUTO", "CSV list."); Mountains_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - Mountains", "Violation", "AUTO", "CSV list."); Plains_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - Plains", "Foreshadow", "AUTO", "CSV list."); Plains_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - Plains", "Displacement", "AUTO", "CSV list."); Plains_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - Plains", "Violation", "AUTO", "CSV list."); Mistlands_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - Mistlands", "Foreshadow", "AUTO", "CSV list."); Mistlands_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - Mistlands", "Displacement", "AUTO", "CSV list."); Mistlands_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - Mistlands", "Violation", "AUTO", "CSV list."); Ocean_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - Ocean", "Foreshadow", "AUTO", "CSV list."); Ocean_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - Ocean", "Displacement", "AUTO", "CSV list."); Ocean_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - Ocean", "Violation", "AUTO", "CSV list."); AshLands_Foreshadow = ((BaseUnityPlugin)this).Config.Bind("Pools - AshLands", "Foreshadow", "AUTO", "CSV list."); AshLands_Displacement = ((BaseUnityPlugin)this).Config.Bind("Pools - AshLands", "Displacement", "AUTO", "CSV list."); AshLands_Violation = ((BaseUnityPlugin)this).Config.Bind("Pools - AshLands", "Violation", "AUTO", "CSV list."); EnableParanoidin = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "EnableParanoidin", true, "Enable/disable the Paranoidin sequence (Phase 2)."); ParanoidinChancePerTickSevere = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "ChancePerTickSevere", 0.01f, "Chance per tick (Tier >= MinTier) to start a Paranoidin sequence. This is *in addition* to audio events."); ParanoidinChancePerTickModerate = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "ChancePerTickModerate", 0.0045f, "Chance per tick when Tier=Moderate to start a Paranoidin sequence."); ParanoidinChancePerTickMild = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "ChancePerTickMild", 0.0015f, "Chance per tick when Tier=Mild to start a Paranoidin sequence."); ParanoidinMinTier = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "MinTier", "Moderate", "Minimum paranoia tier required for Paranoidin to naturally start: None, Mild, Moderate, Severe."); ParanoidinCooldownSeconds = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "CooldownSeconds", 180f, "Cooldown after a Paranoidin sequence starts (seconds)."); ParanoidinEnvironmentEnabled = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "EnvironmentEnabled", true, "If false, Paranoidin will not force any environment/overlay changes."); DisableParanoiaTickDuringRespawnLockout = ((BaseUnityPlugin)this).Config.Bind("Safety", "DisableParanoiaTickDuringRespawnLockout", true, "If true, ParanoiaEngine tick logic is suppressed for a short window during death/respawn transitions to avoid engine edge cases."); RespawnLockoutSeconds = ((BaseUnityPlugin)this).Config.Bind("Safety", "RespawnLockoutSeconds", 20f, "Seconds to suppress ParanoiaEngine + Paranoidin logic during death/respawn transitions."); ParanoidinPrefabNames = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "PrefabNames", "Odin", "CSV list of prefabs to try for Paranoidin visuals (first found is used). Default tries 'Odin'."); ParanoidinFarShowDistance = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "FarShowDistance", 35f, "Distance for the initial far Odin sighting (tease)."); ParanoidinFarShowSeconds = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "FarShowSeconds", 2f, "How long the far Odin stays before vanishing."); ParanoidinStartDistance = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "StartDistance", 18f, "Initial Paranoidin spawn distance (closer than the far tease)."); ParanoidinMinDistance = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "MinDistance", 7f, "Minimum distance Paranoidin will teleport to."); ParanoidinTeleportStep = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "TeleportStep", 3.5f, "How much closer Paranoidin moves when you break line of sight."); ParanoidinTeleportCooldown = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "TeleportCooldown", 0.85f, "Minimum seconds between Paranoidin teleports."); ParanoidinDespawnDistance = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "DespawnDistance", 60f, "If player gets farther than this, Paranoidin despawns."); ParanoidinHoldSeconds = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "HoldSeconds", 3f, "Attack only if LOS + proximity is maintained for this many seconds."); ParanoidinAttackRange = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "AttackRange", 10f, "Attack range (meters)."); ParanoidinAttackWindupSeconds = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "AttackWindupSeconds", 1.15f, "Wind-up seconds before the hit lands (gives a chance to block)."); ParanoidinAttackDamage = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "AttackDamage", 50f, "Damage dealt by Paranoidin hit (blunt)."); ParanoidinDamageRequiresServer = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "DamageRequiresServer", true, "If true, damage only applies when running as server/host (avoids MP client desync)."); ParanoidinDebugAllowClientDamage = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "DebugAllowClientDamage", false, "Testing only. If true, allows damage even when not server/host."); ParanoidinWarningSfx = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "WarningSfx", "", "CSV list of sfx_ prefabs to play during warnings (optional)."); ParanoidinStepSfx = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "StepSfx", "", "CSV list of sfx_ prefabs to play when Paranoidin teleports closer (optional)."); ParanoidinAttackSfx = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "AttackSfx", "", "CSV list of sfx_ prefabs to play right before the hit (optional)."); ParanoidinHauntSfx = ((BaseUnityPlugin)this).Config.Bind("Paranoidin", "HauntSfx", "sfx_wraith_idle,sfx_ghost_idle", "CSV list of ambient haunting SFX played when Paranoidin stalking begins."); CfgHallucinationEnabled = ((BaseUnityPlugin)this).Config.Bind("Hallucination", "Enabled", true, "Enable/disable the Hallucination dungeon feature."); CfgHallucinationWarningTimeSeconds = ((BaseUnityPlugin)this).Config.Bind("Hallucination", "WarningTimeSeconds", 5f, new ConfigDescription("Seconds after entering dungeon before warning message appears.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 60f), Array.Empty())); CfgHallucinationTriggerTimeSeconds = ((BaseUnityPlugin)this).Config.Bind("Hallucination", "TriggerTimeSeconds", 60f, new ConfigDescription("Seconds after entering dungeon before hallucination effect triggers.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 300f), Array.Empty())); CfgHallucinationDurationSeconds = ((BaseUnityPlugin)this).Config.Bind("Hallucination", "DurationSeconds", 300f, new ConfigDescription("How long the hallucination status effect lasts (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange(60f, 600f), Array.Empty())); CfgHallucinationGlobalCooldownSeconds = ((BaseUnityPlugin)this).Config.Bind("Hallucination", "GlobalCooldownSeconds", 600f, new ConfigDescription("Global cooldown before hallucination can trigger again (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange(300f, 3600f), Array.Empty())); CfgHallucinationWarningMessage = ((BaseUnityPlugin)this).Config.Bind("Hallucination", "WarningMessage", "Be quick, the air is thick.", "Warning message shown when entering dungeon."); CfgHallucinationTriggerMessage = ((BaseUnityPlugin)this).Config.Bind("Hallucination", "TriggerMessage", "Your mind begins to warp", "Message shown when hallucination effect is applied."); CfgHallucinationRainbowEnabled = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Visuals", "RainbowEnabled", true, "Enable rainbow color cycling on objects (acid trip effect)."); CfgHallucinationRainbowDistance = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Visuals", "RainbowDistance", 30f, new ConfigDescription("Maximum distance for rainbow effect on objects.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 100f), Array.Empty())); CfgHallucinationMaxFakeCreatures = ((BaseUnityPlugin)this).Config.Bind("Hallucination.FakeCreatures", "MaxFakeCreatures", 3, new ConfigDescription("Maximum number of fake creatures that can exist at once.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10), Array.Empty())); CfgHallucinationFakeCreatureSpawnInterval = ((BaseUnityPlugin)this).Config.Bind("Hallucination.FakeCreatures", "SpawnInterval", 15f, new ConfigDescription("Seconds between fake creature spawns.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 60f), Array.Empty())); CfgHallucinationFakeCreatureMinDistance = ((BaseUnityPlugin)this).Config.Bind("Hallucination.FakeCreatures", "MinDistance", 10f, new ConfigDescription("Minimum spawn distance from player.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 50f), Array.Empty())); CfgHallucinationFakeCreatureMaxDistance = ((BaseUnityPlugin)this).Config.Bind("Hallucination.FakeCreatures", "MaxDistance", 25f, new ConfigDescription("Maximum spawn distance from player.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 100f), Array.Empty())); CfgHallucinationFakeCreatureBiomeOnly = ((BaseUnityPlugin)this).Config.Bind("Hallucination.FakeCreatures", "BiomeOnly", true, "If true, fake creatures will only spawn from the player's current biome pool."); CfgHallucinationFakeCreatureChaotic = ((BaseUnityPlugin)this).Config.Bind("Hallucination.FakeCreatures", "Chaotic", false, "Overrides BiomeOnly. Spawns fully random creatures including bosses and rare monsters for maximum chaos."); CfgHallucinationBlurStrength = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Blur", "BlurStrength", 0.8f, new ConfigDescription("Overall blur intensity multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); CfgHallucinationBlurIterations = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Blur", "BlurIterations", 3, new ConfigDescription("Number of blur downsample passes. Higher = blurrier but costs more.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 6), Array.Empty())); CfgHallucinationBlurDownsample = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Blur", "Downsample", 1, new ConfigDescription("Downsample factor per iteration (power of 2). 1 = half res, 2 = quarter res.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 3), Array.Empty())); CfgHallucinationEdgeWidth = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Blur", "EdgeWidth", 0.4f, new ConfigDescription("How far the edge vignette extends inward (0 = none, 1 = full screen).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); CfgHallucinationEdgeSoftness = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Blur", "EdgeSoftness", 0.3f, new ConfigDescription("Softness of the vignette edge transition.", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 1f), Array.Empty())); CfgHallucinationPulseSpeed = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Blur", "PulseSpeed", 1.5f, new ConfigDescription("Speed of the pulsing effect (cycles per second).", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 5f), Array.Empty())); CfgHallucinationPulseAmplitude = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Blur", "PulseAmplitude", 0.3f, new ConfigDescription("Strength of the pulse (0 = no pulse, 1 = double intensity at peak).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); CfgHallucinationOnsetBurialChambers = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "BurialChambersSeconds", 30f, new ConfigDescription("Seconds before hallucination onset in Burial Chambers (DG_ForestCrypt).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 300f), Array.Empty())); CfgHallucinationOnsetTrollCave = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "TrollCaveSeconds", 45f, new ConfigDescription("Seconds before hallucination onset in Troll Caves (DG_TrollCave).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 300f), Array.Empty())); CfgHallucinationOnsetSunkenCrypt = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "SunkenCryptSeconds", 60f, new ConfigDescription("Seconds before hallucination onset in Sunken Crypts (DG_SunkenCrypt).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 300f), Array.Empty())); CfgHallucinationOnsetFrostCave = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "FrostCaveSeconds", 75f, new ConfigDescription("Seconds before hallucination onset in Frost Caves (DG_FrostCave).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 300f), Array.Empty())); CfgHallucinationOnsetSealedTower = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "SealedTowerSeconds", 90f, new ConfigDescription("Seconds before hallucination onset in Sealed Towers (DG_SealedTower).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 600f), Array.Empty())); CfgHallucinationOnsetInfestedMine = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "InfestedMineSeconds", 105f, new ConfigDescription("Seconds before hallucination onset in Infested Mines (DG_DvergrMine).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 600f), Array.Empty())); CfgHallucinationOnsetPutridHole = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "PutridHoleSeconds", 120f, new ConfigDescription("Seconds before hallucination onset in Putrid Holes (DG_PutridHole).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 600f), Array.Empty())); CfgHallucinationOnsetSmoulderingTomb = ((BaseUnityPlugin)this).Config.Bind("Hallucination.Onset", "SmoulderingTombSeconds", 150f, new ConfigDescription("Seconds before hallucination onset in Smouldering Tombs (DG_SmoulderingTomb).", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 600f), Array.Empty())); CfgWhisperingGreydwarfEnabled = ((BaseUnityPlugin)this).Config.Bind("WhisperingGreydwarfs", "Enabled", true, "Enable/disable Whispering Greydwarfs (emit DemonicWhisperLoop instead of normal sounds)."); CfgWhisperingGreydwarfChance = ((BaseUnityPlugin)this).Config.Bind("WhisperingGreydwarfs", "SpawnChance", 0.15f, new ConfigDescription("Chance (0-1) that a spawned greydwarf becomes a whispering variant.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); } internal static void TryExtractEmbeddedResources() { try { string text = null; try { text = Path.GetDirectoryName(typeof(ParanoiaPlugin).Assembly.Location); } catch { text = null; } if (string.IsNullOrEmpty(text)) { try { text = Paths.PluginPath; } catch { text = null; } } if (!string.IsNullOrEmpty(text)) { TryExtractOne("ParanoiaSE.png", Path.Combine(text, "ParanoiaSE.png")); TryExtractOne("HallucinateSE.png", Path.Combine(text, "HallucinateSE.png")); TryExtractOne("NauseaSE.png", Path.Combine(text, "NauseaSE.png")); string path = Path.Combine(text, "Assets"); TryExtractOne("px_paranoia_haunts", Path.Combine(path, "px_paranoia_haunts")); TryExtractOne("px_relics", Path.Combine(path, "px_relics")); TryExtractOne("px_paranoia_haunts", Path.Combine(text, "px_paranoia_haunts")); TryExtractOne("px_relics", Path.Combine(text, "px_relics")); } } catch { } } private static void TryExtractOne(string embeddedSuffix, string outputPath) { try { if (string.IsNullOrEmpty(embeddedSuffix) || string.IsNullOrEmpty(outputPath) || File.Exists(outputPath)) { return; } byte[] array = null; try { array = ResourcesEmbedded.ReadAllBytesBySuffix(embeddedSuffix); } catch { array = null; } if (array != null && array.Length != 0) { string directoryName = Path.GetDirectoryName(outputPath); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllBytes(outputPath, array); } } catch { } } internal static void LogInfo(string msg) { ParanoiaPlugin self = _self; if (self != null) { ManualLogSource logger = ((BaseUnityPlugin)self).Logger; if (logger != null) { logger.LogInfo((object)msg); } } } internal static void LogWarning(string msg) { ParanoiaPlugin self = _self; if (self != null) { ManualLogSource logger = ((BaseUnityPlugin)self).Logger; if (logger != null) { logger.LogWarning((object)msg); } } } internal static void LogDebug(string msg) { if (DebugLogging == null || !DebugLogging.Value) { return; } ParanoiaPlugin self = _self; if (self != null) { ManualLogSource logger = ((BaseUnityPlugin)self).Logger; if (logger != null) { logger.LogInfo((object)("[DEBUG] " + msg)); } } } internal static void LogWarn(string msg) { ParanoiaPlugin self = _self; if (self != null) { ManualLogSource logger = ((BaseUnityPlugin)self).Logger; if (logger != null) { logger.LogWarning((object)msg); } } } internal static void TryRegisterParanoidinRpc() { try { if (!_paranoidinRpcRegistered && ZRoutedRpc.instance != null) { _paranoidinRpcRegistered = true; ZRoutedRpc.instance.Register("PX_ParanoidinDamage", (Action)RPC_ParanoidinDamage); } } catch { } } private static void RPC_ParanoidinDamage(long sender, ZPackage pkg) { //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_004c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (Object)(object)ZNetScene.instance == (Object)null) { return; } ZDOID val = pkg.ReadZDOID(); float bluntDamage = pkg.ReadSingle(); Vector3 point = pkg.ReadVector3(); Vector3 dir = pkg.ReadVector3(); float pushForce = pkg.ReadSingle(); GameObject val2 = ZNetScene.instance.FindInstance(val); if (Object.op_Implicit((Object)(object)val2)) { Player component = val2.GetComponent(); if (Object.op_Implicit((Object)(object)component) && !((Character)component).IsDead()) { ApplyParanoidinDamageLocal(component, bluntDamage, point, dir, pushForce); } } } catch { } } internal static void ApplyParanoidinDamageAuthoritative(Player player, float bluntDamage, Vector3 point, Vector3 dir, float pushForce) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null || ((Character)player).IsDead()) { return; } bool flag = true; try { flag = ParanoidinDamageRequiresServer == null || ParanoidinDamageRequiresServer.Value; } catch { flag = true; } if (flag && (Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer()) { TryRegisterParanoidinRpc(); if (ZRoutedRpc.instance == null) { return; } ZPackage val = new ZPackage(); val.Write(((Character)player).GetZDOID()); val.Write(bluntDamage); val.Write(point); val.Write(dir); val.Write(pushForce); long num = 0L; try { ZNetPeer val2 = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetServerPeer() : null); if (val2 != null) { num = val2.m_uid; } } catch { } ZRoutedRpc.instance.InvokeRoutedRPC(num, "PX_ParanoidinDamage", new object[1] { val }); } else { ApplyParanoidinDamageLocal(player, bluntDamage, point, dir, pushForce); } } catch { } } private static void ApplyParanoidinDamageLocal(Player player, float bluntDamage, Vector3 point, Vector3 dir, float pushForce) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)player == (Object)null) && !((Character)player).IsDead()) { HitData val = new HitData(); val.m_damage.m_blunt = bluntDamage; val.m_point = point; val.m_dir = dir; val.m_pushForce = pushForce; ((Character)player).Damage(val); } } catch { } } } internal enum ParanoiaCategory { Foreshadow, Displacement, Violation } internal enum ParanoiaTier { None, Mild, Moderate, Severe } internal sealed class ParanoiaEngine : MonoBehaviour { internal enum FireResult { Fired, NotReady, NoLocalPlayer, PrefabNotFound, GateBlocked, RepeatBlocked, CooldownBlocked, SpawnFailed } private sealed class FalseEventProfile { public string Id; public string DisplayName; public int DeckWeight = 1; public float DurationSeconds = 60f; public float StartDelaySeconds = 0f; public float PulseIntervalSeconds = 12f; public string StartMessage; public string PulseMessage; public string EndMessage; public bool DoPuke; public float StaminaDrainOnStart; public bool FakeHitOnStart; public bool TimeDistortion; public string StartOneShotOgg; public float StartOneShotVolume = 1f; public string StartAmbienceOgg; public float StartAmbienceVolume = 0.7f; public string PulseOneShotOgg; public float PulseOneShotVolume = 1f; public bool PulsePreferVanillaSfx; public string[] PulseVanillaSfxPrefabs; public bool PulseBehindPlayer = true; public float PulseBehindMeters = 3f; public float OneShotCooldownSeconds = 6f; } [CompilerGenerated] private sealed class d__114 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ParanoiaEngine <>4__this; private Player 5__1; private float 5__2; private FalseEventProfile 5__3; private float 5__4; private float 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__114(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; case 3: <>1__state = -1; if (<>4__this._falseEventActive) { break; } 5__3 = null; try { 5__3 = <>4__this.PickNextFalseEventFromDeck(); } catch { 5__3 = null; } if (5__3 != null && !string.IsNullOrEmpty(5__3.Id)) { try { 5__4 = Mathf.Max(1f, 5__3.DurationSeconds); } catch { 5__4 = 8f; } try { <>4__this.StartFalseEvent_Local(5__3.Id, 5__4); } catch { } 5__1 = null; 5__3 = null; } break; } 5__1 = Player.m_localPlayer; if ((Object)(object)5__1 == (Object)null) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } if (<>4__this._falseEventActive) { <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 2; return true; } try { 5__5 = Random.value; if (5__5 < 0.7f) { 5__2 = Random.Range(3600f, 7200f); } else if (5__5 < 0.9f) { 5__2 = Random.Range(7200f, 10800f); } else { 5__2 = Random.Range(10800f, 14400f); } } catch { 5__2 = 5400f; } <>2__current = (object)new WaitForSeconds(5__2); <>1__state = 3; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__110 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ParanoiaEngine <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__110(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (<>4__this._falseEventActive && !(Time.time >= <>4__this._falseEventEndsAt)) { <>2__current = null; <>1__state = 1; return true; } <>4__this.StopFalseEvent_Local(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__111 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ParanoiaEngine <>4__this; private FalseEventProfile

5__1; private float 5__2; private Vector3 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__111(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() {

5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1;

5__1 = null; break; } if (<>4__this._falseEventActive) {

5__1 = <>4__this._activeFalseEvent; if (

5__1 != null) { 5__2 = Mathf.Max(0.25f,

5__1.PulseIntervalSeconds); 5__3 = Vector3.zero; try { 5__3 = <>4__this.GetPulsePosition(

5__1.PulseBehindPlayer,

5__1.PulseBehindMeters); } catch { 5__3 = Vector3.zero; } try { if (!string.IsNullOrEmpty(

5__1.PulseOneShotOgg)) { <>4__this.TryPlayFalseEventOneShot(

5__1.PulseOneShotOgg,

5__1.PulseOneShotVolume,

5__1.PulseBehindPlayer); } } catch { } try { if (

5__1.PulsePreferVanillaSfx &&

5__1.PulseVanillaSfxPrefabs != null &&

5__1.PulseVanillaSfxPrefabs.Length != 0) { <>4__this.TryPlayVanillaSfxAt(5__3,

5__1.PulseVanillaSfxPrefabs); } else if (!string.IsNullOrEmpty(

5__1.PulseOneShotOgg)) { <>4__this.TryPlayFalseEventOneShot(

5__1.PulseOneShotOgg,

5__1.PulseOneShotVolume,

5__1.PulseBehindPlayer); } } catch { } <>2__current = (object)new WaitForSeconds(5__2); <>1__state = 1; return true; } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__193 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public ParanoiaEngine <>4__this; private float 5__1; private Vector3

5__2; private Vector3

5__3; private Vector3 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__193(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0086: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_012e: 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_016d: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = Time.time + 2f; break; case 1: <>1__state = -1; break; } if (<>4__this._paranoidinActive && Time.time < 5__1 && !((Object)(object)player == (Object)null) && !((Character)player).IsDead()) { try { if ((Object)(object)<>4__this._paranoidinGo != (Object)null) {

5__2 = ((Component)player).transform.position;

5__3 = <>4__this._paranoidinGo.transform.position -

5__2;

5__3.y = 0f; if (((Vector3)(ref 5__3)).sqrMagnitude < 0.001f) { 5__3 = ((Component)player).transform.forward; } ((Vector3)(ref 5__3)).Normalize(); <>4__this._paranoidinPos += 5__3 * 11f * Time.deltaTime; <>4__this.ClampToGroundStable(ref <>4__this._paranoidinPos); <>4__this._paranoidinGo.transform.position = <>4__this._paranoidinPos; 5__4 =

5__2 - <>4__this._paranoidinPos; 5__4.y = 0f; if (((Vector3)(ref 5__4)).sqrMagnitude > 0.01f) { <>4__this._paranoidinGo.transform.rotation = Quaternion.LookRotation(((Vector3)(ref 5__4)).normalized); } } } catch { } <>2__current = null; <>1__state = 1; return true; } try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__198 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public ParanoiaEngine <>4__this; private float 5__1; private Vector3

5__2; private Vector3 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__198(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0086: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = Time.time + 0.35f; break; case 1: <>1__state = -1; break; } if (<>4__this._paranoidinActive && Time.time < 5__1 && !((Object)(object)player == (Object)null) && !((Character)player).IsDead()) { try { if ((Object)(object)<>4__this._paranoidinGo != (Object)null) {

5__2 = ((Component)player).transform.position; 5__3 =

5__2 - <>4__this._paranoidinGo.transform.position; 5__3.y = 0f; if (((Vector3)(ref 5__3)).sqrMagnitude > 0.01f) { <>4__this._paranoidinGo.transform.rotation = Quaternion.LookRotation(((Vector3)(ref 5__3)).normalized); } } } catch { } <>2__current = null; <>1__state = 1; return true; } try { <>4__this.Haunt3_DropPlayerToOneHpAuthoritative(player); } catch { } try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__197 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public ParanoiaEngine <>4__this; private float 5__1; private Vector3

5__2; private Vector3

5__3; private Vector3 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__197(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0086: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_012e: 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_016d: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = Time.time + 1.75f; break; case 1: <>1__state = -1; break; } if (<>4__this._paranoidinActive && Time.time < 5__1 && !((Object)(object)player == (Object)null) && !((Character)player).IsDead()) { try { if ((Object)(object)<>4__this._paranoidinGo != (Object)null) {

5__2 = ((Component)player).transform.position;

5__3 = <>4__this._paranoidinGo.transform.position -

5__2;

5__3.y = 0f; if (((Vector3)(ref 5__3)).sqrMagnitude < 0.001f) { 5__3 = ((Component)player).transform.forward; } ((Vector3)(ref 5__3)).Normalize(); <>4__this._paranoidinPos += 5__3 * 12.5f * Time.deltaTime; <>4__this.ClampToGroundStable(ref <>4__this._paranoidinPos); <>4__this._paranoidinGo.transform.position = <>4__this._paranoidinPos; 5__4 =

5__2 - <>4__this._paranoidinPos; 5__4.y = 0f; if (((Vector3)(ref 5__4)).sqrMagnitude > 0.01f) { <>4__this._paranoidinGo.transform.rotation = Quaternion.LookRotation(((Vector3)(ref 5__4)).normalized); } } } catch { } <>2__current = null; <>1__state = 1; return true; } try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__203 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public ParanoiaEngine <>4__this; private float 5__1; private Vector3

5__2; private Vector3

5__3; private Vector3 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__203(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0086: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_012e: 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_016d: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = Time.time + 2.2f; break; case 1: <>1__state = -1; break; } if (<>4__this._paranoidinActive && Time.time < 5__1 && !((Object)(object)player == (Object)null) && !((Character)player).IsDead()) { try { if ((Object)(object)<>4__this._paranoidinGo != (Object)null) {

5__2 = ((Component)player).transform.position;

5__3 = <>4__this._paranoidinGo.transform.position -

5__2;

5__3.y = 0f; if (((Vector3)(ref 5__3)).sqrMagnitude < 0.001f) { 5__3 = ((Component)player).transform.forward; } ((Vector3)(ref 5__3)).Normalize(); <>4__this._paranoidinPos += 5__3 * 12f * Time.deltaTime; <>4__this.ClampToGroundStable(ref <>4__this._paranoidinPos); <>4__this._paranoidinGo.transform.position = <>4__this._paranoidinPos; 5__4 =

5__2 - <>4__this._paranoidinPos; 5__4.y = 0f; if (((Vector3)(ref 5__4)).sqrMagnitude > 0.01f) { <>4__this._paranoidinGo.transform.rotation = Quaternion.LookRotation(((Vector3)(ref 5__4)).normalized); } } } catch { } <>2__current = null; <>1__state = 1; return true; } try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__126 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public bool force; public bool ignoreCooldowns; public ParanoiaEngine <>4__this; private int 5__1; private IEnumerator 5__2; private int <>s__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__126(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; 5__1 = <>4__this.PickHauntIndex(); int num = 5__1; <>s__3 = num; switch (<>s__3) { case 2: 5__2 = <>4__this.ParanoidinRoutine_Haunt2(player, force, ignoreCooldowns); break; case 3: 5__2 = <>4__this.ParanoidinRoutine_Haunt3(player, force, ignoreCooldowns); break; case 4: 5__2 = <>4__this.ParanoidinRoutine_Haunt4(player, force, ignoreCooldowns); break; case 5: 5__2 = <>4__this.ParanoidinRoutine_Haunt5(player, force, ignoreCooldowns); break; default: 5__2 = <>4__this.ParanoidinRoutine_Haunt1(player, force, ignoreCooldowns); break; } <>2__current = 5__2; <>1__state = 1; return true; } case 1: <>1__state = -1; if (!ignoreCooldowns) { try { <>4__this._nextAllowed_Paranoidin = Time.time + Mathf.Max(2f, ParanoiaPlugin.ParanoidinCooldownSeconds.Value); } catch { <>4__this._nextAllowed_Paranoidin = Time.time + 60f; } } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__185 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public bool force; public bool ignoreCooldowns; public ParanoiaEngine <>4__this; private bool 5__1; private float 5__2; private float 5__3; private GameObject 5__4; private Vector3 5__5; private float 5__6; private float 5__7; private float 5__8; private float 5__9; private Vector3 5__10; private Vector3 5__11; private float 5__12; private bool 5__13; private bool 5__14; private float 5__15; private float 5__16; private float 5__17; private float 5__18; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__185(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 3u) { try { } finally { <>m__Finally1(); } } 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b2: 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_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_079c: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) //IL_092b: Unknown result type (might be due to invalid IL or missing references) //IL_0914: Unknown result type (might be due to invalid IL or missing references) //IL_0930: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) bool result; try { switch (<>1__state) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; <>4__this._paranoidinActive = true; <>4__this._paranoidinAttacking = false; <>4__this._paranoidinLosHold = 0f; <>4__this._paranoidinNearHold = 0f; <>4__this._paranoidinLastTeleportAt = 0f; <>4__this._paranoidinGroundInit = false; <>4__this._paranoidinNextGroundSampleAt = 0f; <>4__this._paranoidinLastGroundSampleXZ = Vector3.zero; <>4__this._paranoidinPlayerInit = false; <>4__this._paranoidinNextPlayerSampleAt = 0f; <>4__this._paranoidinLastPlayerSpeed = 0f; <>4__this._paranoidinHasAnchor = false; <>4__this._paranoidinNextRetargetAt = 0f; <>4__this.TryApplyParanoidinEnvironment(enable: true); if (!ignoreCooldowns) { try { <>4__this._nextAllowed_Paranoidin = Time.time + Mathf.Max(2f, ParanoiaPlugin.ParanoidinCooldownSeconds.Value); } catch { <>4__this._nextAllowed_Paranoidin = Time.time + 30f; } } 5__1 = Random.value < 0.6f; 5__2 = Time.time + Random.Range(25f, 55f); 5__3 = Time.time + Random.Range(6f, 16f); 5__4 = null; <>1__state = -3; if (!((Object)(object)player == (Object)null) && !((Character)player).IsDead() && !((Object)(object)Player.m_localPlayer != (Object)(object)player)) { 5__5 = <>4__this.GetParanoidinSpawnPos(player, Mathf.Max(8f, ParanoiaPlugin.ParanoidinFarShowDistance.Value), preferFront: false); 5__4 = <>4__this.SpawnGhostOdin(5__5); 5__6 = Mathf.Clamp(ParanoiaPlugin.ParanoidinFarShowSeconds.Value, 0.6f, 6f); 5__7 = 0f; goto IL_02d8; } <>4__this.ForceTerminateParanoidin(); result = false; <>m__Finally1(); goto end_IL_0000; case 1: <>1__state = -3; goto IL_02d8; case 2: <>1__state = -3; goto IL_03ad; case 3: <>1__state = -3; goto IL_0a57; case 4: { <>1__state = -3; goto IL_0adb; } IL_02d8: if (!<>4__this._paranoidinActive || !(5__7 < 5__6) || (Object)(object)player == (Object)null || ((Character)player).IsDead() || (Object)(object)Player.m_localPlayer != (Object)(object)player) { if ((Object)(object)5__4 != (Object)null) { Object.Destroy((Object)(object)5__4); } 5__4 = null; 5__8 = Random.Range(0.7f, 1.5f); 5__9 = 0f; goto IL_03ad; } 5__7 += Time.deltaTime; <>2__current = null; <>1__state = 1; result = true; goto end_IL_0000; IL_03ad: if (!<>4__this._paranoidinActive || !(5__9 < 5__8) || (Object)(object)player == (Object)null || ((Character)player).IsDead() || (Object)(object)Player.m_localPlayer != (Object)(object)player) { 5__10 = <>4__this.GetParanoidinSpawnPos(player, Mathf.Max(6f, ParanoiaPlugin.ParanoidinStartDistance.Value), preferFront: true); <>4__this._paranoidinGo = <>4__this.SpawnGhostOdin(5__10); <>4__this._paranoidinPos = (((Object)(object)<>4__this._paranoidinGo != (Object)null) ? <>4__this._paranoidinGo.transform.position : 5__10); <>4__this._paranoidinGroundY = <>4__this._paranoidinPos.y; <>4__this._paranoidinGroundInit = true; <>4__this._paranoidinLastGroundSampleXZ = new Vector3(<>4__this._paranoidinPos.x, 0f, <>4__this._paranoidinPos.z); <>4__this._paranoidinNextGroundSampleAt = 0f; try { ((Character)player).Message((MessageType)2, "You feel watched...", 0, (Sprite)null); if ((Object)(object)GameCamera.instance != (Object)null) { GameCamera.instance.AddShake(((Component)player).transform.position, 15f, 0.3f, false); } } catch { } if (!_pxSuppressHaunt1Sfx) { ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(<>4__this._paranoidinPos, "HorrerAmbience2.ogg", 0.7f)); ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(<>4__this._paranoidinPos, "Haunt1Voice.ogg", 1f)); } <>4__this.UpdatePlayerSpeedEstimate(player); <>4__this._paranoidinStalkAnchor = <>4__this.PickAnchorAroundPlayer(player, preferFront: true); <>4__this._paranoidinHasAnchor = true; <>4__this._paranoidinNextRetargetAt = Time.time + Random.Range(1f, 1.6f); goto IL_0adb; } 5__9 += Time.deltaTime; <>2__current = null; <>1__state = 2; result = true; goto end_IL_0000; IL_0a57: if (!<>4__this._paranoidinActive || !(5__18 < 5__17) || (Object)(object)player == (Object)null || ((Character)player).IsDead() || (Object)(object)Player.m_localPlayer != (Object)(object)player) { <>4__this.TryApplyParanoidinDamage(player); if ((Object)(object)<>4__this._paranoidinGo != (Object)null) { <>4__this.EndOdinClamp(<>4__this._paranoidinGo); } break; } 5__18 += Time.deltaTime; if ((Object)(object)<>4__this._paranoidinGo != (Object)null && <>4__this._odinClamped) { <>4__this.UpdateOdinClampAnchor(player); } <>2__current = null; <>1__state = 3; result = true; goto end_IL_0000; IL_0adb: if (!<>4__this._paranoidinActive || !(Time.time < 5__2) || (Object)(object)player == (Object)null || ((Character)player).IsDead() || (Object)(object)Player.m_localPlayer != (Object)(object)player || (!force && !<>4__this.IsSafeToFire(player))) { break; } <>4__this.UpdatePlayerSpeedEstimate(player); 5__11 = (((Object)(object)<>4__this._paranoidinGo != (Object)null) ? <>4__this._paranoidinGo.transform.position : <>4__this._paranoidinPos); 5__12 = Vector3.Distance(((Component)player).transform.position, 5__11); if (5__12 > Mathf.Max(18f, ParanoiaPlugin.ParanoidinDespawnDistance.Value)) { break; } 5__13 = <>4__this.HasLineOfSightSimple(player, 5__11); if (!5__13) { 5__16 = Mathf.Max(0.1f, ParanoiaPlugin.ParanoidinTeleportCooldown.Value); if (Time.time - <>4__this._paranoidinLastTeleportAt >= 5__16) { <>4__this._paranoidinLastTeleportAt = Time.time; <>4__this.TeleBlink(player, ref 5__11, preferFront: false); <>4__this.TryPlayConfiguredSfxAt(5__11, ParanoiaPlugin.ParanoidinStepSfx.Value); 5__12 = Vector3.Distance(((Component)player).transform.position, 5__11); } } 5__14 = Time.time < 5__3; <>4__this.DriveChase(player, ref 5__11, 5__12, 5__13, Time.deltaTime, 5__14); if (5__13) { <>4__this._paranoidinLosHold += Time.deltaTime; } else { <>4__this._paranoidinLosHold = 0f; } 5__15 = Mathf.Max(1f, ParanoiaPlugin.ParanoidinAttackRange.Value); if (5__12 <= 5__15) { <>4__this._paranoidinNearHold += Time.deltaTime; } else { <>4__this._paranoidinNearHold = 0f; } if (5__1 && !<>4__this._paranoidinAttacking && Time.time >= 5__3 && (force || <>4__this.GetCurrentTier(player) == ParanoiaTier.Severe)) { <>4__this._paranoidinAttacking = true; <>4__this.ForceCloseForAttack(player); 5__11 = (((Object)(object)<>4__this._paranoidinGo != (Object)null) ? <>4__this._paranoidinGo.transform.position : <>4__this._paranoidinPos); <>4__this.TryPlayConfiguredSfxAt(5__11, ParanoiaPlugin.ParanoidinAttackSfx.Value); if ((Object)(object)<>4__this._paranoidinGo != (Object)null) { <>4__this.BeginOdinClamp(<>4__this._paranoidinGo, player); } 5__17 = Mathf.Clamp(ParanoiaPlugin.ParanoidinAttackWindupSeconds.Value, 0.35f, 3f); 5__18 = 0f; goto IL_0a57; } <>2__current = null; <>1__state = 4; result = true; goto end_IL_0000; } <>m__Finally1(); result = false; end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; try { PxStopAllHauntSfx(); } catch { } try { if ((Object)(object)<>4__this._paranoidinGo != (Object)null) { <>4__this.EndOdinClamp(<>4__this._paranoidinGo); Object.Destroy((Object)(object)<>4__this._paranoidinGo); } } catch { } try { if ((Object)(object)5__4 != (Object)null) { Object.Destroy((Object)(object)5__4); } } catch { } <>4__this.TryApplyParanoidinEnvironment(enable: false); <>4__this._paranoidinGo = null; <>4__this._paranoidinActive = false; <>4__this._paranoidinAttacking = false; <>4__this._paranoidinLosHold = 0f; <>4__this._paranoidinNearHold = 0f; <>4__this._odinPrevParent = null; <>4__this._odinClamped = false; <>4__this.DestroyOdinClampAnchor(); try { <>4__this.SoftReboot_PreserveSleepState("paranoidin_end"); } catch { } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__191 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public bool force; public bool ignoreCooldowns; public ParanoiaEngine <>4__this; private GameObject 5__1; private IEnumerator 5__2; private float 5__3; private GameObject

5__4; private Player 5__5; private Player 5__6; private Vector3 5__7; private object 5__8; private Player 5__9; private Player

5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__191(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__2 = null;

5__4 = null; 5__5 = null; 5__6 = null; 5__8 = null; 5__9 = null;

5__10 = null; <>1__state = -2; } private bool MoveNext() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = <>4__this._pxHaunt1Prefab; try {

5__4 = <>4__this.TryGetPxHauntPrefabByName("PX_Haunt_Haunt2"); if ((Object)(object)

5__4 != (Object)null) { <>4__this._pxHaunt1Prefab =

5__4; }

5__4 = null; } catch { } try { 5__5 = Player.m_localPlayer; 5__6 = (((Object)(object)player != (Object)null) ? player : 5__5); 5__7 = (((Object)(object)5__6 != (Object)null) ? ((Component)5__6).transform.position : Vector3.zero); if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__7, "HorrorAmbience1.ogg", 0.7f)); } if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__7, "WhisperBehindYou.ogg", 1f)); } 5__5 = null; 5__6 = null; } catch { } 5__2 = null; _pxSuppressHaunt1Sfx = true; try { 5__2 = <>4__this.ParanoidinRoutine_Haunt1(player, force, ignoreCooldowns); } catch { try { <>4__this.ForceTerminateParanoidin(); } catch { } 5__2 = null; } 5__3 = Time.time; <>1__state = -3; if (5__2 == null) { break; } goto IL_0327; case 1: <>1__state = -3; break; case 2: { <>1__state = -3; 5__8 = null; goto IL_0327; } IL_0327: try { if (!5__2.MoveNext()) { break; } 5__8 = 5__2.Current; goto IL_0221; } catch { } break; IL_0221: if (<>4__this._paranoidinActive && (Object)(object)<>4__this._paranoidinGo != (Object)null && Time.time >= 5__3) { 5__3 = Time.time + 0.15f; 5__9 = Player.m_localPlayer;

5__10 = (((Object)(object)player != (Object)null) ? player : 5__9); if ((Object)(object)

5__10 != (Object)null && <>4__this.Haunt2_IsRepelledByWater(

5__10)) { <>2__current = <>4__this.Haunt2_ShooAway(

5__10); <>1__state = 1; return true; } 5__9 = null;

5__10 = null; } <>2__current = 5__8; <>1__state = 2; return true; } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; try { PxStopAllHauntSfx(); } catch { } try { _pxSuppressHaunt1Sfx = false; } catch { } try { <>4__this.ForceTerminateParanoidin(); } catch { } try { <>4__this._pxHaunt1Prefab = 5__1; } catch { } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__196 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public bool force; public bool ignoreCooldowns; public ParanoiaEngine <>4__this; private GameObject 5__1; private IEnumerator 5__2; private float 5__3; private Vector3 5__4; private float 5__5; private float 5__6; private float 5__7; private GameObject

5__8; private Player 5__9; private Vector3 5__10; private Player 5__11; private Player 5__12; private object 5__13; private float 5__14; private Player 5__15; private Player

5__16; private float 5__17; private float 5__18; private Vector3 5__19; private float

5__20; private float 5__21; private float 5__22; private float 5__23; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__196(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__2 = null;

5__8 = null; 5__9 = null; 5__11 = null; 5__12 = null; 5__13 = null; 5__15 = null;

5__16 = null; <>1__state = -2; } private bool MoveNext() { //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = <>4__this._pxHaunt1Prefab; try {

5__8 = <>4__this.TryGetPxHauntPrefabByName("PX_Haunt_Haunt3"); if ((Object)(object)

5__8 != (Object)null) { <>4__this._pxHaunt1Prefab =

5__8; }

5__8 = null; } catch { } 5__2 = null; try { 5__9 = (((Object)(object)player != (Object)null) ? player : Player.m_localPlayer); 5__10 = (((Object)(object)5__9 != (Object)null) ? ((Component)5__9).transform.position : Vector3.zero); if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__10, "HorrorAmbience1.ogg", 0.7f)); } if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__10, "HorrorRiser3.ogg", 1f)); } 5__9 = null; } catch { } try { _pxSuppressHaunt1Sfx = true; 5__2 = <>4__this.ParanoidinRoutine_Haunt1(player, force, ignoreCooldowns); } catch { try { _pxSuppressHaunt1Sfx = false; } catch { } try { <>4__this.ForceTerminateParanoidin(); } catch { } 5__2 = null; } 5__3 = Time.time; 5__4 = Vector3.zero; 5__5 = -1f; 5__6 = 0f; 5__7 = 0f; try { 5__11 = Player.m_localPlayer; 5__12 = (((Object)(object)player != (Object)null) ? player : 5__11); if ((Object)(object)5__12 != (Object)null) { 5__4 = ((Component)5__12).transform.position; 5__5 = Time.time; } 5__11 = null; 5__12 = null; } catch { } <>1__state = -3; if (5__2 == null) { break; } goto IL_0636; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; case 3: { <>1__state = -3; 5__13 = null; goto IL_0636; } IL_0636: try { if (!5__2.MoveNext()) { break; } 5__13 = 5__2.Current; goto IL_02cc; } catch { } break; IL_02cc: if (<>4__this._paranoidinActive && (Object)(object)<>4__this._paranoidinGo != (Object)null && Time.time >= 5__3) { 5__14 = Time.time; 5__3 = 5__14 + 0.12f; 5__15 = Player.m_localPlayer;

5__16 = (((Object)(object)player != (Object)null) ? player : 5__15); if ((Object)(object)

5__16 != (Object)null && !((Character)

5__16).IsDead()) { 5__17 = 0f; try { 5__19 = ((Component)

5__16).transform.position; if (5__5 > 0f) {

5__20 = Mathf.Max(0.0001f, 5__14 - 5__5); 5__21 = 5__19.x - 5__4.x; 5__22 = 5__19.z - 5__4.z; 5__23 = Mathf.Sqrt(5__21 * 5__21 + 5__22 * 5__22); 5__17 = 5__23 /
5__20; } 5__4 = 5__19; 5__5 = 5__14; } catch { 5__17 = 0f; 5__5 = 5__14; } 5__18 = 0.12f; if (5__17 <= 0.18f) { 5__6 += 5__18; 5__7 = Mathf.Max(0f, 5__7 - 1.25f * 5__18); } else if (5__17 >= 1.1f) { 5__7 += 5__18; 5__6 = Mathf.Max(0f, 5__6 - 1.25f * 5__18); } else { 5__6 = Mathf.Max(0f, 5__6 - 1.25f * 5__18); 5__7 = Mathf.Max(0f, 5__7 - 1.25f * 5__18); } if (5__6 >= 4f) { <>2__current = <>4__this.Haunt3_ShooAway(

5__16); <>1__state = 1; return true; } if (5__7 >= 1.25f) { <>2__current = <>4__this.Haunt3_PunishToOneHp_ThenEnd(

5__16); <>1__state = 2; return true; } } 5__15 = null;

5__16 = null; } <>2__current = 5__13; <>1__state = 3; return true; } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; try { PxStopAllHauntSfx(); } catch { } try { _pxSuppressHaunt1Sfx = false; } catch { } try { <>4__this._pxHaunt1Prefab = 5__1; } catch { } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__201 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public bool force; public bool ignoreCooldowns; public ParanoiaEngine <>4__this; private GameObject 5__1; private Vector3 <_pxH4_LastMovePos>5__2; private float <_pxH4_NextMoveSfxAt>5__3; private IEnumerator 5__4; private float 5__5; private float 5__6; private GameObject

5__7; private Player 5__8; private Player 5__9; private Vector3 5__10; private object 5__11; private float 5__12; private float
5__13; private Player 5__14; private Player

5__15; private Vector3 5__16; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__201(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__4 = null;

5__7 = null; 5__8 = null; 5__9 = null; 5__11 = null; 5__14 = null;

5__15 = null; <>1__state = -2; } private bool MoveNext() { //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = <>4__this._pxHaunt1Prefab; try {

5__7 = <>4__this.TryGetPxHauntPrefabByName("PX_Haunt_Haunt4"); if ((Object)(object)

5__7 != (Object)null) { <>4__this._pxHaunt1Prefab =

5__7; }

5__7 = null; } catch { } try { _pxSuppressHaunt1Sfx = true; } catch { } try { 5__8 = Player.m_localPlayer; 5__9 = (((Object)(object)player != (Object)null) ? player : 5__8); 5__10 = (((Object)(object)5__9 != (Object)null) ? ((Component)5__9).transform.position : Vector3.zero); if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__10, "HorrerAmbience2.ogg", 0.7f)); ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__10, "CreepyLaugh.ogg", 1f)); } 5__8 = null; 5__9 = null; } catch { } <_pxH4_LastMovePos>5__2 = Vector3.positiveInfinity; <_pxH4_NextMoveSfxAt>5__3 = 0f; 5__4 = null; try { 5__4 = <>4__this.ParanoidinRoutine_Haunt1(player, force, ignoreCooldowns); } catch { try { <>4__this.ForceTerminateParanoidin(); } catch { } 5__4 = null; } 5__5 = Time.time; 5__6 = 0f; <>1__state = -3; if (5__4 == null) { break; } goto IL_04b7; case 1: <>1__state = -3; break; case 2: { <>1__state = -3; 5__11 = null; goto IL_04b7; } IL_04b7: try { if (!5__4.MoveNext()) { break; } 5__11 = 5__4.Current; goto IL_023d; } catch { } break; IL_023d: if (<>4__this._paranoidinActive && (Object)(object)<>4__this._paranoidinGo != (Object)null && Time.time >= 5__5) { 5__12 = Time.time;
5__13 = Mathf.Max(0f, 5__12 - (5__5 - 0.12f)); 5__5 = 5__12 + 0.12f; 5__14 = Player.m_localPlayer;

5__15 = (((Object)(object)player != (Object)null) ? player : 5__14); if ((Object)(object)

5__15 != (Object)null && <>4__this.Haunt4_IsPlayerSheltered(

5__15)) { 5__6 +=

5__13; if (5__6 >= 2f) { <>2__current = <>4__this.Haunt4_ShooAway(

5__15); <>1__state = 1; return true; } } else { 5__6 = 0f; } 5__14 = null;

5__15 = null; } try { if (<>4__this._paranoidinActive && (Object)(object)<>4__this._paranoidinGo != (Object)null) { 5__16 = <>4__this._paranoidinGo.transform.position; if (<_pxH4_LastMovePos>5__2.x == float.PositiveInfinity) { <_pxH4_LastMovePos>5__2 = 5__16; } Vector3 val = 5__16 - <_pxH4_LastMovePos>5__2; if (((Vector3)(ref val)).sqrMagnitude >= 0.25f && Time.time >= <_pxH4_NextMoveSfxAt>5__3) { <_pxH4_LastMovePos>5__2 = 5__16; <_pxH4_NextMoveSfxAt>5__3 = Time.time + 5f; if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__16, "CreepyLaugh.ogg", 1f)); } } } } catch { } <>2__current = 5__11; <>1__state = 2; return true; } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; try { PxStopAllHauntSfx(); } catch { } try { _pxSuppressHaunt1Sfx = false; } catch { } try { <>4__this._pxHaunt1Prefab = 5__1; } catch { } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__205 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public bool force; public bool ignoreCooldowns; public ParanoiaEngine <>4__this; private GameObject 5__1; private GameObject 5__2; private float[] 5__3; private Vector3 5__4; private float 5__5; private float 5__6; private float 5__7; private int 5__8; private float 5__9; private float 5__10; private float 5__11; private Player 5__12; private Player 5__13; private Vector3 5__14; private Vector3 5__15; private float 5__16; private Player

5__17; private float 5__18; private Vector3 5__19; private bool 5__20; private bool 5__21; private bool 5__22; private Vector3 5__23; private float 5__24; private Vector3 5__25; private Vector3 5__26; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__205(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__2 = null; 5__3 = null; 5__12 = null; 5__13 = null;

5__17 = null; <>1__state = -2; } private bool MoveNext() { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_078e: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Unknown result type (might be due to invalid IL or missing references) //IL_07cb: Unknown result type (might be due to invalid IL or missing references) //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_0842: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_0720: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; if (!(Time.time < 5__5)) { 5__16 = Time.time; 5__5 = 5__16 + 0.06f;

5__17 = (((Object)(object)player != (Object)null) ? player : Player.m_localPlayer); if (!((Object)(object)

5__17 == (Object)null) && !((Character)

5__17).IsDead()) { 5__18 = 9999f; 5__19 = Vector3.zero; try { 5__23 = ((Component)

5__17).transform.position + Vector3.up * 0.9f; 5__19 = <>4__this.Haunt5_GetClosestPointOnVisual(<>4__this._paranoidinGo, 5__23); 5__18 = Vector3.Distance(5__23, 5__19); } catch { 5__18 = 9999f; } if (!(5__18 >= 80f)) { 5__20 = <>4__this.Haunt5_IsPlayerLookingAtHaunt(

5__17, <>4__this._paranoidinGo, 0.88f); if (5__20) { 5__6 += 0.06f; 5__7 = 0f; } else { 5__7 += 0.06f; 5__6 = 0f; } 5__21 = 5__20 && 5__6 >= 0.18f; 5__22 = !5__20 && 5__7 >= 0.18f; if (5__21) { 5__11 += 0.06f; if (5__11 >= 25f) { goto IL_0891; } } else { 5__11 = 0f; } if (5__22 && 5__16 - 5__9 >= 0.65f) { 5__9 = 5__16; if (5__8 < 5__3.Length - 1) { 5__8++; } 5__24 = 5__3[5__8]; try { 5__25 = (((Object)(object)<>4__this._paranoidinGo != (Object)null) ? <>4__this._paranoidinGo.transform.position : ((Component)

5__17).transform.position); if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__25, "SharpStringsSFX.ogg", 1f)); } } catch { } <>4__this.Haunt5_TeleportNearPlayer_SideBehindBias(

5__17, 5__24); try { 5__26 = ((Component)

5__17).transform.position + Vector3.up * 0.9f; 5__19 = <>4__this.Haunt5_GetClosestPointOnVisual(<>4__this._paranoidinGo, 5__26); 5__18 = Vector3.Distance(5__26, 5__19); } catch { 5__18 = 9999f; } } if (5__18 <= 3.85f) { 5__10 += 0.06f; if (5__10 >= 0.08f) { <>4__this.Haunt5_KillPlayer_Reliable(

5__17, 5__19); goto IL_0891; } } else { 5__10 = 0f; }

5__17 = null; goto IL_0867; } } goto IL_0891; } } else { <>1__state = -1; 5__1 = <>4__this._pxHaunt1Prefab; 5__2 = null; try { 5__2 = <>4__this.TryGetPxHauntPrefabByName("PX_Haunt_Haunt5"); } catch { 5__2 = null; } if ((Object)(object)5__2 == (Object)null) { try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } try { <>4__this._pxHaunt1Prefab = 5__2; } catch { } 5__3 = new float[7] { 18f, 13f, 10f, 8f, 6.6f, 5.4f, 4.4f }; <>4__this._paranoidinActive = true; <>4__this._paranoidinAttacking = false; try { <>4__this.TryApplyParanoidinEnvironment(enable: true); } catch { } 5__4 = Vector3.zero; try { 5__12 = (((Object)(object)player != (Object)null) ? player : Player.m_localPlayer); if ((Object)(object)5__12 == (Object)null || ((Character)5__12).IsDead()) { try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } 5__4 = <>4__this.GetParanoidinSpawnPos(5__12, 5__3[0], preferFront: true); <>4__this._paranoidinPos = 5__4; 5__12 = null; } catch { try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } try { if ((Object)(object)<>4__this._paranoidinGo != (Object)null) { try { Object.Destroy((Object)(object)<>4__this._paranoidinGo); } catch { } <>4__this._paranoidinGo = null; } <>4__this._paranoidinGo = <>4__this.SpawnGhostOdin(<>4__this._paranoidinPos); } catch { <>4__this._paranoidinGo = null; } if ((Object)(object)<>4__this._paranoidinGo == (Object)null) { try { <>4__this.ForceTerminateParanoidin(); } catch { } return false; } try { 5__13 = (((Object)(object)player != (Object)null) ? player : Player.m_localPlayer); if ((Object)(object)5__13 != (Object)null) { 5__14 = ((Component)5__13).transform.position - <>4__this._paranoidinGo.transform.position; 5__14.y = 0f; if (((Vector3)(ref 5__14)).sqrMagnitude > 0.01f) { <>4__this._paranoidinGo.transform.rotation = Quaternion.LookRotation(((Vector3)(ref 5__14)).normalized); } } 5__13 = null; } catch { } try { 5__15 = (((Object)(object)<>4__this._paranoidinGo != (Object)null) ? <>4__this._paranoidinGo.transform.position : <>4__this._paranoidinPos); if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__15, "TheReaperQueenWarning.ogg", 1f)); ((MonoBehaviour)Game.instance).StartCoroutine(<>4__this.PxPlayEmbeddedOggAt(5__15, "HorrerAmbience2.ogg", 0.7f)); } } catch { } 5__5 = Time.time + 0.06f; 5__6 = 0f; 5__7 = 0f; 5__8 = 0; 5__9 = -999f; 5__10 = 0f; 5__11 = 0f; <>1__state = -3; } goto IL_0867; IL_0867: if (<>4__this._paranoidinActive && (Object)(object)<>4__this._paranoidinGo != (Object)null) { <>2__current = null; <>1__state = 1; return true; } goto IL_0891; IL_0891: <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; try { <>4__this.TryApplyParanoidinEnvironment(enable: false); } catch { } try { PxStopAllHauntSfx(); } catch { } try { <>4__this._pxHaunt1Prefab = 5__1; } catch { } try { <>4__this.ForceTerminateParanoidin(); } catch { } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__122 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Vector3 pos; public string oggFileName; public float volume01; public bool loop; public ParanoiaEngine <>4__this; private string 5__1; private AudioClip 5__2; private WWW 5__3; private GameObject 5__4; private AudioSource 5__5; private bool 5__6; private float 5__7; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__122(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_0178: 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_00b5: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (string.IsNullOrEmpty(oggFileName)) { return false; } 5__1 = null; try { 5__1 = PxEnsureEmbeddedFileOnDisk(oggFileName, "SFX"); } catch { 5__1 = null; } if (string.IsNullOrEmpty(5__1) || !File.Exists(5__1)) { return false; } 5__2 = null; 5__3 = new WWW("file:///" + 5__1); <>2__current = 5__3; <>1__state = 1; return true; case 1: <>1__state = -1; if (!string.IsNullOrEmpty(5__3.error)) { return false; } try { 5__2 = 5__3.GetAudioClip(false, false, (AudioType)14); } catch { 5__2 = null; } if ((Object)(object)5__2 == (Object)null) { return false; } 5__4 = null; 5__5 = null; 5__6 = false; 5__7 = 0f; try { 5__4 = new GameObject("PX_FalseEventSFX_" + oggFileName); Object.DontDestroyOnLoad((Object)(object)5__4); 5__4.transform.position = pos; 5__5 = 5__4.AddComponent(); 5__5.spatialBlend = 1f; 5__5.rolloffMode = (AudioRolloffMode)1; 5__5.maxDistance = 40f; 5__5.minDistance = 1.5f; 5__5.volume = Mathf.Clamp01(volume01); 5__5.loop = loop; 5__5.clip = 5__2; 5__5.Play(); <>4__this._falseEventAudio.Add(5__5); <>4__this._falseEventAudioGos.Add(5__4); 5__6 = true; if (!loop) { 5__7 = Time.time + Mathf.Max(0.25f, 5__2.length + 0.25f); } } catch { } if (!5__6 || loop) { break; } goto IL_02c2; case 2: { <>1__state = -1; goto IL_02c2; } IL_02c2: if (<>4__this._falseEventActive && Time.time < 5__7) { <>2__current = null; <>1__state = 2; return true; } break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__186 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Vector3 pos; public string oggFileName; public float volume01; public ParanoiaEngine <>4__this; private string 5__1; private AudioClip 5__2; private WWW 5__3; private GameObject 5__4; private AudioSource 5__5; private float 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__186(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (string.IsNullOrEmpty(oggFileName)) { return false; } 5__1 = null; try { 5__1 = PxEnsureEmbeddedFileOnDisk(oggFileName, "SFX"); } catch { 5__1 = null; } if (string.IsNullOrEmpty(5__1) || !File.Exists(5__1)) { return false; } 5__2 = null; 5__3 = null; try { 5__3 = new WWW("file://" + 5__1); } catch { return false; } goto IL_00e2; case 1: <>1__state = -1; goto IL_00e2; case 2: { <>1__state = -1; break; } IL_00e2: if (!5__3.isDone) { <>2__current = null; <>1__state = 1; return true; } if (!string.IsNullOrEmpty(5__3.error)) { return false; } try { 5__2 = PxGetWwwAudioClip(5__3); } catch { 5__2 = null; } if ((Object)(object)5__2 == (Object)null) { return false; } 5__4 = null; 5__5 = null; try { 5__4 = new GameObject("PX_SFX_" + oggFileName); 5__4.transform.position = pos; PxRegisterHauntSfxGo(5__4); 5__5 = 5__4.AddComponent(); 5__5.clip = 5__2; 5__5.volume = Mathf.Clamp01(volume01); 5__5.spatialBlend = 1f; 5__5.rolloffMode = (AudioRolloffMode)1; 5__5.minDistance = 2f; 5__5.maxDistance = 40f; 5__5.Play(); } catch { try { if ((Object)(object)5__4 != (Object)null) { PxUnregisterHauntSfxGo(5__4); } } catch { } try { if ((Object)(object)5__4 != (Object)null) { Object.Destroy((Object)(object)5__4); } } catch { } return false; } 5__6 = Time.time + Mathf.Max(0.25f, 5__2.length + 0.25f); break; } if (Time.time < 5__6) { <>2__current = null; <>1__state = 2; return true; } try { if ((Object)(object)5__4 != (Object)null) { PxUnregisterHauntSfxGo(5__4); } } catch { } try { if ((Object)(object)5__4 != (Object)null) { Object.Destroy((Object)(object)5__4); } } catch { } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private bool _falseEventsInited; private const string ZdoKey_LastSleepDay = "PP_LastSleepDay"; private static readonly Biome[] s_foreignBiomes; private const string SleepDeprivedSeName = "SE_Pix_SleepDeprived"; private static readonly int SleepDeprivedSeHash; private float _nextSleepDeprivedSeCheckAt; private bool _postLoginEnsureIconScheduled; private float _postLoginEnsureIconAt; private bool _postLoginEnsureIconDone; private bool _loginSignatureScheduled = false; private bool _loginSignaturePlayed = false; private float _loginSignaturePlayAt = 0f; private float _nextTickAt; private float _nextAllowed_Global; private float _nextAllowed_Foreshadow; private float _nextAllowed_Displacement; private float _nextAllowed_Violation; private float _nextAllowed_Paranoidin; private bool _paranoidinActive; private GameObject _paranoidinGo; private Vector3 _paranoidinPos; private float _paranoidinLastTeleportAt; private float _paranoidinLosHold; private float _paranoidinNearHold; private Coroutine _paranoidinRoutine; private bool _paranoidinAttacking; private readonly Dictionary _soundBlockUntil = new Dictionary(StringComparer.OrdinalIgnoreCase); private int _debugForcedDaysAwake = -1; private bool _sleepDetectWasSleeping; private double _sleepDetectSleepStartTimeSeconds = -1.0; private int _sleepDetectSleepStartDay = -1; private float _respawnLockoutUntil; private const float DefaultPulseIntervalSeconds = 12f; private const float DefaultStartDelaySeconds = 0f; private const string EmbeddedSfxFolder = "SFX"; private bool _falseEventActive; private float _falseEventEndsAt; private Coroutine _falseEventCo; private Coroutine _falseEventPulseCo; private FalseEventProfile _activeFalseEvent; private Coroutine _falseEventAutoCo; private float _falseEventAutoNextAt; private List _falseEventDeck; private int _falseEventDeckIndex; private readonly Dictionary _falseEvents = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly List _falseEventAudio = new List(8); private readonly List _falseEventAudioGos = new List(8); private float _falseEventNextOneShotAt = 0f; private static readonly int[] PukeHashes; private readonly List _hauntBag = new List(10); private int _hauntBagPos = 0; private static bool _pxSuppressHaunt1Sfx; private static readonly List _pxHauntSfxGos; private const string PxHauntsBundleFileName = "px_paranoia_haunts"; private const string PxHaunt1PrefabName = "PX_Haunt_Haunt1"; private AssetBundle _pxHauntsBundle; private GameObject _pxHaunt1Prefab; private float _pxHauntsNextLoadAttemptAt; private Transform _odinClampAnchor; private string _savedEnv; private bool _paranoidinEnvActive; private Transform _odinPrevParent; private bool _odinClamped; private float _paranoidinGroundY; private float _paranoidinNextGroundSampleAt; private bool _paranoidinGroundInit; private Vector3 _paranoidinLastGroundSampleXZ; private Vector3 _paranoidinLastPlayerPos; private float _paranoidinLastPlayerSpeed; private float _paranoidinNextPlayerSampleAt; private bool _paranoidinPlayerInit; private Vector3 _paranoidinStalkAnchor; private float _paranoidinNextRetargetAt; private bool _paranoidinHasAnchor; private const string PxHaunt2PrefabName = "PX_Haunt_Haunt2"; private bool _pxHauntsTriedLoad; private const string PxHaunt3PrefabName = "PX_Haunt_Haunt3"; private const string PxHaunt4PrefabName = "PX_Haunt_Haunt4"; private const string PxHaunt5PrefabName = "PX_Haunt_Haunt5"; public static ParanoiaEngine Instance { get; private set; } private void Awake() { Instance = this; } internal void OnLocalPlayerDied() { try { ForceCleanupRespawnEdgeCase("death"); } catch { } } internal void OnLocalPlayerSpawned() { try { ForceCleanupRespawnEdgeCase("spawn"); } catch { } } private void ForceCleanupRespawnEdgeCase(string reason) { try { bool flag = true; try { flag = ParanoiaPlugin.DisableParanoiaTickDuringRespawnLockout != null && ParanoiaPlugin.DisableParanoiaTickDuringRespawnLockout.Value; } catch { flag = true; } if (flag) { float num = 20f; try { if (ParanoiaPlugin.RespawnLockoutSeconds != null) { num = Mathf.Max(0f, ParanoiaPlugin.RespawnLockoutSeconds.Value); } } catch { num = 20f; } _respawnLockoutUntil = Mathf.Max(_respawnLockoutUntil, Time.time + num); } } catch { } try { ((MonoBehaviour)this).StopAllCoroutines(); } catch { } try { ForceTerminateParanoidin(); } catch { } try { _nextAllowed_Global = Time.time + 0.5f; _nextAllowed_Foreshadow = Time.time + 0.5f; _nextAllowed_Displacement = Time.time + 0.5f; _nextAllowed_Violation = Time.time + 0.5f; } catch { } try { _nextAllowed_Paranoidin = Time.time + 5f; } catch { } } internal void SoftReboot_PreserveSleepState(string reason) { try { int debugForcedDaysAwake = _debugForcedDaysAwake; int num = -1; Player val = null; try { val = Player.m_localPlayer; } catch { val = null; } if ((Object)(object)val != (Object)null) { try { num = GetLastSleepDay(val); } catch { num = -1; } } try { UpdateSleepDeprivedStatusEffect(val, ParanoiaTier.None); } catch { } ParanoiaPlugin.LogDebug("[SoftReboot] reason=" + reason); try { ((MonoBehaviour)this).StopAllCoroutines(); } catch { } try { ((MonoBehaviour)this).CancelInvoke(); } catch { } try { FlushParanoidinCache(); } catch { } try { ForceTerminateParanoidin(); } catch { } try { _paranoidinActive = false; _paranoidinAttacking = false; _paranoidinLosHold = 0f; _paranoidinNearHold = 0f; _paranoidinLastTeleportAt = 0f; _nextAllowed_Global = 0f; _nextAllowed_Foreshadow = 0f; _nextAllowed_Displacement = 0f; _nextAllowed_Violation = 0f; _nextAllowed_Paranoidin = 0f; _soundBlockUntil.Clear(); } catch { } try { Time.timeScale = 1f; } catch { } try { if ((Object)(object)val != (Object)null) { try { MethodInfo method = typeof(Player).GetMethod("SetControlsEnabled", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(bool) }, null); if (method != null) { method.Invoke(val, new object[1] { true }); } } catch { } } } catch { } _debugForcedDaysAwake = debugForcedDaysAwake; if ((Object)(object)val != (Object)null && num >= 0) { try { SetLastSleepDay(val, num); } catch { } } try { _nextTickAt = Time.time + Random.Range(0.2f, 0.7f); } catch { _nextTickAt = Time.time + 0.5f; } } catch { } } private void Start() { _nextTickAt = Time.time + Random.Range(0.3f, 1.2f); if (!_falseEventsInited) { _falseEventsInited = true; try { FalseEvents_Init(); } catch { } } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } try { ParanoiaGreydwarfs.Cleanup(); } catch { } } private bool IsInRespawnLockout() { try { if (ParanoiaPlugin.DisableParanoiaTickDuringRespawnLockout != null && !ParanoiaPlugin.DisableParanoiaTickDuringRespawnLockout.Value) { return false; } return Time.time < _respawnLockoutUntil; } catch { } return false; } private void Update() { //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) if (!ParanoiaPlugin.Enabled.Value) { return; } ParanoiaSerpent.Tick(); ParanoiaRelics.Tick(); ParanoiaPlugin.TryRegisterParanoidinRpc(); if (!_postLoginEnsureIconDone) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { if (!_postLoginEnsureIconScheduled) { _postLoginEnsureIconScheduled = true; _postLoginEnsureIconAt = Time.time + 1f; } if (_postLoginEnsureIconScheduled && Time.time >= _postLoginEnsureIconAt) { try { ObjectDB val = null; try { val = ObjectDB.instance; } catch { val = null; } if ((Object)(object)val == (Object)null) { try { val = Object.FindFirstObjectByType(); } catch { val = null; } } if ((Object)(object)val != (Object)null && val.m_StatusEffects != null) { for (int i = 0; i < val.m_StatusEffects.Count; i++) { StatusEffect val2 = val.m_StatusEffects[i]; if (!((Object)(object)val2 == (Object)null) && (string.Equals(((Object)val2).name, "SE_Pix_SleepDeprived", StringComparison.Ordinal) || val2 is SE_Pix_SleepDeprived)) { try { SE_Pix_SleepDeprived.EnsureIcon(val2 as SE_Pix_SleepDeprived, val); } catch { } break; } } } } catch { } _postLoginEnsureIconDone = true; } } } if (!_loginSignatureScheduled && (Object)(object)Player.m_localPlayer != (Object)null) { _loginSignatureScheduled = true; _loginSignaturePlayAt = Time.time + 2f; } if (_loginSignatureScheduled && !_loginSignaturePlayed && Time.time >= _loginSignaturePlayAt) { _loginSignaturePlayed = true; Vector3 position = ((Component)Player.m_localPlayer).transform.position; if ((Object)(object)Game.instance != (Object)null) { ((MonoBehaviour)this).StartCoroutine(PxPlayEmbeddedOggAt(position, "NewParanoiaSignature.ogg", 0.8f)); } } if (Time.time < _nextTickAt) { return; } _nextTickAt = Time.time + Mathf.Max(0.2f, ParanoiaPlugin.TickIntervalSeconds.Value); Player localPlayer2 = Player.m_localPlayer; if ((Object)(object)localPlayer2 == (Object)null || ((Character)localPlayer2).IsDead() || IsInRespawnLockout()) { return; } TryDetectSleepCompleted(localPlayer2); if (!IsSafeToFire(localPlayer2)) { return; } ParanoiaTier currentTier = GetCurrentTier(localPlayer2); try { UpdateSleepDeprivedStatusEffect(localPlayer2, currentTier); } catch { } if (currentTier != 0) { MaybeTickParanoidin(localPlayer2, currentTier); float num = GetTieredTickChance(currentTier) * GetNightMultiplier(); if (!(Random.value > num)) { TryFireRandomEvent(localPlayer2, currentTier, "tick", ignoreCooldowns: false); } } } internal void OnPlayerSlept(Player player) { RegisterSleepCompleted(player, "sleep"); } private void RegisterSleepCompleted(Player player, string reason) { try { if (!((Object)(object)player == (Object)null)) { _debugForcedDaysAwake = -1; int worldDaySafe = GetWorldDaySafe(); SetLastSleepDay(player, worldDaySafe); float time = Time.time; _nextAllowed_Global = Mathf.Max(_nextAllowed_Global, time + 1f); _nextAllowed_Foreshadow = Mathf.Max(_nextAllowed_Foreshadow, time + 1f); _nextAllowed_Displacement = Mathf.Max(_nextAllowed_Displacement, time + 1f); _nextAllowed_Violation = Mathf.Max(_nextAllowed_Violation, time + 1f); _nextAllowed_Paranoidin = Mathf.Max(_nextAllowed_Paranoidin, time + 3f); ParanoiaPlugin.LogDebug($"Sleep registered ({reason}). LastSleepDay={worldDaySafe}"); } } catch { } } private void TryDetectSleepCompleted(Player player) { try { if ((Object)(object)player == (Object)null) { return; } bool flag = IsPlayerSleepingSafe(player); if (flag && !_sleepDetectWasSleeping) { _sleepDetectWasSleeping = true; _sleepDetectSleepStartDay = GetWorldDaySafe(); _sleepDetectSleepStartTimeSeconds = GetTimeSecondsSafe(); } else if (!flag && _sleepDetectWasSleeping) { _sleepDetectWasSleeping = false; double timeSecondsSafe = GetTimeSecondsSafe(); double num = ((_sleepDetectSleepStartTimeSeconds >= 0.0) ? (timeSecondsSafe - _sleepDetectSleepStartTimeSeconds) : 0.0); if (num > 2.0) { RegisterSleepCompleted(player, "detect"); } _sleepDetectSleepStartTimeSeconds = -1.0; _sleepDetectSleepStartDay = -1; } } catch { } } private double GetTimeSecondsSafe() { try { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.GetTimeSeconds(); } } catch { } return 0.0; } private bool IsPlayerSleepingSafe(Player player) { try { if ((Object)(object)player == (Object)null) { return false; } return player.IsSleeping() || ((Character)player).InBed(); } catch { return false; } } internal void OnPlayerAte(Player player) { if (!ParanoiaPlugin.EnableEatTrigger.Value || (Object)(object)player == (Object)null || ((Character)player).IsDead() || !IsSafeToFire(player)) { return; } ParanoiaTier currentTier = GetCurrentTier(player); if (currentTier != 0) { MaybeTickParanoidin(player, currentTier); if (!(Random.value > Mathf.Clamp01(ParanoiaPlugin.EatTriggerChance.Value))) { TryFireSkewedEvent(player, currentTier, "eat", ignoreCooldowns: false); } } } internal string GetStatusString() { //IL_0044: 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_0138: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return "Paranoia: (no local player)"; } int worldDaySafe = GetWorldDaySafe(); int lastSleepDay = GetLastSleepDay(localPlayer); int daysAwake = GetDaysAwake(localPlayer, worldDaySafe, lastSleepDay); ParanoiaTier currentTier = GetCurrentTier(localPlayer); Biome playerBiomeSafe = GetPlayerBiomeSafe(localPlayer); bool flag = false; bool flag2 = false; try { flag = EnvMan.IsNight(); } catch { } try { flag2 = RandEventSystem.InEvent(); } catch { } float num = Mathf.Max(0f, _nextAllowed_Global - Time.time); float num2 = Mathf.Max(0f, _nextAllowed_Foreshadow - Time.time); float num3 = Mathf.Max(0f, _nextAllowed_Displacement - Time.time); float num4 = Mathf.Max(0f, _nextAllowed_Violation - Time.time); string text = ((_debugForcedDaysAwake >= 0) ? $" (FORCED {_debugForcedDaysAwake}d)" : ""); return $"Paranoia | Day {worldDaySafe} | LastSleepDay {lastSleepDay} | Awake {daysAwake}d{text} | Tier {currentTier}\n" + $"Biome {playerBiomeSafe} | Night {flag} | Event {flag2}\n" + $"Cooldowns (sec): Global {num:0}, Foreshadow {num2:0}, Displacement {num3:0}, Violation {num4:0}"; } private void UpdateSleepDeprivedStatusEffect(Player player, ParanoiaTier tier) { try { if ((Object)(object)player == (Object)null || ((Character)player).IsDead() || Time.time < _nextSleepDeprivedSeCheckAt) { return; } _nextSleepDeprivedSeCheckAt = Time.time + 0.5f; SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan != null) { bool flag = tier != ParanoiaTier.None; bool flag2 = sEMan.HaveStatusEffect(SleepDeprivedSeHash); if (flag && !flag2) { sEMan.AddStatusEffect(SleepDeprivedSeHash, true, 0, 0f); } else if (!flag && flag2) { sEMan.RemoveStatusEffect(SleepDeprivedSeHash, true); } } } catch { } } internal void ForceAwakeDays(int daysAwake) { _debugForcedDaysAwake = Mathf.Max(0, daysAwake); } internal FireResult ForceFire(string prefabNameOrBlank, bool ignoreCooldowns, bool force, out string firedPrefabName, out string reason) { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) firedPrefabName = ""; reason = ""; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { reason = "no local player (or dead)"; return FireResult.NoLocalPlayer; } if (!force && !IsSafeToFire(localPlayer)) { reason = "gate blocked (use 'force' to bypass)"; return FireResult.GateBlocked; } if (!string.IsNullOrWhiteSpace(prefabNameOrBlank)) { string text = (firedPrefabName = prefabNameOrBlank.Trim()); if ((Object)(object)ZNetScene.instance == (Object)null) { reason = "ZNetScene not ready"; return FireResult.NotReady; } if ((Object)(object)ZNetScene.instance.GetPrefab(text) == (Object)null) { reason = "prefab not found"; return FireResult.PrefabNotFound; } if (!ignoreCooldowns) { if (!IsGlobalOffCooldown()) { reason = "global cooldown"; return FireResult.CooldownBlocked; } if (!IsSoundRepeatAllowed(text)) { reason = "repeat-block"; return FireResult.RepeatBlocked; } } float num = Mathf.Max(0.25f, ParanoiaPlugin.ForcedNearSpawnDistance.Value); Vector3 pos = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * num + Vector3.up * 0.35f; if (!TrySpawnSfxPrefab(text, pos)) { reason = "spawn failed"; return FireResult.SpawnFailed; } if (!ignoreCooldowns) { BlockSound(text); ApplyCooldowns(ParanoiaCategory.Foreshadow); } reason = "ok"; return FireResult.Fired; } if (force) { if (TryFireRandomLoadedSfx(localPlayer, ignoreCooldowns, out var pickedName, out reason)) { firedPrefabName = (string.IsNullOrEmpty(pickedName) ? "(random)" : pickedName); return FireResult.Fired; } firedPrefabName = "(random)"; if (string.IsNullOrEmpty(reason)) { reason = "no loaded sfx"; } return FireResult.GateBlocked; } ParanoiaTier currentTier = GetCurrentTier(localPlayer); bool flag = TryFireRandomEvent(localPlayer, currentTier, "pn_fire", ignoreCooldowns); firedPrefabName = "(random)"; reason = (flag ? "ok" : "no eligible event (or blocked internally)"); return (!flag) ? FireResult.GateBlocked : FireResult.Fired; } private bool TryFireRandomLoadedSfx(Player p, bool ignoreCooldowns, out string pickedName, out string reason) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) pickedName = ""; reason = ""; if ((Object)(object)p == (Object)null || ((Character)p).IsDead()) { reason = "no local player (or dead)"; return false; } if ((Object)(object)ZNetScene.instance == (Object)null) { reason = "ZNetScene not ready"; return false; } List loadedSfxPrefabNames = GetLoadedSfxPrefabNames(); if (loadedSfxPrefabNames == null || loadedSfxPrefabNames.Count == 0) { reason = "no loaded sfx_* prefabs found"; return false; } int num = Mathf.Min(12, loadedSfxPrefabNames.Count); for (int i = 0; i < num; i++) { string text = loadedSfxPrefabNames[Random.Range(0, loadedSfxPrefabNames.Count)]; if (string.IsNullOrEmpty(text) || (!ignoreCooldowns && (!IsGlobalOffCooldown() || !IsSoundRepeatAllowed(text)))) { continue; } float num2 = Mathf.Max(0.25f, ParanoiaPlugin.ForcedNearSpawnDistance.Value); Vector3 pos = ((Component)p).transform.position + ((Component)p).transform.forward * num2 + Vector3.up * 0.35f; if (TrySpawnSfxPrefab(text, pos)) { if (!ignoreCooldowns) { BlockSound(text); ApplyCooldowns(ParanoiaCategory.Foreshadow); } pickedName = text; reason = "ok (random loaded sfx)"; return true; } } reason = (ignoreCooldowns ? "spawn failed" : "no eligible sfx (cooldown/repeat-block/spawn)"); return false; } private List GetLoadedSfxPrefabNames() { List list = new List(512); try { if ((Object)(object)ZNetScene.instance == (Object)null) { return list; } ZNetScene instance = ZNetScene.instance; Type type = ((object)instance).GetType(); FieldInfo field = type.GetField("m_prefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.GetValue(instance) is IEnumerable enumerable) { foreach (object item in enumerable) { GameObject val = (GameObject)((item is GameObject) ? item : null); if (!((Object)(object)val == (Object)null)) { string name = ((Object)val).name; if (!string.IsNullOrEmpty(name) && name.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase)) { list.Add(name); } } } } if (list.Count == 0) { FieldInfo field2 = type.GetField("m_namedPrefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null && field2.GetValue(instance) is IDictionary dictionary) { foreach (DictionaryEntry item2 in dictionary) { object? value = item2.Value; GameObject val2 = (GameObject)((value is GameObject) ? value : null); if (!((Object)(object)val2 == (Object)null)) { string name2 = ((Object)val2).name; if (!string.IsNullOrEmpty(name2) && name2.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase)) { list.Add(name2); } } } } } } catch { } try { return list.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy((string s) => s, StringComparer.OrdinalIgnoreCase).ToList(); } catch { return list; } } internal void ListSfxPrefabs(string filter) { if ((Object)(object)ZNetScene.instance == (Object)null) { ParanoiaConsole.Print("pn_listsfx: ZNetScene.instance is null (not in world yet?)"); return; } List list = new List(2048); try { ZNetScene instance = ZNetScene.instance; Type type = ((object)instance).GetType(); FieldInfo field = type.GetField("m_prefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.GetValue(instance) is IEnumerable enumerable) { foreach (object item in enumerable) { GameObject val = (GameObject)((item is GameObject) ? item : null); if (!((Object)(object)val == (Object)null)) { string name = ((Object)val).name; if (!string.IsNullOrEmpty(name)) { list.Add(name); } } } } if (list.Count == 0) { FieldInfo field2 = type.GetField("m_namedPrefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null && field2.GetValue(instance) is IDictionary dictionary) { foreach (DictionaryEntry item2 in dictionary) { object? value = item2.Value; GameObject val2 = (GameObject)((value is GameObject) ? value : null); if (!((Object)(object)val2 == (Object)null)) { string name2 = ((Object)val2).name; if (!string.IsNullOrEmpty(name2)) { list.Add(name2); } } } } } } catch { } if (list.Count == 0) { ParanoiaConsole.Print("pn_listsfx: couldn't enumerate prefabs (field layout differs)."); ParanoiaConsole.Print("pn_listsfx: you can still test with pn_fire using names you already discovered."); return; } string f = (filter ?? "").Trim(); List list2 = (from n in list where n.IndexOf("sfx_", StringComparison.OrdinalIgnoreCase) >= 0 where string.IsNullOrEmpty(f) || n.IndexOf(f, StringComparison.OrdinalIgnoreCase) >= 0 select n).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy((string n) => n, StringComparer.OrdinalIgnoreCase).Take(120) .ToList(); ParanoiaConsole.Print($"pn_listsfx: showing {list2.Count} (limit 120). filter='{f}'"); foreach (string item3 in list2) { ParanoiaConsole.Print(" " + item3); } } private bool IsSafeToFire(Player player) { if (ParanoiaPlugin.DisableDuringActiveEvent.Value) { try { if (RandEventSystem.InEvent()) { return false; } } catch { } } return true; } private float GetNightMultiplier() { try { if (EnvMan.IsNight()) { return Mathf.Max(0.1f, ParanoiaPlugin.NightChanceMultiplier.Value); } } catch { } return 1f; } private int GetDaysAwake(Player player, int day, int lastSleepDay) { if (_debugForcedDaysAwake >= 0) { return _debugForcedDaysAwake; } if (lastSleepDay <= 0) { return 0; } return Mathf.Max(0, day - lastSleepDay); } private ParanoiaTier GetCurrentTier(Player player) { if (!ParanoiaPlugin.UseSleepDeprivation.Value) { return ParanoiaTier.Mild; } int worldDaySafe = GetWorldDaySafe(); int lastSleepDay = GetLastSleepDay(player); if (lastSleepDay <= 0) { SetLastSleepDay(player, worldDaySafe); return ParanoiaTier.None; } int num = GetDaysAwake(player, worldDaySafe, lastSleepDay); float sleepDebtMultiplier = ParanoiaRelics.GetSleepDebtMultiplier(); if (sleepDebtMultiplier > 1f) { num = Mathf.FloorToInt((float)num * sleepDebtMultiplier); } int num2 = Mathf.Max(1, ParanoiaPlugin.DaysWithoutSleepThreshold.Value); if (num < num2) { return ParanoiaTier.None; } if (num >= num2 + 3) { return ParanoiaTier.Severe; } if (num >= num2 + 1) { return ParanoiaTier.Moderate; } return ParanoiaTier.Mild; } private float GetTieredTickChance(ParanoiaTier tier) { float num = Mathf.Clamp01(ParanoiaPlugin.BaseEventChancePerTick.Value); num = Mathf.Clamp01(num * ParanoiaRelics.GetParanoiaIntensityMultiplier()); return tier switch { ParanoiaTier.Mild => num * 1f, ParanoiaTier.Moderate => num * 1.35f, ParanoiaTier.Severe => num * 1.75f, _ => 0f, }; } private static bool IsTierAtLeast(ParanoiaTier tier, ParanoiaTier min) { return tier >= min; } private static ParanoiaTier GetMinTierFromConfig() { try { string text = ((ParanoiaPlugin.ParanoidinMinTier != null) ? ParanoiaPlugin.ParanoidinMinTier.Value : "Moderate"); if (string.IsNullOrWhiteSpace(text)) { return ParanoiaTier.Moderate; } text = text.Trim(); if (text.Equals("None", StringComparison.OrdinalIgnoreCase)) { return ParanoiaTier.None; } if (text.Equals("Mild", StringComparison.OrdinalIgnoreCase)) { return ParanoiaTier.Mild; } if (text.Equals("Moderate", StringComparison.OrdinalIgnoreCase)) { return ParanoiaTier.Moderate; } if (text.Equals("Severe", StringComparison.OrdinalIgnoreCase)) { return ParanoiaTier.Severe; } } catch { } return ParanoiaTier.Moderate; } private static float GetParanoidinChanceForTier(ParanoiaTier tier) { try { if (tier == ParanoiaTier.Severe && ParanoiaPlugin.ParanoidinChancePerTickSevere != null) { return ParanoiaPlugin.ParanoidinChancePerTickSevere.Value; } if (tier == ParanoiaTier.Moderate && ParanoiaPlugin.ParanoidinChancePerTickModerate != null) { return ParanoiaPlugin.ParanoidinChancePerTickModerate.Value; } if (tier == ParanoiaTier.Mild && ParanoiaPlugin.ParanoidinChancePerTickMild != null) { return ParanoiaPlugin.ParanoidinChancePerTickMild.Value; } } catch { } return 0f; } private bool TryFireSkewedEvent(Player player, ParanoiaTier tier, string source, bool ignoreCooldowns) { float value = Random.value; ParanoiaCategory cat = ((tier == ParanoiaTier.Severe && value < 0.18f) ? ParanoiaCategory.Violation : ((tier == ParanoiaTier.Moderate && value < 0.1f) ? ParanoiaCategory.Violation : ParanoiaCategory.Foreshadow)); if (!ignoreCooldowns && (!IsGlobalOffCooldown() || !IsCategoryOffCooldown(cat))) { return false; } if (!TryPlayFromCategory(player, cat, source, ignoreCooldowns)) { return false; } if (!ignoreCooldowns) { ApplyCooldowns(cat); } return true; } private bool TryFireRandomEvent(Player player, ParanoiaTier tier, string source, bool ignoreCooldowns) { ParanoiaCategory cat = RollCategory(tier); if (!ignoreCooldowns && (!IsGlobalOffCooldown() || !IsCategoryOffCooldown(cat))) { return false; } if (!TryPlayFromCategory(player, cat, source, ignoreCooldowns)) { return false; } if (!ignoreCooldowns) { ApplyCooldowns(cat); } return true; } private ParanoiaCategory RollCategory(ParanoiaTier tier) { float value = Random.value; switch (tier) { case ParanoiaTier.Mild: if (value < 0.7f) { return ParanoiaCategory.Foreshadow; } if (value < 0.99f) { return ParanoiaCategory.Displacement; } return ParanoiaCategory.Violation; case ParanoiaTier.Moderate: if (value < 0.55f) { return ParanoiaCategory.Foreshadow; } if (value < 0.97f) { return ParanoiaCategory.Displacement; } return ParanoiaCategory.Violation; default: if (value < 0.35f) { return ParanoiaCategory.Foreshadow; } if (value < 0.95f) { return ParanoiaCategory.Displacement; } return ParanoiaCategory.Violation; } } private bool IsGlobalOffCooldown() { return Time.time >= _nextAllowed_Global; } private bool IsCategoryOffCooldown(ParanoiaCategory cat) { return cat switch { ParanoiaCategory.Foreshadow => Time.time >= _nextAllowed_Foreshadow, ParanoiaCategory.Displacement => Time.time >= _nextAllowed_Displacement, ParanoiaCategory.Violation => Time.time >= _nextAllowed_Violation, _ => true, }; } private void ApplyCooldowns(ParanoiaCategory cat) { float time = Time.time; _nextAllowed_Global = time + Mathf.Max(1f, ParanoiaPlugin.GlobalCooldownSeconds.Value); switch (cat) { case ParanoiaCategory.Foreshadow: _nextAllowed_Foreshadow = time + Mathf.Max(1f, ParanoiaPlugin.ForeshadowCooldownSeconds.Value); break; case ParanoiaCategory.Displacement: _nextAllowed_Displacement = time + Mathf.Max(1f, ParanoiaPlugin.DisplacementCooldownSeconds.Value); break; case ParanoiaCategory.Violation: _nextAllowed_Violation = time + Mathf.Max(1f, ParanoiaPlugin.ViolationCooldownSeconds.Value); break; } } private Biome MaybePickForeignBiome(Biome current, ParanoiaCategory cat) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0079: Invalid comparison between I4 and Unknown //IL_00c3: 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_00b1: 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) if (cat != ParanoiaCategory.Violation) { return current; } float num = 0f; try { num = Mathf.Clamp01(ParanoiaPlugin.ViolationForeignBiomeChance.Value); } catch { } if (num <= 0f) { return current; } if (Random.value > num) { return current; } Biome[] array = s_foreignBiomes; List list = new List(array.Length); for (int i = 0; i < array.Length; i++) { if ((int)array[i] != (int)current) { list.Add(array[i]); } } if (list.Count == 0) { return current; } return list[Random.Range(0, list.Count)]; } private bool TryPlayFromCategory(Player player, ParanoiaCategory cat, string source, bool ignoreCooldowns) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //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_0101: 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) Biome playerBiomeSafe = GetPlayerBiomeSafe(player); Biome val = MaybePickForeignBiome(playerBiomeSafe, cat); List poolForBiomeAndCategory = GetPoolForBiomeAndCategory(val, cat); if (poolForBiomeAndCategory == null || poolForBiomeAndCategory.Count == 0) { ParanoiaPlugin.LogDebug($"No pool entries for biome={playerBiomeSafe} poolBiome={val} cat={cat}"); return false; } int num = Mathf.Min(10, poolForBiomeAndCategory.Count); for (int i = 0; i < num; i++) { string text = poolForBiomeAndCategory[Random.Range(0, poolForBiomeAndCategory.Count)]; if (string.IsNullOrWhiteSpace(text)) { continue; } text = text.Trim(); if (!ignoreCooldowns && !IsSoundRepeatAllowed(text)) { continue; } Vector3 spawnPosition = GetSpawnPosition(player, cat); if (TrySpawnSfxPrefab(text, spawnPosition)) { if (!ignoreCooldowns) { BlockSound(text); } ParanoiaPlugin.LogDebug($"PLAY [{source}] biome={playerBiomeSafe} poolBiome={val} tier={GetCurrentTier(player)} cat={cat} prefab={text}"); return true; } } return false; } private bool IsSoundRepeatAllowed(string prefabName) { float value; return !_soundBlockUntil.TryGetValue(prefabName, out value) || Time.time >= value; } private void BlockSound(string prefabName) { float num = Mathf.Max(5f, ParanoiaPlugin.SameSoundRepeatBlockSeconds.Value); _soundBlockUntil[prefabName] = Time.time + num; } private Vector3 GetSpawnPosition(Player player, ParanoiaCategory cat) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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) //IL_00f9: 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_010a: 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_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_018f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)player).transform.position; Vector3 forward = ((Component)player).transform.forward; switch (cat) { case ParanoiaCategory.Displacement: { float num5 = Random.Range(Mathf.Max(1f, ParanoiaPlugin.DisplacementMinDistance.Value), Mathf.Max(2f, ParanoiaPlugin.DisplacementMaxDistance.Value)); float num6 = Random.Range(-110f, 110f); Vector3 val3 = Quaternion.Euler(0f, num6, 0f) * forward; return position + ((Vector3)(ref val3)).normalized * num5 + Vector3.up * 0.5f; } case ParanoiaCategory.Violation: { float num3 = Mathf.Max(1f, ParanoiaPlugin.ViolationDistance.Value); float num4 = Random.Range(140f, 220f); Vector3 val2 = Quaternion.Euler(0f, num4, 0f) * forward; return position + ((Vector3)(ref val2)).normalized * num3 + Vector3.up * 0.3f; } default: { float num = Mathf.Max(1f, ParanoiaPlugin.ForeshadowDistance.Value); float num2 = Random.Range(-70f, 70f); Vector3 val = Quaternion.Euler(0f, num2, 0f) * forward; return position + ((Vector3)(ref val)).normalized * num + Vector3.up * 0.3f; } } } private bool TrySpawnSfxPrefab(string prefabName, Vector3 pos) { //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) try { if (string.IsNullOrWhiteSpace(prefabName)) { return false; } string text = prefabName.Trim(); if (!text.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase) && !text.StartsWith("vfx_", StringComparison.OrdinalIgnoreCase)) { return false; } if ((Object)(object)ZNetScene.instance == (Object)null) { return false; } GameObject prefab = ZNetScene.instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { return false; } try { if ((Object)(object)prefab.GetComponent() != (Object)null || (Object)(object)prefab.GetComponentInChildren(true) != (Object)null) { return false; } } catch { return false; } GameObject val = Object.Instantiate(prefab, pos, Quaternion.identity); try { ZNetView[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { ((Behaviour)componentsInChildren[i]).enabled = false; } } } catch { } try { ZSyncTransform[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if ((Object)(object)componentsInChildren2[j] != (Object)null) { ((Behaviour)componentsInChildren2[j]).enabled = false; } } } catch { } try { SpawnArea[] componentsInChildren3 = val.GetComponentsInChildren(true); for (int k = 0; k < componentsInChildren3.Length; k++) { if ((Object)(object)componentsInChildren3[k] != (Object)null) { ((Behaviour)componentsInChildren3[k]).enabled = false; } } } catch { } try { SpawnSystem[] componentsInChildren4 = val.GetComponentsInChildren(true); for (int l = 0; l < componentsInChildren4.Length; l++) { if ((Object)(object)componentsInChildren4[l] != (Object)null) { ((Behaviour)componentsInChildren4[l]).enabled = false; } } } catch { } try { ZSFX[] componentsInChildren5 = val.GetComponentsInChildren(true); for (int m = 0; m < componentsInChildren5.Length; m++) { if ((Object)(object)componentsInChildren5[m] != (Object)null && !((Behaviour)componentsInChildren5[m]).enabled) { ((Behaviour)componentsInChildren5[m]).enabled = true; } } } catch { } if (ParanoiaPlugin.ForcePlayAudioSources.Value) { try { AudioSource[] componentsInChildren6 = val.GetComponentsInChildren(true); foreach (AudioSource val2 in componentsInChildren6) { if ((Object)(object)val2 == (Object)null) { continue; } if (!((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = true; } if ((Object)(object)val2.clip != (Object)null && !val2.isPlaying) { try { val2.Play(); } catch { } } } } catch { } } Object.Destroy((Object)(object)val, 6f); return true; } catch { return false; } } private List GetPoolForBiomeAndCategory(Biome biome, ParanoiaCategory cat) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_000e: 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_0026: Expected I4, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) ConfigEntry val = null; if ((int)biome <= 16) { switch (biome - 1) { case 0: goto IL_0062; case 1: goto IL_00a2; case 3: goto IL_00c2; case 2: goto IL_0153; } if ((int)biome != 8) { if ((int)biome != 16) { goto IL_0153; } val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.Plains_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.Plains_Foreshadow, _ => ParanoiaPlugin.Plains_Violation, }); } else { val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.BlackForest_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.BlackForest_Foreshadow, _ => ParanoiaPlugin.BlackForest_Violation, }); } } else if ((int)biome != 32) { if ((int)biome != 256) { if ((int)biome != 512) { goto IL_0153; } val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.Mistlands_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.Mistlands_Foreshadow, _ => ParanoiaPlugin.Mistlands_Violation, }); } else { val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.Ocean_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.Ocean_Foreshadow, _ => ParanoiaPlugin.Ocean_Violation, }); } } else { val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.AshLands_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.AshLands_Foreshadow, _ => ParanoiaPlugin.AshLands_Violation, }); } goto IL_0157; IL_0153: val = null; goto IL_0157; IL_00c2: val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.Mountains_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.Mountains_Foreshadow, _ => ParanoiaPlugin.Mountains_Violation, }); goto IL_0157; IL_0157: string text = val?.Value; if (string.IsNullOrWhiteSpace(text) || text.Trim().Equals("AUTO", StringComparison.OrdinalIgnoreCase)) { return ParanoiaPlugin.GetAutoPool(biome, cat); } List list = GetCsvList(text); if (list.Count > 0) { List list2 = new List(list.Count); for (int i = 0; i < list.Count; i++) { string text2 = list[i]; if (!string.IsNullOrWhiteSpace(text2)) { text2 = text2.Trim(); if (text2.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase) && ParanoiaPlugin.IsSfxAvailable(text2)) { list2.Add(text2); } } } list = list2; } if (list.Count == 0) { return ParanoiaPlugin.GetAutoPool(biome, cat); } return list; IL_00a2: val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.Swamp_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.Swamp_Foreshadow, _ => ParanoiaPlugin.Swamp_Violation, }); goto IL_0157; IL_0062: val = (ConfigEntry)(cat switch { ParanoiaCategory.Displacement => ParanoiaPlugin.Meadows_Displacement, ParanoiaCategory.Foreshadow => ParanoiaPlugin.Meadows_Foreshadow, _ => ParanoiaPlugin.Meadows_Violation, }); goto IL_0157; } private static List GetCsvList(string csv) { if (string.IsNullOrWhiteSpace(csv)) { return new List(0); } return (from s in csv.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries) select s.Trim() into s where !string.IsNullOrWhiteSpace(s) select s).ToList(); } private static GameObject FindPrefabByNameContains(string needleLower) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown if (string.IsNullOrEmpty(needleLower)) { return null; } try { if ((Object)(object)ZNetScene.instance == (Object)null) { return null; } string value = needleLower.ToLowerInvariant(); GameObject val = null; if (ZNetScene.instance.m_prefabs != null) { foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)prefab == (Object)null) { continue; } string name = ((Object)prefab).name; if (string.IsNullOrEmpty(name)) { continue; } string text = name.ToLowerInvariant(); if (text.Contains(value) && !((Object)(object)prefab.GetComponent() != (Object)null)) { if (text == "odin" || text == "fx_odin") { return prefab; } if ((Object)(object)val == (Object)null) { val = prefab; } } } } if ((Object)(object)val == (Object)null) { Type type = ((object)ZNetScene.instance).GetType(); FieldInfo field = type.GetField("m_namedPrefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.GetValue(ZNetScene.instance) is IDictionary dictionary) { foreach (DictionaryEntry item in dictionary) { object? value2 = item.Value; GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null); if ((Object)val2 == (Object)null) { continue; } string name2 = ((Object)val2).name; if (string.IsNullOrEmpty(name2)) { continue; } string text2 = name2.ToLowerInvariant(); if (!text2.Contains(value) || (Object)(object)val2.GetComponent() != (Object)null) { continue; } if (text2 == "odin" || text2 == "fx_odin") { return val2; } val = val2; break; } } } return val; } catch { return null; } } private Biome GetPlayerBiomeSafe(Player player) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) try { return Heightmap.FindBiome(((Component)player).transform.position); } catch { return (Biome)1; } } private int GetWorldDaySafe() { try { if ((Object)(object)ZNet.instance == (Object)null) { return 1; } double timeSeconds = ZNet.instance.GetTimeSeconds(); double num = ((ParanoiaPlugin.SleepTest_DaySeconds != null) ? ((double)Mathf.Max(1f, ParanoiaPlugin.SleepTest_DaySeconds.Value)) : 1800.0); return Mathf.Max(1, Mathf.FloorToInt((float)(timeSeconds / num)) + 1); } catch { return 1; } } private int GetLastSleepDay(Player player) { try { ZNetView component = ((Component)player).GetComponent(); if ((Object)(object)component == (Object)null) { return 0; } ZDO zDO = component.GetZDO(); if (zDO == null) { return 0; } return zDO.GetInt("PP_LastSleepDay", 0); } catch { return 0; } } private void SetLastSleepDay(Player player, int day) { try { ZNetView component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null)) { ZDO zDO = component.GetZDO(); if (zDO != null) { zDO.Set("PP_LastSleepDay", Mathf.Max(1, day)); } } } catch { } } private void TryPlayConfiguredSfxAt(Vector3 pos, string csvList) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) try { if (string.IsNullOrWhiteSpace(csvList)) { return; } List csvList2 = GetCsvList(csvList); if (csvList2 == null || csvList2.Count == 0) { return; } string text = csvList2[Random.Range(0, csvList2.Count)]; if (!string.IsNullOrWhiteSpace(text)) { text = text.Trim(); if (text.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase)) { TrySpawnSfxPrefab(text, pos); } } } catch { } } private void FalseEvents_Init() { RegisterFalseEvent(new FalseEventProfile { Id = "wolves", DisplayName = "The forest is moving...", DurationSeconds = 60f, StartMessage = "You feel watched.", PulseMessage = "Something circles just beyond sight...", EndMessage = "The presence fades.", PulseIntervalSeconds = 10f, StartAmbienceOgg = "HorrorAmbience1.ogg", StartAmbienceVolume = 0.35f }); RegisterFalseEvent(new FalseEventProfile { Id = "queen", DisplayName = "A distant scream echoes...", DurationSeconds = 75f, StartMessage = "Your blood runs cold.", PulseMessage = "The air trembles with dread.", EndMessage = "Silence returns.", PulseIntervalSeconds = 12f, StartOneShotOgg = "TheReaperQueenWarning.ogg", StartOneShotVolume = 1f }); RegisterFalseEvent(new FalseEventProfile { Id = "hit", DisplayName = "Something struck you!", DurationSeconds = 18f, StartMessage = "Something hits you from the dark.", PulseMessage = "You hear movement nearby...", EndMessage = "Nothing follows.", PulseIntervalSeconds = 7f, FakeHitOnStart = true, StaminaDrainOnStart = 25f, OneShotCooldownSeconds = 7f }); RegisterFalseEvent(new FalseEventProfile { Id = "steps", DisplayName = "Footsteps behind you...", DurationSeconds = 55f, StartMessage = "You hear someone behind you.", PulseMessage = "Closer...", EndMessage = "The steps stop.", PulseIntervalSeconds = 9f, PulseBehindPlayer = true, PulseBehindMeters = 2.5f, OneShotCooldownSeconds = 6f, PulsePreferVanillaSfx = true, PulseVanillaSfxPrefabs = new string[5] { "sfx_troll_footstep", "sfx_troll_step", "sfx_troll_walk", "sfx_troll_idle_footstep", "sfx_troll_attack_footstep" }, PulseOneShotOgg = "WhisperBehindYou.ogg", PulseOneShotVolume = 0.55f }); RegisterFalseEvent(new FalseEventProfile { Id = "warp", DisplayName = "Time slips...", DurationSeconds = 35f, StartMessage = "The world feels slightly delayed.", PulseMessage = "Your heartbeat stutters.", EndMessage = "Time snaps back into place.", PulseIntervalSeconds = 8f, TimeDistortion = true, OneShotCooldownSeconds = 8f }); RegisterTerminalCommands_FalseEvents(); } private void RegisterFalseEvent(FalseEventProfile p) { if (p != null && !string.IsNullOrEmpty(p.Id)) { if (p.DurationSeconds <= 0f) { p.DurationSeconds = 60f; } if (p.PulseIntervalSeconds <= 0f) { p.PulseIntervalSeconds = 12f; } if (p.OneShotCooldownSeconds < 0.25f) { p.OneShotCooldownSeconds = 0.25f; } if (string.IsNullOrEmpty(p.DisplayName)) { p.DisplayName = p.Id; } _falseEvents[p.Id] = p; } } private void RegisterTerminalCommands_FalseEvents() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: 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_004a: Expected O, but got Unknown //IL_0045: 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_006f: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) new ConsoleCommand("pn_falseevent_start", "[id] [seconds] - Starts a Paranoia false event (client illusion only).", (ConsoleEvent)delegate(ConsoleEventArgs args) { if ((Object)(object)Player.m_localPlayer == (Object)null) { Terminal context4 = args.Context; if (context4 != null) { context4.AddString("Must be in-game to run this command."); } } else { string text = ((args.Args != null && args.Args.Length >= 2) ? args.Args[1] : null); float result = -1f; if (string.IsNullOrEmpty(text)) { Terminal context5 = args.Context; if (context5 != null) { context5.AddString("Usage: pn_falseevent_start [seconds]"); } Terminal context6 = args.Context; if (context6 != null) { context6.AddString("Available ids: " + string.Join(", ", _falseEvents.Keys)); } } else { if (args.Args.Length >= 3) { float.TryParse(args.Args[2], out result); } StartFalseEvent_Local(text, result); } } }, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); new ConsoleCommand("pn_falseevent_stop", "- Stops the current Paranoia false event.", (ConsoleEvent)delegate(ConsoleEventArgs args) { if ((Object)(object)Player.m_localPlayer == (Object)null) { Terminal context3 = args.Context; if (context3 != null) { context3.AddString("Must be in-game to run this command."); } } else { StopFalseEvent_Local(); } }, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); new ConsoleCommand("pn_falseevent_list", "- Lists available false events.", (ConsoleEvent)delegate(ConsoleEventArgs args) { if ((Object)(object)Player.m_localPlayer == (Object)null) { Terminal context = args.Context; if (context != null) { context.AddString("Must be in-game to run this command."); } return; } foreach (KeyValuePair falseEvent in _falseEvents) { Terminal context2 = args.Context; if (context2 != null) { context2.AddString($"- {falseEvent.Key} ({falseEvent.Value.DisplayName}) {falseEvent.Value.DurationSeconds:0}s"); } } }, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); EnsureFalseEventAutoLoop(); } private MonoBehaviour GetCoroutineHost() { if ((Object)(object)Game.instance != (Object)null) { return (MonoBehaviour)(object)Game.instance; } if ((Object)(object)Player.m_localPlayer != (Object)null) { return (MonoBehaviour)(object)Player.m_localPlayer; } return null; } private void StartFalseEvent_Local(string id, float durationOverrideSeconds) { if (!_falseEvents.TryGetValue(id, out var value) || value == null) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, "Unknown false event: " + id, 0, (Sprite)null, false); } return; } StopFalseEvent_Local(); _activeFalseEvent = value; _falseEventActive = true; float num = ((durationOverrideSeconds > 0f) ? durationOverrideSeconds : value.DurationSeconds); _falseEventEndsAt = Time.time + num; _falseEventNextOneShotAt = 0f; MonoBehaviour coroutineHost = GetCoroutineHost(); if ((Object)(object)coroutineHost != (Object)null) { _falseEventCo = coroutineHost.StartCoroutine(FalseEvent_MainLoop()); _falseEventPulseCo = coroutineHost.StartCoroutine(FalseEvent_PulseLoop()); } if (!string.IsNullOrEmpty(value.StartMessage)) { MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)2, value.StartMessage, 0, (Sprite)null, false); } } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { if (value.StaminaDrainOnStart > 0f) { try { ((Character)localPlayer).UseStamina(value.StaminaDrainOnStart); } catch { } } if (value.DoPuke) { TryApplyPuke(localPlayer); } if (value.FakeHitOnStart) { MessageHud instance3 = MessageHud.instance; if (instance3 != null) { instance3.ShowMessage((MessageType)2, "Something strikes you!", 0, (Sprite)null, false); } } } if (!string.IsNullOrEmpty(value.StartOneShotOgg)) { TryPlayFalseEventOneShot(value.StartOneShotOgg, value.StartOneShotVolume, behindPlayer: false); } if (!string.IsNullOrEmpty(value.StartAmbienceOgg)) { TryPlayFalseEventAmbience(value.StartAmbienceOgg, value.StartAmbienceVolume); } } [IteratorStateMachine(typeof(d__110))] private IEnumerator FalseEvent_MainLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__110(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__111))] private IEnumerator FalseEvent_PulseLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__111(0) { <>4__this = this }; } private void StopFalseEvent_Local() { if (!_falseEventActive && _activeFalseEvent == null && _falseEventCo == null && _falseEventPulseCo == null) { return; } _falseEventActive = false; _activeFalseEvent = null; try { if (_falseEventCo != null) { ((MonoBehaviour)this).StopCoroutine(_falseEventCo); } } catch { } try { if (_falseEventPulseCo != null) { ((MonoBehaviour)this).StopCoroutine(_falseEventPulseCo); } } catch { } _falseEventCo = null; _falseEventPulseCo = null; try { StopAllFalseEventAudio(); } catch { } } private void EnsureFalseEventAutoLoop() { try { if (_falseEventAutoCo != null) { return; } MonoBehaviour coroutineHost = GetCoroutineHost(); if (!((Object)(object)coroutineHost == (Object)null)) { if (_falseEventAutoNextAt <= 0f) { _falseEventAutoNextAt = Time.time + Random.Range(45f, 120f); } _falseEventAutoCo = coroutineHost.StartCoroutine(FalseEvent_AutoLoop()); } } catch { } } [IteratorStateMachine(typeof(d__114))] private IEnumerator FalseEvent_AutoLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__114(0) { <>4__this = this }; } private FalseEventProfile PickNextFalseEventFromDeck() { try { if (_falseEventDeck == null || _falseEventDeck.Count == 0 || _falseEventDeckIndex >= _falseEventDeck.Count) { BuildFalseEventDeck(); } if (_falseEventDeck == null || _falseEventDeck.Count == 0) { return null; } if (_falseEventDeckIndex < 0) { _falseEventDeckIndex = 0; } if (_falseEventDeckIndex >= _falseEventDeck.Count) { _falseEventDeckIndex = 0; } FalseEventProfile result = _falseEventDeck[_falseEventDeckIndex]; _falseEventDeckIndex++; return result; } catch { return null; } } private void BuildFalseEventDeck() { _falseEventDeckIndex = 0; try { List list = new List(); foreach (KeyValuePair falseEvent in _falseEvents) { if (falseEvent.Value != null && !string.IsNullOrEmpty(falseEvent.Value.Id)) { list.Add(falseEvent.Value); } } if (list.Count == 0) { _falseEventDeck = null; return; } List list2 = new List(64); for (int i = 0; i < list.Count; i++) { FalseEventProfile falseEventProfile = list[i]; int num = 1; try { num = Mathf.Clamp(falseEventProfile.DeckWeight, 1, 100); } catch { num = 1; } for (int j = 0; j < num; j++) { list2.Add(falseEventProfile); } } for (int k = 0; k < list2.Count; k++) { int index = Random.Range(k, list2.Count); FalseEventProfile value = list2[k]; list2[k] = list2[index]; list2[index] = value; } _falseEventDeck = list2; } catch { _falseEventDeck = null; _falseEventDeckIndex = 0; } } private void TryApplyPuke(Player plr) { if ((Object)(object)plr == (Object)null) { return; } try { try { plr.StartEmote("puke", true); } catch { } SEMan sEMan = ((Character)plr).GetSEMan(); if (sEMan == null) { return; } for (int i = 0; i < PukeHashes.Length; i++) { int num = PukeHashes[i]; try { if (sEMan.HaveStatusEffect(num)) { try { sEMan.RemoveStatusEffect(num, false); } catch { } } sEMan.AddStatusEffect(num, false, 0, 0f); break; } catch { } } } catch { } } private Vector3 GetPulsePosition(bool behindPlayer, float behindMeters) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { val = ((Component)localPlayer).transform.position; if (behindPlayer) { val -= ((Component)localPlayer).transform.forward * Mathf.Max(0.5f, behindMeters); } } return val; } private bool TryPlayVanillaSfxAt(Vector3 pos, string[] prefabNames) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) try { if (prefabNames == null || prefabNames.Length == 0) { return false; } if ((Object)(object)ZNetScene.instance == (Object)null) { return false; } foreach (string text in prefabNames) { if (!string.IsNullOrEmpty(text)) { GameObject prefab = ZNetScene.instance.GetPrefab(text); if (!((Object)(object)prefab == (Object)null)) { Object.Instantiate(prefab, pos, Quaternion.identity); return true; } } } } catch { } return false; } private void TryPlayFalseEventOneShot(string oggFileName, float volume01, bool behindPlayer) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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) if (string.IsNullOrEmpty(oggFileName) || Time.time < _falseEventNextOneShotAt || _activeFalseEvent == null) { return; } _falseEventNextOneShotAt = Time.time + Mathf.Max(0.25f, _activeFalseEvent.OneShotCooldownSeconds); Vector3 val = Vector3.zero; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { val = ((Component)localPlayer).transform.position; if (behindPlayer) { val -= ((Component)localPlayer).transform.forward * Mathf.Max(0.5f, _activeFalseEvent.PulseBehindMeters); } } MonoBehaviour coroutineHost = GetCoroutineHost(); if ((Object)(object)coroutineHost != (Object)null) { coroutineHost.StartCoroutine(PxPlayEmbeddedOggAt(val, oggFileName, Mathf.Clamp01(volume01), loop: false)); } } private void TryPlayFalseEventAmbience(string oggFileName, float volume01) { //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_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_0048: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(oggFileName)) { Vector3 pos = Vector3.zero; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { pos = ((Component)localPlayer).transform.position; } MonoBehaviour coroutineHost = GetCoroutineHost(); if ((Object)(object)coroutineHost != (Object)null) { coroutineHost.StartCoroutine(PxPlayEmbeddedOggAt(pos, oggFileName, Mathf.Clamp01(volume01), loop: true)); } } } [IteratorStateMachine(typeof(d__122))] private IEnumerator PxPlayEmbeddedOggAt(Vector3 pos, string oggFileName, float volume01, bool loop) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__122(0) { <>4__this = this, pos = pos, oggFileName = oggFileName, volume01 = volume01, loop = loop }; } private void StopAllFalseEventAudio() { try { for (int i = 0; i < _falseEventAudio.Count; i++) { try { if ((Object)(object)_falseEventAudio[i] != (Object)null) { _falseEventAudio[i].Stop(); } } catch { } } } catch { } try { for (int j = 0; j < _falseEventAudioGos.Count; j++) { try { if ((Object)(object)_falseEventAudioGos[j] != (Object)null) { Object.Destroy((Object)(object)_falseEventAudioGos[j]); } } catch { } } } catch { } _falseEventAudio.Clear(); _falseEventAudioGos.Clear(); } [IteratorStateMachine(typeof(d__126))] private IEnumerator ParanoidinRoutineDispatch(Player player, bool force, bool ignoreCooldowns) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__126(0) { <>4__this = this, player = player, force = force, ignoreCooldowns = ignoreCooldowns }; } private int PickHauntIndex() { if (_hauntBagPos >= _hauntBag.Count) { RefillHauntBag(); } return _hauntBag[_hauntBagPos++]; } private void RefillHauntBag() { _hauntBag.Clear(); _hauntBag.AddRange(new int[8] { 1, 2, 3, 4, 1, 2, 3, 4 }); _hauntBag.Add(Random.Range(1, 5)); _hauntBag.Add(5); for (int num = _hauntBag.Count - 1; num > 0; num--) { int index = Random.Range(0, num + 1); int value = _hauntBag[num]; _hauntBag[num] = _hauntBag[index]; _hauntBag[index] = value; } _hauntBagPos = 0; } private static void PxRegisterHauntSfxGo(GameObject go) { if ((Object)(object)go == (Object)null) { return; } try { _pxHauntSfxGos.Add(go); } catch { } } private static void PxUnregisterHauntSfxGo(GameObject go) { if ((Object)(object)go == (Object)null) { return; } try { _pxHauntSfxGos.Remove(go); } catch { } } private static void PxStopAllHauntSfx() { try { for (int num = _pxHauntSfxGos.Count - 1; num >= 0; num--) { GameObject val = _pxHauntSfxGos[num]; try { if ((Object)(object)val != (Object)null) { try { AudioSource component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.Stop(); } } catch { } try { Object.Destroy((Object)(object)val); } catch { } } } catch { } } } catch { } finally { try { _pxHauntSfxGos.Clear(); } catch { } } } private GameObject TryGetPxHaunt1Prefab() { try { if ((Object)(object)_pxHaunt1Prefab != (Object)null) { return _pxHaunt1Prefab; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup < _pxHauntsNextLoadAttemptAt) { return null; } _pxHauntsNextLoadAttemptAt = realtimeSinceStartup + 1f; string text = null; try { text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } catch { text = null; } if (string.IsNullOrEmpty(text)) { return null; } string text2 = Path.Combine(text, "Assets", "px_paranoia_haunts"); if (!File.Exists(text2)) { return null; } _pxHauntsBundle = AssetBundle.LoadFromFile(text2); if ((Object)(object)_pxHauntsBundle == (Object)null) { return null; } try { _pxHaunt1Prefab = _pxHauntsBundle.LoadAsset("PX_Haunt_Haunt1"); } catch { _pxHaunt1Prefab = null; } if ((Object)(object)_pxHaunt1Prefab == (Object)null) { try { string text3 = "PX_Haunt_Haunt1".ToLowerInvariant(); string[] allAssetNames = _pxHauntsBundle.GetAllAssetNames(); foreach (string text4 in allAssetNames) { if (string.IsNullOrEmpty(text4)) { continue; } string text5 = text4.ToLowerInvariant(); if (text5.EndsWith(text3 + ".prefab", StringComparison.Ordinal) || text5.Contains(text3)) { try { _pxHaunt1Prefab = _pxHauntsBundle.LoadAsset(text4); } catch { _pxHaunt1Prefab = null; } if ((Object)(object)_pxHaunt1Prefab != (Object)null) { break; } } } } catch { } } return _pxHaunt1Prefab; } catch { return null; } } internal bool DebugIsParanoidinActive() { return _paranoidinActive; } internal bool DebugStartParanoidin(bool force, bool ignoreCooldowns) { try { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return false; } if (_paranoidinActive) { return false; } if (!force) { if (!ParanoiaPlugin.EnableParanoidin.Value) { return false; } if (!IsSafeToFire(localPlayer)) { return false; } if (!ignoreCooldowns && Time.time < _nextAllowed_Paranoidin) { return false; } } else if (!ignoreCooldowns && Time.time < _nextAllowed_Paranoidin) { return false; } if (_paranoidinRoutine != null) { try { ((MonoBehaviour)this).StopCoroutine(_paranoidinRoutine); } catch { } _paranoidinRoutine = null; } _paranoidinRoutine = ((MonoBehaviour)this).StartCoroutine(ParanoidinRoutineDispatch(localPlayer, force, ignoreCooldowns)); return true; } catch { return false; } } internal void DebugStopParanoidin() { try { ForceTerminateParanoidin(); } catch { } } internal void FlushParanoidinCache() { try { if (_paranoidinRoutine != null) { try { ((MonoBehaviour)this).StopCoroutine(_paranoidinRoutine); } catch { } _paranoidinRoutine = null; } ForceTerminateParanoidin(); try { _nextAllowed_Paranoidin = Time.time + 2f; } catch { } } catch { } } private void ForceTerminateParanoidin() { try { _paranoidinActive = false; _paranoidinAttacking = false; _paranoidinLosHold = 0f; _paranoidinNearHold = 0f; TryApplyParanoidinEnvironment(enable: false); if ((Object)(object)_paranoidinGo != (Object)null) { EndOdinClamp(_paranoidinGo); Object.Destroy((Object)(object)_paranoidinGo); _paranoidinGo = null; } DestroyOdinClampAnchor(); } catch { } } private void MaybeTickParanoidin(Player player, ParanoiaTier tier) { try { if (!ParanoiaPlugin.EnableParanoidin.Value || _paranoidinActive) { return; } if ((Object)(object)player != (Object)null && ((Character)player).GetSEMan() != null) { int stableHashCode = StringExtensionMethods.GetStableHashCode("SE_Pix_Hallucinate"); if (((Character)player).GetSEMan().HaveStatusEffect(stableHashCode)) { return; } } float num = Mathf.Clamp01(GetParanoidinChanceForTier(tier)); if (num <= 0f || Time.time < _nextAllowed_Paranoidin) { return; } float num2 = 1f; try { num2 = GetNightMultiplier(); } catch { } num = Mathf.Clamp01(num * num2); if (Random.value > num) { return; } if (_paranoidinRoutine != null) { try { ((MonoBehaviour)this).StopCoroutine(_paranoidinRoutine); } catch { } _paranoidinRoutine = null; } _paranoidinRoutine = ((MonoBehaviour)this).StartCoroutine(ParanoidinRoutineDispatch(player, force: false, ignoreCooldowns: false)); } catch { } } private void EnsureOdinClampAnchor() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if ((Object)(object)_odinClampAnchor != (Object)null) { return; } try { GameObject val = new GameObject("PX_OdinClampAnchor"); _odinClampAnchor = val.transform; } catch { } } private void DestroyOdinClampAnchor() { try { if ((Object)(object)_odinClampAnchor != (Object)null) { GameObject gameObject = ((Component)_odinClampAnchor).gameObject; _odinClampAnchor = null; if ((Object)(object)gameObject != (Object)null) { Object.Destroy((Object)(object)gameObject); } } } catch { _odinClampAnchor = null; } } private void UpdateOdinClampAnchor(Player player) { //IL_0029: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)_odinClampAnchor == (Object)null || (Object)(object)player == (Object)null) { return; } try { Transform transform = ((Component)player).transform; Vector3 position = transform.position + transform.forward * 1.1f + Vector3.up * 1.05f; _odinClampAnchor.position = position; _odinClampAnchor.rotation = Quaternion.LookRotation(-transform.forward, Vector3.up); } catch { } } private void BeginOdinClamp(GameObject odinGo, Player player) { if ((Object)(object)odinGo == (Object)null || (Object)(object)player == (Object)null) { return; } try { EnsureOdinClampAnchor(); if (!((Object)(object)_odinClampAnchor == (Object)null)) { UpdateOdinClampAnchor(player); _odinPrevParent = odinGo.transform.parent; odinGo.transform.SetParent(_odinClampAnchor, true); _odinClamped = true; } } catch { } } private void EndOdinClamp(GameObject odinGo) { if (!_odinClamped) { return; } try { if ((Object)(object)odinGo != (Object)null) { odinGo.transform.SetParent(_odinPrevParent, true); } } catch { } _odinPrevParent = null; _odinClamped = false; } private void UpdatePlayerSpeedEstimate(Player player) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0088: 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_0092: 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_00c5: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)player == (Object)null)) { float time = Time.time; if (!_paranoidinPlayerInit) { _paranoidinPlayerInit = true; _paranoidinLastPlayerPos = ((Component)player).transform.position; _paranoidinLastPlayerSpeed = 0f; _paranoidinNextPlayerSampleAt = time + 0.2f; } else if (!(time < _paranoidinNextPlayerSampleAt)) { _paranoidinNextPlayerSampleAt = time + 0.2f; Vector3 position = ((Component)player).transform.position; Vector3 val = position - _paranoidinLastPlayerPos; val.y = 0f; float num = ((Vector3)(ref val)).magnitude / 0.2f; _paranoidinLastPlayerSpeed = Mathf.Clamp(num, 0f, 25f); _paranoidinLastPlayerPos = position; } } } catch { } } private void ClampToGroundStable(ref Vector3 pos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_007f: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) try { Vector3 val = pos; val.y = 0f; int num; if (_paranoidinGroundInit) { Vector3 val2 = val - _paranoidinLastGroundSampleXZ; num = ((((Vector3)(ref val2)).sqrMagnitude >= 0.122499995f) ? 1 : 0); } else { num = 1; } bool flag = (byte)num != 0; if (!_paranoidinGroundInit || (flag && Time.time >= _paranoidinNextGroundSampleAt)) { _paranoidinNextGroundSampleAt = Time.time + 0.2f; Vector3 val3 = pos + Vector3.up * 3f; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val3, Vector3.down, ref val4, 25f, -1, (QueryTriggerInteraction)1)) { float num2 = ((RaycastHit)(ref val4)).point.y + 0.05f; bool flag2 = false; try { Heightmap val5 = (((Object)(object)((RaycastHit)(ref val4)).collider != (Object)null) ? ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() : null); flag2 = (Object)(object)val5 != (Object)null || !_paranoidinGroundInit; } catch { flag2 = true; } if (flag2) { float num3 = Mathf.Abs(num2 - pos.y); if (!_paranoidinGroundInit || num3 <= 6f) { _paranoidinGroundY = num2; _paranoidinGroundInit = true; _paranoidinLastGroundSampleXZ = val; } } } } if (_paranoidinGroundInit) { pos.y = _paranoidinGroundY; } } catch { if (_paranoidinGroundInit) { pos.y = _paranoidinGroundY; } } } private Vector3 PickAnchorAroundPlayer(Player player, bool preferFront) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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) //IL_01b4: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)player).transform.position; Vector3 forward = ((Component)player).transform.forward; forward.y = 0f; Vector3 right = ((Component)player).transform.right; right.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); if (((Vector3)(ref right)).sqrMagnitude < 0.01f) { right = Vector3.right; } ((Vector3)(ref right)).Normalize(); float paranoidinLastPlayerSpeed = _paranoidinLastPlayerSpeed; float num = 3.2f; num = ((paranoidinLastPlayerSpeed <= 0.25f) ? 2.1f : ((paranoidinLastPlayerSpeed <= 1.25f) ? 2.8f : ((!(paranoidinLastPlayerSpeed <= 4.5f)) ? 4.5f : 3.6f))); float num2 = ((!preferFront) ? Random.Range(0f, 360f) : Random.Range(-55f, 55f)); float num3 = num2 * ((float)Math.PI / 180f); Vector3 val = forward * Mathf.Cos(num3) + right * Mathf.Sin(num3); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = position + val * num; val2 += right * Random.Range(-0.35f, 0.35f); val2 += forward * Random.Range(-0.35f, 0.35f); val2.y = position.y; ClampToGroundStable(ref val2); return val2; } private void EnsureStalkAnchor(Player player, bool preferFront) { //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) if (!_paranoidinHasAnchor || Time.time >= _paranoidinNextRetargetAt) { _paranoidinStalkAnchor = PickAnchorAroundPlayer(player, preferFront); _paranoidinHasAnchor = true; float paranoidinLastPlayerSpeed = _paranoidinLastPlayerSpeed; float num = 1.35f; num = ((paranoidinLastPlayerSpeed <= 0.25f) ? 1.9f : ((paranoidinLastPlayerSpeed <= 1.25f) ? 1.6f : ((!(paranoidinLastPlayerSpeed <= 4.5f)) ? 0.95f : 1.25f))); _paranoidinNextRetargetAt = Time.time + Random.Range(num * 0.85f, num * 1.25f); } } private void TeleBlink(Player player, ref Vector3 ppos, bool preferFront) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Vector3 position = (_paranoidinStalkAnchor = (_paranoidinPos = (ppos = PickAnchorAroundPlayer(player, preferFront)))); _paranoidinHasAnchor = true; _paranoidinNextRetargetAt = Time.time + Random.Range(1f, 1.8f); if ((Object)(object)_paranoidinGo != (Object)null) { _paranoidinGo.transform.position = position; } } private void DriveChase(Player player, ref Vector3 ppos, float distToPlayer, bool hasLos, float dt, bool preferFrontAnchor) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003a: 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_00ab: 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_00b3: 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_00bf: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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) float num = Mathf.Max(18f, ParanoiaPlugin.ParanoidinDespawnDistance.Value * 0.75f); if (distToPlayer > num) { Vector3 position = (_paranoidinPos = (ppos = PickAnchorAroundPlayer(player, preferFront: false))); if ((Object)(object)_paranoidinGo != (Object)null) { _paranoidinGo.transform.position = position; } return; } EnsureStalkAnchor(player, preferFrontAnchor); float num2 = 3.2f; float num3 = 12f; float num4 = Mathf.Clamp01(distToPlayer / 14f); float num5 = Mathf.Lerp(num2, num3, num4); if (hasLos) { num5 *= 0.9f; } Vector3 paranoidinStalkAnchor = _paranoidinStalkAnchor; Vector3 pos = Vector3.MoveTowards(ppos, paranoidinStalkAnchor, num5 * dt); ClampToGroundStable(ref pos); ppos = pos; _paranoidinPos = pos; if (!((Object)(object)_paranoidinGo != (Object)null)) { return; } _paranoidinGo.transform.position = pos; try { Vector3 val = ((Component)player).transform.position - pos; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.1f) { _paranoidinGo.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized); } } catch { } } private void ForceCloseForAttack(Player player) { //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_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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { Vector3 position = ((Component)player).transform.position; Vector3 forward = ((Component)player).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); Vector3 pos = position + forward * 1.4f; ClampToGroundStable(ref pos); _paranoidinPos = pos; if ((Object)(object)_paranoidinGo != (Object)null) { _paranoidinGo.transform.position = pos; } } } private bool HasLineOfSightSimple(Player player, Vector3 targetPos) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //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_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_006e: 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_0075: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) try { Vector3 val = ((Component)player).transform.position + Vector3.up * 1.6f; try { Vector3 headPoint = ((Character)player).GetHeadPoint(); if (headPoint != Vector3.zero) { val = headPoint; } } catch { } Vector3 val2 = targetPos - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= 0.05f) { return true; } val2 /= magnitude; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val, val2, ref val3, magnitude, -1, (QueryTriggerInteraction)1)) { Vector3 val4 = ((RaycastHit)(ref val3)).point - targetPos; return ((Vector3)(ref val4)).sqrMagnitude <= 1.44f; } return true; } catch { return true; } } private GameObject GetParanoidinVisualPrefab() { try { try { GameObject val = TryGetPxHaunt1Prefab(); if ((Object)(object)val != (Object)null) { return val; } } catch { } bool flag = true; try { flag = ParanoiaPlugin.ParanoidinUseSafeVisuals == null || ParanoiaPlugin.ParanoidinUseSafeVisuals.Value; } catch { flag = true; } if (flag) { string[] array = new string[12] { "vfx_wisp", "wisp", "vfx_ghost", "ghost", "vfx_wraith", "wraith", "vfx_mist", "mist", "vfx_fog", "fog", "vfx_smoke", "smoke" }; for (int i = 0; i < array.Length; i++) { try { GameObject val2 = FindPrefabByNameContains(array[i]); if ((Object)(object)val2 != (Object)null) { return val2; } } catch { } } } try { string text = null; try { text = ((ParanoiaPlugin.ParanoidinPrefabNames != null) ? ParanoiaPlugin.ParanoidinPrefabNames.Value : null); } catch { text = null; } if (!string.IsNullOrEmpty(text)) { string[] array2 = text.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < array2.Length; j++) { string text2 = array2[j].Trim(); if (string.IsNullOrEmpty(text2)) { continue; } try { GameObject val3 = FindPrefabByNameContains(text2); if ((Object)(object)val3 != (Object)null) { return val3; } } catch { } } } } catch { } GameObject result = null; try { result = FindPrefabByNameContains("Odin"); } catch { } return result; } catch { GameObject result2 = null; try { result2 = FindPrefabByNameContains("Odin"); } catch { } return result2; } } private GameObject SpawnGhostOdin(Vector3 pos) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) try { try { if (ParanoiaPlugin.ParanoidinSpawnVisualGhost != null && !ParanoiaPlugin.ParanoidinSpawnVisualGhost.Value) { return null; } } catch { } GameObject paranoidinVisualPrefab = GetParanoidinVisualPrefab(); if ((Object)(object)paranoidinVisualPrefab == (Object)null) { return null; } GameObject val = Object.Instantiate(paranoidinVisualPrefab, pos, Quaternion.identity); bool flag = false; try { flag = (Object)(object)_pxHaunt1Prefab != (Object)null && (Object)(object)paranoidinVisualPrefab == (Object)(object)_pxHaunt1Prefab; } catch { flag = false; } if (!flag) { try { StripParanoidinCloneToVisualOnly(val); } catch { } } if (!flag) { try { ParticleSystem[] componentsInChildren = val.GetComponentsInChildren(true); foreach (ParticleSystem val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { try { MainModule main = val2.main; ((MainModule)(ref main)).loop = false; } catch { } try { val2.Play(true); } catch { } } } } catch { } } if (!flag) { try { Animator[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if ((Object)(object)componentsInChildren2[j] != (Object)null) { componentsInChildren2[j].speed = 0f; } } } catch { } } try { Renderer[] componentsInChildren3 = val.GetComponentsInChildren(true); for (int k = 0; k < componentsInChildren3.Length; k++) { if ((Object)(object)componentsInChildren3[k] != (Object)null) { componentsInChildren3[k].enabled = true; } } } catch { } try { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { Vector3 val3 = ((Component)localPlayer).transform.position - val.transform.position; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude > 0.1f) { val.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized); } } } catch { } Object.Destroy((Object)(object)val, 65f); return val; } catch { return null; } } private void StripParanoidinCloneToVisualOnly(GameObject root) { if ((Object)(object)root == (Object)null) { return; } try { Collider[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { componentsInChildren[i].enabled = false; } } } catch { } try { Rigidbody[] componentsInChildren2 = root.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if ((Object)(object)componentsInChildren2[j] != (Object)null) { componentsInChildren2[j].isKinematic = true; componentsInChildren2[j].detectCollisions = false; } } } catch { } try { Component[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (Component val in componentsInChildren3) { if ((Object)(object)val == (Object)null || val is Transform || val is Renderer || val is MeshFilter || val is Light || val is ParticleSystem || val is Animator) { continue; } string name = ((object)val).GetType().Name; if (name == "ZNetView" || name.StartsWith("ZSync", StringComparison.Ordinal) || name.StartsWith("ZNet", StringComparison.Ordinal)) { try { Object.Destroy((Object)(object)val); } catch { } continue; } switch (name) { default: if (!(name == "FootStep")) { Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.enabled = false; } break; } goto case "Character"; case "Character": case "Humanoid": case "MonsterAI": case "BaseAI": case "Ragdoll": try { Object.Destroy((Object)(object)val); } catch { } break; } } } catch { } } private Vector3 GetParanoidinSpawnPos(Player player, float dist, bool preferFront) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //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_0098: Unknown result type (might be due to invalid IL or missing references) UpdatePlayerSpeedEstimate(player); Vector3 pos = PickAnchorAroundPlayer(player, preferFront); try { float num = Mathf.Max(2f, dist); Vector3 position = ((Component)player).transform.position; Vector3 val = pos - position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)player).transform.forward; } ((Vector3)(ref val)).Normalize(); pos = position + val * num; pos.y = position.y; ClampToGroundStable(ref pos); } catch { } return pos; } private void TryPlayHitSfxFallback(Vector3 pos) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[2] { "sfx_hit", "sfx_damage" }; for (int i = 0; i < array.Length; i++) { try { TryPlayConfiguredSfxAt(pos, array[i]); break; } catch { } } } private void TryApplyParanoidinDamage(Player player) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null || ((Character)player).IsDead()) { return; } float num = 15f; try { num = Mathf.Max(1f, ParanoiaPlugin.ParanoidinAttackDamage.Value); } catch { } try { float health = ((Character)player).GetHealth(); float num2 = Mathf.Max(0f, health - 1f); if (num > num2) { num = num2; } } catch { } HitData val = new HitData(); val.m_damage.m_blunt = num; Vector3 val2 = (((Object)(object)_paranoidinGo != (Object)null) ? _paranoidinGo.transform.position : _paranoidinPos); Vector3 dir = ((Component)player).transform.position - val2; dir.y = 0f; if (((Vector3)(ref dir)).sqrMagnitude > 0.01f) { ((Vector3)(ref dir)).Normalize(); } else { dir = ((Component)player).transform.forward; } val.m_dir = dir; val.m_point = ((Component)player).transform.position + Vector3.up * 1.1f; val.m_pushForce = 2f; TryPlayHitSfxFallback(val.m_point); ParanoiaPlugin.ApplyParanoidinDamageAuthoritative(player, num, val.m_point, val.m_dir, val.m_pushForce); } catch { } } private static bool TryInvokeRainDanceOverlay(bool enable) { try { Type type = Type.GetType("Pix.RainDance.RainDancePlugin, Pix.RainDance"); if (type == null) { return false; } MethodInfo method = type.GetMethod("ApplyParanoiaOverlay", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method == null) { return false; } method.Invoke(null, new object[1] { enable }); return true; } catch { return false; } } private static void EnvMan_SetForceEnvironment_Reflect(string env) { try { if (!((Object)(object)EnvMan.instance == (Object)null)) { MethodInfo method = typeof(EnvMan).GetMethod("SetForceEnvironment", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); if (method != null) { method.Invoke(EnvMan.instance, new object[1] { env }); } } } catch { } } private static string EnvMan_GetForcedEnvironment_Reflect() { try { if ((Object)(object)EnvMan.instance == (Object)null) { return null; } FieldInfo field = typeof(EnvMan).GetField("m_forceEnvironment", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(EnvMan.instance); return value as string; } } catch { } return null; } private void TryApplyParanoidinEnvironment(bool enable) { try { try { if (ParanoiaPlugin.ParanoidinEnvironmentEnabled != null && !ParanoiaPlugin.ParanoidinEnvironmentEnabled.Value) { return; } } catch { } if (enable) { if (_paranoidinEnvActive) { return; } if (TryInvokeRainDanceOverlay(enable: true)) { _paranoidinEnvActive = true; return; } _savedEnv = EnvMan_GetForcedEnvironment_Reflect(); string[] array = new string[2] { "Darklands_dark", "ThunderStorm" }; bool paranoidinEnvActive = false; for (int i = 0; i < array.Length; i++) { try { EnvMan_SetForceEnvironment_Reflect(array[i]); paranoidinEnvActive = true; } catch { continue; } break; } _paranoidinEnvActive = paranoidinEnvActive; } else if (_paranoidinEnvActive) { TryInvokeRainDanceOverlay(enable: false); if (string.IsNullOrEmpty(_savedEnv)) { EnvMan_SetForceEnvironment_Reflect(""); } else { EnvMan_SetForceEnvironment_Reflect(_savedEnv); } _savedEnv = null; _paranoidinEnvActive = false; } } catch { } } [IteratorStateMachine(typeof(d__185))] internal IEnumerator ParanoidinRoutine_Haunt1(Player player, bool force, bool ignoreCooldowns) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__185(0) { <>4__this = this, player = player, force = force, ignoreCooldowns = ignoreCooldowns }; } [IteratorStateMachine(typeof(d__186))] private IEnumerator PxPlayEmbeddedOggAt(Vector3 pos, string oggFileName, float volume01) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__186(0) { <>4__this = this, pos = pos, oggFileName = oggFileName, volume01 = volume01 }; } private static AudioClip PxGetWwwAudioClip(WWW www) { if (www == null) { return null; } try { MethodInfo method = typeof(WWW).GetMethod("GetAudioClip", new Type[3] { typeof(bool), typeof(bool), typeof(AudioType) }); if (method != null) { object obj = method.Invoke(www, new object[3] { false, false, (object)(AudioType)14 }); return (AudioClip)((obj is AudioClip) ? obj : null); } } catch { } try { return www.GetAudioClip(false, false); } catch { } return null; } private static string PxEnsureEmbeddedFileOnDisk(string fileName, string subFolder) { string text = null; try { text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } catch { text = null; } if (string.IsNullOrEmpty(text)) { return null; } string text2 = text; try { if (!string.IsNullOrEmpty(subFolder)) { text2 = Path.Combine(text, subFolder); } Directory.CreateDirectory(text2); } catch { text2 = text; } string text3 = Path.Combine(text2, fileName); try { if (File.Exists(text3)) { return text3; } } catch { } try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text4 = executingAssembly.GetManifestResourceNames().FirstOrDefault((string n) => n.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)); if (string.IsNullOrEmpty(text4)) { return text3; } using Stream stream = executingAssembly.GetManifestResourceStream(text4); if (stream == null) { return text3; } using FileStream destination = File.Open(text3, FileMode.Create, FileAccess.Write, FileShare.Read); stream.CopyTo(destination); } catch { } return text3; } [IteratorStateMachine(typeof(d__191))] internal IEnumerator ParanoidinRoutine_Haunt2(Player player, bool force, bool ignoreCooldowns) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__191(0) { <>4__this = this, player = player, force = force, ignoreCooldowns = ignoreCooldowns }; } private bool Haunt2_IsRepelledByWater(Player player) { try { try { if (((Character)player).InLiquid()) { return true; } } catch { } try { if (((Character)player).IsSwimming()) { return true; } } catch { } try { SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan != null) { List statusEffects = sEMan.GetStatusEffects(); if (statusEffects != null) { for (int i = 0; i < statusEffects.Count; i++) { StatusEffect val = statusEffects[i]; if ((Object)(object)val == (Object)null) { continue; } string text = null; try { text = ((Object)val).name; } catch { text = null; } if (!string.IsNullOrEmpty(text)) { text = text.ToLowerInvariant(); if (text.Contains("wet")) { return true; } } } } } } catch { } return false; } catch { return false; } } [IteratorStateMachine(typeof(d__193))] private IEnumerator Haunt2_ShooAway(Player player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__193(0) { <>4__this = this, player = player }; } private GameObject TryGetPxHauntPrefabByName(string prefabName) { try { if ((Object)(object)_pxHauntsBundle == (Object)null) { if (_pxHauntsTriedLoad) { return null; } _pxHauntsTriedLoad = true; string text = null; try { text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } catch { text = null; } if (string.IsNullOrEmpty(text)) { return null; } string text2 = Path.Combine(text, "Assets", "px_paranoia_haunts"); if (!File.Exists(text2)) { return null; } _pxHauntsBundle = AssetBundle.LoadFromFile(text2); } if ((Object)(object)_pxHauntsBundle == (Object)null) { return null; } GameObject val = null; try { val = _pxHauntsBundle.LoadAsset(prefabName); } catch { val = null; } if ((Object)(object)val == (Object)null) { try { string text3 = prefabName.ToLowerInvariant(); string[] allAssetNames = _pxHauntsBundle.GetAllAssetNames(); foreach (string text4 in allAssetNames) { if (string.IsNullOrEmpty(text4)) { continue; } string text5 = text4.ToLowerInvariant(); if (text5.EndsWith(text3 + ".prefab", StringComparison.Ordinal) || text5.Contains(text3)) { try { val = _pxHauntsBundle.LoadAsset(text4); } catch { val = null; } if ((Object)(object)val != (Object)null) { break; } } } } catch { } } return val; } catch { return null; } } [IteratorStateMachine(typeof(d__196))] internal IEnumerator ParanoidinRoutine_Haunt3(Player player, bool force, bool ignoreCooldowns) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__196(0) { <>4__this = this, player = player, force = force, ignoreCooldowns = ignoreCooldowns }; } [IteratorStateMachine(typeof(d__197))] private IEnumerator Haunt3_ShooAway(Player player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__197(0) { <>4__this = this, player = player }; } [IteratorStateMachine(typeof(d__198))] private IEnumerator Haunt3_PunishToOneHp_ThenEnd(Player player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__198(0) { <>4__this = this, player = player }; } private void Haunt3_DropPlayerToOneHpAuthoritative(Player player) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null || ((Character)player).IsDead()) { return; } float num = 0f; try { num = ((Character)player).GetHealth(); } catch { num = 0f; } if (num <= 1.01f) { return; } float num2 = Mathf.Max(0f, num - 1f); Vector3 point = ((Component)player).transform.position + Vector3.up * 0.9f; Vector3 dir = Vector3.back; try { dir = -((Component)player).transform.forward; dir.y = 0f; if (((Vector3)(ref dir)).sqrMagnitude < 0.01f) { dir = Vector3.back; } ((Vector3)(ref dir)).Normalize(); } catch { dir = Vector3.back; } try { ParanoiaPlugin.ApplyParanoidinDamageAuthoritative(player, num2, point, dir, 0f); } catch { } try { HitData val = new HitData(); val.m_point = point; val.m_dir = dir; val.m_pushForce = 0f; val.m_damage.m_blunt = num2; ((Character)player).Damage(val); } catch { } } catch { } } [IteratorStateMachine(typeof(d__201))] internal IEnumerator ParanoidinRoutine_Haunt4(Player player, bool force, bool ignoreCooldowns) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__201(0) { <>4__this = this, player = player, force = force, ignoreCooldowns = ignoreCooldowns }; } private bool Haunt4_IsPlayerSheltered(Player player) { try { return player.InShelter(); } catch { return false; } } [IteratorStateMachine(typeof(d__203))] private IEnumerator Haunt4_ShooAway(Player player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__203(0) { <>4__this = this, player = player }; } [IteratorStateMachine(typeof(d__205))] internal IEnumerator ParanoidinRoutine_Haunt5(Player player, bool force, bool ignoreCooldowns) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__205(0) { <>4__this = this, player = player, force = force, ignoreCooldowns = ignoreCooldowns }; } private float Haunt5_DistanceXZ(Vector3 a, Vector3 b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) float num = a.x - b.x; float num2 = a.z - b.z; return Mathf.Sqrt(num * num + num2 * num2); } private Vector3 Haunt5_GetClosestPointOnVisual(GameObject go, Vector3 point) { //IL_00e8: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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) //IL_0044: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00b3: 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_0083: 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) try { if ((Object)(object)go == (Object)null) { return point; } Renderer[] componentsInChildren = go.GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return go.transform.position; } bool flag = false; Bounds val = default(Bounds); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (!flag) { return go.transform.position; } return ((Bounds)(ref val)).ClosestPoint(point); } catch { try { return ((Object)(object)go != (Object)null) ? go.transform.position : point; } catch { return point; } } } private bool Haunt5_IsPlayerLookingAtHaunt(Player player, GameObject hauntGo, float dotThreshold) { //IL_0080: 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_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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00e1: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null || (Object)(object)hauntGo == (Object)null) { return false; } Transform val = null; try { if ((Object)(object)GameCamera.instance != (Object)null) { val = ((Component)GameCamera.instance).transform; } } catch { val = null; } if ((Object)(object)val == (Object)null) { try { val = ((Component)player).transform; } catch { val = null; } } if ((Object)(object)val == (Object)null) { return false; } Vector3 position = val.position; Vector3 forward = val.forward; Vector3 val2 = hauntGo.transform.position - position; val2.y = 0f; forward.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { return true; } ((Vector3)(ref val2)).Normalize(); ((Vector3)(ref forward)).Normalize(); float num = Vector3.Dot(forward, val2); return num >= dotThreshold; } catch { return false; } } private void Haunt5_TeleportNearPlayer_SideBehindBias(Player player, float desiredDistance) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) //IL_0071: 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_007a: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)player == (Object)null) && !((Object)(object)_paranoidinGo == (Object)null)) { Vector3 position = ((Component)player).transform.position; Vector3 forward = ((Component)player).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); Vector3 val = Vector3.Cross(Vector3.up, forward); Vector3 normalized = ((Vector3)(ref val)).normalized; float time = Time.time; float num = Mathf.Sin(time * 1.7f); float num2 = Mathf.Cos(time * 1.1f); Vector3 val2 = ((num < 0.35f) ? (-forward) : forward); Vector3 val3 = val2 * (0.92f + 0.08f * Mathf.Abs(num)) + normalized * (0.45f * num2); if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = val2; } Vector3 paranoidinPos = position + ((Vector3)(ref val3)).normalized * Mathf.Max(2.25f, desiredDistance); _paranoidinPos = paranoidinPos; ClampToGroundStable(ref _paranoidinPos); _paranoidinGo.transform.position = _paranoidinPos; Vector3 val4 = position - _paranoidinPos; val4.y = 0f; if (((Vector3)(ref val4)).sqrMagnitude > 0.01f) { _paranoidinGo.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val4)).normalized); } } } catch { } } private void Haunt5_KillPlayer_Reliable(Player player, Vector3 point) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00ac: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null || ((Character)player).IsDead()) { return; } if (point == Vector3.zero) { try { point = ((Component)player).transform.position + Vector3.up * 0.9f; } catch { } } Vector3 dir = -((Component)player).transform.forward; dir.y = 0f; if (((Vector3)(ref dir)).sqrMagnitude < 0.01f) { dir = Vector3.back; } ((Vector3)(ref dir)).Normalize(); HitData val = new HitData(); val.m_point = point; val.m_dir = dir; val.m_pushForce = 0f; val.m_damage.m_damage = 9999f; try { ParanoiaPlugin.ApplyParanoidinDamageAuthoritative(player, 9999f, point, dir, 0f); } catch { } try { if (((Character)player).IsDead()) { return; } } catch { } try { ZNetView val2 = null; try { val2 = ((Component)player).GetComponent(); } catch { val2 = null; } if ((Object)(object)val2 != (Object)null && val2.IsValid()) { try { val2.InvokeRPC("Damage", new object[1] { val }); } catch { } try { Type typeFromHandle = typeof(ZNetView); MethodInfo method = typeFromHandle.GetMethod("InvokeRPC", new Type[3] { typeof(long), typeof(string), typeof(object) }); if (method != null) { try { long num = 0L; try { num = ((val2.GetZDO() != null) ? val2.GetZDO().GetOwner() : 0); } catch { num = 0L; } if (num != 0) { method.Invoke(val2, new object[3] { num, "Damage", val }); } } catch { } try { method.Invoke(val2, new object[3] { 0L, "Damage", val }); } catch { } } MethodInfo method2 = typeFromHandle.GetMethod("InvokeRPC", new Type[3] { typeof(long), typeof(string), typeof(object[]) }); if (method2 != null) { try { long num2 = 0L; try { num2 = ((val2.GetZDO() != null) ? val2.GetZDO().GetOwner() : 0); } catch { num2 = 0L; } if (num2 != 0) { method2.Invoke(val2, new object[3] { num2, "Damage", new object[1] { val } }); } } catch { } try { method2.Invoke(val2, new object[3] { 0L, "Damage", new object[1] { val } }); } catch { } } } catch { } } } catch { } try { if (((Character)player).IsDead()) { return; } } catch { } try { ((Character)player).Damage(val); } catch { } } catch { } } static ParanoiaEngine() { Biome[] array = new Biome[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); s_foreignBiomes = (Biome[])(object)array; SleepDeprivedSeHash = StringExtensionMethods.GetStableHashCode("SE_Pix_SleepDeprived"); PukeHashes = new int[4] { StringExtensionMethods.GetStableHashCode("Puke"), StringExtensionMethods.GetStableHashCode("SE_Puke"), StringExtensionMethods.GetStableHashCode("se_puke"), StringExtensionMethods.GetStableHashCode("puke") }; _pxHauntSfxGos = new List(); } } internal static class ResourcesEmbedded { private static readonly Assembly _asm = typeof(ResourcesEmbedded).Assembly; private static string[] _names; internal static string[] Names() { try { if (_names == null) { _names = _asm.GetManifestResourceNames(); } return _names ?? Array.Empty(); } catch { return Array.Empty(); } } internal static byte[] ReadAllBytesBySuffix(string endsWithFileName) { if (string.IsNullOrEmpty(endsWithFileName)) { return null; } try { string text = null; string[] array = Names(); foreach (string text2 in array) { if (text2 != null && text2.EndsWith(endsWithFileName, StringComparison.OrdinalIgnoreCase)) { text = text2; break; } } if (string.IsNullOrEmpty(text)) { return null; } using Stream stream = _asm.GetManifestResourceStream(text); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } catch { return null; } } internal static Sprite LoadPngSprite(string pngFileName, float pixelsPerUnit = 100f) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) byte[] array = ReadAllBytesBySuffix(pngFileName); if (array == null || array.Length < 8) { return null; } try { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!PngIconLoader.TryLoadPngIntoTexture(val, array)) { return null; } if (((Texture)val).width <= 2 && ((Texture)val).height <= 2) { return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), pixelsPerUnit); } catch { return null; } } internal static AssetBundle LoadAssetBundle(string bundleFileName) { byte[] array = ReadAllBytesBySuffix(bundleFileName); if (array == null || array.Length < 16) { return null; } try { return AssetBundle.LoadFromMemory(array); } catch { return null; } } internal static string ExtractToCache(string endsWithFileName, string cacheFolder = "Pix.Paranoia") { if (string.IsNullOrEmpty(endsWithFileName)) { return null; } try { byte[] array = ReadAllBytesBySuffix(endsWithFileName); if (array == null || array.Length == 0) { return null; } string text; try { text = Path.Combine(Paths.BepInExRootPath, "cache", cacheFolder); } catch { text = Path.Combine(Application.persistentDataPath, "cache", cacheFolder); } Directory.CreateDirectory(text); string text2 = Path.Combine(text, endsWithFileName); File.WriteAllBytes(text2, array); return text2; } catch { return null; } } } internal static class PngIconLoader { private static MethodInfo _miLoadImage; private static bool _resolved; private static void Resolve() { if (_resolved) { return; } _resolved = true; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!(assembly.GetName().Name != "UnityEngine.ImageConversionModule")) { Type type = assembly.GetType("UnityEngine.ImageConversion", throwOnError: false); if (!(type == null)) { _miLoadImage = type.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(Texture2D), typeof(byte[]), typeof(bool) }, null); break; } } } } catch { } } internal static bool TryLoadPngIntoTexture(Texture2D tex, byte[] data) { if ((Object)(object)tex == (Object)null || data == null || data.Length < 8) { return false; } Resolve(); if (_miLoadImage == null) { return false; } try { object obj = _miLoadImage.Invoke(null, new object[3] { tex, data, false }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } private static Sprite MakeSpriteFromBytes(byte[] bytes) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_007f: 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) if (bytes == null || bytes.Length < 8) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!TryLoadPngIntoTexture(val, bytes)) { return null; } if (((Texture)val).width <= 2 && ((Texture)val).height <= 2) { return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } internal static void EnsureIcon(string pngFileName, string fallbackSeNameContains, StatusEffect se, ObjectDB odb, ref Sprite iconCached, ref bool iconIsCustom, ref DateTime customIconWriteUtc) { try { if ((Object)(object)se == (Object)null) { return; } if (((Object)(object)iconCached != (Object)null) & iconIsCustom) { se.m_icon = iconCached; return; } Sprite val = ResourcesEmbedded.LoadPngSprite(pngFileName); if ((Object)(object)val != (Object)null) { iconCached = val; iconIsCustom = true; se.m_icon = val; return; } string text = null; try { text = Path.GetDirectoryName(typeof(ParanoiaPlugin).Assembly.Location); } catch { } if (!string.IsNullOrEmpty(text)) { string path = Path.Combine(text, pngFileName); if (File.Exists(path)) { try { byte[] bytes = File.ReadAllBytes(path); val = MakeSpriteFromBytes(bytes); } catch { val = null; } if ((Object)(object)val != (Object)null) { iconCached = val; iconIsCustom = true; se.m_icon = val; return; } } } Sprite val2 = null; if ((Object)(object)odb != (Object)null && odb.m_StatusEffects != null) { for (int i = 0; i < odb.m_StatusEffects.Count; i++) { StatusEffect val3 = odb.m_StatusEffects[i]; if ((Object)(object)val3 == (Object)null) { continue; } string name = ((Object)val3).name; if (!string.IsNullOrEmpty(name) && name.IndexOf(fallbackSeNameContains, StringComparison.OrdinalIgnoreCase) >= 0) { val2 = val3.m_icon; if ((Object)(object)val2 != (Object)null) { break; } } } } if ((Object)(object)val2 == (Object)null) { val2 = se.m_icon; } if (!((Object)(object)val2 == (Object)null)) { iconCached = val2; iconIsCustom = false; se.m_icon = val2; } } catch { } } } internal sealed class SE_Pix_SleepDeprived : StatusEffect { private static Sprite _iconCached; private static bool _iconIsCustom; private static DateTime _customIconWriteUtc; public override string GetTooltipString() { try { if ((Object)(object)ParanoiaEngine.Instance != (Object)null) { return ParanoiaEngine.Instance.GetStatusString(); } } catch { } return "Sleeplessness is fueling paranoia."; } internal static void EnsureIcon(SE_Pix_SleepDeprived se, ObjectDB odb) { PngIconLoader.EnsureIcon("ParanoiaSE.png", "rested", (StatusEffect)(object)se, odb, ref _iconCached, ref _iconIsCustom, ref _customIconWriteUtc); } } internal static class SePersistence { private const string SaveKey = "PIX_SE_Data"; private static readonly FieldInfo FI_mTime = typeof(StatusEffect).GetField("m_time", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly HashSet TrackedHashes = new HashSet { StringExtensionMethods.GetStableHashCode("SE_Pix_Nausea"), StringExtensionMethods.GetStableHashCode("SE_Pix_InfectedMinor"), StringExtensionMethods.GetStableHashCode("SE_Pix_InfectedMedium"), StringExtensionMethods.GetStableHashCode("SE_Pix_InfectedTerminal"), StringExtensionMethods.GetStableHashCode("SE_Pix_AntidoteWorking"), StringExtensionMethods.GetStableHashCode("SE_Pix_Hallucinate"), StringExtensionMethods.GetStableHashCode("SE_Pix_Cured") }; internal static void OnPlayerSave(Player p) { try { if ((Object)(object)p == (Object)null) { return; } SEMan sEMan = ((Character)p).GetSEMan(); List list = ((sEMan != null) ? sEMan.GetStatusEffects() : null); if (list == null) { SetData(p, ""); return; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { StatusEffect val = list[i]; if ((Object)(object)val == (Object)null) { continue; } int num = val.NameHash(); if (TrackedHashes.Contains(num)) { float value = 0f; if (FI_mTime != null) { value = (float)FI_mTime.GetValue(val); } if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(num).Append(':').Append(val.m_ttl) .Append(':') .Append(value); } } SetData(p, stringBuilder.ToString()); } catch { } } internal static void OnPlayerLoad(Player p) { try { if ((Object)(object)p == (Object)null) { return; } string data = GetData(p); if (string.IsNullOrEmpty(data)) { return; } SetData(p, ""); SEMan sEMan = ((Character)p).GetSEMan(); if (sEMan == null) { return; } string[] array = data.Split(new char[1] { ';' }); for (int i = 0; i < array.Length; i++) { try { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length < 3 || !int.TryParse(array2[0], out var result) || !float.TryParse(array2[1], out var result2) || !float.TryParse(array2[2], out var result3) || !TrackedHashes.Contains(result) || result2 <= 0f || result3 >= result2 || sEMan.HaveStatusEffect(result)) { continue; } ObjectDB instance = ObjectDB.instance; StatusEffect val = ((instance != null) ? instance.GetStatusEffect(result) : null); if (!((Object)(object)val == (Object)null)) { StatusEffect val2 = val.Clone(); val2.m_ttl = result2; if (FI_mTime != null) { FI_mTime.SetValue(val2, result3); } sEMan.AddStatusEffect(val2, false, 0, 0f); } } catch { } } } catch { } } private static void SetData(Player p, string value) { if (p.m_customData.ContainsKey("PIX_SE_Data")) { p.m_customData["PIX_SE_Data"] = value; } else { p.m_customData.Add("PIX_SE_Data", value); } } private static string GetData(Player p) { if (p.m_customData.ContainsKey("PIX_SE_Data")) { return p.m_customData["PIX_SE_Data"]; } return null; } } internal static class ParanoiaConsole { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__1_0; public static ConsoleEvent <>9__1_1; public static ConsoleEvent <>9__1_2; public static ConsoleEvent <>9__1_3; public static ConsoleEvent <>9__1_4; public static ConsoleEvent <>9__1_5; public static ConsoleEvent <>9__1_6; internal void b__1_0(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { Print("pn_status: engine not ready"); } else { Print(instance.GetStatusString()); } } catch (Exception ex) { Print("pn_status failed: " + ex.Message); } } internal void b__1_1(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { Print("pn_forcesleep: engine not ready"); return; } int result = 0; if (args != null && args.Args != null && args.Args.Length >= 2) { int.TryParse(args.Args[1], out result); } instance.ForceAwakeDays(result); Print("pn_forcesleep: set awake days to " + result); Print(instance.GetStatusString()); } catch (Exception ex) { Print("pn_forcesleep failed: " + ex.Message); } } internal void b__1_2(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { Print("pn_paranoidin: engine not ready"); return; } string text = ((args != null && args.Args != null && args.Args.Length >= 2) ? args.Args[1] : "status"); bool flag = false; bool flag2 = false; bool flag3 = false; if (args != null && args.Args != null) { for (int i = 2; i < args.Args.Length; i++) { string text2 = args.Args[i]; if (!string.IsNullOrWhiteSpace(text2)) { if (text2.Equals("force", StringComparison.OrdinalIgnoreCase)) { flag = true; } else if (text2.Equals("soft", StringComparison.OrdinalIgnoreCase)) { flag2 = true; } else if (text2.Equals("nocd", StringComparison.OrdinalIgnoreCase)) { flag3 = true; } } } } bool flag4 = true; if (flag2) { flag4 = false; } if (flag) { flag4 = true; } if (text.Equals("stop", StringComparison.OrdinalIgnoreCase)) { instance.DebugStopParanoidin(); Print("pn_paranoidin: stopped"); } else if (text.Equals("start", StringComparison.OrdinalIgnoreCase)) { Print(instance.DebugStartParanoidin(flag4, flag3) ? ("pn_paranoidin: started" + (flag4 ? " (FORCE)" : " (soft)") + (flag3 ? " (NOCD)" : "")) : "pn_paranoidin: did not start (already active / not ready / gated)"); } else { Print("pn_paranoidin: " + (instance.DebugIsParanoidinActive() ? "ACTIVE" : "inactive")); } } catch (Exception ex) { Print("pn_paranoidin failed: " + ex.Message); } } internal void b__1_3(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { Print("pn_flush: engine not ready"); return; } instance.FlushParanoidinCache(); Print("pn_flush: Paranoidin state cleared"); } catch (Exception ex) { Print("pn_flush failed: " + ex.Message); } } internal void b__1_4(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { Print("pn_softreboot: engine not ready"); return; } instance.SoftReboot_PreserveSleepState("console"); Print("pn_softreboot: soft reboot complete (sleep deprivation preserved)"); } catch (Exception ex) { Print("pn_softreboot failed: " + ex.Message); } } internal void b__1_5(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { if (args != null) { Terminal context = args.Context; if (context != null) { context.AddString("[Pix.Paranoia] pn_fire: engine not ready"); } } return; } bool ignoreCooldowns = false; bool flag = false; bool flag2 = false; string text = ""; if (args?.Args != null) { for (int i = 1; i < args.Args.Length; i++) { string text2 = args.Args[i]; if (!string.IsNullOrWhiteSpace(text2)) { if (text2.Equals("nocd", StringComparison.OrdinalIgnoreCase)) { ignoreCooldowns = true; } else if (text2.Equals("force", StringComparison.OrdinalIgnoreCase)) { flag = true; } else if (text2.Equals("event", StringComparison.OrdinalIgnoreCase)) { flag2 = true; } else if (string.IsNullOrEmpty(text)) { text = text2.Trim(); } } } } if (text.Equals("event", StringComparison.OrdinalIgnoreCase)) { flag2 = true; text = "random"; } bool flag3 = !string.IsNullOrEmpty(text); bool flag4 = !flag3 || text.Equals("random", StringComparison.OrdinalIgnoreCase); bool flag5 = flag3 && text.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase); string prefabNameOrBlank = text; bool force; if (flag5) { force = flag; } else if (flag4) { force = ((!flag2) ? true : false); prefabNameOrBlank = ""; } else { force = flag; } if (instance.ForceFire(prefabNameOrBlank, ignoreCooldowns, force, out var firedPrefabName, out var reason) == ParanoiaEngine.FireResult.Fired) { if (args != null) { Terminal context2 = args.Context; if (context2 != null) { context2.AddString("[Pix.Paranoia] pn_fire: fired " + firedPrefabName + " (" + reason + ")"); } } } else if (args != null) { Terminal context3 = args.Context; if (context3 != null) { context3.AddString("[Pix.Paranoia] pn_fire: did not fire " + firedPrefabName + " (" + reason + ")"); } } } catch (Exception ex) { if (args != null) { Terminal context4 = args.Context; if (context4 != null) { context4.AddString("[Pix.Paranoia] pn_fire failed: " + ex.Message); } } } } internal void b__1_6(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { Print("pn_listsfx: engine not ready"); return; } string filter = ((args != null && args.Args != null && args.Args.Length >= 2) ? args.Args[1] : ""); instance.ListSfxPrefabs(filter); } catch (Exception ex) { Print("pn_listsfx failed: " + ex.Message); } } } private static bool _registered; internal static void TryRegister() { //IL_0048: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_0128: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0160: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown if (_registered) { return; } _registered = true; try { object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate { try { ParanoiaEngine instance7 = ParanoiaEngine.Instance; if ((Object)(object)instance7 == (Object)null) { Print("pn_status: engine not ready"); } else { Print(instance7.GetStatusString()); } } catch (Exception ex8) { Print("pn_status failed: " + ex8.Message); } }; <>c.<>9__1_0 = val; obj = (object)val; } new ConsoleCommand("pn_status", "Print Pix.Paranoia status", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__1_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { try { ParanoiaEngine instance6 = ParanoiaEngine.Instance; if ((Object)(object)instance6 == (Object)null) { Print("pn_forcesleep: engine not ready"); } else { int result = 0; if (args != null && args.Args != null && args.Args.Length >= 2) { int.TryParse(args.Args[1], out result); } instance6.ForceAwakeDays(result); Print("pn_forcesleep: set awake days to " + result); Print(instance6.GetStatusString()); } } catch (Exception ex7) { Print("pn_forcesleep failed: " + ex7.Message); } }; <>c.<>9__1_1 = val2; obj2 = (object)val2; } new ConsoleCommand("pn_forcesleep", "Set awake days (testing). Usage: pn_forcesleep ", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__1_2; if (obj3 == null) { ConsoleEvent val3 = delegate(ConsoleEventArgs args) { try { ParanoiaEngine instance5 = ParanoiaEngine.Instance; if ((Object)(object)instance5 == (Object)null) { Print("pn_paranoidin: engine not ready"); } else { string text3 = ((args != null && args.Args != null && args.Args.Length >= 2) ? args.Args[1] : "status"); bool flag6 = false; bool flag7 = false; bool flag8 = false; if (args != null && args.Args != null) { for (int j = 2; j < args.Args.Length; j++) { string text4 = args.Args[j]; if (!string.IsNullOrWhiteSpace(text4)) { if (text4.Equals("force", StringComparison.OrdinalIgnoreCase)) { flag6 = true; } else if (text4.Equals("soft", StringComparison.OrdinalIgnoreCase)) { flag7 = true; } else if (text4.Equals("nocd", StringComparison.OrdinalIgnoreCase)) { flag8 = true; } } } } bool flag9 = true; if (flag7) { flag9 = false; } if (flag6) { flag9 = true; } if (text3.Equals("stop", StringComparison.OrdinalIgnoreCase)) { instance5.DebugStopParanoidin(); Print("pn_paranoidin: stopped"); } else if (text3.Equals("start", StringComparison.OrdinalIgnoreCase)) { Print(instance5.DebugStartParanoidin(flag9, flag8) ? ("pn_paranoidin: started" + (flag9 ? " (FORCE)" : " (soft)") + (flag8 ? " (NOCD)" : "")) : "pn_paranoidin: did not start (already active / not ready / gated)"); } else { Print("pn_paranoidin: " + (instance5.DebugIsParanoidinActive() ? "ACTIVE" : "inactive")); } } } catch (Exception ex6) { Print("pn_paranoidin failed: " + ex6.Message); } }; <>c.<>9__1_2 = val3; obj3 = (object)val3; } new ConsoleCommand("pn_paranoidin", "Paranoidin control. Usage: pn_paranoidin [start|stop|status] [force] [soft] [nocd]\n start = FORCE by default (for testing). Add \"soft\" to respect normal gating.", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj4 = <>c.<>9__1_3; if (obj4 == null) { ConsoleEvent val4 = delegate { try { ParanoiaEngine instance4 = ParanoiaEngine.Instance; if ((Object)(object)instance4 == (Object)null) { Print("pn_flush: engine not ready"); } else { instance4.FlushParanoidinCache(); Print("pn_flush: Paranoidin state cleared"); } } catch (Exception ex5) { Print("pn_flush failed: " + ex5.Message); } }; <>c.<>9__1_3 = val4; obj4 = (object)val4; } new ConsoleCommand("pn_flush", "Force-clear Paranoidin state/coroutines/objects. Usage: pn_flush", (ConsoleEvent)obj4, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj5 = <>c.<>9__1_4; if (obj5 == null) { ConsoleEvent val5 = delegate { try { ParanoiaEngine instance3 = ParanoiaEngine.Instance; if ((Object)(object)instance3 == (Object)null) { Print("pn_softreboot: engine not ready"); } else { instance3.SoftReboot_PreserveSleepState("console"); Print("pn_softreboot: soft reboot complete (sleep deprivation preserved)"); } } catch (Exception ex4) { Print("pn_softreboot failed: " + ex4.Message); } }; <>c.<>9__1_4 = val5; obj5 = (object)val5; } new ConsoleCommand("pn_softreboot", "Soft-reboot Paranoia runtime while preserving sleep deprivation state. Usage: pn_softreboot", (ConsoleEvent)obj5, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj6 = <>c.<>9__1_5; if (obj6 == null) { ConsoleEvent val6 = delegate(ConsoleEventArgs args) { try { ParanoiaEngine instance2 = ParanoiaEngine.Instance; if ((Object)(object)instance2 == (Object)null) { if (args != null) { Terminal context = args.Context; if (context != null) { context.AddString("[Pix.Paranoia] pn_fire: engine not ready"); } } } else { bool ignoreCooldowns = false; bool flag = false; bool flag2 = false; string text = ""; if (args?.Args != null) { for (int i = 1; i < args.Args.Length; i++) { string text2 = args.Args[i]; if (!string.IsNullOrWhiteSpace(text2)) { if (text2.Equals("nocd", StringComparison.OrdinalIgnoreCase)) { ignoreCooldowns = true; } else if (text2.Equals("force", StringComparison.OrdinalIgnoreCase)) { flag = true; } else if (text2.Equals("event", StringComparison.OrdinalIgnoreCase)) { flag2 = true; } else if (string.IsNullOrEmpty(text)) { text = text2.Trim(); } } } } if (text.Equals("event", StringComparison.OrdinalIgnoreCase)) { flag2 = true; text = "random"; } bool flag3 = !string.IsNullOrEmpty(text); bool flag4 = !flag3 || text.Equals("random", StringComparison.OrdinalIgnoreCase); bool flag5 = flag3 && text.StartsWith("sfx_", StringComparison.OrdinalIgnoreCase); string prefabNameOrBlank = text; bool force; if (flag5) { force = flag; } else if (flag4) { force = ((!flag2) ? true : false); prefabNameOrBlank = ""; } else { force = flag; } if (instance2.ForceFire(prefabNameOrBlank, ignoreCooldowns, force, out var firedPrefabName, out var reason) == ParanoiaEngine.FireResult.Fired) { if (args != null) { Terminal context2 = args.Context; if (context2 != null) { context2.AddString("[Pix.Paranoia] pn_fire: fired " + firedPrefabName + " (" + reason + ")"); } } } else if (args != null) { Terminal context3 = args.Context; if (context3 != null) { context3.AddString("[Pix.Paranoia] pn_fire: did not fire " + firedPrefabName + " (" + reason + ")"); } } } } catch (Exception ex3) { if (args != null) { Terminal context4 = args.Context; if (context4 != null) { context4.AddString("[Pix.Paranoia] pn_fire failed: " + ex3.Message); } } } }; <>c.<>9__1_5 = val6; obj6 = (object)val6; } new ConsoleCommand("pn_fire", "pn_fire [sfx_prefab|random] [nocd] [force] [event|sfx]\n random (default) = SFX-random (loaded sfx_*)\n event = Event-random (eligibility system)\n nocd = bypass cooldown + repeat-block\n force = bypass safety gate\nExamples:\n pn_fire random nocd\n pn_fire random event nocd\n pn_fire sfx_trollfire_roar nocd\n pn_fire sfx_trollfire_roar force", (ConsoleEvent)obj6, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj7 = <>c.<>9__1_6; if (obj7 == null) { ConsoleEvent val7 = delegate(ConsoleEventArgs args) { try { ParanoiaEngine instance = ParanoiaEngine.Instance; if ((Object)(object)instance == (Object)null) { Print("pn_listsfx: engine not ready"); } else { string filter = ((args != null && args.Args != null && args.Args.Length >= 2) ? args.Args[1] : ""); instance.ListSfxPrefabs(filter); } } catch (Exception ex2) { Print("pn_listsfx failed: " + ex2.Message); } }; <>c.<>9__1_6 = val7; obj7 = (object)val7; } new ConsoleCommand("pn_listsfx", "List available sfx prefabs. Usage: pn_listsfx [filter]", (ConsoleEvent)obj7, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } catch (Exception ex) { Debug.Log((object)("[Pix.Paranoia] Console register failed: " + ex.Message)); } } internal static void Print(string msg) { try { Debug.Log((object)("[Pix.Paranoia] " + msg)); } catch { } try { if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, msg, 0, (Sprite)null, false); } } catch { } } } [HarmonyPatch] internal static class ParanoiaPatches { [HarmonyPatch(typeof(Player), "ConsumeItem")] [HarmonyPostfix] private static void Player_ConsumeItem_Postfix(Player __instance) { try { if (ParanoiaPlugin.Enabled.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { ParanoiaEngine.Instance?.OnPlayerAte(__instance); } } catch { } } [HarmonyPatch(typeof(Player), "OnDeath")] [HarmonyPostfix] private static void Player_OnDeath_Postfix(Player __instance) { try { if (ParanoiaPlugin.Enabled.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { ParanoiaEngine.Instance?.OnLocalPlayerDied(); HallucinationManager.Instance?.CleanupAllFakeCreatures(); } } catch { } } [HarmonyPatch(typeof(Player), "Save")] [HarmonyPrefix] private static void Player_Save_Prefix(Player __instance) { try { if (!((Object)(object)__instance == (Object)null)) { SePersistence.OnPlayerSave(__instance); } } catch { } } [HarmonyPatch(typeof(Player), "Load")] [HarmonyPostfix] private static void Player_Load_Postfix(Player __instance) { try { if (!((Object)(object)__instance == (Object)null)) { SePersistence.OnPlayerLoad(__instance); } } catch { } } [HarmonyPatch(typeof(Game), "Logout")] [HarmonyPrefix] private static void Game_Logout_Prefix() { try { if (ParanoiaPlugin.Enabled.Value) { HallucinationManager.Instance?.CleanupAllFakeCreatures(); ParanoiaGreydwarfs.Cleanup(); } } catch { } } [HarmonyPatch(typeof(Player), "TeleportTo")] [HarmonyPrefix] private static void Player_TeleportTo_Prefix(Player __instance) { try { if (ParanoiaPlugin.Enabled.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { HallucinationManager.Instance?.CleanupAllFakeCreatures(); } } catch { } } [HarmonyPatch(typeof(Game), "SpawnPlayer")] [HarmonyPostfix] private static void Game_SpawnPlayer_Postfix() { try { if (ParanoiaPlugin.Enabled.Value) { ParanoiaEngine.Instance?.OnLocalPlayerSpawned(); } } catch { } } [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPostfix] private static void ObjectDB_Awake_Postfix(ObjectDB __instance) { try { if (!((Object)(object)__instance == (Object)null)) { EnsureSleepDeprivedStatusEffect(__instance); EnsureHallucinationStatusEffect(__instance); } } catch { } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPostfix] private static void ObjectDB_CopyOtherDB_Postfix(ObjectDB __instance) { try { if (!((Object)(object)__instance == (Object)null)) { EnsureSleepDeprivedStatusEffect(__instance); EnsureHallucinationStatusEffect(__instance); } } catch { } } private static void EnsureSleepDeprivedStatusEffect(ObjectDB odb) { try { if ((Object)(object)odb == (Object)null || odb.m_StatusEffects == null) { return; } for (int i = 0; i < odb.m_StatusEffects.Count; i++) { StatusEffect val = odb.m_StatusEffects[i]; if ((Object)(object)val == (Object)null) { continue; } string text = null; try { text = ((Object)val).name; } catch { text = null; } if (!string.IsNullOrEmpty(text) && text.Equals("SE_Pix_SleepDeprived", StringComparison.Ordinal)) { try { SE_Pix_SleepDeprived.EnsureIcon(val as SE_Pix_SleepDeprived, odb); return; } catch { return; } } } SE_Pix_SleepDeprived sE_Pix_SleepDeprived = ScriptableObject.CreateInstance(); if (!((Object)(object)sE_Pix_SleepDeprived == (Object)null)) { ((Object)sE_Pix_SleepDeprived).name = "SE_Pix_SleepDeprived"; ((StatusEffect)sE_Pix_SleepDeprived).m_name = "Paranoid"; ((StatusEffect)sE_Pix_SleepDeprived).m_tooltip = ""; try { SE_Pix_SleepDeprived.EnsureIcon(sE_Pix_SleepDeprived, odb); } catch { } odb.m_StatusEffects.Add((StatusEffect)(object)sE_Pix_SleepDeprived); } } catch { } } private static void EnsureHallucinationStatusEffect(ObjectDB odb) { try { if ((Object)(object)odb == (Object)null || odb.m_StatusEffects == null) { return; } for (int i = 0; i < odb.m_StatusEffects.Count; i++) { StatusEffect val = odb.m_StatusEffects[i]; if ((Object)(object)val == (Object)null) { continue; } string text = null; try { text = ((Object)val).name; } catch { text = null; } if (!string.IsNullOrEmpty(text) && text.Equals("SE_Pix_Hallucinate", StringComparison.Ordinal)) { try { SE_Pix_Hallucinate.EnsureIcon(val as SE_Pix_Hallucinate, odb); return; } catch { return; } } } SE_Pix_Hallucinate sE_Pix_Hallucinate = ScriptableObject.CreateInstance(); if (!((Object)(object)sE_Pix_Hallucinate == (Object)null)) { ((Object)sE_Pix_Hallucinate).name = "SE_Pix_Hallucinate"; ((StatusEffect)sE_Pix_Hallucinate).m_name = "Hallucinating"; ((StatusEffect)sE_Pix_Hallucinate).m_tooltip = ""; ((StatusEffect)sE_Pix_Hallucinate).m_ttl = ParanoiaPlugin.CfgHallucinationDurationSeconds.Value; try { SE_Pix_Hallucinate.EnsureIcon(sE_Pix_Hallucinate, odb); } catch { } odb.m_StatusEffects.Add((StatusEffect)(object)sE_Pix_Hallucinate); } } catch { } } [HarmonyPatch(typeof(Character), "Damage")] [HarmonyPrefix] private static bool Character_Damage_Prefix(Character __instance, HitData hit) { try { if ((Object)(object)__instance == (Object)null || hit == null) { return true; } if (!(__instance is Player)) { return true; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null) { return true; } GameObject gameObject = ((Component)attacker).gameObject; if ((Object)(object)gameObject == (Object)null) { return true; } if (((Object)gameObject).name.Contains("_hallucination") || (Object)(object)gameObject.GetComponent() != (Object)null) { return false; } } catch { } return true; } } } namespace Pix.Paranoia.Relics { internal static class ParanoiaRelics { private enum RelicTier { None, Meadows, BlackForest, Swamp, Mountains, Plains, Mistlands, Ashlands } private sealed class RelicDef { public RelicTier Tier; public string PrefabName; public string LocNameKey; public string LocDescKey; public string DisplayName; public string DisplayDesc; public string SeName; public string TrophyPrefab; } [HarmonyPatch] private static class Patch_CharacterDrop_DropItems { [CompilerGenerated] private sealed class d__2 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private int 5__1; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (_targets == null) { Prepare(); } if (_targets == null || _targets.Length == 0) { return false; } 5__1 = 0; break; case 1: <>1__state = -1; 5__1++; break; } if (5__1 < _targets.Length) { <>2__current = _targets[5__1]; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__2(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static MethodBase[] _targets; private static bool Prepare() { try { if (_targets != null) { return _targets.Length != 0; } MethodInfo[] methods = typeof(CharacterDrop).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (methods == null) { _targets = Array.Empty(); return false; } List list = new List(8); foreach (MethodInfo methodInfo in methods) { if (methodInfo == null || methodInfo.IsGenericMethod || methodInfo.ReturnType != typeof(void)) { continue; } string name = methodInfo.Name; switch (name) { default: if (!(name == "OnKilled")) { continue; } break; case "DropItems": case "DropLoot": case "DropAllItems": case "OnDeath": break; } list.Add(methodInfo); } _targets = list.ToArray(); return _targets.Length != 0; } catch { _targets = Array.Empty(); return false; } } [IteratorStateMachine(typeof(d__2))] [HarmonyTargetMethods] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(-2); } private static void Postfix(CharacterDrop __instance) { try { if (!((Object)(object)__instance == (Object)null)) { TryDropRelicForBoss(((Component)__instance).gameObject); } } catch (Exception arg) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)$"[Relics] CharacterDrop postfix exception: {arg}"); } } } } [HarmonyPatch] private static class Patch_ItemData_NameHelpers { [CompilerGenerated] private sealed class d__2 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private int 5__1; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (_targets == null) { Prepare(); } if (_targets == null || _targets.Length == 0) { return false; } 5__1 = 0; break; case 1: <>1__state = -1; 5__1++; break; } if (5__1 < _targets.Length) { <>2__current = _targets[5__1]; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__2(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static MethodBase[] _targets; private static bool Prepare() { try { if (_targets != null) { return _targets.Length != 0; } MethodInfo[] methods = typeof(ItemData).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (methods == null) { _targets = Array.Empty(); return false; } List list = new List(8); foreach (MethodInfo methodInfo in methods) { if (methodInfo == null || methodInfo.IsGenericMethod || methodInfo.ReturnType != typeof(string)) { continue; } string name = methodInfo.Name; if (!(name != "GetDecoratedName") || !(name != "GetHoverName") || !(name != "GetName")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters == null || parameters.Length == 0) { list.Add(methodInfo); } } } _targets = list.ToArray(); return _targets.Length != 0; } catch { _targets = Array.Empty(); return false; } } [IteratorStateMachine(typeof(d__2))] [HarmonyTargetMethods] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(-2); } private static void Postfix(ItemData __instance, ref string __result) { try { if (__instance != null && IsCursedRelic(__instance, out var tier) && _defByTier.TryGetValue(tier, out var value) && value != null) { __result = value.DisplayName; } } catch { } } } [HarmonyPatch] private static class Patch_ItemData_GetTooltip { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private List.Enumerator <>s__1; private MethodInfo 5__2; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = default(List.Enumerator); 5__2 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__1 = AccessTools.GetDeclaredMethods(typeof(ItemData)).GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; 5__2 = null; break; } while (<>s__1.MoveNext()) { 5__2 = <>s__1.Current; if (5__2 == null || 5__2.Name != "GetTooltip" || 5__2.ReturnType != typeof(string)) { continue; } <>2__current = 5__2; <>1__state = 1; return true; } <>m__Finally1(); <>s__1 = default(List.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__0(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyTargetMethods] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2); } private static void Postfix(ItemData __instance, ref string __result) { try { if (__instance != null && IsCursedRelic(__instance, out var tier)) { string text = "" + BuildTooltipForTier(tier) + ""; string text2 = __result ?? ""; int num = text2.IndexOf('\n'); if (num < 0) { __result = text + "\n" + text2; return; } string text3 = text2.Substring(0, num); string text4 = text2.Substring(num + 1); __result = text3 + "\n" + text + "\n" + text4; } } catch { } } } [HarmonyPatch(typeof(Player), "GetMaxCarryWeight")] private static class Patch_Player_GetMaxCarryWeight { [HarmonyPostfix] private static void Postfix(Player __instance, ref float __result) { if ((Object)(object)__instance == (Object)null) { return; } RelicTier cachedRelicTier = GetCachedRelicTier(__instance); if (cachedRelicTier != 0) { float carryWeightBonusForTier = GetCarryWeightBonusForTier(cachedRelicTier); if (carryWeightBonusForTier > 0f) { __result += carryWeightBonusForTier; } } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] private static class Patch_ObjectDB_Awake { private static void Prefix(ObjectDB __instance) { try { InjectRelicsIntoObjectDBLists(__instance, "ObjectDB.Awake:Prefix"); } catch (Exception arg) { Debug.LogError((object)$"[Paranoia][Relics] ObjectDB.Awake Prefix exception: {arg}"); } } private static void Postfix(ObjectDB __instance) { try { FinalizeRelics_ObjectDBCaches(__instance, "ObjectDB.Awake:Postfix"); } catch (Exception arg) { Debug.LogError((object)$"[Paranoia][Relics] ObjectDB.Awake Postfix exception: {arg}"); } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] private static class Patch_ObjectDB_CopyOtherDB { private static void Postfix(ObjectDB __instance) { try { RegisterRelicsIntoObjectDB(__instance, "ObjectDB.CopyOtherDB:Postfix"); } catch (Exception arg) { Debug.LogError((object)$"[Paranoia][Relics] ObjectDB.CopyOtherDB Postfix exception: {arg}"); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class Patch_ZNetScene_Awake { private static void Postfix(ZNetScene __instance) { try { if ((Object)(object)__instance == (Object)null || !TryLoadRelicBundle()) { return; } for (int i = 0; i < _defs.Count; i++) { RelicDef relicDef = _defs[i]; if (relicDef != null && !string.IsNullOrEmpty(relicDef.PrefabName)) { GameObject val = FindRelicPrefabByName(relicDef.PrefabName); if (!((Object)(object)val == (Object)null)) { PrepareWorldItemPrefab(val, relicDef); TryAddToZNetScene(__instance, val); } } } } catch { } } } [HarmonyPatch(typeof(ItemDrop), "Awake")] private static class Patch_ItemDrop_Awake { private static void Postfix(ItemDrop __instance) { try { if ((Object)(object)__instance == (Object)null) { return; } string prefabName = (((Object)(object)((Component)__instance).gameObject != (Object)null) ? ((Object)((Component)__instance).gameObject).name : null); if (IsRelicPrefabName(prefabName)) { RelicTier tierFromPrefabName = GetTierFromPrefabName(prefabName); if (tierFromPrefabName != 0 && __instance.m_itemData != null) { StampRelicItemData(__instance.m_itemData, tierFromPrefabName); NormalizeRelicItem(__instance.m_itemData, tierFromPrefabName); } } } catch { } } } private static ManualLogSource _log; private const string RelicBundleResourceHint = "px_relics"; private static readonly Dictionary _cachedPlayerRelicTier = new Dictionary(); private static readonly Dictionary _cachedInventoryVersion = new Dictionary(); private const string CdCursed = "PX_Cursed"; private const string CdTier = "PX_CursedRelicTier"; private const string CdUid = "PX_CursedRelicUid"; private static readonly int ZdoKey_RelicTier = StringExtensionMethods.GetStableHashCode("pix_relic_tier"); private static readonly HashSet RelicPrefabNames = new HashSet(StringComparer.OrdinalIgnoreCase) { "Meadows_Relic", "BlackForest_Relic", "Swamp_Relic", "Mountains_Relic", "Mountain_Relic", "Plains_Relic", "Mistlands_Relic", "Ashlands_Relic" }; private const string DebuffLine_All = "Paranoia rate 2x"; private static ConfigEntry CfgEnabled; private static ConfigEntry CfgBossDropChance; private static ConfigEntry CfgMeadows_CarryWeightAdd; private static ConfigEntry CfgBlackForest_CarryWeightAdd; private static ConfigEntry CfgSwamp_CarryWeightAdd; private static ConfigEntry CfgMountains_CarryWeightAdd; private static ConfigEntry CfgPlains_CarryWeightAdd; private static ConfigEntry CfgMistlands_CarryWeightAdd; private static ConfigEntry CfgAshlands_CarryWeightAdd; private static ConfigEntry CfgParanoiaRateMultiplier; private static ConfigEntry CfgHauntEnabled; private static ConfigEntry CfgHauntCheckIntervalSeconds; private static ConfigEntry CfgHauntRollChance; private static ConfigEntry CfgHauntCooldownMinSeconds; private static ConfigEntry CfgHauntCooldownMaxSeconds; private static ConfigEntry CfgTickSeconds; private static readonly List _defs = new List(8); private static readonly Dictionary _defByTier = new Dictionary(); private static readonly Dictionary _tierByBossPrefab = new Dictionary(StringComparer.OrdinalIgnoreCase); private static AssetBundle _relicBundle; private static bool _warnedNoOdbRefresh; private static float _nextTickAt; private static long _lastLocalPlayerKey; private static readonly Dictionary _activeTierByPlayer = new Dictionary(); private static readonly Dictionary _lastAppliedTierByPlayer = new Dictionary(); private static readonly Dictionary _nextHauntRollAtByPlayer = new Dictionary(); private static readonly Dictionary _hauntCooldownUntilByPlayer = new Dictionary(); private static bool _refReady; private static MethodInfo _miEnvManIsNightStatic; private static MethodInfo _miEnvManIsNightInstance; private static MethodInfo _miObjectMemberwiseClone; private static FieldInfo _fiZNetScenePrefabs; private static FieldInfo _fiZNetSceneNamedPrefabs; private static FieldInfo _fiObjectDbItems; private static MethodInfo _miObjectDbUpdateItemHashes; private static MethodInfo _miObjectDbUpdateItemList; private static MethodInfo _miObjectDbUpdateRecipeHashes; private static MethodInfo _miLocalizationAddWord; private static bool _locDone; private static readonly HashSet _recentDropKeys = new HashSet(); private static float _nextDropKeyCleanup; private static float HauntCheckIntervalSeconds => Mathf.Max(5f, (CfgHauntCheckIntervalSeconds != null) ? CfgHauntCheckIntervalSeconds.Value : 30f); private static float HauntRollChance => Mathf.Clamp01((CfgHauntRollChance != null) ? CfgHauntRollChance.Value : 0.15f); private static bool IsRelicPrefabName(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return false; } return RelicPrefabNames.Contains(prefabName); } private static bool IsRelicItemData(ItemData item) { if (item == null) { return false; } try { if (item.m_customData != null && item.m_customData.TryGetValue("PX_Cursed", out var value) && value == "1") { return true; } } catch { } try { if ((Object)(object)item.m_dropPrefab != (Object)null && IsRelicPrefabName(((Object)item.m_dropPrefab).name)) { return true; } } catch { } string text = null; try { text = ((item.m_shared != null) ? item.m_shared.m_name : null); } catch { text = null; } if (!string.IsNullOrEmpty(text)) { if (text[0] == '$') { text = text.Substring(1); } if (text.StartsWith("item_relic_", StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static void StampRelicItemData(ItemData item, RelicTier tier) { if (item == null || tier == RelicTier.None) { return; } try { if (item.m_customData == null) { item.m_customData = new Dictionary(); } item.m_customData["PX_Cursed"] = "1"; Dictionary customData = item.m_customData; int num = (int)tier; customData["PX_CursedRelicTier"] = num.ToString(); } catch { } RelicDef def = GetDef(tier); if (def != null) { try { if (item.m_shared != null) { item.m_shared.m_name = "$" + def.LocNameKey; item.m_shared.m_description = "$" + def.LocDescKey; } } catch { } } try { if ((Object)(object)item.m_dropPrefab == (Object)null && def != null && !string.IsNullOrEmpty(def.PrefabName)) { GameObject val = FindRelicPrefabByName(def.PrefabName); if ((Object)(object)val != (Object)null) { item.m_dropPrefab = val; } } } catch { } } private static RelicDef GetDef(RelicTier tier) { if (tier == RelicTier.None) { return null; } if (_defByTier.TryGetValue(tier, out var value)) { return value; } for (int i = 0; i < _defs.Count; i++) { if (_defs[i].Tier == tier) { return _defs[i]; } } return null; } private static RelicTier GetTierFromPrefabName(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return RelicTier.None; } if (prefabName.EndsWith("(Clone)", StringComparison.Ordinal)) { prefabName = prefabName.Replace("(Clone)", "").Trim(); } if (string.Equals(prefabName, "Mountain_Relic", StringComparison.OrdinalIgnoreCase)) { prefabName = "Mountain_Relic"; } else if (string.Equals(prefabName, "Mountains_Relic", StringComparison.OrdinalIgnoreCase)) { prefabName = "Mountain_Relic"; } for (int i = 0; i < _defs.Count; i++) { RelicDef relicDef = _defs[i]; if (relicDef != null && !string.IsNullOrEmpty(relicDef.PrefabName) && string.Equals(relicDef.PrefabName, prefabName, StringComparison.OrdinalIgnoreCase)) { return relicDef.Tier; } } return RelicTier.None; } private static RelicTier GetCachedRelicTier(Player player) { if ((Object)(object)player == (Object)null) { return RelicTier.None; } int instanceID = ((Object)player).GetInstanceID(); Inventory val = null; try { val = ((Humanoid)player).GetInventory(); } catch { return RelicTier.None; } if (val == null) { return RelicTier.None; } List list = null; try { list = val.GetAllItems(); } catch { return RelicTier.None; } if (list == null) { _cachedPlayerRelicTier[instanceID] = RelicTier.None; _cachedInventoryVersion[instanceID] = 0; return RelicTier.None; } int count = list.Count; if (_cachedInventoryVersion.TryGetValue(instanceID, out var value) && value == count && _cachedPlayerRelicTier.TryGetValue(instanceID, out var value2)) { return value2; } if (list.Count == 0) { _cachedPlayerRelicTier[instanceID] = RelicTier.None; _cachedInventoryVersion[instanceID] = count; return RelicTier.None; } RelicTier relicTier = RelicTier.None; for (int i = 0; i < list.Count; i++) { RelicTier tierFromItem = GetTierFromItem(list[i]); if (tierFromItem > relicTier) { relicTier = tierFromItem; } } _cachedPlayerRelicTier[instanceID] = relicTier; _cachedInventoryVersion[instanceID] = count; return relicTier; } internal static void Init(ConfigFile config, ManualLogSource log) { _log = log; BindConfig(config); BuildDefs(); BuildBossTierMap(); EnsureReflectionCache(); } internal static void ApplyPatches(Harmony harmony) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if (harmony == null) { return; } try { harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterDrop), "GenerateDropList", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ParanoiaRelics), "CharacterDrop_GenerateDropList_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception arg) { Debug.LogError((object)$"[Paranoia][Relics] Failed to patch CharacterDrop.GenerateDropList: {arg}"); } } private static void CharacterDrop_GenerateDropList_Postfix(CharacterDrop __instance, ref List> __result) { try { if ((Object)(object)__instance == (Object)null || __result == null || (CfgEnabled != null && !CfgEnabled.Value)) { return; } Character component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsBoss()) { return; } string cleanPrefabName = GetCleanPrefabName(((Component)component).gameObject); if (string.IsNullOrEmpty(cleanPrefabName) || !_tierByBossPrefab.TryGetValue(cleanPrefabName, out var value) || value == RelicTier.None) { return; } float num = Mathf.Clamp01((CfgBossDropChance != null) ? CfgBossDropChance.Value : 0.2f); if (num <= 0f) { return; } float value2 = Random.value; if (value2 > num) { Debug.Log((object)$"[Paranoia][Relics] Boss '{cleanPrefabName}' roll {value2:F3} > {num:F3}, no relic drop"); return; } if (!_defByTier.TryGetValue(value, out var value3) || value3 == null) { Debug.LogError((object)$"[Paranoia][Relics] No def for tier={value}"); return; } GameObject val = FindRelicPrefabByName(value3.PrefabName); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("[Paranoia][Relics] Prefab '" + value3.PrefabName + "' not found in ZNetScene")); return; } Debug.Log((object)$"[Paranoia][Relics] Boss '{cleanPrefabName}' roll {value2:F3} <= {num:F3}, adding {value3.PrefabName} to drop list"); __result.Add(new KeyValuePair(val, 1)); } catch (Exception arg) { Debug.LogError((object)$"[Paranoia][Relics] CharacterDrop_GenerateDropList_Postfix exception: {arg}"); } } internal static void Tick() { if (CfgEnabled != null && !CfgEnabled.Value) { return; } if (!_locDone) { EnsureRelicLocalization(); } float time = Time.time; if (time < _nextTickAt) { return; } _nextTickAt = time + Mathf.Max(0.1f, (CfgTickSeconds != null) ? CfgTickSeconds.Value : 0.5f); if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return; } try { ClientWriteRelicTierToZdo(); } catch { } if (!ZNet.instance.IsServer() || (CfgHauntEnabled != null && !CfgHauntEnabled.Value) || (Object)(object)ZNetScene.instance == (Object)null) { return; } List list = null; try { list = Player.GetAllPlayers(); } catch { list = null; } if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { Player val = list[i]; if (Object.op_Implicit((Object)(object)val)) { EvaluatePlayerRelic(val); MaybeServerHaunt(val, time); } } return; } try { ServerHauntViaZdos(time); } catch { } } private static void ClientWriteRelicTierToZdo() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } ZNetView component = ((Component)localPlayer).GetComponent(); if (!((Object)(object)component == (Object)null)) { ZDO zDO = component.GetZDO(); if (zDO != null) { EvaluatePlayerRelic(localPlayer); RelicTier activeRelicTier = GetActiveRelicTier(localPlayer); zDO.Set(ZdoKey_RelicTier, (int)activeRelicTier, false); } } } private static void ServerHauntViaZdos(float now) { //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) List list = null; try { list = ZNet.instance.GetAllCharacterZDOS(); } catch { list = null; } if (list == null || list.Count == 0) { return; } for (int i = 0; i < list.Count; i++) { try { ZDO val = list[i]; if (val == null) { continue; } int @int = val.GetInt(ZdoKey_RelicTier, 0); if (@int <= 0 || @int > 7) { continue; } RelicTier relicTier = (RelicTier)@int; long num = ((ZDOID)(ref val.m_uid)).UserID; if (num == 0) { num = ((object)(ZDOID)(ref val.m_uid)).GetHashCode(); } if ((_hauntCooldownUntilByPlayer.TryGetValue(num, out var value) && now < value) || (_nextHauntRollAtByPlayer.TryGetValue(num, out var value2) && now < value2)) { continue; } _nextHauntRollAtByPlayer[num] = now + HauntCheckIntervalSeconds; if (Random.value > HauntRollChance) { continue; } List list2 = new List(2); switch (relicTier) { case RelicTier.Meadows: list2.Add("Greydwarf_Elite"); break; case RelicTier.BlackForest: list2.Add((Random.value < 0.5f) ? "Troll" : "Greydwarf_shaman"); break; case RelicTier.Swamp: list2.Add("Abomination"); break; case RelicTier.Mountains: list2.Add((Random.value < 0.5f) ? "Hatchling" : "StoneGolem"); break; case RelicTier.Plains: list2.Add("GoblinBrute"); break; case RelicTier.Mistlands: list2.Add("SeekerBrute"); break; case RelicTier.Ashlands: list2.Add("Morgen"); break; } if (list2.Count == 0) { continue; } Vector3 val2 = val.GetPosition() + Vector3.forward * 6f + Vector3.up * 0.2f; for (int j = 0; j < list2.Count; j++) { GameObject prefab = ZNetScene.instance.GetPrefab(list2[j]); if (!((Object)(object)prefab == (Object)null)) { InstantiateNetworkedPrefab(prefab, val2 + Random.insideUnitSphere * 1.5f, Quaternion.identity); } } float num2 = Mathf.Max(5f, (CfgHauntCooldownMinSeconds != null) ? CfgHauntCooldownMinSeconds.Value : 480f); float num3 = Mathf.Max(num2, (CfgHauntCooldownMaxSeconds != null) ? CfgHauntCooldownMaxSeconds.Value : 900f); float num4 = Random.Range(num2, num3); _hauntCooldownUntilByPlayer[num] = now + num4; } catch { } } } internal static float GetParanoiaRateMultiplier() { float num = ((CfgParanoiaRateMultiplier != null) ? CfgParanoiaRateMultiplier.Value : 2f); return Mathf.Max(1f, num); } public static float GetParanoiaIntensityMultiplier() { return GetParanoiaRateMultiplier(); } public static float GetSleepDebtMultiplier() { return GetParanoiaRateMultiplier(); } private static bool HasAnyCursedRelic(Player p) { if ((Object)(object)p == (Object)null) { return false; } try { Inventory inventory = ((Humanoid)p).GetInventory(); if (inventory == null) { return false; } List allItems = inventory.GetAllItems(); if (allItems == null) { return false; } for (int i = 0; i < allItems.Count; i++) { ItemData item = allItems[i]; if (IsRelicItemData(item) && GetTierFromItem(item) != 0) { return true; } } } catch { } return false; } private static void BindConfig(ConfigFile config) { CfgEnabled = config.Bind("Relics", "Enabled", true, "Enable cursed relics (custom prefab boss drops)."); CfgTickSeconds = config.Bind("Relics", "TickSeconds", 0.5f, "Relic scan/apply interval (seconds)."); CfgBossDropChance = config.Bind("Relics.Drops", "BossRelicRollChance", 0.2f, "Chance per boss kill to drop its cursed relic (0-1)."); CfgParanoiaRateMultiplier = config.Bind("Relics.Debuff", "ParanoiaRateMultiplier", 2f, "Debuff multiplier while carrying ANY cursed relic. (Shown as 'Paranoia rate 2x')"); CfgMeadows_CarryWeightAdd = config.Bind("Relics.Meadows", "CarryWeightAdd", 25f, "+25 carry weight while carrying Meadows relic."); CfgBlackForest_CarryWeightAdd = config.Bind("Relics.BlackForest", "CarryWeightAdd", 50f, "+50 carry weight while carrying BlackForest relic."); CfgSwamp_CarryWeightAdd = config.Bind("Relics.Swamp", "CarryWeightAdd", 100f, "+100 carry weight while carrying Swamp relic."); CfgMountains_CarryWeightAdd = config.Bind("Relics.Mountains", "CarryWeightAdd", 150f, "+150 carry weight while carrying Mountains relic."); CfgPlains_CarryWeightAdd = config.Bind("Relics.Plains", "CarryWeightAdd", 200f, "+200 carry weight while carrying Plains relic."); CfgMistlands_CarryWeightAdd = config.Bind("Relics.Mistlands", "CarryWeightAdd", 250f, "+250 carry weight while carrying Mistlands relic."); CfgAshlands_CarryWeightAdd = config.Bind("Relics.Ashlands", "CarryWeightAdd", 350f, "+350 carry weight while carrying Ashlands relic."); CfgHauntEnabled = config.Bind("Relics.Haunt", "Enabled", true, "Enable server-side haunt rolls while carrying a cursed relic."); CfgHauntCheckIntervalSeconds = config.Bind("Relics.Haunt", "CheckIntervalSeconds", 30f, "How often to roll for a haunt (seconds)."); CfgHauntRollChance = config.Bind("Relics.Haunt", "RollChance", 0.15f, "Chance each check interval to trigger a haunt (0-1)."); CfgHauntCooldownMinSeconds = config.Bind("Relics.Haunt", "CooldownMinSeconds", 480f, "Minimum cooldown after a successful haunt (seconds)."); CfgHauntCooldownMaxSeconds = config.Bind("Relics.Haunt", "CooldownMaxSeconds", 900f, "Maximum cooldown after a successful haunt (seconds)."); } private static void BuildDefs() { _defs.Clear(); _defByTier.Clear(); AddDef(RelicTier.Meadows, "Meadows_Relic", "item_relic_meadows", "item_relic_meadows_desc", "The Cursed Antler Axe", "A cursed axe forged from Eikthyr's legacy.", "SE_PX_Relic_Meadows", "TrophyEikthyr"); AddDef(RelicTier.BlackForest, "BlackForest_Relic", "item_relic_blackforest", "item_relic_blackforest_desc", "The Cursed Elder Relic", "A relic pulsing with ancient roots.", "SE_PX_Relic_BlackForest", "TrophyTheElder"); AddDef(RelicTier.Swamp, "Swamp_Relic", "item_relic_swamp", "item_relic_swamp_desc", "The Cursed Swamp Relic", "It reeks of death and devotion.", "SE_PX_Relic_Swamp", "TrophyBonemass"); AddDef(RelicTier.Mountains, "Mountain_Relic", "item_relic_mountains", "item_relic_mountains_desc", "The Cursed Mountain Relic", "Cold as the last breath of a dragon.", "SE_PX_Relic_Mountains", "TrophyDragonQueen"); AddDef(RelicTier.Plains, "Plains_Relic", "item_relic_plains", "item_relic_plains_desc", "The Cursed Plains Relic", "Warm to the touch. Wrongly alive.", "SE_PX_Relic_Plains", "TrophyGoblinKing"); AddDef(RelicTier.Mistlands, "Mistlands_Relic", "item_relic_mistlands", "item_relic_mistlands_desc", "The Cursed Mistlands Relic", "It hums beneath the fog of the hive.", "SE_PX_Relic_Mistlands", "TrophySeekerQueen"); AddDef(RelicTier.Ashlands, "Ashlands_Relic", "item_relic_ashlands", "item_relic_ashlands_desc", "The Cursed Ashlands Relic", "Heat-scarred. Hungry.", "SE_PX_Relic_Ashlands", "TrophyFader"); } private static void AddDef(RelicTier tier, string prefabName, string locNameKey, string locDescKey, string displayName, string displayDesc, string seName, string trophyPrefab) { RelicDef relicDef = new RelicDef { Tier = tier, PrefabName = prefabName, LocNameKey = locNameKey, LocDescKey = locDescKey, DisplayName = displayName, DisplayDesc = displayDesc, SeName = seName, TrophyPrefab = trophyPrefab }; _defs.Add(relicDef); _defByTier[tier] = relicDef; } private static void BuildBossTierMap() { _tierByBossPrefab.Clear(); _tierByBossPrefab["Eikthyr"] = RelicTier.Meadows; _tierByBossPrefab["gd_king"] = RelicTier.BlackForest; _tierByBossPrefab["GDKing"] = RelicTier.BlackForest; _tierByBossPrefab["TheElder"] = RelicTier.BlackForest; _tierByBossPrefab["Bonemass"] = RelicTier.Swamp; _tierByBossPrefab["Dragon"] = RelicTier.Mountains; _tierByBossPrefab["Moder"] = RelicTier.Mountains; _tierByBossPrefab["GoblinKing"] = RelicTier.Plains; _tierByBossPrefab["Yagluth"] = RelicTier.Plains; _tierByBossPrefab["SeekerQueen"] = RelicTier.Mistlands; _tierByBossPrefab["Queen"] = RelicTier.Mistlands; _tierByBossPrefab["Fader"] = RelicTier.Ashlands; } private static bool TryLoadRelicBundle() { if ((Object)(object)_relicBundle != (Object)null) { return true; } try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string n) => n.EndsWith(".px_relics", StringComparison.OrdinalIgnoreCase) || n.EndsWith(".px_relics.bytes", StringComparison.OrdinalIgnoreCase) || n.IndexOf("px_relics", StringComparison.OrdinalIgnoreCase) >= 0); if (string.IsNullOrEmpty(text)) { return false; } using (Stream stream = executingAssembly.GetManifestResourceStream(text)) { if (stream == null) { return false; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); _relicBundle = AssetBundle.LoadFromMemory(memoryStream.ToArray()); } if ((Object)(object)_relicBundle == (Object)null) { return false; } return true; } catch (Exception) { return false; } } private static int InjectRelicsIntoObjectDBLists(ObjectDB odb, string phaseTag) { if ((Object)(object)odb == (Object)null) { return 0; } EnsureReflectionCache(); if (!TryLoadRelicBundle()) { return 0; } int num = 0; for (int i = 0; i < _defs.Count; i++) { RelicDef relicDef = _defs[i]; if (relicDef == null || string.IsNullOrEmpty(relicDef.PrefabName)) { continue; } GameObject val = FindRelicPrefabByName(relicDef.PrefabName); if (!((Object)(object)val == (Object)null)) { PrepareWorldItemPrefab(val, relicDef); if ((Object)(object)ZNetScene.instance != (Object)null) { TryAddToZNetScene(ZNetScene.instance, val); } if (TryAddToObjectDB(odb, val)) { num++; } } } return num; } private static void FinalizeRelics_ObjectDBCaches(ObjectDB odb, string phaseTag) { if (!((Object)(object)odb == (Object)null)) { RefreshObjectDB(odb); EnsureRelicLocalization(); bool flag = false; try { flag = (Object)(object)odb.GetItemPrefab("Meadows_Relic") != (Object)null; } catch { flag = false; } if (flag) { } } } private static void RegisterRelicsIntoObjectDB(ObjectDB odb, string phaseTag) { int num = InjectRelicsIntoObjectDBLists(odb, phaseTag); FinalizeRelics_ObjectDBCaches(odb, phaseTag); } private static void EnsureRelicPrefabsRegistered_ObjectDB(ObjectDB odb) { RegisterRelicsIntoObjectDB(odb, "EnsureRelicPrefabsRegistered_ObjectDB"); } private static GameObject FindRelicPrefabByName(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return null; } TryLoadRelicBundle(); try { if ((Object)(object)ObjectDB.instance != (Object)null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName); if ((Object)(object)itemPrefab != (Object)null) { return itemPrefab; } } } catch { } try { if ((Object)(object)ZNetScene.instance != (Object)null) { GameObject prefab = ZNetScene.instance.GetPrefab(prefabName); if ((Object)(object)prefab != (Object)null) { return prefab; } } } catch { } try { if ((Object)(object)_relicBundle != (Object)null) { GameObject val = _relicBundle.LoadAsset(prefabName); if ((Object)(object)val != (Object)null) { return val; } } } catch { } return null; } private static void PrepareWorldItemPrefab(GameObject prefab, RelicDef def) { //IL_013a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null || def == null) { return; } try { ((Object)prefab).name = def.PrefabName; ItemDrop component = prefab.GetComponent(); if ((Object)(object)component != (Object)null) { try { component.m_itemData.m_dropPrefab = prefab; } catch { } } try { component.m_autoPickup = true; } catch { } if (!((Object)(object)component == (Object)null)) { component.m_itemData.m_stack = 1; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_name = def.DisplayName ?? ("$" + def.LocNameKey); component.m_itemData.m_shared.m_description = def.DisplayDesc ?? ("$" + def.LocDescKey); if (component.m_itemData.m_shared.m_icons == null || component.m_itemData.m_shared.m_icons.Length == 0 || (Object)(object)component.m_itemData.m_shared.m_icons[0] == (Object)null) { } component.m_itemData.m_shared.m_itemType = (ItemType)16; component.m_itemData.m_shared.m_teleportable = true; component.m_itemData.m_shared.m_questItem = false; } } catch { } } private static bool TryAddToZNetScene(ZNetScene zns, GameObject prefab) { if ((Object)(object)zns == (Object)null || (Object)(object)prefab == (Object)null) { return false; } try { EnsureReflectionCache(); List zNetPrefabs = GetZNetPrefabs(zns); if (zNetPrefabs != null && !zNetPrefabs.Contains(prefab)) { zNetPrefabs.Add(prefab); } Dictionary zNetNamedPrefabs = GetZNetNamedPrefabs(zns); if (zNetNamedPrefabs != null) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); if (!zNetNamedPrefabs.ContainsKey(stableHashCode)) { zNetNamedPrefabs[stableHashCode] = prefab; } } return true; } catch { return false; } } private static bool TryAddToObjectDB(ObjectDB odb, GameObject prefab) { if ((Object)(object)odb == (Object)null || (Object)(object)prefab == (Object)null) { return false; } try { EnsureReflectionCache(); List objectDbItems = GetObjectDbItems(odb); if (objectDbItems == null) { return false; } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); for (int i = 0; i < objectDbItems.Count; i++) { if ((Object)(object)objectDbItems[i] != (Object)null && StringExtensionMethods.GetStableHashCode(((Object)objectDbItems[i]).name) == stableHashCode) { return false; } } objectDbItems.Add(prefab); return true; } catch { return false; } } private static bool InvokeObjectDbMethod(ObjectDB odb, MethodInfo mi) { if ((Object)(object)odb == (Object)null || mi == null) { return false; } try { ParameterInfo[] parameters = mi.GetParameters(); if (parameters == null || parameters.Length == 0) { mi.Invoke(odb, null); return true; } if (parameters.Length == 1) { object obj = null; Type parameterType = parameters[0].ParameterType; if (parameterType == typeof(bool)) { obj = false; } else if (parameterType == typeof(int)) { obj = 0; } else if (parameterType == typeof(float)) { obj = 0f; } else if (parameterType.IsValueType) { obj = Activator.CreateInstance(parameterType); } mi.Invoke(odb, new object[1] { obj }); return true; } return false; } catch (Exception) { return false; } } private static void RefreshObjectDB(ObjectDB odb) { if (!((Object)(object)odb == (Object)null)) { EnsureReflectionCache(); bool flag = false; flag |= InvokeObjectDbMethod(odb, _miObjectDbUpdateItemHashes); flag |= InvokeObjectDbMethod(odb, _miObjectDbUpdateItemList); if (!(flag | InvokeObjectDbMethod(odb, _miObjectDbUpdateRecipeHashes)) && !_warnedNoOdbRefresh) { _warnedNoOdbRefresh = true; } } } private static void EnsureRelicLocalization() { if (_locDone) { return; } _locDone = true; try { EnsureReflectionCache(); Localization instance = Localization.instance; if (instance == null || _miLocalizationAddWord == null) { _locDone = false; return; } for (int i = 0; i < _defs.Count; i++) { RelicDef relicDef = _defs[i]; if (relicDef != null) { if (!string.IsNullOrEmpty(relicDef.LocNameKey) && !string.IsNullOrEmpty(relicDef.DisplayName)) { _miLocalizationAddWord.Invoke(instance, new object[2] { relicDef.LocNameKey, relicDef.DisplayName }); } if (!string.IsNullOrEmpty(relicDef.LocDescKey) && !string.IsNullOrEmpty(relicDef.DisplayDesc)) { _miLocalizationAddWord.Invoke(instance, new object[2] { relicDef.LocDescKey, relicDef.DisplayDesc }); } } } } catch { _locDone = false; } } private static void EvaluatePlayerRelic(Player p) { if ((Object)(object)p == (Object)null) { return; } try { RelicTier relicTier = RelicTier.None; Inventory inventory = ((Humanoid)p).GetInventory(); if (inventory != null) { List allItems = inventory.GetAllItems(); if (allItems != null) { for (int i = 0; i < allItems.Count; i++) { ItemData item = allItems[i]; RelicTier tierFromItem = GetTierFromItem(item); if (tierFromItem > relicTier) { relicTier = tierFromItem; } } } } long playerKey = GetPlayerKey(p); _activeTierByPlayer[playerKey] = relicTier; } catch { } } private static RelicTier GetActiveRelicTier(Player p) { if ((Object)(object)p == (Object)null) { return RelicTier.None; } long playerKey = GetPlayerKey(p); if (_activeTierByPlayer.TryGetValue(playerKey, out var value)) { return value; } return RelicTier.None; } private static RelicTier GetTierFromItem(ItemData item) { if (item == null) { return RelicTier.None; } if (!IsRelicItemData(item)) { return RelicTier.None; } try { if (item.m_customData != null && item.m_customData.TryGetValue("PX_Cursed", out var value) && value == "1" && item.m_customData.TryGetValue("PX_CursedRelicTier", out var value2) && int.TryParse(value2, out var result) && result >= 0 && result <= 7) { RelicTier relicTier = (RelicTier)result; NormalizeRelicItem(item, relicTier); return relicTier; } string text = null; try { text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : null); } catch { text = null; } if (!string.IsNullOrEmpty(text)) { for (int i = 0; i < _defs.Count; i++) { RelicDef relicDef = _defs[i]; if (string.Equals(text, relicDef.PrefabName, StringComparison.OrdinalIgnoreCase)) { StampRelicItemData(item, relicDef.Tier); NormalizeRelicItem(item, relicDef.Tier); return relicDef.Tier; } } } string text2 = null; try { text2 = ((item.m_shared != null) ? item.m_shared.m_name : null); } catch { text2 = null; } if (!string.IsNullOrEmpty(text2)) { for (int j = 0; j < _defs.Count; j++) { RelicDef relicDef2 = _defs[j]; if (string.Equals(text2, "$" + relicDef2.LocNameKey, StringComparison.OrdinalIgnoreCase) || string.Equals(text2, relicDef2.LocNameKey, StringComparison.OrdinalIgnoreCase) || (!string.IsNullOrEmpty(relicDef2.DisplayName) && string.Equals(text2, relicDef2.DisplayName, StringComparison.OrdinalIgnoreCase))) { StampRelicItemData(item, relicDef2.Tier); NormalizeRelicItem(item, relicDef2.Tier); return relicDef2.Tier; } } } } catch { } return RelicTier.None; } private static void NormalizeRelicItem(ItemData item, RelicTier tier) { if (item == null || tier == RelicTier.None) { return; } RelicDef value = null; try { _defByTier.TryGetValue(tier, out value); } catch { value = null; } try { if (item.m_customData == null) { item.m_customData = new Dictionary(); } item.m_customData["PX_Cursed"] = "1"; Dictionary customData = item.m_customData; int num = (int)tier; customData["PX_CursedRelicTier"] = num.ToString(); item.m_customData["PX_CursedRelicUid"] = Guid.NewGuid().ToString("N"); try { if (item.m_shared != null) { item.m_shared.m_maxStackSize = 1; } } catch { } } catch { } try { if ((Object)(object)item.m_dropPrefab == (Object)null && value != null) { GameObject val = FindRelicPrefabByName(value.PrefabName); if ((Object)(object)val != (Object)null) { item.m_dropPrefab = val; } } } catch { } } private static long GetPlayerKey(Player p) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) try { ZDOID zDOID = ((Character)p).GetZDOID(); long num = 0L; try { num = ((ZDOID)(ref zDOID)).UserID; } catch { num = 0L; } if (num != 0) { return num; } } catch { } try { return StringExtensionMethods.GetStableHashCode(p.GetPlayerName() ?? ""); } catch { return 0L; } } private static void MaybeServerHaunt(Player p, float now) { //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null) { return; } try { if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer()) { return; } RelicTier activeRelicTier = GetActiveRelicTier(p); if (activeRelicTier == RelicTier.None) { return; } long playerKey = GetPlayerKey(p); if ((_hauntCooldownUntilByPlayer.TryGetValue(playerKey, out var value) && now < value) || (_nextHauntRollAtByPlayer.TryGetValue(playerKey, out var value2) && now < value2)) { return; } _nextHauntRollAtByPlayer[playerKey] = now + HauntCheckIntervalSeconds; if (Random.value > HauntRollChance) { return; } List list = new List(2); switch (activeRelicTier) { case RelicTier.Meadows: list.Add("Greydwarf_Elite"); break; case RelicTier.BlackForest: list.Add((Random.value < 0.5f) ? "Troll" : "Greydwarf_shaman"); break; case RelicTier.Swamp: list.Add("Abomination"); break; case RelicTier.Mountains: list.Add((Random.value < 0.5f) ? "Hatchling" : "StoneGolem"); break; case RelicTier.Plains: list.Add("GoblinBrute"); break; case RelicTier.Mistlands: list.Add("SeekerBrute"); break; case RelicTier.Ashlands: list.Add("Morgen"); break; } if (list.Count == 0) { return; } Vector3 val = ((Component)p).transform.position + ((Component)p).transform.forward * 6f + Vector3.up * 0.2f; for (int i = 0; i < list.Count; i++) { GameObject prefab = ZNetScene.instance.GetPrefab(list[i]); if (!((Object)(object)prefab == (Object)null)) { InstantiateNetworkedPrefab(prefab, val + Random.insideUnitSphere * 1.5f, Quaternion.identity); } } float num = Mathf.Max(5f, (CfgHauntCooldownMinSeconds != null) ? CfgHauntCooldownMinSeconds.Value : 480f); float num2 = Mathf.Max(num, (CfgHauntCooldownMaxSeconds != null) ? CfgHauntCooldownMaxSeconds.Value : 900f); float num3 = Random.Range(num, num2); _hauntCooldownUntilByPlayer[playerKey] = now + num3; } catch { } } private static void TryDropRelicForBoss(GameObject go) { //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)go == (Object)null || (CfgEnabled != null && !CfgEnabled.Value) || ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer())) { return; } float num = Mathf.Clamp01((CfgBossDropChance != null) ? CfgBossDropChance.Value : 0.2f); if (num <= 0f) { return; } string cleanPrefabName = GetCleanPrefabName(go); if (string.IsNullOrEmpty(cleanPrefabName)) { return; } Debug.Log((object)("[Paranoia][Relics] TryDropRelicForBoss fired for '" + cleanPrefabName + "'")); if (!_tierByBossPrefab.TryGetValue(cleanPrefabName, out var value) || value == RelicTier.None) { return; } int instanceID = ((Object)go).GetInstanceID(); float time = Time.time; if (time > _nextDropKeyCleanup) { _recentDropKeys.Clear(); _nextDropKeyCleanup = time + 60f; } if (!_recentDropKeys.Add(instanceID)) { return; } float value2 = Random.value; if (value2 > num) { Debug.Log((object)$"[Paranoia][Relics] Roll {value2:F3} > chance {num:F3}, no drop for '{cleanPrefabName}'"); return; } Debug.Log((object)$"[Paranoia][Relics] Roll {value2:F3} <= chance {num:F3}, dropping tier={value} for '{cleanPrefabName}'"); if (!_defByTier.TryGetValue(value, out var value3) || value3 == null) { Debug.LogError((object)$"[Paranoia][Relics] No def for tier={value}"); return; } GameObject val = FindRelicPrefabByName(value3.PrefabName); if ((Object)(object)val == (Object)null) { Debug.LogError((object)$"[Paranoia][Relics] Could not find prefab '{value3.PrefabName}' bundle={(Object)(object)_relicBundle != (Object)null} zns={(Object)(object)ZNetScene.instance != (Object)null}"); return; } Debug.Log((object)$"[Paranoia][Relics] Found prefab '{((Object)val).name}' hasZNV={(Object)(object)val.GetComponent() != (Object)null}"); Vector3 val2 = go.transform.position + Vector3.up * 1.2f; GameObject val3 = InstantiateNetworkedPrefab(val, val2, Quaternion.identity); if ((Object)(object)val3 == (Object)null) { Debug.LogError((object)"[Paranoia][Relics] InstantiateNetworkedPrefab returned null"); return; } ItemDrop component = val3.GetComponent(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"[Paranoia][Relics] Spawned object has no ItemDrop"); return; } MarkAsCursedRelicInstance(component.m_itemData, value); Debug.Log((object)$"[Paranoia][Relics] Successfully dropped {value3.PrefabName} at {val2}"); } catch (Exception arg) { Debug.LogError((object)$"[Paranoia][Relics] TryDropRelicForBoss exception: {arg}"); } } private static void MarkAsCursedRelicInstance(ItemData item, RelicTier tier) { if (item == null) { return; } try { EnsureCustomData(item); item.m_stack = 1; item.m_customData["PX_Cursed"] = "1"; Dictionary customData = item.m_customData; int num = (int)tier; customData["PX_CursedRelicTier"] = num.ToString(); item.m_customData["PX_CursedRelicUid"] = Guid.NewGuid().ToString("N"); try { if (item.m_shared != null) { item.m_shared.m_maxStackSize = 1; } } catch { } } catch { } } private static void EnsureCustomData(ItemData item) { if (item != null && item.m_customData == null) { item.m_customData = new Dictionary(); } } private static string GetCleanPrefabName(GameObject go) { if ((Object)(object)go == (Object)null) { return null; } try { string text = ((Object)go).name ?? ""; int num = text.IndexOf("(Clone)", StringComparison.OrdinalIgnoreCase); if (num >= 0) { text = text.Substring(0, num); } return text.Trim(); } catch { return null; } } private static GameObject InstantiateNetworkedPrefab(GameObject prefab, Vector3 pos, Quaternion rot) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { return null; } try { if ((Object)(object)ZNetScene.instance != (Object)null) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); GameObject prefab2 = ZNetScene.instance.GetPrefab(stableHashCode); if ((Object)(object)prefab2 != (Object)null) { prefab = prefab2; Debug.Log((object)$"[Paranoia][Relics] Using ZNetScene prefab '{((Object)prefab).name}' hash={stableHashCode}"); } else { Debug.LogError((object)$"[Paranoia][Relics] Prefab '{((Object)prefab).name}' hash={stableHashCode} NOT in ZNetScene!"); } } GameObject val = Object.Instantiate(prefab, pos, rot); if ((Object)(object)val == (Object)null) { return null; } ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Debug.Log((object)$"[Paranoia][Relics] Instantiated '{((Object)val).name}' ZDO={component.GetZDO()?.m_uid}"); } else { Debug.LogError((object)("[Paranoia][Relics] Instantiated '" + ((Object)val).name + "' has NO ZNetView!")); } return val; } catch (Exception arg) { Debug.LogError((object)$"[Paranoia][Relics] InstantiateNetworkedPrefab exception: {arg}"); return null; } } private static bool IsCursedRelic(ItemData item, out RelicTier tier) { tier = RelicTier.None; if (item == null) { return false; } try { tier = GetTierFromItem(item); return tier != RelicTier.None; } catch { tier = RelicTier.None; return false; } } private static string BuildTooltipForTier(RelicTier tier) { string buffLineForTier = GetBuffLineForTier(tier); return "Cursed Relic\n" + buffLineForTier + "\nParanoia rate 2x"; } private static string GetBuffLineForTier(RelicTier tier) { float carryWeightBonusForTier = GetCarryWeightBonusForTier(tier); if (carryWeightBonusForTier > 0f) { return "Carry weight +" + carryWeightBonusForTier.ToString("0"); } return "No buff"; } private static float GetCarryWeightBonusForTier(RelicTier tier) { return tier switch { RelicTier.Meadows => (CfgMeadows_CarryWeightAdd != null) ? CfgMeadows_CarryWeightAdd.Value : 25f, RelicTier.BlackForest => (CfgBlackForest_CarryWeightAdd != null) ? CfgBlackForest_CarryWeightAdd.Value : 50f, RelicTier.Swamp => (CfgSwamp_CarryWeightAdd != null) ? CfgSwamp_CarryWeightAdd.Value : 100f, RelicTier.Mountains => (CfgMountains_CarryWeightAdd != null) ? CfgMountains_CarryWeightAdd.Value : 150f, RelicTier.Plains => (CfgPlains_CarryWeightAdd != null) ? CfgPlains_CarryWeightAdd.Value : 200f, RelicTier.Mistlands => (CfgMistlands_CarryWeightAdd != null) ? CfgMistlands_CarryWeightAdd.Value : 250f, RelicTier.Ashlands => (CfgAshlands_CarryWeightAdd != null) ? CfgAshlands_CarryWeightAdd.Value : 350f, _ => 0f, }; } private static void EnsureReflectionCache() { if (_refReady) { return; } _refReady = true; try { _miObjectMemberwiseClone = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic); } catch { } try { _fiZNetScenePrefabs = typeof(ZNetScene).GetField("m_prefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _fiZNetSceneNamedPrefabs = typeof(ZNetScene).GetField("m_namedPrefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { } try { _fiObjectDbItems = typeof(ObjectDB).GetField("m_items", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { } try { MethodInfo[] methods = typeof(ObjectDB).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _miObjectDbUpdateItemHashes = methods.FirstOrDefault((MethodInfo m) => string.Equals(m.Name, "UpdateItemHashes", StringComparison.Ordinal)); _miObjectDbUpdateItemList = methods.FirstOrDefault((MethodInfo m) => string.Equals(m.Name, "UpdateItemList", StringComparison.Ordinal)); _miObjectDbUpdateRecipeHashes = methods.FirstOrDefault((MethodInfo m) => string.Equals(m.Name, "UpdateRecipeHashes", StringComparison.Ordinal)); } catch { } try { Type typeFromHandle = typeof(EnvMan); _miEnvManIsNightStatic = typeFromHandle.GetMethod("IsNight", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _miEnvManIsNightInstance = typeFromHandle.GetMethod("IsNight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { } try { _miLocalizationAddWord = typeof(Localization).GetMethod("AddWord", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { } } private static List GetZNetPrefabs(ZNetScene zns) { try { return (_fiZNetScenePrefabs != null) ? (_fiZNetScenePrefabs.GetValue(zns) as List) : null; } catch { return null; } } private static Dictionary GetZNetNamedPrefabs(ZNetScene zns) { try { return (_fiZNetSceneNamedPrefabs != null) ? (_fiZNetSceneNamedPrefabs.GetValue(zns) as Dictionary) : null; } catch { return null; } } private static List GetObjectDbItems(ObjectDB odb) { try { return (_fiObjectDbItems != null) ? (_fiObjectDbItems.GetValue(odb) as List) : null; } catch { return null; } } } } namespace Pix.Paranoia.Nausea { public static class ParanoiaNausea { private static bool _initialized; private static readonly int NauseaSeHash = StringExtensionMethods.GetStableHashCode("SE_Pix_Nausea"); private static readonly Dictionary _cooldowns = new Dictionary(); private static readonly Dictionary _pendingNausea = new Dictionary(); private static Sprite _nauseaIcon; private static bool _iconIsCustom; private static DateTime _customIconWriteUtc; internal static MethodInfo _miPlayerClearFood; internal static ConfigEntry CfgEnabled; internal static ConfigEntry CfgDuration; internal static ConfigEntry CfgReapplyCooldown; internal static ConfigEntry CfgVomitStaminaLoss; internal static ConfigEntry CfgVomitSlowDuration; internal static ConfigEntry CfgVomitSlowPercent; private static readonly HashSet _nauseaAttackers = new HashSet(StringComparer.OrdinalIgnoreCase) { "Blob", "BlobElite", "BlobTar", "Bonemass" }; public static void Init(Harmony harmony, ConfigFile config) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_018d: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown if (_initialized) { return; } try { CfgEnabled = config.Bind("Nausea", "Enabled", true, "Enable nausea effect when hit by Blobs/Oozers."); CfgDuration = config.Bind("Nausea", "DurationSeconds", 180f, new ConfigDescription("How long the nausea builds before vomit.", (AcceptableValueBase)(object)new AcceptableValueRange(30f, 600f), Array.Empty())); CfgReapplyCooldown = config.Bind("Nausea", "ReapplyCooldownSeconds", 20f, new ConfigDescription("Cooldown before nausea can be reapplied to the same player.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 120f), Array.Empty())); CfgVomitStaminaLoss = config.Bind("Nausea", "VomitStaminaLoss", 30f, new ConfigDescription("Stamina drained when the player vomits.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); CfgVomitSlowDuration = config.Bind("Nausea", "VomitSlowDurationSeconds", 4f, new ConfigDescription("How long the post-vomit slow lasts.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 15f), Array.Empty())); CfgVomitSlowPercent = config.Bind("Nausea", "VomitSlowPercent", 0.35f, new ConfigDescription("Movement speed reduction during post-vomit slow (0-1).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.8f), Array.Empty())); harmony.Patch((MethodBase)AccessTools.Method(typeof(Character), "RPC_Damage", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ParanoiaNausea), "RPC_Damage_Prefix", (Type[])null), new HarmonyMethod(typeof(ParanoiaNausea), "RPC_Damage_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ParanoiaNausea), "ObjectDB_Awake_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ObjectDB), "CopyOtherDB", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ParanoiaNausea), "ObjectDB_CopyOtherDB_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _initialized = true; } catch (Exception ex) { Debug.LogError((object)("[ParanoiaNausea] Init failed: " + ex.Message)); } } private static void ObjectDB_Awake_Postfix(ObjectDB __instance) { try { EnsureNauseaStatusEffect(__instance); } catch { } } private static void ObjectDB_CopyOtherDB_Postfix(ObjectDB __instance) { try { EnsureNauseaStatusEffect(__instance); } catch { } } private static void EnsureNauseaStatusEffect(ObjectDB odb) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)odb == (Object)null || odb.m_StatusEffects == null) { return; } for (int i = 0; i < odb.m_StatusEffects.Count; i++) { StatusEffect val = odb.m_StatusEffects[i]; if (!((Object)(object)val == (Object)null)) { string text = null; try { text = ((Object)val).name; } catch { text = null; } if (!string.IsNullOrEmpty(text) && text.Equals("SE_Pix_Nausea", StringComparison.Ordinal)) { return; } } } SE_Pix_Nausea sE_Pix_Nausea = ScriptableObject.CreateInstance(); if (!((Object)(object)sE_Pix_Nausea == (Object)null)) { ((Object)sE_Pix_Nausea).name = "SE_Pix_Nausea"; ((StatusEffect)sE_Pix_Nausea).m_name = "Nauseous"; ((StatusEffect)sE_Pix_Nausea).m_tooltip = "Your stomach churns violently...you're going to be sick."; ((StatusEffect)sE_Pix_Nausea).m_ttl = CfgDuration?.Value ?? 180f; ((StatusEffect)sE_Pix_Nausea).m_startMessage = "Your stomach churns..."; ((StatusEffect)sE_Pix_Nausea).m_startMessageType = (MessageType)2; TryAssignIcon(sE_Pix_Nausea, odb); odb.m_StatusEffects.Add((StatusEffect)(object)sE_Pix_Nausea); } } private static void TryAssignIcon(SE_Pix_Nausea se, ObjectDB odb) { PngIconLoader.EnsureIcon("NauseaSE.png", "poison", (StatusEffect)(object)se, odb, ref _nauseaIcon, ref _iconIsCustom, ref _customIconWriteUtc); } private static void RPC_Damage_Prefix(Character __instance, HitData hit) { try { ConfigEntry cfgEnabled = CfgEnabled; if ((cfgEnabled != null && !cfgEnabled.Value) || (Object)(object)__instance == (Object)null || hit == null || !__instance.IsOwner() || !(__instance is Player) || hit.GetTotalDamage() <= 0f) { return; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null) { return; } string prefabName = GetPrefabName(((Component)attacker).gameObject); if (!string.IsNullOrEmpty(prefabName)) { bool flag = _nauseaAttackers.Contains(prefabName); if (!flag && hit.m_damage.m_poison > 0f) { flag = prefabName.IndexOf("blob", StringComparison.OrdinalIgnoreCase) >= 0 || prefabName.IndexOf("Bonemass", StringComparison.OrdinalIgnoreCase) >= 0; } if (flag) { int instanceID = ((Object)__instance).GetInstanceID(); _pendingNausea[instanceID] = hit; } } } catch { } } private static void RPC_Damage_Postfix(Character __instance) { try { if ((Object)(object)__instance == (Object)null) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!_pendingNausea.TryGetValue(instanceID, out var _)) { return; } _pendingNausea.Remove(instanceID); Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null || ((Character)val).IsDead()) { return; } float time = Time.time; float num = CfgReapplyCooldown?.Value ?? 20f; if (_cooldowns.TryGetValue(instanceID, out var value2) && time - value2 < num) { return; } SEMan sEMan = ((Character)val).GetSEMan(); if (sEMan != null && !sEMan.HaveStatusEffect(NauseaSeHash)) { SE_Pix_Nausea sE_Pix_Nausea = sEMan.AddStatusEffect(NauseaSeHash, false, 0, 0f) as SE_Pix_Nausea; if ((Object)(object)sE_Pix_Nausea != (Object)null) { ((StatusEffect)sE_Pix_Nausea).m_ttl = CfgDuration?.Value ?? 180f; } _cooldowns[instanceID] = time; } } catch { } } private static string GetPrefabName(GameObject go) { if ((Object)(object)go == (Object)null) { return null; } string text = ((Object)go).name; if (string.IsNullOrEmpty(text)) { return null; } int num = text.IndexOf("(Clone)", StringComparison.OrdinalIgnoreCase); if (num > 0) { text = text.Substring(0, num).Trim(); } return text; } } internal sealed class SE_Pix_Nausea : StatusEffect { private static readonly int[] PukeHashes = new int[4] { StringExtensionMethods.GetStableHashCode("Puke"), StringExtensionMethods.GetStableHashCode("SE_Puke"), StringExtensionMethods.GetStableHashCode("se_puke"), StringExtensionMethods.GetStableHashCode("puke") }; private bool _vomitTriggered; private bool _slowActive; private float _slowEndsAt; public override void Setup(Character character) { ((StatusEffect)this).Setup(character); _vomitTriggered = false; _slowActive = false; } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (_slowActive && Time.time >= _slowEndsAt) { _slowActive = false; } } public override bool IsDone() { if ((double)base.m_ttl <= 0.0 || (double)base.m_time <= (double)base.m_ttl) { return false; } if (!_vomitTriggered) { _vomitTriggered = true; TriggerVomit(); } if (_slowActive) { return false; } return true; } public override string GetIconText() { if (_slowActive) { float num = Mathf.Max(0f, _slowEndsAt - Time.time); return StatusEffect.GetTimeString(num, false, false); } if ((double)base.m_ttl > 0.0) { return StatusEffect.GetTimeString(base.m_ttl - ((StatusEffect)this).GetDuration(), false, false); } return ""; } public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir) { if (_slowActive) { float num = ParanoiaNausea.CfgVomitSlowPercent?.Value ?? 0.35f; speed *= 1f - num; } } private void TriggerVomit() { try { if ((Object)(object)base.m_character == (Object)null) { return; } Character character = base.m_character; Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val == (Object)null) { return; } base.m_character.Message((MessageType)2, "You vomit violently!", 0, (Sprite)null); try { val.StartEmote("puke", true); } catch { } TryClearFood(val); TryApplyVanillaPukeEffect(val); float num = ParanoiaNausea.CfgVomitStaminaLoss?.Value ?? 30f; if (num > 0f) { try { ((Character)val).UseStamina(num); } catch { } } float num2 = ParanoiaNausea.CfgVomitSlowDuration?.Value ?? 4f; if (num2 > 0f) { _slowActive = true; _slowEndsAt = Time.time + num2; } } catch { } } private void TryClearFood(Player player) { try { if (!((Object)(object)player == (Object)null)) { if (ParanoiaNausea._miPlayerClearFood == null) { ParanoiaNausea._miPlayerClearFood = typeof(Player).GetMethod("ClearFood", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (ParanoiaNausea._miPlayerClearFood != null) { ParanoiaNausea._miPlayerClearFood.Invoke(player, null); } } } catch { } } private void TryApplyVanillaPukeEffect(Player player) { try { if ((Object)(object)player == (Object)null) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return; } int[] pukeHashes = PukeHashes; foreach (int num in pukeHashes) { try { if (sEMan.HaveStatusEffect(num)) { sEMan.RemoveStatusEffect(num, false); } if ((Object)(object)sEMan.AddStatusEffect(num, false, 0, 0f) != (Object)null) { break; } } catch { } } } catch { } } public override string GetTooltipString() { if (_slowActive) { return "Weakened from vomiting. Movement slowed."; } return "Your stomach churns violently... you're going to be sick."; } } } namespace Pix.Paranoia.Infection { public static class ParanoiaInfection { private static bool _initialized; private static ManualLogSource _logger; private static readonly int InfectedMinorHash = StringExtensionMethods.GetStableHashCode("SE_Pix_InfectedMinor"); private static readonly int InfectedMediumHash = StringExtensionMethods.GetStableHashCode("SE_Pix_InfectedMedium"); private static readonly int InfectedTerminalHash = StringExtensionMethods.GetStableHashCode("SE_Pix_InfectedTerminal"); private static readonly int AntidoteWorkingHash = StringExtensionMethods.GetStableHashCode("SE_Pix_AntidoteWorking"); private static readonly int CuredHash = StringExtensionMethods.GetStableHashCode("SE_Pix_Cured"); private static readonly int ZdoKey_InfectionCooldownEnd = StringExtensionMethods.GetStableHashCode("pix_infectionCdEnd"); private static Sprite _infectedIcon; private static bool _infectedIconIsCustom; private static DateTime _infectedIconWriteUtc; private static Sprite _curedIcon; private static bool _curedIconIsCustom; private static DateTime _curedIconWriteUtc; internal static ConfigEntry CfgEnabled; internal static ConfigEntry CfgCooldownSeconds; internal static ConfigEntry CfgMinorDuration; internal static ConfigEntry CfgMediumDuration; internal static ConfigEntry CfgTerminalDuration; internal static ConfigEntry CfgFatigueSpikeInterval; internal static ConfigEntry CfgMinorFatigueSeconds; internal static ConfigEntry CfgMediumFatigueSeconds; internal static ConfigEntry CfgTerminalFatigueSeconds; internal static ConfigEntry CfgAntidoteArmSeconds; internal static ConfigEntry CfgCarryPenaltyMinor; internal static ConfigEntry CfgCarryPenaltyMedium; internal static ConfigEntry CfgCarryPenaltyTerminal; private static readonly HashSet _infectionSources = new HashSet(StringComparer.OrdinalIgnoreCase) { "Seeker", "SeekerBrute", "Tick", "Brood" }; private static readonly Dictionary _pendingInfection = new Dictionary(); public static void Init(Harmony harmony, ManualLogSource logger, ConfigFile config) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Expected O, but got Unknown //IL_031a: Expected O, but got Unknown //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Expected O, but got Unknown //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Expected O, but got Unknown //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Expected O, but got Unknown if (_initialized) { return; } _logger = logger; try { CfgEnabled = config.Bind("Infection", "Enabled", true, "Enable the Mistlands infection mechanic from bug-type enemies."); CfgCooldownSeconds = config.Bind("Infection", "Infection Cooldown", 360f, new ConfigDescription("Seconds before a player can be infected again after an infection.", (AcceptableValueBase)(object)new AcceptableValueRange(30f, 1800f), Array.Empty())); CfgMinorDuration = config.Bind("Infection", "Minor Duration", 180f, new ConfigDescription("Duration of Minor Infection in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange(30f, 600f), Array.Empty())); CfgMediumDuration = config.Bind("Infection", "Medium Duration", 300f, new ConfigDescription("Duration of Medium Infection in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange(60f, 900f), Array.Empty())); CfgTerminalDuration = config.Bind("Infection", "Terminal Duration", 420f, new ConfigDescription("Duration of Terminal Infection in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange(120f, 1200f), Array.Empty())); CfgFatigueSpikeInterval = config.Bind("Infection", "Fatigue Spike Interval", 60f, new ConfigDescription("Seconds between fatigue spikes.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 300f), Array.Empty())); CfgMinorFatigueSeconds = config.Bind("Infection", "Minor Fatigue Duration", 2f, new ConfigDescription("Duration of fatigue spike for Minor Infection.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 15f), Array.Empty())); CfgMediumFatigueSeconds = config.Bind("Infection", "Medium Fatigue Duration", 5f, new ConfigDescription("Duration of fatigue spike for Medium Infection.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 20f), Array.Empty())); CfgTerminalFatigueSeconds = config.Bind("Infection", "Terminal Fatigue Duration", 7f, new ConfigDescription("Duration of fatigue spike for Terminal Infection.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 30f), Array.Empty())); CfgAntidoteArmSeconds = config.Bind("Infection", "Antidote Arm Time", 35f, new ConfigDescription("Seconds for the antidote to take effect after drinking a healing mead.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 120f), Array.Empty())); CfgCarryPenaltyMinor = config.Bind("Infection", "Carry Penalty Minor", 0.15f, new ConfigDescription("Carry weight reduction fraction for Minor Infection.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.5f), Array.Empty())); CfgCarryPenaltyMedium = config.Bind("Infection", "Carry Penalty Medium", 0.25f, new ConfigDescription("Carry weight reduction fraction for Medium Infection.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.6f), Array.Empty())); CfgCarryPenaltyTerminal = config.Bind("Infection", "Carry Penalty Terminal", 0.35f, new ConfigDescription("Carry weight reduction fraction for Terminal Infection.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.8f), Array.Empty())); harmony.Patch((MethodBase)AccessTools.Method(typeof(Character), "RPC_Damage", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ParanoiaInfection), "RPC_Damage_Prefix", (Type[])null), new HarmonyMethod(typeof(ParanoiaInfection), "RPC_Damage_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Player), "ConsumeItem", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ParanoiaInfection), "ConsumeItem_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ParanoiaInfection), "ObjectDB_Awake_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ObjectDB), "CopyOtherDB", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ParanoiaInfection), "ObjectDB_CopyOtherDB_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _initialized = true; } catch (Exception ex) { Debug.LogError((object)("[ParanoiaInfection] Init failed: " + ex.Message)); } } private static void Log(string msg) { try { ManualLogSource logger = _logger; if (logger != null) { logger.LogInfo((object)("[Infection] " + msg)); } } catch { } } private static void ObjectDB_Awake_Postfix(ObjectDB __instance) { try { RegisterStatusEffects(__instance); } catch { } } private static void ObjectDB_CopyOtherDB_Postfix(ObjectDB __instance) { try { RegisterStatusEffects(__instance); } catch { } } private static void RegisterStatusEffects(ObjectDB odb) { if (!((Object)(object)odb == (Object)null) && odb.m_StatusEffects != null) { TryRegisterSE(odb, "SE_Pix_InfectedMinor", "Minor Infection", "A mild infection courses through your veins...", CfgMinorDuration?.Value ?? 180f, "You feel a slight itch..."); TryRegisterSE(odb, "SE_Pix_InfectedMedium", "Infection", "The infection is spreading. Your body weakens.", CfgMediumDuration?.Value ?? 300f, "Something writhes beneath your skin..."); TryRegisterSE(odb, "SE_Pix_InfectedTerminal", "Terminal Infection", "The infection has taken hold. Find an antidote or perish.", CfgTerminalDuration?.Value ?? 420f, "The infection burns through your blood!"); TryRegisterSE(odb, "SE_Pix_AntidoteWorking", "Antidote", "The antidote is fighting the infection...", CfgAntidoteArmSeconds?.Value ?? 35f, "The antidote begins to take effect..."); TryRegisterSE(odb, "SE_Pix_Cured", "Cured", "The antidote purges the infection.", 10f, "The infection subsides."); } } private static void TryRegisterSE(ObjectDB odb, string seName, string displayName, string tooltip, float ttl, string startMessage) where T : StatusEffect { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < odb.m_StatusEffects.Count; i++) { StatusEffect val = odb.m_StatusEffects[i]; if ((Object)(object)val != (Object)null && ((Object)val).name != null && ((Object)val).name.Equals(seName, StringComparison.Ordinal)) { return; } } T val2 = ScriptableObject.CreateInstance(); if (!((Object)(object)val2 == (Object)null)) { ((Object)(object)val2).name = seName; ((StatusEffect)val2).m_name = displayName; ((StatusEffect)val2).m_tooltip = tooltip; ((StatusEffect)val2).m_ttl = ttl; ((StatusEffect)val2).m_startMessage = startMessage; ((StatusEffect)val2).m_startMessageType = (MessageType)2; if (val2 is SE_Pix_Cured) { AssignCuredIcon((StatusEffect)(object)val2, odb); } else { AssignInfectedIcon((StatusEffect)(object)val2, odb); } odb.m_StatusEffects.Add((StatusEffect)(object)val2); } } private static void AssignInfectedIcon(StatusEffect se, ObjectDB odb) { PngIconLoader.EnsureIcon("InfectedSE.png", "poison", se, odb, ref _infectedIcon, ref _infectedIconIsCustom, ref _infectedIconWriteUtc); } private static void AssignCuredIcon(StatusEffect se, ObjectDB odb) { PngIconLoader.EnsureIcon("CuredSE.png", "rested", se, odb, ref _curedIcon, ref _curedIconIsCustom, ref _curedIconWriteUtc); } private static void RPC_Damage_Prefix(Character __instance, HitData hit) { try { ConfigEntry cfgEnabled = CfgEnabled; if ((cfgEnabled != null && !cfgEnabled.Value) || (Object)(object)__instance == (Object)null || hit == null || !__instance.IsOwner() || !(__instance is Player) || hit.GetTotalDamage() <= 0f) { return; } Character attacker = hit.GetAttacker(); if (!((Object)(object)attacker == (Object)null)) { string prefabName = GetPrefabName(((Component)attacker).gameObject); if (!string.IsNullOrEmpty(prefabName) && _infectionSources.Contains(prefabName)) { int instanceID = ((Object)__instance).GetInstanceID(); _pendingInfection[instanceID] = hit; } } } catch { } } private static void RPC_Damage_Postfix(Character __instance) { try { if ((Object)(object)__instance == (Object)null) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!_pendingInfection.TryGetValue(instanceID, out var value)) { return; } _pendingInfection.Remove(instanceID); Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null || ((Character)val).IsDead() || IsOnInfectionCooldown(val)) { return; } SEMan sEMan = ((Character)val).GetSEMan(); if (sEMan == null || sEMan.HaveStatusEffect(InfectedMinorHash) || sEMan.HaveStatusEffect(InfectedMediumHash) || sEMan.HaveStatusEffect(InfectedTerminalHash)) { return; } Character attacker = value.GetAttacker(); string text = (((Object)(object)attacker != (Object)null) ? GetPrefabName(((Component)attacker).gameObject) : ""); bool isTick = text.Equals("Tick", StringComparison.OrdinalIgnoreCase); int num = RollInfectionTier(isTick); StatusEffect val2 = sEMan.AddStatusEffect(num, false, 0, 0f); if ((Object)(object)val2 != (Object)null) { if (num == InfectedMinorHash) { val2.m_ttl = CfgMinorDuration?.Value ?? 180f; } else if (num == InfectedMediumHash) { val2.m_ttl = CfgMediumDuration?.Value ?? 300f; } else if (num == InfectedTerminalHash) { val2.m_ttl = CfgTerminalDuration?.Value ?? 420f; } } SetInfectionCooldown(val); } catch { } } private static int RollInfectionTier(bool isTick) { float value = Random.value; if (isTick) { if (value < 0.75f) { return InfectedTerminalHash; } if (value < 0.95f) { return InfectedMediumHash; } return InfectedMinorHash; } if (value < 0.75f) { return InfectedMinorHash; } if (value < 0.95f) { return InfectedMediumHash; } return InfectedTerminalHash; } private static double GetWorldTime() { try { return ((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTimeSeconds() : 0.0; } catch { return 0.0; } } private static bool IsOnInfectionCooldown(Player player) { try { ZNetView component = ((Component)player).GetComponent(); if ((Object)(object)component == (Object)null || component.GetZDO() == null) { return false; } float @float = component.GetZDO().GetFloat(ZdoKey_InfectionCooldownEnd, 0f); return GetWorldTime() < (double)@float; } catch { return false; } } private static void SetInfectionCooldown(Player player) { try { ZNetView component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null) && component.GetZDO() != null) { float num = (float)(GetWorldTime() + (double)(CfgCooldownSeconds?.Value ?? 360f)); component.GetZDO().Set(ZdoKey_InfectionCooldownEnd, num); } } catch { } } private static void ConsumeItem_Postfix(Player __instance, Inventory inventory, ItemData item, bool __result) { try { if (!__result || (Object)(object)__instance == (Object)null || item == null || !((Character)__instance).IsOwner() || !IsHealingMead(item)) { return; } SEMan sEMan = ((Character)__instance).GetSEMan(); if (sEMan != null && sEMan.HaveStatusEffect(InfectedTerminalHash) && !sEMan.HaveStatusEffect(AntidoteWorkingHash)) { StatusEffect val = sEMan.AddStatusEffect(AntidoteWorkingHash, false, 0, 0f); if ((Object)(object)val != (Object)null) { val.m_ttl = CfgAntidoteArmSeconds?.Value ?? 35f; } } } catch { } } private static bool IsHealingMead(ItemData item) { if (item == null) { return false; } string text = null; try { GameObject dropPrefab = item.m_dropPrefab; text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } catch { } if (!string.IsNullOrEmpty(text) && text.IndexOf("MeadHealth", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if ((Object)(object)item.m_shared.m_consumeStatusEffect != (Object)null) { string name = ((Object)item.m_shared.m_consumeStatusEffect).name; if (!string.IsNullOrEmpty(name) && name.IndexOf("heal", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } if (item.m_shared.m_foodRegen > 0f && item.m_shared.m_food <= 0f) { return true; } return false; } internal static bool HasAnyInfection(SEMan seman) { if (seman == null) { return false; } return seman.HaveStatusEffect(InfectedMinorHash) || seman.HaveStatusEffect(InfectedMediumHash) || seman.HaveStatusEffect(InfectedTerminalHash); } internal static void ApplyCured(Player player) { try { SEMan val = ((player != null) ? ((Character)player).GetSEMan() : null); if (val != null) { val.RemoveStatusEffect(InfectedTerminalHash, true); StatusEffect val2 = val.AddStatusEffect(CuredHash, false, 0, 0f); if ((Object)(object)val2 != (Object)null) { val2.m_ttl = 10f; } ((Character)player).Message((MessageType)2, "The infection subsides.", 0, (Sprite)null); } } catch { } } internal static void InfectionKill(Player player) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //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) try { if (!((Object)(object)player == (Object)null) && !((Character)player).IsDead()) { ((Character)player).Message((MessageType)2, "The infection has spread too far.", 0, (Sprite)null); HitData val = new HitData(); val.m_damage.m_damage = 99999f; val.m_point = ((Component)player).transform.position; ((Character)player).Damage(val); } } catch { } } private static string GetPrefabName(GameObject go) { if ((Object)(object)go == (Object)null) { return null; } string text = ((Object)go).name; if (string.IsNullOrEmpty(text)) { return null; } int num = text.IndexOf("(Clone)", StringComparison.OrdinalIgnoreCase); if (num > 0) { text = text.Substring(0, num).Trim(); } return text; } } internal abstract class SE_Pix_InfectedBase : StatusEffect { private float _nextFatigueSpikeAtRelative; private bool _fatigueActive; private float _fatigueEndsAtRelative; protected abstract float GetCarryPenalty(); protected abstract float GetFatigueSpikeDuration(); protected virtual float GetFatigueSpikeInterval() { return ParanoiaInfection.CfgFatigueSpikeInterval?.Value ?? 60f; } public override void Setup(Character character) { ((StatusEffect)this).Setup(character); _nextFatigueSpikeAtRelative = GetFatigueSpikeInterval(); _fatigueActive = false; } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (_fatigueActive) { if (base.m_time >= _fatigueEndsAtRelative) { _fatigueActive = false; } } else if (base.m_time >= _nextFatigueSpikeAtRelative) { _fatigueActive = true; _fatigueEndsAtRelative = base.m_time + GetFatigueSpikeDuration(); _nextFatigueSpikeAtRelative = _fatigueEndsAtRelative + GetFatigueSpikeInterval(); if ((Object)(object)base.m_character != (Object)null) { base.m_character.Message((MessageType)1, "A wave of fatigue washes over you...", 0, (Sprite)null); } } } public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir) { if (_fatigueActive) { speed *= 0.4f; } } public override void ModifyMaxCarryWeight(float baseLimit, ref float limit) { float carryPenalty = GetCarryPenalty(); if (carryPenalty > 0f) { limit *= 1f - carryPenalty; } } public override void ModifyStaminaRegen(ref float staminaRegen) { float carryPenalty = GetCarryPenalty(); if (carryPenalty > 0f) { staminaRegen *= 1f - carryPenalty; } } public override string GetIconText() { if (_fatigueActive) { float num = Mathf.Max(0f, _fatigueEndsAtRelative - base.m_time); return StatusEffect.GetTimeString(num, false, false); } if ((double)base.m_ttl > 0.0) { return StatusEffect.GetTimeString(base.m_ttl - ((StatusEffect)this).GetDuration(), false, false); } return ""; } public override string GetTooltipString() { if (_fatigueActive) { return "A wave of fatigue slows your movements..."; } return base.m_tooltip; } } internal sealed class SE_Pix_InfectedMinor : SE_Pix_InfectedBase { protected override float GetCarryPenalty() { return ParanoiaInfection.CfgCarryPenaltyMinor?.Value ?? 0.15f; } protected override float GetFatigueSpikeDuration() { return ParanoiaInfection.CfgMinorFatigueSeconds?.Value ?? 2f; } } internal sealed class SE_Pix_InfectedMedium : SE_Pix_InfectedBase { protected override float GetCarryPenalty() { return ParanoiaInfection.CfgCarryPenaltyMedium?.Value ?? 0.25f; } protected override float GetFatigueSpikeDuration() { return ParanoiaInfection.CfgMediumFatigueSeconds?.Value ?? 5f; } } internal sealed class SE_Pix_InfectedTerminal : SE_Pix_InfectedBase { private float _nextWarningAt; private bool _criticalWarningShown; protected override float GetCarryPenalty() { return ParanoiaInfection.CfgCarryPenaltyTerminal?.Value ?? 0.35f; } protected override float GetFatigueSpikeDuration() { return ParanoiaInfection.CfgTerminalFatigueSeconds?.Value ?? 7f; } protected override float GetFatigueSpikeInterval() { return 45f; } public override void Setup(Character character) { base.Setup(character); _nextWarningAt = 0f; _criticalWarningShown = false; } public override void UpdateStatusEffect(float dt) { base.UpdateStatusEffect(dt); if ((Object)(object)((StatusEffect)this).m_character == (Object)null) { return; } Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { float num = ((StatusEffect)this).m_ttl - ((StatusEffect)this).GetDuration(); if (num <= 60f && !_criticalWarningShown) { _criticalWarningShown = true; ((Character)val).Message((MessageType)2, "The infection is reaching critical levels!", 0, (Sprite)null); } if (num <= 30f && ((StatusEffect)this).m_time >= _nextWarningAt) { _nextWarningAt = ((StatusEffect)this).m_time + 10f; ((Character)val).Message((MessageType)1, "Your heart races... find an antidote!", 0, (Sprite)null); } } } public override bool IsDone() { if ((double)((StatusEffect)this).m_ttl <= 0.0 || (double)((StatusEffect)this).m_time <= (double)((StatusEffect)this).m_ttl) { return false; } Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && !((Character)val).IsDead()) { ParanoiaInfection.InfectionKill(val); } return true; } } internal sealed class SE_Pix_AntidoteWorking : StatusEffect { private bool _hadTerminalInfection; public override void Setup(Character character) { ((StatusEffect)this).Setup(character); Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { SEMan sEMan = ((Character)val).GetSEMan(); _hadTerminalInfection = sEMan != null && sEMan.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Pix_InfectedTerminal")); } } public override string GetIconText() { if ((double)base.m_ttl > 0.0) { return StatusEffect.GetTimeString(base.m_ttl - ((StatusEffect)this).GetDuration(), false, false); } return ""; } public override string GetTooltipString() { return "The antidote is fighting the infection..."; } public override bool IsDone() { if ((double)base.m_ttl <= 0.0 || (double)base.m_time <= (double)base.m_ttl) { return false; } try { Character character = base.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { if (_hadTerminalInfection) { ParanoiaInfection.ApplyCured(val); } else { ParanoiaInfection.InfectionKill(val); } } } catch { } return true; } } internal sealed class SE_Pix_Cured : StatusEffect { public override bool IsDone() { return (double)base.m_ttl > 0.0 && (double)base.m_time > (double)base.m_ttl; } public override string GetIconText() { if ((double)base.m_ttl > 0.0) { return StatusEffect.GetTimeString(base.m_ttl - ((StatusEffect)this).GetDuration(), false, false); } return ""; } public override string GetTooltipString() { return "The antidote purges the infection."; } } } namespace Pix.Paranoia.Hallucinations { internal sealed class HallucinationBlurEffect : MonoBehaviour { private bool _active; private float _intensity; private float _targetIntensity; private const float FadeSpeed = 2f; private const int MaxRtStack = 8; private GameObject _vignetteOverlay; private RawImage _vignetteImage; private Texture2D _vignetteTex; private float _lastEdgeWidth = -1f; private float _lastEdgeSoft = -1f; internal static HallucinationBlurEffect Instance { get; private set; } private void Awake() { Instance = this; ((Behaviour)this).enabled = false; } internal void SetActive(bool on) { _targetIntensity = (on ? 1f : 0f); if (on && !_active) { _active = true; ((Behaviour)this).enabled = true; EnsureVignetteOverlay(); } } internal bool IsActive() { return _active; } private void EnsureVignetteOverlay() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_vignetteOverlay != (Object)null) { return; } try { _vignetteOverlay = new GameObject("PX_HallucinationVignette"); _vignetteOverlay.layer = LayerMask.NameToLayer("UI"); ((Object)_vignetteOverlay).hideFlags = (HideFlags)61; Canvas val = _vignetteOverlay.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 99; CanvasScaler val2 = _vignetteOverlay.AddComponent(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); GameObject val3 = new GameObject("VignetteImage"); val3.transform.SetParent(_vignetteOverlay.transform, false); val3.layer = LayerMask.NameToLayer("UI"); RectTransform val4 = val3.AddComponent(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.sizeDelta = Vector2.zero; val4.anchoredPosition = Vector2.zero; _vignetteImage = val3.AddComponent(); ((Graphic)_vignetteImage).raycastTarget = false; ((Graphic)_vignetteImage).color = new Color(0f, 0f, 0f, 0f); _vignetteOverlay.SetActive(false); } catch (Exception ex) { ParanoiaPlugin.LogWarn("[HallucinationBlur] Failed to create vignette overlay: " + ex.Message); } } private void BuildVignetteTexture(int size, float edgeWidth, float edgeSoft) { //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_0067: 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_007d: Expected O, but got Unknown //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) if ((Object)(object)_vignetteTex != (Object)null && Mathf.Approximately(_lastEdgeWidth, edgeWidth) && Mathf.Approximately(_lastEdgeSoft, edgeSoft)) { return; } if ((Object)(object)_vignetteTex != (Object)null) { Object.Destroy((Object)(object)_vignetteTex); } _vignetteTex = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; float num = (float)size * 0.5f; float num2 = Mathf.Clamp01(1f - edgeWidth); float num3 = edgeSoft * 0.5f; float num4 = Mathf.Max(num2 - num3, 0f); float num5 = Mathf.Min(num2 + num3, 1f); float num6 = Mathf.Max(num5 - num4, 0.001f); Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < size; i++) { float num7 = ((float)i - num) / num; float num8 = num7 * num7; for (int j = 0; j < size; j++) { float num9 = ((float)j - num) / num; float num10 = Mathf.Sqrt(num9 * num9 + num8); float num11 = num10 / 1.414f; float num12 = Mathf.Clamp01((num11 - num4) / num6); byte b = (byte)(num12 * 255f); array[i * size + j] = new Color32((byte)0, (byte)0, (byte)0, b); } } _vignetteTex.SetPixels32(array); _vignetteTex.Apply(false, true); _lastEdgeWidth = edgeWidth; _lastEdgeSoft = edgeSoft; if ((Object)(object)_vignetteImage != (Object)null) { _vignetteImage.texture = (Texture)(object)_vignetteTex; } } private void DestroyVignetteOverlay() { if ((Object)(object)_vignetteOverlay != (Object)null) { Object.Destroy((Object)(object)_vignetteOverlay); _vignetteOverlay = null; _vignetteImage = null; } } private void OnRenderImage(RenderTexture src, RenderTexture dst) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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) if (_intensity <= 0.001f) { Graphics.Blit((Texture)(object)src, dst); return; } try { int num = 3; int num2 = 1; float num3 = 1f; float num4 = 1.5f; float num5 = 0.3f; if (ParanoiaPlugin.CfgHallucinationBlurIterations != null) { num = Mathf.Clamp(ParanoiaPlugin.CfgHallucinationBlurIterations.Value, 1, 8); } if (ParanoiaPlugin.CfgHallucinationBlurDownsample != null) { num2 = Mathf.Clamp(ParanoiaPlugin.CfgHallucinationBlurDownsample.Value, 1, 4); } if (ParanoiaPlugin.CfgHallucinationBlurStrength != null) { num3 = ParanoiaPlugin.CfgHallucinationBlurStrength.Value; } if (ParanoiaPlugin.CfgHallucinationPulseSpeed != null) { num4 = ParanoiaPlugin.CfgHallucinationPulseSpeed.Value; } if (ParanoiaPlugin.CfgHallucinationPulseAmplitude != null) { num5 = ParanoiaPlugin.CfgHallucinationPulseAmplitude.Value; } float num6 = 1f + num5 * Mathf.Sin(Time.time * num4); float num7 = Mathf.Clamp01(num3 * _intensity * num6); int num8 = Mathf.Max(1, Mathf.RoundToInt((float)num * num7)); num8 = Mathf.Clamp(num8, 1, 8); int num9 = ((Texture)src).width; int num10 = ((Texture)src).height; RenderTextureFormat format = src.format; RenderTexture[] array = (RenderTexture[])(object)new RenderTexture[num8]; RenderTexture val = src; for (int i = 0; i < num8; i++) { num9 = Mathf.Max(num9 >> num2, 1); num10 = Mathf.Max(num10 >> num2, 1); RenderTexture temporary = RenderTexture.GetTemporary(num9, num10, 0, format); ((Texture)temporary).filterMode = (FilterMode)1; Graphics.Blit((Texture)(object)val, temporary); array[i] = temporary; val = temporary; } for (int num11 = num8 - 1; num11 > 0; num11--) { Graphics.Blit((Texture)(object)array[num11], array[num11 - 1]); } Graphics.Blit((Texture)(object)array[0], dst); for (int j = 0; j < num8; j++) { RenderTexture.ReleaseTemporary(array[j]); } } catch { Graphics.Blit((Texture)(object)src, dst); } } private void Update() { //IL_01cd: Unknown result type (might be due to invalid IL or missing references) try { if (Mathf.Abs(_intensity - _targetIntensity) > 0.001f) { _intensity = Mathf.MoveTowards(_intensity, _targetIntensity, 2f * Time.deltaTime); } else { _intensity = _targetIntensity; } if (_intensity <= 0f && _active) { _active = false; ((Behaviour)this).enabled = false; if ((Object)(object)_vignetteOverlay != (Object)null) { _vignetteOverlay.SetActive(false); } } else if (_active) { float edgeWidth = 0.4f; float edgeSoft = 0.3f; float num = 1.5f; float num2 = 0.3f; if (ParanoiaPlugin.CfgHallucinationEdgeWidth != null) { edgeWidth = ParanoiaPlugin.CfgHallucinationEdgeWidth.Value; } if (ParanoiaPlugin.CfgHallucinationEdgeSoftness != null) { edgeSoft = ParanoiaPlugin.CfgHallucinationEdgeSoftness.Value; } if (ParanoiaPlugin.CfgHallucinationPulseSpeed != null) { num = ParanoiaPlugin.CfgHallucinationPulseSpeed.Value; } if (ParanoiaPlugin.CfgHallucinationPulseAmplitude != null) { num2 = ParanoiaPlugin.CfgHallucinationPulseAmplitude.Value; } BuildVignetteTexture(256, edgeWidth, edgeSoft); float num3 = 1f + num2 * Mathf.Sin(Time.time * num); float num4 = Mathf.Clamp01(_intensity * num3 * 0.7f); EnsureVignetteOverlay(); if ((Object)(object)_vignetteOverlay != (Object)null && !_vignetteOverlay.activeSelf) { _vignetteOverlay.SetActive(true); } if ((Object)(object)_vignetteImage != (Object)null) { ((Graphic)_vignetteImage).color = new Color(0f, 0f, 0f, num4); } } } catch { } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } DestroyVignetteOverlay(); if ((Object)(object)_vignetteTex != (Object)null) { Object.Destroy((Object)(object)_vignetteTex); _vignetteTex = null; } } private void OnDisable() { _intensity = 0f; _active = false; if ((Object)(object)_vignetteOverlay != (Object)null) { _vignetteOverlay.SetActive(false); } } } internal sealed class HallucinationManager : MonoBehaviour { private const string HallucinateSeName = "SE_Pix_Hallucinate"; private static readonly int HallucinateSeHash = StringExtensionMethods.GetStableHashCode("SE_Pix_Hallucinate"); private bool _isInDungeon; private float _dungeonEntryTime; private bool _warningShown; private bool _hallucinationApplied; private float _nextHallucinationAllowedAt; private string _dungeonType = ""; private Biome _preDungeonBiome = (Biome)0; private readonly List _fakeCreatures = new List(); private float _nextFakeCreatureSpawnAt; private float _nextFakeCreatureCleanupAt; private static List _cachedAllCreaturePrefabs; private static List _cachedChaoticPrefabs; private static Dictionary> _cachedBiomePrefabs; private static int _cachedPrefabCount; private static readonly Dictionary s_biomeCreatureNames = new Dictionary { { (Biome)1, new string[4] { "Boar", "Deer", "Neck", "Greyling" } }, { (Biome)8, new string[6] { "Greydwarf", "Greydwarf_Elite", "Greydwarf_Shaman", "Skeleton", "Ghost", "Troll" } }, { (Biome)256, new string[2] { "Serpent", "Leviathan" } }, { (Biome)2, new string[6] { "Draugr", "Blob", "BlobElite", "Wraith", "Leech", "Abomination" } }, { (Biome)4, new string[5] { "Wolf", "Fenring", "StoneGolem", "Hatchling", "Ulv" } }, { (Biome)16, new string[5] { "Goblin", "GoblinBrute", "GoblinShaman", "Lox", "Deathsquito" } }, { (Biome)512, new string[5] { "Seeker", "SeekerBrute", "Gjall", "Tick", "Dverger" } }, { (Biome)32, new string[1] { "Morgen" } } }; private static readonly FieldInfo s_fiRightItem = typeof(Humanoid).GetField("m_rightItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo s_fiLeftItem = typeof(Humanoid).GetField("m_leftItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); public static HallucinationManager Instance { get; private set; } private void Awake() { Instance = this; } private void Update() { try { if (!ParanoiaPlugin.Enabled.Value) { CleanupFakeCreatures(); return; } if (!ParanoiaPlugin.CfgHallucinationEnabled.Value) { CleanupFakeCreatures(); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { CleanupFakeCreatures(); ResetDungeonState(); return; } if (Time.time >= _nextFakeCreatureCleanupAt) { CleanupDistantFakeCreatures(localPlayer); _nextFakeCreatureCleanupAt = Time.time + 0.5f; } UpdateDungeonDetection(localPlayer); UpdateFakeCreatureSpawning(localPlayer); } catch { } } private void UpdateDungeonDetection(Player player) { try { bool flag = IsInDungeon(player); if (flag && !_isInDungeon) { _dungeonType = GetDungeonType(player); ParanoiaPlugin.LogDebug($"[Hallucination] Detected dungeon type: {_dungeonType}, onset time: {GetOnsetTimeForDungeon(_dungeonType)}s"); OnDungeonEntered(); } else if (!flag && _isInDungeon) { OnDungeonExited(); } if (_isInDungeon && !_hallucinationApplied) { float num = Time.time - _dungeonEntryTime; float value = ParanoiaPlugin.CfgHallucinationWarningTimeSeconds.Value; float onsetTimeForDungeon = GetOnsetTimeForDungeon(_dungeonType); if (!_warningShown && num >= value) { ShowWarningMessage(player); _warningShown = true; } if (num >= onsetTimeForDungeon) { ApplyHallucination(player); } } } catch { } } private bool IsInDungeon(Player player) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_003d: Invalid comparison between Unknown and I4 try { if ((Object)(object)player == (Object)null) { return false; } Vector3 position = ((Component)player).transform.position; if (position.y > 3000f) { return true; } Biome val = Heightmap.FindBiome(position); if ((int)val == 0) { return true; } return false; } catch { return false; } } private void OnDungeonEntered() { //IL_0079: 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_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) try { if (Time.time < _nextHallucinationAllowedAt) { return; } _isInDungeon = true; _dungeonEntryTime = Time.time; _warningShown = false; _hallucinationApplied = false; try { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && WorldGenerator.instance != null) { _preDungeonBiome = WorldGenerator.instance.GetBiome(((Component)localPlayer).transform.position); } } catch { _preDungeonBiome = (Biome)0; } ParanoiaPlugin.LogDebug($"[Hallucination] Player entered dungeon, pre-dungeon biome: {_preDungeonBiome}"); } catch { } } private void OnDungeonExited() { try { ParanoiaPlugin.LogDebug("[Hallucination] Player exited dungeon"); ResetDungeonState(); } catch { } } private void ResetDungeonState() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) _isInDungeon = false; _warningShown = false; _hallucinationApplied = false; _dungeonType = ""; _preDungeonBiome = (Biome)0; CleanupFakeCreatures(); RestoreRainbowMaterials(); } private static string GetDungeonType(Player player) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null) { return ""; } Location location = Location.GetLocation(((Component)player).transform.position, true); if ((Object)(object)location == (Object)null) { return ""; } string text = ((Object)((Component)location).gameObject).name; if (string.IsNullOrEmpty(text)) { return ""; } if (text.Contains("(Clone)")) { text = text.Replace("(Clone)", "").Trim(); } return text; } catch { return ""; } } private static float GetOnsetTimeForDungeon(string dungeonType) { try { if (string.IsNullOrEmpty(dungeonType)) { return ParanoiaPlugin.CfgHallucinationTriggerTimeSeconds?.Value ?? 60f; } if (dungeonType.Contains("DG_ForestCrypt")) { return ParanoiaPlugin.CfgHallucinationOnsetBurialChambers?.Value ?? 30f; } if (dungeonType.Contains("DG_TrollCave")) { return ParanoiaPlugin.CfgHallucinationOnsetTrollCave?.Value ?? 45f; } if (dungeonType.Contains("DG_SunkenCrypt")) { return ParanoiaPlugin.CfgHallucinationOnsetSunkenCrypt?.Value ?? 60f; } if (dungeonType.Contains("DG_FrostCave")) { return ParanoiaPlugin.CfgHallucinationOnsetFrostCave?.Value ?? 75f; } if (dungeonType.Contains("DG_SealedTower")) { return ParanoiaPlugin.CfgHallucinationOnsetSealedTower?.Value ?? 90f; } if (dungeonType.Contains("DG_DvergrMine")) { return ParanoiaPlugin.CfgHallucinationOnsetInfestedMine?.Value ?? 105f; } if (dungeonType.Contains("DG_PutridHole")) { return ParanoiaPlugin.CfgHallucinationOnsetPutridHole?.Value ?? 120f; } if (dungeonType.Contains("DG_SmoulderingTomb")) { return ParanoiaPlugin.CfgHallucinationOnsetSmoulderingTomb?.Value ?? 150f; } return ParanoiaPlugin.CfgHallucinationTriggerTimeSeconds?.Value ?? 60f; } catch { return 60f; } } private void RestoreRainbowMaterials() { try { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { SEMan sEMan = ((Character)localPlayer).GetSEMan(); SE_Pix_Hallucinate sE_Pix_Hallucinate = ((sEMan != null) ? sEMan.GetStatusEffect(HallucinateSeHash) : null) as SE_Pix_Hallucinate; if ((Object)(object)sE_Pix_Hallucinate != (Object)null) { sE_Pix_Hallucinate.CleanupEffects(); } } } catch { } } private void ShowWarningMessage(Player player) { try { if (!((Object)(object)player == (Object)null)) { string text = ParanoiaPlugin.CfgHallucinationWarningMessage.Value; if (string.IsNullOrEmpty(text)) { text = "Be quick, the air is thick."; } ((Character)player).Message((MessageType)2, text, 0, (Sprite)null); ParanoiaPlugin.LogDebug("[Hallucination] Warning shown: " + text); } } catch { } } private void ApplyHallucination(Player player) { try { if ((Object)(object)player == (Object)null || _hallucinationApplied) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return; } bool flag = false; try { flag = sEMan.HaveStatusEffect(HallucinateSeHash); } catch { flag = false; } if (!flag) { sEMan.AddStatusEffect(HallucinateSeHash, true, 0, 0f); string text = ParanoiaPlugin.CfgHallucinationTriggerMessage.Value; if (string.IsNullOrEmpty(text)) { text = "Your mind begins to warp"; } ((Character)player).Message((MessageType)2, text, 0, (Sprite)null); ParanoiaPlugin.LogDebug("[Hallucination] Status effect applied"); } _hallucinationApplied = true; _nextHallucinationAllowedAt = Time.time + ParanoiaPlugin.CfgHallucinationGlobalCooldownSeconds.Value; } catch { } } private void UpdateFakeCreatureSpawning(Player player) { try { if ((Object)(object)player == (Object)null) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return; } bool flag = false; try { flag = sEMan.HaveStatusEffect(HallucinateSeHash); } catch { flag = false; } if (!flag) { CleanupFakeCreatures(); return; } CleanupDeadFakeCreatures(); if (!(Time.time < _nextFakeCreatureSpawnAt)) { int value = ParanoiaPlugin.CfgHallucinationMaxFakeCreatures.Value; if (_fakeCreatures.Count < value) { SpawnFakeCreature(player); float value2 = ParanoiaPlugin.CfgHallucinationFakeCreatureSpawnInterval.Value; _nextFakeCreatureSpawnAt = Time.time + value2; } } } catch { } } private static void RebuildPrefabCache() { //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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) _cachedAllCreaturePrefabs = new List(); _cachedChaoticPrefabs = new List(); _cachedBiomePrefabs = new Dictionary>(); _cachedPrefabCount = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.m_prefabs.Count : 0); Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } Character component = prefab.GetComponent(); if ((Object)(object)component == (Object)null || component is Player) { continue; } _cachedChaoticPrefabs.Add(prefab); Humanoid val = (Humanoid)(object)((component is Humanoid) ? component : null); if (!((Object)(object)val != (Object)null) || !((Character)val).IsBoss()) { _cachedAllCreaturePrefabs.Add(prefab); if (!dictionary.ContainsKey(((Object)prefab).name)) { dictionary[((Object)prefab).name] = prefab; } } } foreach (KeyValuePair s_biomeCreatureName in s_biomeCreatureNames) { Biome key = s_biomeCreatureName.Key; string[] value = s_biomeCreatureName.Value; List list = new List(); for (int i = 0; i < value.Length; i++) { if (dictionary.TryGetValue(value[i], out var value2)) { list.Add(value2); } } if (list.Count > 0) { _cachedBiomePrefabs[key] = list; } } ParanoiaPlugin.LogDebug($"[Hallucination] Prefab cache built: {_cachedAllCreaturePrefabs.Count} creatures, {_cachedChaoticPrefabs.Count} chaotic, {_cachedBiomePrefabs.Count} biomes mapped"); } private void SpawnFakeCreature(Player player) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Invalid comparison between Unknown and I4 //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Invalid comparison between Unknown and I4 //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null || (Object)(object)ZNetScene.instance == (Object)null) { return; } int count = ZNetScene.instance.m_prefabs.Count; if (_cachedAllCreaturePrefabs == null || _cachedPrefabCount != count) { RebuildPrefabCache(); } if (_cachedAllCreaturePrefabs == null || _cachedAllCreaturePrefabs.Count == 0) { return; } bool flag = ParanoiaPlugin.CfgHallucinationFakeCreatureChaotic != null && ParanoiaPlugin.CfgHallucinationFakeCreatureChaotic.Value; List value = null; if (flag) { value = _cachedChaoticPrefabs; } else { Biome val = (Biome)0; if ((int)_preDungeonBiome > 0) { val = _preDungeonBiome; } else { try { val = Heightmap.FindBiome(((Component)player).transform.position); } catch { } if ((int)val == 0) { try { if (WorldGenerator.instance != null) { val = WorldGenerator.instance.GetBiome(((Component)player).transform.position); } } catch { } } } if (_cachedBiomePrefabs != null && (int)val > 0) { _cachedBiomePrefabs.TryGetValue(val, out value); } ParanoiaPlugin.LogDebug($"[Hallucination] Spawn attempt - biome={val}, poolSize={value?.Count ?? 0}"); bool flag2 = ParanoiaPlugin.CfgHallucinationFakeCreatureBiomeOnly != null && ParanoiaPlugin.CfgHallucinationFakeCreatureBiomeOnly.Value; if (value == null || value.Count == 0) { if (flag2) { return; } value = _cachedAllCreaturePrefabs; } } GameObject val2 = value[Random.Range(0, value.Count)]; Vector3 val3 = FindSpawnPosition(player); Quaternion val4 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); GameObject val5 = Object.Instantiate(val2, val3, val4); if ((Object)(object)val5 == (Object)null) { return; } ((Object)val5).name = ((Object)val2).name + "_hallucination"; ZNetView component = val5.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = false; ZDO zDO = component.GetZDO(); if (zDO != null) { zDO.Persistent = false; } } NeuterFakeCreature(val5); FakeCreatureMarker fakeCreatureMarker = val5.AddComponent(); if ((Object)(object)fakeCreatureMarker != (Object)null) { fakeCreatureMarker.Initialize(this); } _fakeCreatures.Add(val5); ParanoiaPlugin.LogDebug($"[Hallucination] Spawned fake creature: {((Object)val2).name} at {val3}"); } catch (Exception ex) { ParanoiaPlugin.LogWarn("[Hallucination] Failed to spawn fake creature: " + ex.Message); } } private static void NeuterFakeCreature(GameObject go) { try { Humanoid component = go.GetComponent(); if ((Object)(object)component != (Object)null) { try { component.UnequipAllItems(); } catch { } component.m_defaultItems = Array.Empty(); component.m_randomWeapon = Array.Empty(); component.m_randomArmor = Array.Empty(); component.m_randomShield = Array.Empty(); component.m_randomSets = Array.Empty(); component.m_randomItems = Array.Empty(); component.m_unarmedWeapon = null; try { if (s_fiRightItem != null) { s_fiRightItem.SetValue(component, null); } } catch { } try { if (s_fiLeftItem != null) { s_fiLeftItem.SetValue(component, null); } } catch { } try { Inventory inventory = component.GetInventory(); if (inventory != null) { inventory.RemoveAll(); } } catch { } } CharacterDrop component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { try { component2.SetDropsEnabled(false); } catch { } try { component2.m_drops.Clear(); return; } catch { return; } } } catch { } } private Vector3 FindSpawnPosition(Player player) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) try { float value = ParanoiaPlugin.CfgHallucinationFakeCreatureMinDistance.Value; float value2 = ParanoiaPlugin.CfgHallucinationFakeCreatureMaxDistance.Value; Vector3 val = default(Vector3); float num3 = default(float); for (int i = 0; i < 10; i++) { float num = Random.Range(0f, 360f) * ((float)Math.PI / 180f); float num2 = Random.Range(value, value2); ((Vector3)(ref val))..ctor(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2); Vector3 val2 = ((Component)player).transform.position + val; if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val2, ref num3)) { val2.y = num3 + 0.5f; return val2; } } return ((Component)player).transform.position + ((Component)player).transform.forward * value; } catch { return ((Component)player).transform.position + Vector3.forward * 10f; } } internal void OnFakeCreatureHit(GameObject fakeCreature) { try { if (!((Object)(object)fakeCreature == (Object)null)) { ParanoiaPlugin.LogDebug("[Hallucination] Fake creature hit, despawning: " + ((Object)fakeCreature).name); _fakeCreatures.Remove(fakeCreature); DestroyFakeCreature(fakeCreature); } } catch { } } private void CleanupDistantFakeCreatures(Player player) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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) try { if ((Object)(object)player == (Object)null) { return; } float num = 100f; Vector3 position = ((Component)player).transform.position; for (int num2 = _fakeCreatures.Count - 1; num2 >= 0; num2--) { GameObject val = _fakeCreatures[num2]; if ((Object)(object)val == (Object)null) { _fakeCreatures.RemoveAt(num2); } else { float num3 = Vector3.Distance(val.transform.position, position); if (num3 > num) { ParanoiaPlugin.LogDebug($"[Hallucination] Destroying distant fake creature: {((Object)val).name} at distance {num3}"); DestroyFakeCreature(val); _fakeCreatures.RemoveAt(num2); } } } } catch { } } private void CleanupDeadFakeCreatures() { try { _fakeCreatures.RemoveAll((GameObject fc) => (Object)(object)fc == (Object)null); } catch { } } private void CleanupFakeCreatures() { try { foreach (GameObject fakeCreature in _fakeCreatures) { if ((Object)(object)fakeCreature != (Object)null) { DestroyFakeCreature(fakeCreature); } } _fakeCreatures.Clear(); } catch { } } private static void DestroyFakeCreature(GameObject fc) { try { if (!((Object)(object)fc == (Object)null)) { ZNetView component = fc.GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid() && (Object)(object)ZNetScene.instance != (Object)null) { ZNetScene.instance.Destroy(fc); } else { Object.Destroy((Object)(object)fc); } } } catch { try { Object.Destroy((Object)(object)fc); } catch { } } } internal void CleanupAllFakeCreatures() { try { ParanoiaPlugin.LogDebug("[Hallucination] Force cleanup all fake creatures (logout/death/teleport)"); CleanupFakeCreatures(); } catch { } } private void OnDestroy() { CleanupFakeCreatures(); } } internal sealed class FakeCreatureMarker : MonoBehaviour { private HallucinationManager _manager; private Character _character; private bool _initialized; internal void Initialize(HallucinationManager manager) { _manager = manager; _character = ((Component)this).GetComponent(); _initialized = true; } private void Update() { try { if (_initialized && !((Object)(object)_manager == (Object)null) && (Object)(object)_character != (Object)null && _character.IsDead()) { _manager.OnFakeCreatureHit(((Component)this).gameObject); } } catch { } } } internal sealed class SE_Pix_Hallucinate : StatusEffect { private static Sprite _iconCached; private static bool _iconIsCustom; private static DateTime _customIconWriteUtc; private float _rainbowCycleTime; private float _nextRendererRefreshAt; private List _trackedRenderers = new List(); private Dictionary _originalMaterials = new Dictionary(); private Material _rainbowMaterial; public override void Setup(Character character) { ((StatusEffect)this).Setup(character); if (character is Player) { ActivateBlurEffect(); StartRainbowEffect(); } } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (base.m_character is Player) { ActivateBlurEffect(); UpdateRainbowEffect(dt); } else { CleanupEffects(); } } public override void Stop() { CleanupEffects(); ((StatusEffect)this).Stop(); } private void ActivateBlurEffect() { try { Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { HallucinationBlurEffect hallucinationBlurEffect = ((Component)main).GetComponent(); if ((Object)(object)hallucinationBlurEffect == (Object)null) { hallucinationBlurEffect = ((Component)main).gameObject.AddComponent(); } hallucinationBlurEffect.SetActive(on: true); } } catch { } } private void DeactivateBlurEffect() { try { if ((Object)(object)HallucinationBlurEffect.Instance != (Object)null) { HallucinationBlurEffect.Instance.SetActive(on: false); } } catch { } } private void StartRainbowEffect() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown try { _rainbowCycleTime = 0f; _trackedRenderers.Clear(); _originalMaterials.Clear(); if ((Object)(object)_rainbowMaterial == (Object)null) { _rainbowMaterial = new Material(Shader.Find("Standard")); _rainbowMaterial.SetFloat("_Mode", 2f); _rainbowMaterial.SetInt("_SrcBlend", 5); _rainbowMaterial.SetInt("_DstBlend", 10); _rainbowMaterial.SetInt("_ZWrite", 0); _rainbowMaterial.DisableKeyword("_ALPHATEST_ON"); _rainbowMaterial.EnableKeyword("_ALPHABLEND_ON"); _rainbowMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON"); _rainbowMaterial.renderQueue = 3000; } } catch { } } private void UpdateRainbowEffect(float dt) { //IL_0044: 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_0072: 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) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) try { if (!ParanoiaPlugin.CfgHallucinationRainbowEnabled.Value) { return; } _rainbowCycleTime += dt; float num = _rainbowCycleTime * 0.3f % 1f; Color val = Color.HSVToRGB(num, 0.8f, 1f); val.a = 0.3f; if ((Object)(object)_rainbowMaterial != (Object)null) { _rainbowMaterial.SetColor("_Color", val); _rainbowMaterial.SetColor("_EmissionColor", val * 0.5f); } RefreshTrackedRenderers(); foreach (Renderer trackedRenderer in _trackedRenderers) { if ((Object)(object)trackedRenderer == (Object)null || !trackedRenderer.enabled) { continue; } try { if (!_originalMaterials.ContainsKey(trackedRenderer)) { _originalMaterials[trackedRenderer] = trackedRenderer.materials; } Material[] materials = trackedRenderer.materials; for (int i = 0; i < materials.Length; i++) { if ((Object)(object)materials[i] != (Object)null && (Object)(object)materials[i] != (Object)(object)_rainbowMaterial) { materials[i].SetColor("_EmissionColor", val * 0.2f); materials[i].EnableKeyword("_EMISSION"); } } } catch { } } } catch { } } private void RefreshTrackedRenderers() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) try { if (Time.time < _nextRendererRefreshAt) { return; } _nextRendererRefreshAt = Time.time + 0.5f; float maxDist = ParanoiaPlugin.CfgHallucinationRainbowDistance.Value; Vector3 playerPos = ((Component)base.m_character).transform.position; _trackedRenderers.RemoveAll(delegate(Renderer r) { //IL_002c: 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_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)r == (Object)null || !((Component)r).gameObject.activeInHierarchy) { return true; } float num = Vector3.Distance(((Component)r).transform.position, playerPos); if (num > maxDist) { if (_originalMaterials.ContainsKey(r)) { try { r.materials = _originalMaterials[r]; Material[] materials = r.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 != (Object)null) { val2.DisableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", Color.black); } } } catch { } _originalMaterials.Remove(r); } return true; } return false; }); Renderer[] array = Object.FindObjectsByType((FindObjectsSortMode)0); Renderer[] array2 = array; foreach (Renderer val in array2) { if ((Object)(object)val == (Object)null || !val.enabled || _trackedRenderers.Contains(val) || Vector3.Distance(((Component)val).transform.position, playerPos) > maxDist) { continue; } GameObject gameObject = ((Component)val).gameObject; if (!((Object)(object)gameObject == (Object)null) && !((Object)(object)gameObject.GetComponent() != (Object)null) && !((Object)(object)gameObject.GetComponent() != (Object)null) && !((Object)gameObject).name.Contains("_ghost") && !((Object)gameObject).name.Contains("GUI") && !((Object)gameObject).name.Contains("UI")) { _trackedRenderers.Add(val); if (_trackedRenderers.Count >= 100) { break; } } } } catch { } } internal void CleanupEffects() { try { DeactivateBlurEffect(); RestoreOriginalMaterials(); _trackedRenderers.Clear(); _originalMaterials.Clear(); } catch { } } private void RestoreOriginalMaterials() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) try { foreach (KeyValuePair originalMaterial in _originalMaterials) { if (!((Object)(object)originalMaterial.Key != (Object)null) || originalMaterial.Value == null) { continue; } try { originalMaterial.Key.materials = originalMaterial.Value; Material[] materials = originalMaterial.Key.materials; foreach (Material val in materials) { if ((Object)(object)val != (Object)null) { val.DisableKeyword("_EMISSION"); val.SetColor("_EmissionColor", Color.black); } } } catch { } } } catch { } } public override string GetTooltipString() { return "Your mind is warping. Reality feels... unstable."; } internal static void EnsureIcon(SE_Pix_Hallucinate se, ObjectDB odb) { PngIconLoader.EnsureIcon("HallucinateSE.png", "poison", (StatusEffect)(object)se, odb, ref _iconCached, ref _iconIsCustom, ref _customIconWriteUtc); } } } namespace Pix.Paranoia.Creatures { public static class ParanoiaGreydwarfs { private sealed class ParanoiaWhisperingGreydwarfMarker : MonoBehaviour { } private static bool _initialized; private static AudioClip _whisperClip; private static readonly HashSet _targetPrefabs = new HashSet(StringComparer.OrdinalIgnoreCase) { "Greydwarf", "Greydwarf_Shaman", "Greydwarf_Elite" }; private static readonly HashSet _whisperingGreydwarfs = new HashSet(); public static void Init(Harmony harmony) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if (_initialized) { return; } try { harmony.Patch((MethodBase)AccessTools.Method(typeof(Character), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ParanoiaGreydwarfs), "Character_Awake_Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _initialized = true; } catch (Exception ex) { Debug.LogError((object)("[ParanoiaGreydwarfs] Init failed: " + ex.Message)); } } [HarmonyPostfix] [HarmonyPatch(typeof(Character), "Awake")] private static void Character_Awake_Postfix(Character __instance) { try { ConfigEntry cfgWhisperingGreydwarfEnabled = ParanoiaPlugin.CfgWhisperingGreydwarfEnabled; if (cfgWhisperingGreydwarfEnabled == null || !cfgWhisperingGreydwarfEnabled.Value || (Object)(object)__instance == (Object)null || __instance is Player) { return; } string prefabName = GetPrefabName(((Component)__instance).gameObject); if (string.IsNullOrEmpty(prefabName) || !_targetPrefabs.Contains(prefabName)) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!_whisperingGreydwarfs.Contains(instanceID)) { float num = ParanoiaPlugin.CfgWhisperingGreydwarfChance?.Value ?? 0.15f; if (!(Random.value > num)) { MakeWhispering(__instance); _whisperingGreydwarfs.Add(instanceID); } } } catch (Exception ex) { Debug.LogWarning((object)("[ParanoiaGreydwarfs] Character_Awake_Postfix error: " + ex.Message)); } } private static void MakeWhispering(Character character) { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)character == (Object)null) { return; } if ((Object)(object)_whisperClip == (Object)null) { _whisperClip = FindWhisperClip(); if ((Object)(object)_whisperClip == (Object)null) { Debug.LogWarning((object)"[ParanoiaGreydwarfs] Could not find DemonicWhisperLoop audio clip"); return; } } AudioSource[] componentsInChildren = ((Component)character).GetComponentsInChildren(true); AudioSource[] array = componentsInChildren; foreach (AudioSource val in array) { if (!((Object)(object)val == (Object)null)) { val.mute = true; val.volume = 0f; } } BaseAI component = ((Component)character).GetComponent(); if ((Object)(object)component != (Object)null) { ((MonoBehaviour)component).CancelInvoke("DoIdleSound"); } ZSFX[] componentsInChildren2 = ((Component)character).GetComponentsInChildren(true); ZSFX[] array2 = componentsInChildren2; foreach (ZSFX val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { val2.m_playOnAwake = false; val2.Stop(); } } GameObject val3 = new GameObject("ParanoiaWhisper"); val3.transform.SetParent(((Component)character).transform); val3.transform.localPosition = Vector3.zero; AudioSource val4 = val3.AddComponent(); val4.clip = _whisperClip; val4.loop = true; val4.volume = 0.3f; val4.spatialBlend = 1f; val4.minDistance = 2f; val4.maxDistance = 15f; val4.rolloffMode = (AudioRolloffMode)1; val4.Play(); ((Component)character).gameObject.AddComponent(); } catch (Exception ex) { Debug.LogWarning((object)("[ParanoiaGreydwarfs] MakeWhispering error: " + ex.Message)); } } private static AudioClip FindWhisperClip() { try { GameObject[] array = Resources.FindObjectsOfTypeAll(); GameObject[] array2 = array; foreach (GameObject val in array2) { AudioSource[] componentsInChildren = val.GetComponentsInChildren(true); AudioSource[] array3 = componentsInChildren; foreach (AudioSource val2 in array3) { if ((Object)(object)val2.clip != (Object)null && ((Object)val2.clip).name.Contains("DemonicWhisperLoop")) { return val2.clip; } } } ZSFX[] array4 = Resources.FindObjectsOfTypeAll(); ZSFX[] array5 = array4; foreach (ZSFX val3 in array5) { if (val3.m_audioClips == null) { continue; } AudioClip[] audioClips = val3.m_audioClips; foreach (AudioClip val4 in audioClips) { if ((Object)(object)val4 != (Object)null && ((Object)val4).name.Contains("DemonicWhisperLoop")) { return val4; } } } } catch (Exception ex) { Debug.LogWarning((object)("[ParanoiaGreydwarfs] FindWhisperClip error: " + ex.Message)); } return null; } private static string GetPrefabName(GameObject go) { if ((Object)(object)go == (Object)null) { return null; } string text = ((Object)go).name; if (string.IsNullOrEmpty(text)) { return null; } int num = text.IndexOf("(Clone)", StringComparison.OrdinalIgnoreCase); if (num > 0) { text = text.Substring(0, num).Trim(); } return text; } public static void Cleanup() { _whisperingGreydwarfs.Clear(); } } internal static class ParanoiaSerpent { private sealed class PxPullRunner : MonoBehaviour { [CompilerGenerated] private sealed class d__30 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PxPullRunner <>4__this; private Player 5__1; private Character 5__2; private Vector3 5__3; private Vector3 5__4; private Vector3 5__5; private float 5__6; private Vector3 5__7; private Rigidbody 5__8; private float 5__9; private float 5__10; private float 5__11; private float 5__12; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__30(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__8 = null; <>1__state = -2; } private bool MoveNext() { //IL_005a: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; 5__1 = null; 5__2 = null; 5__8 = null; break; } if (Time.time < <>4__this._endAt) { 5__1 = Player.m_localPlayer; if ((Object)(object)5__1 == (Object)null) { <>4__this.CleanupTether(); return false; } 5__2 = FindCharacterByZdo(<>4__this._serpentId); if ((Object)(object)5__2 != (Object)null) { <>4__this._lastSerpentSeenAt = Time.time; <>4__this._lastSerpentPos = ((Component)5__2).transform.position; } else if (<>4__this._lastSerpentSeenAt <= 0f || Time.time - <>4__this._lastSerpentSeenAt > 2f) { <>4__this.CleanupTether(); return false; } <>4__this.EnsureTether(); <>4__this.UpdateTether(<>4__this._lastSerpentPos, 5__1); 5__3 = ((Component)5__1).transform.position; 5__4 = <>4__this._lastSerpentPos + Vector3.up * 0.8f; 5__5 = 5__4 - 5__3; 5__6 = ((Vector3)(ref 5__5)).magnitude; if (5__6 > 0.05f) { 5__5 /= 5__6; } else { 5__5 = Vector3.zero; } 5__7 = 5__5 * <>4__this._force; 5__8 = CharacterBodyRef.Invoke((Character)(object)5__1); if ((Object)(object)5__8 != (Object)null) { if (!<>4__this._didStartPop) { <>4__this._didStartPop = true; 5__10 = 5__8.velocity.y; if (5__10 < <>4__this._startPopVyGate && IsGroundedish(5__1, <>4__this._startPopGroundedDist)) { 5__8.AddForce(Vector3.up * <>4__this._startPopImpulse, (ForceMode)2); } } 5__9 = Time.time - <>4__this._startedAt; if (5__9 <= 0.85f) { 5__11 = 5__8.velocity.y; if (5__11 < 2.5f) { 5__12 = Mathf.Min(<>4__this._up, 1.25f); 5__7.y = Mathf.Max(5__7.y, 5__12); } } 5__8.AddForce(5__7, (ForceMode)2); } <>2__current = (object)new WaitForFixedUpdate(); <>1__state = 1; return true; } <>4__this.CleanupTether(); ((Behaviour)<>4__this).enabled = false; <>4__this._co = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private ManualLogSource _logger; private Coroutine _co; private ZDOID _serpentId; private float _startedAt; private float _endAt; private float _force; private float _up; private const float SerpentLostGraceSeconds = 2f; private float _lastSerpentSeenAt; private Vector3 _lastSerpentPos; private const float UpPhaseSeconds = 0.85f; private const float UpVelGate = 2.5f; private const float UpPerTickClamp = 1.25f; private const float UpMaxInputClamp = 6.5f; private bool _didStartPop = false; private float _startPopImpulse = 10f; private float _startPopVyGate = 1.5f; private float _startPopGroundedDist = 1.2f; private GameObject _tetherGo; private LineRenderer _tetherLr; private Material _tetherMat; internal void Init(ManualLogSource logger) { _logger = logger; } internal void StartPull(ZDOID serpentId, float duration, float forcePerTick, float upBoost) { //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_0061: 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) _serpentId = serpentId; float num = Mathf.Max(0.2f, duration); _startedAt = Time.time; _endAt = _startedAt + num; _force = Mathf.Max(1f, forcePerTick); _up = Mathf.Clamp(upBoost, 0f, 6.5f); _lastSerpentSeenAt = 0f; _lastSerpentPos = Vector3.zero; _didStartPop = false; EnsureTether(); if (_co != null) { ((MonoBehaviour)this).StopCoroutine(_co); } _co = ((MonoBehaviour)this).StartCoroutine(CoPull()); } private void OnDisable() { CancelPullInternal(); } private void OnDestroy() { CancelPullInternal(); if (_pullRunner == this) { _pullRunner = null; } } private void CancelPullInternal() { try { if (_co != null) { ((MonoBehaviour)this).StopCoroutine(_co); _co = null; } } catch { } CleanupTether(); } private void EnsureTether() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0129: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Object)(object)_tetherGo != (Object)null && (Object)(object)_tetherLr != (Object)null)) { return; } try { _tetherGo = new GameObject("PX_SerpentTether"); ((Object)_tetherGo).hideFlags = (HideFlags)61; _tetherGo.transform.SetParent(((Component)localPlayer).transform, false); _tetherLr = _tetherGo.AddComponent(); _tetherLr.useWorldSpace = true; _tetherLr.positionCount = 2; _tetherLr.startWidth = 0.05f; _tetherLr.endWidth = 0.045f; _tetherLr.numCapVertices = 6; _tetherLr.numCornerVertices = 2; _tetherLr.textureMode = (LineTextureMode)1; _tetherLr.alignment = (LineAlignment)0; Material vanillaHarpoonLineMaterial = GetVanillaHarpoonLineMaterial(); if ((Object)(object)vanillaHarpoonLineMaterial != (Object)null) { _tetherMat = vanillaHarpoonLineMaterial; ((Renderer)_tetherLr).sharedMaterial = _tetherMat; _tetherLr.startColor = Color.white; _tetherLr.endColor = Color.white; return; } Shader val = Shader.Find("Unlit/Texture"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Particles/Additive"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Particles/Standard Unlit"); } if ((Object)(object)val != (Object)null) { _tetherMat = new Material(val); _tetherMat.color = Color.white; ((Renderer)_tetherLr).sharedMaterial = _tetherMat; } } catch (Exception ex) { ManualLogSource logger = _logger; if (logger != null) { logger.LogWarning((object)("[ParanoiaSerpent] Failed to create tether LineRenderer: " + ex.Message)); } CleanupTether(); } } private void UpdateTether(Vector3 serpentPos, Player lp) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004f: 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_0063: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_tetherLr == (Object)null) { return; } if ((Object)(object)lp == (Object)null) { CleanupTether(); return; } Vector3 val = serpentPos + Vector3.up * 1.2f; Vector3 val2 = ((Component)lp).transform.position + Vector3.up * 1f; _tetherLr.SetPosition(0, val); _tetherLr.SetPosition(1, val2); try { if ((Object)(object)_tetherMat != (Object)null && (Object)(object)_tetherMat.mainTexture != (Object)null) { float num = Vector3.Distance(val, val2); _tetherMat.mainTextureScale = new Vector2(Mathf.Max(1f, num * 0.9f), 1f); } } catch { } } private void CleanupTether() { _tetherLr = null; _tetherMat = null; if ((Object)(object)_tetherGo != (Object)null) { try { Object.Destroy((Object)(object)_tetherGo); } catch { } _tetherGo = null; } } private static bool IsGroundedish(Player p, float maxDist) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0032: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)p == (Object)null) { return false; } Vector3 val = ((Component)p).transform.position + Vector3.up * 0.2f; RaycastHit val2 = default(RaycastHit); return Physics.Raycast(val, Vector3.down, ref val2, maxDist, -1, (QueryTriggerInteraction)1); } catch { return false; } } [IteratorStateMachine(typeof(d__30))] private IEnumerator CoPull() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__30(0) { <>4__this = this }; } } private static ManualLogSource _log; private const string SerpentPrefabName = "Serpent"; private static int _serpentPrefabHash; private const float ServerDecisionInterval = 1.75f; private const float HarpoonCooldownSeconds = 10f; private const bool DisableSafetyForTesting = false; private const float HarpoonMinRange = 2f; private const float HarpoonMaxRange = 45f; private const float PullDurationSeconds = 2.25f; private const float PullForcePerFixedTick = 1.35f; private const float PullMinUpBoost = 5f; private const float AttachGraceSeconds = 6f; private const string RpcStartPull = "PX_SerpentStartPull"; private static float _nextRpcTryRegisterAt; private static bool _rpcsRegistered; private static ZRoutedRpc _registeredRpcInstance; private static MethodInfo _miInvokeRoutedRpcPkg; private static Material _vanillaHarpoonLineMat; private static bool _vanillaHarpoonLineMatSearched; private static readonly Dictionary _nextHarpoonAt = new Dictionary(128); private static readonly Dictionary _attachGrace = new Dictionary(256); private static PxPullRunner _pullRunner; private static MethodInfo _miIsPointInsideArea; private static bool _warnedNoBaseApi; private static readonly FieldRef CharacterBodyRef = AccessTools.FieldRefAccess("m_body"); private static float _nextSerpentPollAt; private static bool _loggedPollStart; private static float _nextPollDiagAt; private static readonly List _serpentZdoBuffer = new List(64); private static int _serpentZdoScanIndex; private static Material GetVanillaHarpoonLineMaterial() { if (_vanillaHarpoonLineMatSearched) { return _vanillaHarpoonLineMat; } _vanillaHarpoonLineMatSearched = true; try { ZNetScene instance = ZNetScene.instance; GameObject val = (((Object)(object)instance != (Object)null) ? instance.GetPrefab("projectile_chitinharpoon") : null); if ((Object)(object)val != (Object)null) { LineRenderer componentInChildren = val.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial != (Object)null) { _vanillaHarpoonLineMat = ((Renderer)componentInChildren).sharedMaterial; return _vanillaHarpoonLineMat; } } Material[] array = Resources.FindObjectsOfTypeAll(); Material[] array2 = array; foreach (Material val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { string name = ((Object)val2).name; if (!string.IsNullOrEmpty(name) && (name.IndexOf("harpoon", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("rope", StringComparison.OrdinalIgnoreCase) >= 0)) { _vanillaHarpoonLineMat = val2; return _vanillaHarpoonLineMat; } } } } catch { } return _vanillaHarpoonLineMat; } internal static void Init(ManualLogSource logger) { _log = logger; EnsureHashes(); ManualLogSource log = _log; if (log != null) { log.LogInfo((object)"[ParanoiaSerpent] Init(logger) OK"); } } internal static void Init(Harmony harmony, ManualLogSource logger) { _log = logger; EnsureHashes(); Patch(harmony); } internal static void Tick() { try { TryRegisterRpcsThrottled(); if ((Object)(object)Player.m_localPlayer != (Object)null) { EnsurePullRunner(); } PollSerpentLasso(); } catch (Exception ex) { Debug.LogError((object)("[Paranoia][Serpent] Tick exception: " + ex)); } } private static void PollSerpentLasso() { try { if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || ZDOMan.instance == null) { return; } if (!_loggedPollStart) { _loggedPollStart = true; Debug.Log((object)"[Paranoia][Serpent] PollSerpentLasso active on server (ZDO-based)"); } float time = Time.time; if (time < _nextSerpentPollAt) { return; } _nextSerpentPollAt = time + 1.75f; EnsureHashes(); _serpentZdoBuffer.Clear(); _serpentZdoScanIndex = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("Serpent", _serpentZdoBuffer, ref _serpentZdoScanIndex)) { } List list = null; try { list = ZNet.instance.GetAllCharacterZDOS(); } catch { } int count = _serpentZdoBuffer.Count; int num = list?.Count ?? 0; for (int i = 0; i < count; i++) { ZDO val = _serpentZdoBuffer[i]; if (val != null) { ProcessSerpentLassoZDO(val, list, time); } } if (time >= _nextPollDiagAt) { _nextPollDiagAt = time + 30f; int num2 = 0; try { num2 = ZNet.instance.GetPeerConnections(); } catch { } Debug.Log((object)$"[Paranoia][Serpent] Poll(ZDO): serpents={count} playerZdos={num} peers={num2}"); } } catch (Exception ex) { Debug.LogError((object)("[Paranoia][Serpent] PollSerpentLasso exception: " + ex)); } } private static void ProcessSerpentLassoZDO(ZDO serpentZdo, List playerZdos, float now) { //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_003c: 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_0060: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0149: Unknown result type (might be due to invalid IL or missing references) try { int hashCode = ((object)(ZDOID)(ref serpentZdo.m_uid)).GetHashCode(); Vector3 position = serpentZdo.GetPosition(); if (_nextHarpoonAt.TryGetValue(hashCode, out var value) && now < value) { return; } ZDO val = FindClosestEligiblePlayerZDO(position, 45f, playerZdos); if (val == null) { return; } Vector3 position2 = val.GetPosition(); float num = Vector3.Distance(position, position2); if (num < 2f) { return; } bool flag = true; if (IsOceanAt(position) && IsOceanAt(position2) && !IsInPlayerBase(position2)) { long owner = val.GetOwner(); ulong key = MakePairKey((uint)hashCode, owner); if (!_attachGrace.TryGetValue(key, out var value2) || !(now < value2)) { _attachGrace[key] = now + 6f; _nextHarpoonAt[hashCode] = now + 10f; ZDOID uid = serpentZdo.m_uid; Debug.Log((object)$"[Paranoia][Serpent] FIRING pull RPC -> owner={owner} dist={num:F1} serpentZdo={uid}"); SendPullRpcToOwner(owner, uid, 2.25f, 1.35f, 5f); } } } catch (Exception ex) { Debug.LogError((object)("[Paranoia][Serpent] ProcessSerpentLassoZDO exception: " + ex)); } } private static ZDO FindClosestEligiblePlayerZDO(Vector3 serpentPos, float range, List playerZdos) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: 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) if (playerZdos == null || playerZdos.Count == 0) { return null; } ZDO result = null; float num = float.MaxValue; for (int i = 0; i < playerZdos.Count; i++) { ZDO val = playerZdos[i]; if (val == null) { continue; } Vector3 position = val.GetPosition(); float num2 = Vector3.Distance(serpentPos, position); if (!(num2 > range)) { bool flag = true; if (IsOceanAt(position) && !IsInPlayerBase(position) && num2 < num) { result = val; num = num2; } } } return result; } private static void TryRegisterRpcsThrottled() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance == null || (_rpcsRegistered && instance == _registeredRpcInstance) || Time.time < _nextRpcTryRegisterAt) { return; } _nextRpcTryRegisterAt = Time.time + 1f; try { instance.Register("PX_SerpentStartPull", (Action)RPC_StartPull); _rpcsRegistered = true; _registeredRpcInstance = instance; } catch (Exception) { _rpcsRegistered = true; _registeredRpcInstance = instance; } } private static void SendPullRpcToOwner(long owner, ZDOID serpentZdo, float duration, float forcePerTick, float upBoost) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) try { if (owner == 0) { return; } ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { Debug.Log((object)$"[Paranoia][Serpent] SendPullRpc -> owner={owner} dur={duration:0.00} force={forcePerTick:0.00} up={upBoost:0.00}"); ZPackage val = new ZPackage(); val.Write((byte)1); val.Write(serpentZdo); val.Write(duration); val.Write(forcePerTick); val.Write(upBoost); if (!TryInvokeRoutedRpcWithPackage(instance, owner, "PX_SerpentStartPull", val)) { instance.InvokeRoutedRPC(owner, "PX_SerpentStartPull", new object[1] { val }); } } } catch (Exception ex) { Debug.LogError((object)("[Paranoia][Serpent] SendPullRpcToOwner failed: " + ex)); } } private static bool TryInvokeRoutedRpcWithPackage(ZRoutedRpc zr, long targetPeer, string rpcName, ZPackage pkg) { //IL_017e: Unknown result type (might be due to invalid IL or missing references) try { if (zr == null) { return false; } if (_miInvokeRoutedRpcPkg == null) { _miInvokeRoutedRpcPkg = typeof(ZRoutedRpc).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(delegate(MethodInfo m) { if (m.Name != "InvokeRoutedRPC") { return false; } ParameterInfo[] parameters2 = m.GetParameters(); return parameters2.Length >= 3 && parameters2[0].ParameterType == typeof(long) && parameters2[1].ParameterType == typeof(string) && parameters2[2].ParameterType == typeof(ZPackage); }); } if (_miInvokeRoutedRpcPkg == null) { return false; } ParameterInfo[] parameters = _miInvokeRoutedRpcPkg.GetParameters(); object[] array = new object[parameters.Length]; array[0] = targetPeer; array[1] = rpcName; array[2] = pkg; for (int i = 3; i < parameters.Length; i++) { Type parameterType = parameters[i].ParameterType; if (parameterType == typeof(bool)) { array[i] = false; } else if (parameterType == typeof(int)) { array[i] = 0; } else if (parameterType == typeof(long)) { array[i] = 0L; } else if (parameterType == typeof(float)) { array[i] = 0f; } else if (parameterType == typeof(string)) { array[i] = null; } else if (parameterType == typeof(Vector3)) { array[i] = Vector3.zero; } else { array[i] = null; } } _miInvokeRoutedRpcPkg.Invoke(zr, array); return true; } catch { return false; } } private static void RPC_StartPull(long sender, ZPackage pkg) { //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_0068: Unknown result type (might be due to invalid IL or missing references) try { byte b = 0; try { b = pkg.ReadByte(); } catch { b = 0; } ZDOID serpentId = pkg.ReadZDOID(); float duration = pkg.ReadSingle(); float forcePerTick = pkg.ReadSingle(); float upBoost = pkg.ReadSingle(); Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { EnsurePullRunner(); if (!((Object)(object)_pullRunner == (Object)null)) { _pullRunner.StartPull(serpentId, duration, forcePerTick, upBoost); } } } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)("[ParanoiaSerpent] RPC_StartPull failed: " + ex)); } } } private static void Patch(Harmony harmony) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown if (harmony == null) { return; } try { MethodInfo methodInfo = AccessTools.Method(typeof(Player), "OnDestroy", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ParanoiaSerpent), "Player_OnDestroy_Postfix", (Type[])null, (Type[])null); if (methodInfo != null && methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)("[ParanoiaSerpent] Patch exception: " + ex)); } } } private static void Player_OnDestroy_Postfix(Player __instance) { try { if (!((Object)(object)__instance == (Object)null) && (!((Object)(object)Player.m_localPlayer != (Object)null) || !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) && (Object)(object)_pullRunner != (Object)null) { try { Object.Destroy((Object)(object)_pullRunner); } catch { } _pullRunner = null; } } catch { } } private static void EnsurePullRunner() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && (!((Object)(object)_pullRunner != (Object)null) || !Object.op_Implicit((Object)(object)_pullRunner))) { _pullRunner = ((Component)localPlayer).gameObject.GetComponent(); if ((Object)(object)_pullRunner == (Object)null) { _pullRunner = ((Component)localPlayer).gameObject.AddComponent(); } _pullRunner.Init(_log); } } private static Character FindCharacterByZdo(ZDOID id) { //IL_0066: 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) List allCharacters = Character.GetAllCharacters(); foreach (Character item in allCharacters) { if (!Object.op_Implicit((Object)(object)item)) { continue; } ZNetView component = ((Component)item).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null && zDO.m_uid == id) { return item; } } } return null; } private static bool IsOceanAt(Vector3 pos) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 try { if (WorldGenerator.instance != null) { Biome biome = WorldGenerator.instance.GetBiome(pos); return (biome & 0x100) > 0; } Biome val = Heightmap.FindBiome(pos); return (val & 0x100) > 0; } catch { return false; } } private static bool IsInPlayerBase(Vector3 pos) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) try { if (_miIsPointInsideArea == null) { _miIsPointInsideArea = typeof(EffectArea).GetMethod("IsPointInsideArea", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Vector3), typeof(Type) }, null); } if (_miIsPointInsideArea != null) { if (_miIsPointInsideArea.Invoke(null, new object[2] { pos, (object)(Type)4 }) is bool result) { return result; } return false; } if (!_warnedNoBaseApi) { _warnedNoBaseApi = true; ManualLogSource log = _log; if (log != null) { log.LogWarning((object)"[ParanoiaSerpent] Base-area API not found (EffectArea.IsPointInsideArea). Falling back to ocean-only rule."); } } return false; } catch { if (!_warnedNoBaseApi) { _warnedNoBaseApi = true; ManualLogSource log2 = _log; if (log2 != null) { log2.LogWarning((object)"[ParanoiaSerpent] Base-area check failed. Falling back to ocean-only rule."); } } return false; } } private static void EnsureHashes() { if (_serpentPrefabHash != 0) { return; } try { _serpentPrefabHash = StringExtensionMethods.GetStableHashCode("Serpent"); } catch { _serpentPrefabHash = 0; } } private static ulong MakePairKey(uint serpentUid, long playerId) { uint num = (uint)playerId; return ((ulong)serpentUid << 32) | num; } } }