Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PoltergeistProtocol v1.0.0
BepInEx/plugins/PoltergeistProtocol/PoltergeistProtocol.dll
Decompiled 27 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using PoltergeistProtocol.Abilities; using PoltergeistProtocol.Config; using PoltergeistProtocol.Core; using PoltergeistProtocol.Networking; using PoltergeistProtocol.UI; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PoltergeistProtocol")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4f4743a37260ce61e0ad51a587201c7e37018dc0")] [assembly: AssemblyProduct("Poltergeist Protocol")] [assembly: AssemblyTitle("PoltergeistProtocol")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PoltergeistProtocol { [BepInPlugin("com.poltergeistprotocol.repo", "PoltergeistProtocol", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.poltergeistprotocol.repo"; public const string PluginName = "PoltergeistProtocol"; public const string PluginVersion = "1.0.0"; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static PoltergeistConfig ConfigSettings { get; private set; } internal static Harmony HarmonyInstance { get; private set; } internal static PoltergeistRuntime Runtime { get; private set; } private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //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_007a: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; ConfigSettings = new PoltergeistConfig(((BaseUnityPlugin)this).Config); if (!ConfigSettings.ModEnabled.Value) { Log.LogInfo((object)"PoltergeistProtocol v1.0.0 is disabled in config."); return; } HarmonyInstance = new Harmony("com.poltergeistprotocol.repo"); HarmonyInstance.PatchAll(typeof(Plugin).Assembly); GameObject val = new GameObject("PoltergeistProtocol_Runtime"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; Runtime = val.AddComponent<PoltergeistRuntime>(); Log.LogInfo((object)"PoltergeistProtocol v1.0.0 initialized (All 21 abilities ready)."); } private void OnDestroy() { if ((Object)(object)Runtime != (Object)null) { Object.Destroy((Object)(object)((Component)Runtime).gameObject); Runtime = null; } Harmony harmonyInstance = HarmonyInstance; if (harmonyInstance != null) { harmonyInstance.UnpatchSelf(); } HarmonyInstance = null; } } internal sealed class PoltergeistRuntime : MonoBehaviour { private gameState _lastGameState; internal PoltergeistNetworkBus NetworkBus { get; private set; } internal GuardrailRegistry Guardrails { get; private set; } internal EctoplasmManager Ectoplasm { get; private set; } internal TetherAnchorManager TetherAnchor { get; private set; } internal GhostStateController GhostState { get; private set; } internal PhysicsAbilities Physics { get; private set; } internal ComedyVoiceAbilities ComedyVoice { get; private set; } internal MonsterAbilities Monsters { get; private set; } internal SupportAbilities Support { get; private set; } internal MultiGhostAbilities MultiGhost { get; private set; } internal AbilityRouter Abilities { get; private set; } internal MinimalGhostHud Hud { get; private set; } private void Awake() { NetworkBus = new PoltergeistNetworkBus(); NetworkBus.Register(); Guardrails = new GuardrailRegistry(); Ectoplasm = new EctoplasmManager(); TetherAnchor = new TetherAnchorManager(); GhostState = new GhostStateController(Ectoplasm, TetherAnchor); Physics = new PhysicsAbilities(Guardrails, NetworkBus); Physics.RegisterNetworkHandlers(NetworkBus); ComedyVoice = new ComedyVoiceAbilities(Guardrails, NetworkBus); ComedyVoice.RegisterNetworkHandlers(NetworkBus); Monsters = new MonsterAbilities(Guardrails, NetworkBus); Monsters.RegisterNetworkHandlers(NetworkBus); Support = new SupportAbilities(Guardrails); Support.RegisterNetworkHandlers(NetworkBus); MultiGhost = new MultiGhostAbilities(NetworkBus, Ectoplasm, GhostState); MultiGhost.RegisterNetworkHandlers(NetworkBus); Abilities = new AbilityRouter(GhostState, Ectoplasm, NetworkBus, ComedyVoice); Hud = new MinimalGhostHud(); } private void Update() { //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_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 if (Plugin.ConfigSettings == null || !Plugin.ConfigSettings.ModEnabled.Value) { return; } GameDirector instance = GameDirector.instance; gameState val = (gameState)(((Object)(object)instance != (Object)null) ? ((int)instance.currentState) : 0); if (val != _lastGameState) { if ((int)_lastGameState == 2 && (int)val != 2) { ResetRoundState(); } _lastGameState = val; } float unscaledDeltaTime = Time.unscaledDeltaTime; float deltaTime = Time.deltaTime; GhostState?.Tick(unscaledDeltaTime); ComedyVoice?.UpdateTick(deltaTime); Monsters?.UpdateTick(deltaTime); Support?.UpdateTick(deltaTime); Abilities?.Tick(); } private void FixedUpdate() { if (Plugin.ConfigSettings != null && Plugin.ConfigSettings.ModEnabled.Value) { float fixedDeltaTime = Time.fixedDeltaTime; Physics?.FixedUpdateTick(fixedDeltaTime); ComedyVoice?.FixedUpdateTick(fixedDeltaTime); Monsters?.FixedUpdateTick(fixedDeltaTime); } } private void OnGUI() { if (Plugin.ConfigSettings != null && Plugin.ConfigSettings.ModEnabled.Value) { Hud?.Draw(GhostState, Ectoplasm, Abilities, MultiGhost); } } private void ResetRoundState() { GhostState?.Reset(); TetherAnchor?.Reset(); Ectoplasm?.Reset(); Guardrails?.Reset(); Physics?.Reset(); ComedyVoice?.Reset(); Monsters?.Reset(); Support?.Reset(); MultiGhost?.Reset(); } private void OnDestroy() { if (NetworkBus != null) { Physics?.UnregisterNetworkHandlers(NetworkBus); ComedyVoice?.UnregisterNetworkHandlers(NetworkBus); Monsters?.UnregisterNetworkHandlers(NetworkBus); Support?.UnregisterNetworkHandlers(NetworkBus); MultiGhost?.UnregisterNetworkHandlers(NetworkBus); NetworkBus.Unregister(); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "PoltergeistProtocol"; public const string PLUGIN_NAME = "Poltergeist Protocol"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace PoltergeistProtocol.UI { public sealed class MinimalGhostHud { private GUIStyle _boxStyle; private GUIStyle _textStyle; private GUIStyle _dimStyle; private Texture2D _bgTex; public void Draw(GhostStateController state, EctoplasmManager ectoplasm, AbilityRouter router, MultiGhostAbilities multiGhost) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (state == null || !state.IsLocalPlayerDead || !Plugin.ConfigSettings.ShowMinimalHud.Value) { return; } EnsureStyles(); bool flag = multiGhost != null && !string.IsNullOrEmpty(multiGhost.LocalActiveBetLabel); float num = 390f; float num2 = ((!state.IsFreeFloating) ? (flag ? 92f : 74f) : (flag ? 152f : 134f)); Rect val = default(Rect); ((Rect)(ref val))..ctor(18f, (float)Screen.height - num2 - 18f, num, num2); GUI.Box(val, GUIContent.none, _boxStyle); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width - 20f, ((Rect)(ref val)).height - 16f)); PoltergeistConfig configSettings = Plugin.ConfigSettings; if (!state.IsFreeFloating) { GUILayout.Label($"<b>POLTERGEIST</b> | Ectoplasm: {ectoplasm.Current:0}/{ectoplasm.Max:0}", _textStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("[" + configSettings.ToggleGhostFloatKey.Value + "] Ghost Float | [" + configSettings.HeadWiggleKey.Value + "] Head Honk | [" + configSettings.QuickVoiceManifestKey.Value + "] Walkie", _dimStyle, Array.Empty<GUILayoutOption>()); } else { string text = (state.IsAtTetherLimit ? " <color=#FF9966>(MAX TETHER)</color>" : string.Empty); GUILayout.Label($"<b>GHOST</b> | Anchor: {state.CurrentAnchorLabel} ({state.LastAnchorDistance:0.0}m/{configSettings.TetherRadius.Value:0}m){text}", _textStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"Ectoplasm: <b>{ectoplasm.Current:0}</b> / {ectoplasm.Max:0} (+{ectoplasm.RegenPerSecond:0.0}/s, {ectoplasm.DeadCount} dead)", _textStyle, Array.Empty<GUILayoutOption>()); if (router.TryGetSelectedAbility(out var info)) { float localCooldownRemaining = router.GetLocalCooldownRemaining(info.Id); string text2 = ((localCooldownRemaining > 0.05f) ? $"<color=#FFAA55>CD {localCooldownRemaining:0.1}s</color>" : (ectoplasm.CanAfford(info.Cost) ? "<color=#88FFAA>READY</color>" : "<color=#FF7777>LOW ECTO</color>")); GUILayout.Label($"[{info.Category}] <b>{info.DisplayName}</b> ({info.Cost:0}) [{text2}]", _textStyle, Array.Empty<GUILayoutOption>()); } if (!string.IsNullOrEmpty(router.CurrentTargetHint)) { GUILayout.Label(router.CurrentTargetHint, _dimStyle, Array.Empty<GUILayoutOption>()); } GUILayout.Label("[" + configSettings.CycleAbilityPrevKey.Value + "/" + configSettings.CycleAbilityNextKey.Value + "] Cycle | [" + configSettings.UseAbilityKey.Value + "] Cast | [" + configSettings.ToggleAnchorKey.Value + "] Anchor | [" + configSettings.ToggleGhostFloatKey.Value + "] Exit", _dimStyle, Array.Empty<GUILayoutOption>()); } if (flag) { GUILayout.Label("<color=#FFD966>" + multiGhost.LocalActiveBetLabel + "</color> (chat: " + configSettings.BetCommandPrefix.Value + " <name>)", _dimStyle, Array.Empty<GUILayoutOption>()); } if (state.ToastTimer > 0f && !string.IsNullOrEmpty(state.LastStatusToast)) { GUILayout.Label("<i><color=#CCE6FF>" + state.LastStatusToast + "</color></i>", _textStyle, Array.Empty<GUILayoutOption>()); } GUILayout.EndArea(); } private void EnsureStyles() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0047: 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_0079: Expected O, but got Unknown //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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00f1: 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_011c: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) int value = Plugin.ConfigSettings.HudFontSize.Value; if ((Object)(object)_bgTex == (Object)null) { _bgTex = new Texture2D(1, 1); _bgTex.SetPixel(0, 0, new Color(0.05f, 0.06f, 0.09f, 0.72f)); _bgTex.Apply(); } if (_boxStyle == null) { _boxStyle = new GUIStyle(GUI.skin.box); _boxStyle.normal.background = _bgTex; } if (_textStyle == null || _textStyle.fontSize != value) { _textStyle = new GUIStyle(GUI.skin.label) { fontSize = value, richText = true, wordWrap = false }; _textStyle.normal.textColor = new Color(0.92f, 0.96f, 1f, 0.96f); _dimStyle = new GUIStyle(_textStyle) { fontSize = Mathf.Max(11, value - 3) }; _dimStyle.normal.textColor = new Color(0.72f, 0.78f, 0.86f, 0.88f); } } } } namespace PoltergeistProtocol.Patches { [HarmonyPatch(typeof(ChatManager))] internal static class BettingChatPatches { [HarmonyPatch("MessageSend")] [HarmonyPrefix] private static bool MessageSendPrefix(ChatManager __instance, bool _possessed) { PoltergeistConfig configSettings = Plugin.ConfigSettings; if (configSettings == null || !configSettings.BettingEnabled.Value || !configSettings.EnableTtsHooks.Value || _possessed) { return true; } if (!SemiFunc.IsSpectating() || (Object)(object)__instance == (Object)null || string.IsNullOrWhiteSpace(__instance.chatMessage)) { return true; } string text = configSettings.BetCommandPrefix.Value?.Trim(); if (string.IsNullOrEmpty(text)) { text = "/bet"; } string text2 = __instance.chatMessage.Trim(); if (!text2.StartsWith(text, StringComparison.OrdinalIgnoreCase)) { return true; } string targetQuery = ((text2.Length > text.Length) ? text2.Substring(text.Length).Trim() : string.Empty); Plugin.Runtime?.MultiGhost?.TryPlaceBet(targetQuery); __instance.ChatReset(); return false; } } [HarmonyPatch(typeof(PlayerHealth))] internal static class PlayerDamageBetPatches { [HarmonyPatch("Hurt")] [HarmonyPrefix] private static void HurtPrefix(PlayerHealth __instance, int damage) { if (damage > 0 && !((Object)(object)__instance == (Object)null) && !__instance.godMode && !(__instance.invincibleTimer > 0f) && (Object)(object)__instance.playerAvatar != (Object)null && !__instance.playerAvatar.deadSet && (!SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient)) { Plugin.Runtime?.MultiGhost?.OnLivingPlayerDamaged(__instance.playerAvatar); } } [HarmonyPatch("UpdateHealthRPC")] [HarmonyPrefix] private static void UpdateHealthRpcPrefix(PlayerHealth __instance, int healthNew) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.playerAvatar == (Object)null) && !__instance.playerAvatar.deadSet && healthNew < __instance.health && (!SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient)) { Plugin.Runtime?.MultiGhost?.OnLivingPlayerDamaged(__instance.playerAvatar); } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] internal static class SafeLootPatches { [HarmonyPatch("Break")] [HarmonyPrefix] private static bool BreakPrefix(PhysGrabObjectImpactDetector __instance, bool _forceBreak) { if (_forceBreak) { return true; } GuardrailRegistry guardrailRegistry = Plugin.Runtime?.Guardrails; if (guardrailRegistry != null && guardrailRegistry.IsObjectProtected(__instance.physGrabObject)) { return false; } return true; } } [HarmonyPatch(typeof(SpectateCamera))] internal static class SpectatePatches { [HarmonyPatch("StateNormal")] [HarmonyPrefix] private static bool StateNormalPrefix() { GhostStateController ghostStateController = Plugin.Runtime?.GhostState; if (ghostStateController != null) { return !ghostStateController.IsFreeFloating; } return true; } [HarmonyPatch("StateHead")] [HarmonyPrefix] private static bool StateHeadPrefix() { GhostStateController ghostStateController = Plugin.Runtime?.GhostState; if (ghostStateController != null) { return !ghostStateController.IsFreeFloating; } return true; } [HarmonyPatch("LateUpdate")] [HarmonyPostfix] private static void LateUpdatePostfix(SpectateCamera __instance) { GhostStateController ghostStateController = Plugin.Runtime?.GhostState; if (ghostStateController != null && ghostStateController.IsFreeFloating) { ghostStateController.LateUpdateCamera(__instance); } } [HarmonyPatch("PlayerSwitch")] [HarmonyPostfix] private static void PlayerSwitchPostfix(SpectateCamera __instance) { Plugin.Runtime?.TetherAnchor?.OnSpectateTargetSwitched(__instance.player); } [HarmonyPatch("StopSpectate")] [HarmonyPostfix] private static void StopSpectatePostfix() { Plugin.Runtime?.GhostState?.ExitFreeFloat(silent: true); } } [HarmonyPatch(typeof(PlayerVoiceChat))] internal static class VoiceChatPatches { [HarmonyPatch("ToggleMixer")] [HarmonyPostfix] private static void ToggleMixerPostfix(PlayerVoiceChat __instance) { PoltergeistConfig configSettings = Plugin.ConfigSettings; if (configSettings == null || !configSettings.EnableVoiceHooks.Value) { return; } ComedyVoiceAbilities comedyVoiceAbilities = Plugin.Runtime?.ComedyVoice; if (comedyVoiceAbilities == null || !comedyVoiceAbilities.HasActiveVoiceOverride(__instance, out var distorted)) { return; } if ((Object)(object)__instance.audioSource != (Object)null) { AudioMixerGroup val = ((distorted && (Object)(object)__instance.mixerMicrophoneSoundDistorted != (Object)null) ? __instance.mixerMicrophoneSoundDistorted : __instance.mixerMicrophoneSound); if ((Object)(object)val != (Object)null) { __instance.audioSource.outputAudioMixerGroup = val; } } if ((Object)(object)__instance.ttsAudioSource != (Object)null && (Object)(object)__instance.mixerTTSSound != (Object)null) { __instance.ttsAudioSource.outputAudioMixerGroup = __instance.mixerTTSSound; } } } [HarmonyPatch(typeof(PhysGrabObject))] internal static class HeadVentriloquismGrabPatches { [HarmonyPatch("GrabStarted")] [HarmonyPostfix] private static void GrabStartedPostfix(PhysGrabObject __instance) { TryTriggerHeadLine(__instance); } [HarmonyPatch("GrabEnded")] [HarmonyPostfix] private static void GrabEndedPostfix(PhysGrabObject __instance) { TryTriggerHeadLine(__instance); } private static void TryTriggerHeadLine(PhysGrabObject pgo) { PoltergeistConfig configSettings = Plugin.ConfigSettings; if (configSettings != null && configSettings.EnableTtsHooks.Value && configSettings.DeadHeadVentriloquismEnabled.Value && !((Object)(object)pgo == (Object)null)) { PlayerDeathHead component = ((Component)pgo).GetComponent<PlayerDeathHead>(); if ((Object)(object)component != (Object)null) { Plugin.Runtime?.ComedyVoice?.OnHeadHandled(component); } } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] internal static class HeadVentriloquismImpactPatches { [HarmonyPatch("ImpactLight")] [HarmonyPostfix] private static void ImpactLightPostfix(PhysGrabObjectImpactDetector __instance) { PoltergeistConfig configSettings = Plugin.ConfigSettings; if (configSettings != null && configSettings.EnableTtsHooks.Value && configSettings.DeadHeadVentriloquismEnabled.Value && !((Object)(object)__instance == (Object)null)) { PlayerDeathHead component = ((Component)__instance).GetComponent<PlayerDeathHead>(); if ((Object)(object)component != (Object)null) { Plugin.Runtime?.ComedyVoice?.OnHeadHandled(component); } } } } } namespace PoltergeistProtocol.Networking { public enum PoltergeistOpCode : byte { None = 0, FlickRequest = 1, DoorActionRequest = 2, CartActionRequest = 3, CursedRattleRequest = 4, HeadWiggleRequest = 5, VoiceHijackSync = 10, HauntedWalkieSync = 11, PhantomFalseAlarmBroadcast = 12, LightFlickerBroadcast = 13, CursedGripRequest = 14, VentriloquismBroadcast = 15, AcousticDecoyRequest = 20, SpectralBoopRequest = 21, TinyTripwireRequest = 22, ColdSpotRequest = 23, EmergencyCushionRequest = 24, GhostlyGlintBroadcast = 25, StaticJumpStartRequest = 26, GoosebumpBoostRequest = 27, SeanceNotifyBroadcast = 28, BetPlacedSync = 29, BetResolvedBroadcast = 30 } public sealed class PoltergeistNetworkBus : IOnEventCallback { private bool _registered; public event Action<PoltergeistOpCode, object[], int> OnMessageReceived; public void Register() { if (!_registered) { PhotonNetwork.AddCallbackTarget((object)this); _registered = true; } } public void Unregister() { if (_registered) { PhotonNetwork.RemoveCallbackTarget((object)this); _registered = false; } } public void SendToMaster(PoltergeistOpCode opCode, params object[] args) { if (!SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient) { int arg = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0); this.OnMessageReceived?.Invoke(opCode, args ?? Array.Empty<object>(), arg); } else { Raise(opCode, (ReceiverGroup)2, args); } } public void SendToAll(PoltergeistOpCode opCode, bool includeSelf, params object[] args) { if (!SemiFunc.IsMultiplayer()) { if (includeSelf) { this.OnMessageReceived?.Invoke(opCode, args ?? Array.Empty<object>(), 0); } } else { Raise(opCode, (ReceiverGroup)(includeSelf ? 1 : 0), args); } } private static void Raise(PoltergeistOpCode opCode, ReceiverGroup receivers, object[] args) { //IL_003c: 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_0042: 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_0049: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) byte value = Plugin.ConfigSettings.PhotonEventCode.Value; object[] array = new object[((args != null) ? args.Length : 0) + 1]; array[0] = (byte)opCode; if (args != null && args.Length != 0) { Array.Copy(args, 0, array, 1, args.Length); } RaiseEventOptions val = new RaiseEventOptions { Receivers = receivers }; PhotonNetwork.RaiseEvent(value, (object)array, val, SendOptions.SendReliable); } public void OnEvent(EventData photonEvent) { if (Plugin.ConfigSettings != null && photonEvent.Code == Plugin.ConfigSettings.PhotonEventCode.Value && photonEvent.CustomData is object[] array && array.Length >= 1 && array[0] is byte b) { PoltergeistOpCode arg = (PoltergeistOpCode)b; object[] array2 = new object[array.Length - 1]; if (array2.Length != 0) { Array.Copy(array, 1, array2, 0, array2.Length); } this.OnMessageReceived?.Invoke(arg, array2, photonEvent.Sender); } } } } namespace PoltergeistProtocol.Core { public enum GhostAbilityId { PoltergeistFlick, DoorSlamHold, CartTapBrake, CursedRattle, HeadWiggleHonk, RoomLightFlicker, PhantomFalseAlarm, CursedGrip, DeadHeadVentriloquism, HauntedWalkie, MonsterVoiceHijack, AcousticDecoy, SpectralBoop, TinyTripwire, ColdSpotSlow, EmergencyCushion, GhostlyGlint, StaticJumpStart, GoosebumpBoost } public readonly struct GhostAbilityInfo { public readonly GhostAbilityId Id; public readonly string Category; public readonly string DisplayName; public readonly float Cost; public readonly float Cooldown; public GhostAbilityInfo(GhostAbilityId id, string category, string displayName, float cost, float cooldown) { Id = id; Category = category; DisplayName = displayName; Cost = cost; Cooldown = cooldown; } } public sealed class AbilityRouter { private readonly GhostStateController _state; private readonly EctoplasmManager _ectoplasm; private readonly PoltergeistNetworkBus _net; private readonly ComedyVoiceAbilities _comedy; private readonly List<GhostAbilityInfo> _abilities = new List<GhostAbilityInfo>(); private readonly Dictionary<GhostAbilityId, float> _localCooldowns = new Dictionary<GhostAbilityId, float>(); private const float MaxTargetRange = 8.5f; public int SelectedIndex { get; private set; } public string CurrentTargetHint { get; private set; } = string.Empty; public AbilityRouter(GhostStateController state, EctoplasmManager ectoplasm, PoltergeistNetworkBus net, ComedyVoiceAbilities comedy) { _state = state; _ectoplasm = ectoplasm; _net = net; _comedy = comedy; RebuildAbilityList(); } public void RebuildAbilityList() { PoltergeistConfig configSettings = Plugin.ConfigSettings; _abilities.Clear(); if (configSettings.PoltergeistFlickEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.PoltergeistFlick, "Physics", "Poltergeist Flick", configSettings.PoltergeistFlickCost.Value, configSettings.PoltergeistFlickCooldown.Value)); } if (configSettings.DoorSlamHoldEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.DoorSlamHold, "Physics", "Door Slam / Hold", configSettings.DoorSlamHoldCost.Value, configSettings.DoorSlamHoldCooldown.Value)); } if (configSettings.CartTapBrakeEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.CartTapBrake, "Physics", "Cart Tap / Brake", configSettings.CartTapBrakeCost.Value, configSettings.CartTapBrakeCooldown.Value)); } if (configSettings.CursedRattleEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.CursedRattle, "Physics", "Cursed Rattle", configSettings.CursedRattleCost.Value, configSettings.CursedRattleCooldown.Value)); } if (configSettings.HeadWiggleHonkEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.HeadWiggleHonk, "Physics", "Head Wiggle & Honk", configSettings.HeadWiggleHonkCost.Value, configSettings.HeadWiggleHonkCooldown.Value)); } if (configSettings.RoomLightFlickerEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.RoomLightFlicker, "Haunt", "Room Light Flicker", configSettings.RoomLightFlickerCost.Value, configSettings.RoomLightFlickerCooldown.Value)); } if (configSettings.PhantomFalseAlarmEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.PhantomFalseAlarm, "Haunt", "Phantom False Alarm", configSettings.PhantomFalseAlarmCost.Value, configSettings.PhantomFalseAlarmCooldown.Value)); } if (configSettings.CursedGripEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.CursedGrip, "Haunt", "Cursed Grip", configSettings.CursedGripCost.Value, configSettings.CursedGripCooldown.Value)); } if (configSettings.EnableTtsHooks.Value && configSettings.DeadHeadVentriloquismEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.DeadHeadVentriloquism, "Voice", "Head Ventriloquism", configSettings.DeadHeadVentriloquismCost.Value, configSettings.DeadHeadVentriloquismCooldown.Value)); } if (configSettings.EnableVoiceHooks.Value && configSettings.HauntedWalkieEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.HauntedWalkie, "Voice", "Haunted Walkie", configSettings.HauntedWalkieCost.Value, configSettings.HauntedWalkieCooldown.Value)); } if (configSettings.EnableVoiceHooks.Value && configSettings.MonsterVoiceHijackEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.MonsterVoiceHijack, "Voice", "Monster Voice Hijack", configSettings.MonsterVoiceHijackCost.Value, configSettings.MonsterVoiceHijackCooldown.Value)); } if (configSettings.AcousticDecoyEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.AcousticDecoy, "Monster", "Acoustic Decoy", configSettings.AcousticDecoyCost.Value, configSettings.AcousticDecoyCooldown.Value)); } if (configSettings.SpectralBoopEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.SpectralBoop, "Monster", "Spectral Boop", configSettings.SpectralBoopCost.Value, configSettings.SpectralBoopCooldown.Value)); } if (configSettings.TinyTripwireEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.TinyTripwire, "Monster", "Tiny Tripwire", configSettings.TinyTripwireCost.Value, configSettings.TinyTripwireCooldown.Value)); } if (configSettings.ColdSpotSlowEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.ColdSpotSlow, "Monster", "Cold Spot Slow", configSettings.ColdSpotSlowCost.Value, configSettings.ColdSpotSlowCooldown.Value)); } if (configSettings.EmergencyCushionEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.EmergencyCushion, "Support", "Emergency Cushion", configSettings.EmergencyCushionCost.Value, configSettings.EmergencyCushionCooldown.Value)); } if (configSettings.GhostlyGlintEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.GhostlyGlint, "Support", "Ghostly Glint", configSettings.GhostlyGlintCost.Value, configSettings.GhostlyGlintCooldown.Value)); } if (configSettings.StaticJumpStartEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.StaticJumpStart, "Support", "Static Jump-Start", configSettings.StaticJumpStartCost.Value, configSettings.StaticJumpStartCooldown.Value)); } if (configSettings.GoosebumpBoostEnabled.Value) { _abilities.Add(new GhostAbilityInfo(GhostAbilityId.GoosebumpBoost, "Support", "Goosebump Boost", configSettings.GoosebumpBoostCost.Value, configSettings.GoosebumpBoostCooldown.Value)); } if (SelectedIndex >= _abilities.Count) { SelectedIndex = 0; } } public bool TryGetSelectedAbility(out GhostAbilityInfo info) { if (_abilities.Count == 0) { info = default(GhostAbilityInfo); return false; } SelectedIndex = Mathf.Clamp(SelectedIndex, 0, _abilities.Count - 1); info = _abilities[SelectedIndex]; return true; } public float GetLocalCooldownRemaining(GhostAbilityId id) { if (_localCooldowns.TryGetValue(id, out var value)) { return Mathf.Max(0f, value - Time.unscaledTime); } return 0f; } public void Tick() { if (!_state.IsLocalPlayerDead) { CurrentTargetHint = string.Empty; return; } PoltergeistConfig configSettings = Plugin.ConfigSettings; if (configSettings.HeadWiggleHonkEnabled.Value && GhostInput.WasPressedThisFrame(configSettings.HeadWiggleKey.Value)) { TryTriggerHeadWiggle(); } if (configSettings.EnableVoiceHooks.Value && configSettings.HauntedWalkieEnabled.Value && GhostInput.WasPressedThisFrame(configSettings.QuickVoiceManifestKey.Value)) { TryTriggerHauntedWalkie(); } if (!_state.IsFreeFloating || _abilities.Count == 0) { CurrentTargetHint = string.Empty; return; } float scrollY = GhostInput.GetScrollY(); if (GhostInput.WasPressedThisFrame(configSettings.CycleAbilityNextKey.Value) || scrollY < -0.1f) { SelectedIndex = (SelectedIndex + 1) % _abilities.Count; _state.PlaySubtleCue(positive: true); } else if (GhostInput.WasPressedThisFrame(configSettings.CycleAbilityPrevKey.Value) || scrollY > 0.1f) { SelectedIndex = (SelectedIndex - 1 + _abilities.Count) % _abilities.Count; _state.PlaySubtleCue(positive: true); } UpdateTargetHint(); if (!Cursor.visible && GhostInput.WasPressedThisFrame(configSettings.UseAbilityKey.Value)) { TryExecuteSelectedAbility(); } } private void UpdateTargetHint() { //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) if (!TryGetSelectedAbility(out var info)) { CurrentTargetHint = string.Empty; return; } PoltergeistConfig configSettings = Plugin.ConfigSettings; switch (info.Id) { case GhostAbilityId.HeadWiggleHonk: case GhostAbilityId.DeadHeadVentriloquism: CurrentTargetHint = (((Object)(object)PlayerAvatar.instance?.playerDeathHead != (Object)null) ? "Target: Your Severed Head" : "No Severed Head"); return; case GhostAbilityId.HauntedWalkie: CurrentTargetHint = $"{configSettings.HauntedWalkieDuration.Value:0.1}s distorted mic/TTS ({configSettings.HauntedWalkieRange.Value:0}m)"; return; case GhostAbilityId.PhantomFalseAlarm: CurrentTargetHint = "Plays 3D sound at aim point (AI ignores)"; return; case GhostAbilityId.RoomLightFlicker: CurrentTargetHint = "Flickers nearby lights & teammate flashlight"; return; case GhostAbilityId.AcousticDecoy: CurrentTargetHint = $"Emits AI-detectable knock ({configSettings.AcousticDecoyInvestigateRadius.Value:0}m)"; return; case GhostAbilityId.TinyTripwire: CurrentTargetHint = $"Places {configSettings.TinyTripwireDuration.Value:0.0}s pest tripwire on floor"; return; case GhostAbilityId.ColdSpotSlow: CurrentTargetHint = $"Chills {configSettings.ColdSpotSlowRadius.Value:0.0}m zone (-{configSettings.ColdSpotSlowPercent.Value * 100f:0}% speed)"; return; case GhostAbilityId.MonsterVoiceHijack: case GhostAbilityId.SpectralBoop: { float maxRange = ((info.Id == GhostAbilityId.MonsterVoiceHijack) ? configSettings.MonsterVoiceHijackRange.Value : 8.5f); Enemy val = FindTargetedEnemy(maxRange); CurrentTargetHint = (((Object)(object)val != (Object)null) ? ("Target Monster: " + (val.EnemyParent?.enemyName ?? "Monster")) : "Aim at a monster"); return; } case GhostAbilityId.GoosebumpBoost: { PlayerAvatar val2 = FindNearbyLivingPlayer(configSettings.GoosebumpBoostPassThroughRadius.Value); CurrentTargetHint = (((Object)(object)val2 != (Object)null) ? $"Ready to boost: {SemiFunc.PlayerGetName(val2)} (+{configSettings.GoosebumpBoostStaminaGainPercent.Value * 100f:0}% stamina)" : $"Float within {configSettings.GoosebumpBoostPassThroughRadius.Value:0.1}m of a living teammate"); return; } } if (!TryRaycastTarget(8.5f, out var hit)) { CurrentTargetHint = info.Id switch { GhostAbilityId.CursedGrip => "Aim at an item held by a living teammate", GhostAbilityId.StaticJumpStart => "Aim at a depleted battery-powered tool", GhostAbilityId.EmergencyCushion => "Aim at a falling valuable to cushion it", GhostAbilityId.GhostlyGlint => "Aim at a valuable or medkit to highlight", _ => "Aim at prop, door, or C.A.R.T.", }; return; } if (info.Id == GhostAbilityId.StaticJumpStart) { ItemBattery val3 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<ItemBattery>() ?? ((Component)((RaycastHit)(ref hit)).collider).GetComponentInChildren<ItemBattery>(); if ((Object)(object)val3 == (Object)null || val3.isUnchargable) { CurrentTargetHint = "Target has no rechargeable battery"; return; } bool flag = val3.batteryLife <= 15f || val3.currentBars == 0; CurrentTargetHint = (flag ? $"Depleted Battery ({val3.batteryLife:0}%) -> +{configSettings.StaticJumpStartChargePercent.Value * 100f:0}%" : $"Battery still has {val3.batteryLife:0}% (only depleted tools)"); return; } PhysGrabHinge componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabHinge>(); if ((Object)(object)componentInParent != (Object)null) { CurrentTargetHint = (componentInParent.broken ? "Door (Broken)" : ("Door [" + (componentInParent.closed ? "Closed" : "Open") + "] (Shift=Hold)")); return; } PhysGrabCart componentInParent2 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabCart>(); if ((Object)(object)componentInParent2 != (Object)null) { if (componentInParent2.cartBeingPulled || ((Object)(object)componentInParent2.physGrabObject != (Object)null && componentInParent2.physGrabObject.playerGrabbing != null && componentInParent2.physGrabObject.playerGrabbing.Count > 0)) { CurrentTargetHint = "C.A.R.T. (Held by teammate)"; return; } int num; if ((Object)(object)componentInParent2.rb != (Object)null) { Vector3 linearVelocity = componentInParent2.rb.linearVelocity; num = ((((Vector3)(ref linearVelocity)).magnitude > 0.5f) ? 1 : 0); } else { num = 0; } bool flag2 = (byte)num != 0; CurrentTargetHint = (flag2 ? "C.A.R.T. [Rolling -> Brake]" : "C.A.R.T. (Shift=Brake)"); return; } PhysGrabObject componentInParent3 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent3 != (Object)null && !componentInParent3.isPlayer && !componentInParent3.isEnemy) { bool flag3 = componentInParent3.playerGrabbing != null && componentInParent3.playerGrabbing.Count > 0; if (info.Id == GhostAbilityId.CursedGrip) { CurrentTargetHint = (flag3 ? "Target: Held Item (Ready for Cursed Grip)" : "Item is not currently held"); } else if (info.Id == GhostAbilityId.GhostlyGlint) { bool flag4 = (Object)(object)((Component)componentInParent3).GetComponent<ItemHealthPack>() != (Object)null || (Object)(object)((Component)componentInParent3).GetComponentInChildren<ItemHealthPack>() != (Object)null; CurrentTargetHint = ((componentInParent3.isValuable || flag4) ? "Target: Valuable / Medkit (Ready to Glint)" : "Target: Prop"); } else { CurrentTargetHint = (componentInParent3.isValuable ? "Target: Valuable (Safe-Loot ON)" : "Target: Prop"); } } else { CurrentTargetHint = string.Empty; } } private void TryExecuteSelectedAbility() { //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_00cd: 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_00d6: 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_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: 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_0140: 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) //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_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07ab: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: 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_053d: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026c: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) if (!TryGetSelectedAbility(out var info)) { return; } switch (info.Id) { case GhostAbilityId.HeadWiggleHonk: TryTriggerHeadWiggle(); return; case GhostAbilityId.HauntedWalkie: TryTriggerHauntedWalkie(); return; case GhostAbilityId.DeadHeadVentriloquism: TryTriggerManualVentriloquism(); return; } float localCooldownRemaining = GetLocalCooldownRemaining(info.Id); if (localCooldownRemaining > 0.05f) { _state.ShowToast($"Cooldown: {localCooldownRemaining:0.1}s", 1.1f); return; } if (!_ectoplasm.CanAfford(info.Cost)) { _state.ShowToast($"Need {info.Cost:0} Ectoplasm", 1.2f); _state.PlaySubtleCue(positive: false); return; } PoltergeistConfig configSettings = Plugin.ConfigSettings; bool flag = false; Vector3 val = _state.GhostRotation * Vector3.forward; Vector3 normalized = ((Vector3)(ref val)).normalized; switch (info.Id) { case GhostAbilityId.RoomLightFlicker: { RaycastHit hit4; Vector3 val5 = (TryRaycastTarget(12f, out hit4) ? ((RaycastHit)(ref hit4)).point : (_state.GhostPosition + normalized * 4f)); int num = 0; if ((Object)(object)((RaycastHit)(ref hit4)).collider != (Object)null) { PlayerAvatar componentInParent = ((Component)((RaycastHit)(ref hit4)).collider).GetComponentInParent<PlayerAvatar>(); if ((Object)(object)componentInParent != (Object)null && !componentInParent.deadSet && (Object)(object)componentInParent.photonView != (Object)null) { num = componentInParent.photonView.ViewID; } } if (num == 0 && (Object)(object)SpectateCamera.instance?.player != (Object)null && !SpectateCamera.instance.player.deadSet && (Object)(object)SpectateCamera.instance.player.photonView != (Object)null) { val = ((Component)SpectateCamera.instance.player).transform.position - val5; if (((Vector3)(ref val)).sqrMagnitude <= configSettings.RoomLightFlickerRadius.Value * configSettings.RoomLightFlickerRadius.Value) { num = SpectateCamera.instance.player.photonView.ViewID; } } _net.SendToAll(PoltergeistOpCode.LightFlickerBroadcast, true, val5.x, val5.y, val5.z, num, configSettings.RoomLightFlickerDuration.Value); _state.ShowToast("Light Flicker!", 1.2f); flag = true; break; } case GhostAbilityId.PhantomFalseAlarm: { RaycastHit hit3; Vector3 val3 = (TryRaycastTarget(configSettings.PhantomFalseAlarmRange.Value, out hit3) ? ((RaycastHit)(ref hit3)).point : (_state.GhostPosition + normalized * 5f)); byte b = (byte)Random.Range(0, 3); _net.SendToAll(PoltergeistOpCode.PhantomFalseAlarmBroadcast, true, val3.x, val3.y, val3.z, b); _state.ShowToast(b switch { 1 => "Phantom Door Creak!", 0 => "Phantom Footsteps!", _ => "Phantom Spook!", }, 1.3f); flag = true; break; } case GhostAbilityId.MonsterVoiceHijack: { Enemy val6 = FindTargetedEnemy(configSettings.MonsterVoiceHijackRange.Value); if ((Object)(object)val6 == (Object)null || (Object)(object)val6.PhotonView == (Object)null) { _state.ShowToast("No monster targeted", 1.1f); return; } int localActorNumber = GetLocalActorNumber(); _net.SendToAll(PoltergeistOpCode.VoiceHijackSync, true, localActorNumber, val6.PhotonView.ViewID, configSettings.MonsterVoiceHijackDuration.Value); _state.ShowToast($"Voice Hijacked ({configSettings.MonsterVoiceHijackDuration.Value:0.0}s)!", 1.8f); flag = true; break; } case GhostAbilityId.AcousticDecoy: { RaycastHit hit2; Vector3 val2 = (TryRaycastTarget(10f, out hit2) ? ((RaycastHit)(ref hit2)).point : _state.GhostPosition); _net.SendToMaster(PoltergeistOpCode.AcousticDecoyRequest, val2.x, val2.y, val2.z); _state.ShowToast("Acoustic Decoy Pinged!", 1.4f); flag = true; break; } case GhostAbilityId.SpectralBoop: { Enemy val7 = FindTargetedEnemy(8.5f); if ((Object)(object)val7 == (Object)null || (Object)(object)val7.PhotonView == (Object)null) { _state.ShowToast("No monster targeted", 1.1f); return; } _net.SendToMaster(PoltergeistOpCode.SpectralBoopRequest, val7.PhotonView.ViewID, normalized.x, normalized.y, normalized.z, _state.GhostPosition.x, _state.GhostPosition.y, _state.GhostPosition.z); _state.ShowToast("Spectral Boop!", 1.4f); flag = true; break; } case GhostAbilityId.TinyTripwire: { Vector3 val9 = FindFloorPlacementPoint(9f); Vector3 forward = default(Vector3); ((Vector3)(ref forward))..ctor(normalized.x, 0f, normalized.z); if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); _net.SendToMaster(PoltergeistOpCode.TinyTripwireRequest, val9.x, val9.y, val9.z, forward.x, forward.z); _state.ShowToast("Tiny Tripwire Set!", 1.4f); flag = true; break; } case GhostAbilityId.ColdSpotSlow: { Vector3 val8 = FindFloorPlacementPoint(10f); _net.SendToAll(PoltergeistOpCode.ColdSpotRequest, true, val8.x, val8.y, val8.z); _state.ShowToast("Cold Spot Chilled!", 1.4f); flag = true; break; } case GhostAbilityId.GoosebumpBoost: { PlayerAvatar val4 = FindNearbyLivingPlayer(configSettings.GoosebumpBoostPassThroughRadius.Value); if ((Object)(object)val4 == (Object)null || (Object)(object)val4.photonView == (Object)null) { _state.ShowToast("Move closer to a living teammate!", 1.2f); return; } _net.SendToAll(PoltergeistOpCode.GoosebumpBoostRequest, true, val4.photonView.ViewID); _state.ShowToast("Goosebump Boost -> " + SemiFunc.PlayerGetName(val4) + "!", 1.5f); flag = true; break; } default: { if (!TryRaycastTarget(8.5f, out var hit)) { _state.ShowToast("No valid target in range", 1.1f); return; } flag = ExecuteRaycastAbility(info.Id, hit, normalized); break; } } if (!flag) { _state.ShowToast("No valid target for " + info.DisplayName, 1.1f); return; } _ectoplasm.TrySpend(info.Cost); _localCooldowns[info.Id] = Time.unscaledTime + info.Cooldown; _state.PlaySubtleCue(positive: true); } private bool ExecuteRaycastAbility(GhostAbilityId id, RaycastHit hit, Vector3 lookDir) { //IL_009e: 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_00c0: 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_0159: 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) //IL_0237: 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) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) switch (id) { case GhostAbilityId.PoltergeistFlick: { PhysGrabObject componentInParent2 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2.photonView != (Object)null && !componentInParent2.isPlayer && !componentInParent2.isEnemy && !componentInParent2.isCart) { _net.SendToMaster(PoltergeistOpCode.FlickRequest, componentInParent2.photonView.ViewID, lookDir.x, lookDir.y + 0.15f, lookDir.z); return true; } return false; } case GhostAbilityId.DoorSlamHold: { PhysGrabHinge componentInParent4 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabHinge>(); if ((Object)(object)componentInParent4 != (Object)null && !componentInParent4.broken) { PhotonView val2 = (((Object)(object)componentInParent4.photon != (Object)null) ? componentInParent4.photon : ((Component)componentInParent4).GetComponentInParent<PhotonView>()); if ((Object)(object)val2 != (Object)null) { bool flag = GhostInput.IsSprintHeld(); _net.SendToMaster(PoltergeistOpCode.DoorActionRequest, val2.ViewID, flag, lookDir.x, lookDir.y, lookDir.z); _state.ShowToast(flag ? "Ghost Hold!" : "Door Slam!", 1.4f); return true; } } return false; } case GhostAbilityId.CartTapBrake: { PhysGrabCart componentInParent7 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabCart>(); if ((Object)(object)componentInParent7 != (Object)null && (Object)(object)componentInParent7.photonView != (Object)null) { if (componentInParent7.cartBeingPulled || ((Object)(object)componentInParent7.physGrabObject != (Object)null && componentInParent7.physGrabObject.playerGrabbing != null && componentInParent7.physGrabObject.playerGrabbing.Count > 0)) { _state.ShowToast("Cart is held by a teammate", 1.2f); return false; } int num; if ((Object)(object)componentInParent7.rb != (Object)null) { Vector3 linearVelocity = componentInParent7.rb.linearVelocity; num = ((((Vector3)(ref linearVelocity)).magnitude > 0.5f) ? 1 : 0); } else { num = 0; } bool flag2 = (byte)num != 0; bool flag3 = GhostInput.IsSprintHeld() || flag2; _net.SendToMaster(PoltergeistOpCode.CartActionRequest, componentInParent7.photonView.ViewID, flag3, lookDir.x, 0f, lookDir.z); _state.ShowToast(flag3 ? "C.A.R.T. Emergency Brake!" : "Cart Tap!", 1.4f); return true; } return false; } case GhostAbilityId.CursedRattle: { PhysGrabObject componentInParent3 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent3 != (Object)null && (Object)(object)componentInParent3.photonView != (Object)null && !componentInParent3.isPlayer && !componentInParent3.isEnemy && !componentInParent3.isCart) { _net.SendToMaster(PoltergeistOpCode.CursedRattleRequest, componentInParent3.photonView.ViewID); _state.ShowToast("Cursed Rattle!", 1.4f); return true; } return false; } case GhostAbilityId.CursedGrip: { PhysGrabObject componentInParent5 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent5 != (Object)null && (Object)(object)componentInParent5.photonView != (Object)null && !componentInParent5.isPlayer && !componentInParent5.isEnemy && componentInParent5.playerGrabbing != null && componentInParent5.playerGrabbing.Count > 0) { _net.SendToMaster(PoltergeistOpCode.CursedGripRequest, componentInParent5.photonView.ViewID); _state.ShowToast("Cursed Grip!", 1.4f); return true; } return false; } case GhostAbilityId.EmergencyCushion: { PhysGrabObject componentInParent6 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent6 != (Object)null && (Object)(object)componentInParent6.photonView != (Object)null && !componentInParent6.isPlayer && !componentInParent6.isEnemy) { _net.SendToMaster(PoltergeistOpCode.EmergencyCushionRequest, componentInParent6.photonView.ViewID); _state.ShowToast("Emergency Cushion!", 1.4f); return true; } return false; } case GhostAbilityId.GhostlyGlint: { PhysGrabObject componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.photonView != (Object)null && !componentInParent.isPlayer && !componentInParent.isEnemy) { _net.SendToAll(PoltergeistOpCode.GhostlyGlintBroadcast, true, componentInParent.photonView.ViewID, Plugin.ConfigSettings.GhostlyGlintDuration.Value); _state.ShowToast("Ghostly Glint!", 1.3f); return true; } return false; } case GhostAbilityId.StaticJumpStart: { ItemBattery val = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<ItemBattery>() ?? ((Component)((RaycastHit)(ref hit)).collider).GetComponentInChildren<ItemBattery>(); if ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null && !val.isUnchargable && (val.batteryLife <= 15f || val.currentBars == 0)) { _net.SendToMaster(PoltergeistOpCode.StaticJumpStartRequest, val.photonView.ViewID); _state.ShowToast("Static Jump-Start!", 1.6f); return true; } return false; } default: return false; } } private void TryTriggerHeadWiggle() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00f4: Unknown result type (might be due to invalid IL or missing references) PlayerDeathHead val = PlayerAvatar.instance?.playerDeathHead; if ((Object)(object)val == (Object)null || (Object)(object)val.photonView == (Object)null) { return; } float localCooldownRemaining = GetLocalCooldownRemaining(GhostAbilityId.HeadWiggleHonk); if (localCooldownRemaining > 0.05f) { _state.ShowToast($"Head Wiggle CD: {localCooldownRemaining:0.1}s", 1f); return; } float value = Plugin.ConfigSettings.HeadWiggleHonkCost.Value; if (!_ectoplasm.TrySpend(value)) { _state.ShowToast($"Need {value:0} Ectoplasm", 1.1f); return; } Vector3 val2 = (_state.IsFreeFloating ? (_state.GhostRotation * Vector3.forward) : Random.insideUnitSphere); _net.SendToMaster(PoltergeistOpCode.HeadWiggleRequest, val.photonView.ViewID, val2.x, val2.z); _localCooldowns[GhostAbilityId.HeadWiggleHonk] = Time.unscaledTime + Plugin.ConfigSettings.HeadWiggleHonkCooldown.Value; _state.ShowToast("Head Wiggle & Honk!", 1.2f); } private void TryTriggerManualVentriloquism() { PlayerDeathHead val = PlayerAvatar.instance?.playerDeathHead; if ((Object)(object)val == (Object)null || (Object)(object)val.photonView == (Object)null) { _state.ShowToast("No severed head found", 1.1f); return; } float localCooldownRemaining = GetLocalCooldownRemaining(GhostAbilityId.DeadHeadVentriloquism); if (localCooldownRemaining > 0.05f) { _state.ShowToast($"Ventriloquism CD: {localCooldownRemaining:0.1}s", 1f); return; } float value = Plugin.ConfigSettings.DeadHeadVentriloquismCost.Value; if (!_ectoplasm.TrySpend(value)) { _state.ShowToast($"Need {value:0} Ectoplasm", 1.1f); return; } _comedy.TriggerManualVentriloquism(val); _localCooldowns[GhostAbilityId.DeadHeadVentriloquism] = Time.unscaledTime + Plugin.ConfigSettings.DeadHeadVentriloquismCooldown.Value; _state.ShowToast("Head Spoke!", 1.2f); } private void TryTriggerHauntedWalkie() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_00c8: Unknown result type (might be due to invalid IL or missing references) PoltergeistConfig configSettings = Plugin.ConfigSettings; if (configSettings.EnableVoiceHooks.Value && configSettings.HauntedWalkieEnabled.Value) { float localCooldownRemaining = GetLocalCooldownRemaining(GhostAbilityId.HauntedWalkie); if (localCooldownRemaining > 0.05f) { _state.ShowToast($"Walkie CD: {localCooldownRemaining:0.1}s", 1f); return; } if (!_ectoplasm.TrySpend(configSettings.HauntedWalkieCost.Value)) { _state.ShowToast($"Need {configSettings.HauntedWalkieCost.Value:0} Ectoplasm", 1.1f); _state.PlaySubtleCue(positive: false); return; } Vector3 val = (_state.IsFreeFloating ? _state.GhostPosition : (((Object)(object)SpectateCamera.instance?.MainCamera != (Object)null) ? ((Component)SpectateCamera.instance.MainCamera).transform.position : Vector3.zero)); int localActorNumber = GetLocalActorNumber(); _net.SendToAll(PoltergeistOpCode.HauntedWalkieSync, true, localActorNumber, val.x, val.y, val.z, configSettings.HauntedWalkieDuration.Value); _localCooldowns[GhostAbilityId.HauntedWalkie] = Time.unscaledTime + configSettings.HauntedWalkieCooldown.Value; _state.ShowToast($"Haunted Walkie LIVE ({configSettings.HauntedWalkieDuration.Value:0.0}s)!"); } } private Enemy FindTargetedEnemy(float maxRange) { //IL_0006: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) Vector3 ghostPosition = _state.GhostPosition; Vector3 val = _state.GhostRotation * Vector3.forward; RaycastHit val2 = default(RaycastHit); if (Physics.SphereCast(ghostPosition, 0.55f, val, ref val2, maxRange, -1, (QueryTriggerInteraction)1)) { Enemy componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Enemy>(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } EnemyRigidbody componentInParent2 = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<EnemyRigidbody>(); if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2.enemy != (Object)null) { return componentInParent2.enemy; } } return null; } private Vector3 FindFloorPlacementPoint(float maxRange) { //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_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_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_0026: 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_0084: 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_0098: 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_006d: 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_003d: Unknown result type (might be due to invalid IL or missing references) if (TryRaycastTarget(maxRange, out var hit)) { RaycastHit val = default(RaycastHit); if (Physics.Raycast(((RaycastHit)(ref hit)).point + Vector3.up * 0.25f, Vector3.down, ref val, 4f, -1, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val)).point; } return ((RaycastHit)(ref hit)).point; } RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(_state.GhostPosition, Vector3.down, ref val2, 6f, -1, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val2)).point; } return _state.GhostPosition + _state.GhostRotation * Vector3.forward * 3f; } private PlayerAvatar FindNearbyLivingPlayer(float maxRadius) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) GameDirector instance = GameDirector.instance; if ((Object)(object)instance == (Object)null || instance.PlayerList == null) { return null; } float num = maxRadius * maxRadius; PlayerAvatar result = null; for (int i = 0; i < instance.PlayerList.Count; i++) { PlayerAvatar val = instance.PlayerList[i]; if (!((Object)(object)val == (Object)null) && !val.deadSet && !val.isDisabled) { Vector3 val2 = ((Component)val).transform.position + Vector3.up * 0.9f - _state.GhostPosition; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; result = val; } } } return result; } private bool TryRaycastTarget(float maxDistance, out RaycastHit hit) { //IL_0006: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) Vector3 ghostPosition = _state.GhostPosition; Vector3 val = _state.GhostRotation * Vector3.forward; return Physics.Raycast(ghostPosition, val, ref hit, maxDistance, -1, (QueryTriggerInteraction)1); } private static int GetLocalActorNumber() { if (!SemiFunc.IsMultiplayer() || PhotonNetwork.LocalPlayer == null) { return 0; } return PhotonNetwork.LocalPlayer.ActorNumber; } } public sealed class EctoplasmManager { private bool _wasFull = true; public float Current { get; private set; } public float Max { get; private set; } public float RegenPerSecond { get; private set; } public int DeadCount { get; private set; } public event Action OnReachedFull; public EctoplasmManager() { Reset(); } public void Reset() { PoltergeistConfig configSettings = Plugin.ConfigSettings; DeadCount = 1; Max = configSettings.BaseMaxEctoplasm.Value; RegenPerSecond = configSettings.BaseRegenPerSecond.Value; Current = Max; _wasFull = true; } public void Tick(float deltaTime, bool isDead) { PoltergeistConfig configSettings = Plugin.ConfigSettings; DeadCount = CountDeadPlayers(); int num = Mathf.Max(0, DeadCount - 1); Max = configSettings.BaseMaxEctoplasm.Value + (float)num * configSettings.BonusMaxPerExtraDeadPlayer.Value; RegenPerSecond = configSettings.BaseRegenPerSecond.Value + (float)num * configSettings.BonusRegenPerExtraDeadPlayer.Value; if (!isDead) { Current = Mathf.Min(Max, Current); return; } if (Current < Max) { Current = Mathf.Min(Max, Current + RegenPerSecond * deltaTime); } bool flag = Current >= Max - 0.01f; if (flag && !_wasFull) { this.OnReachedFull?.Invoke(); } _wasFull = flag; } public bool CanAfford(float cost) { return Current >= cost - 0.01f; } public bool TrySpend(float cost) { if (cost <= 0f) { return true; } if (!CanAfford(cost)) { return false; } Current = Mathf.Max(0f, Current - cost); _wasFull = Current >= Max - 0.01f; return true; } public void RefillFraction(float fraction) { if (!(fraction <= 0f)) { Current = Mathf.Min(Max, Current + Max * fraction); _wasFull = Current >= Max - 0.01f; } } private static int CountDeadPlayers() { GameDirector instance = GameDirector.instance; if ((Object)(object)instance == (Object)null || instance.PlayerList == null || instance.PlayerList.Count == 0) { return 1; } int num = 0; for (int i = 0; i < instance.PlayerList.Count; i++) { PlayerAvatar val = instance.PlayerList[i]; if ((Object)(object)val != (Object)null && (val.deadSet || val.isDisabled)) { num++; } } return Mathf.Max(1, num); } } public static class GhostInput { private static readonly Dictionary<string, Key> KeyCache = new Dictionary<string, Key>(StringComparer.OrdinalIgnoreCase); public static bool CanReadInput() { return SemiFunc.NoTextInputsActive(); } public static bool WasPressedThisFrame(string binding) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(binding) || !CanReadInput()) { return false; } string binding2 = binding.Trim(); if (TryGetMouseButton(binding2, out var control)) { if (control != null) { return control.wasPressedThisFrame; } return false; } if (TryResolveKey(binding2, out var key) && Keyboard.current != null) { KeyControl val = Keyboard.current[key]; if (val != null) { return ((ButtonControl)val).wasPressedThisFrame; } return false; } return false; } public static bool IsPressed(string binding) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(binding) || !CanReadInput()) { return false; } string binding2 = binding.Trim(); if (TryGetMouseButton(binding2, out var control)) { if (control != null) { return control.isPressed; } return false; } if (TryResolveKey(binding2, out var key) && Keyboard.current != null) { KeyControl val = Keyboard.current[key]; if (val != null) { return ((ButtonControl)val).isPressed; } return false; } return false; } public static Vector2 GetMoveAxes() { //IL_000e: 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) if (!CanReadInput() || Keyboard.current == null) { return Vector2.zero; } Keyboard current = Keyboard.current; float num = 0f; float num2 = 0f; if (((ButtonControl)current.dKey).isPressed || ((ButtonControl)current.rightArrowKey).isPressed) { num += 1f; } if (((ButtonControl)current.aKey).isPressed || ((ButtonControl)current.leftArrowKey).isPressed) { num -= 1f; } if (((ButtonControl)current.wKey).isPressed || ((ButtonControl)current.upArrowKey).isPressed) { num2 += 1f; } if (((ButtonControl)current.sKey).isPressed || ((ButtonControl)current.downArrowKey).isPressed) { num2 -= 1f; } Vector2 result = default(Vector2); ((Vector2)(ref result))..ctor(num, num2); if (((Vector2)(ref result)).sqrMagnitude > 1f) { ((Vector2)(ref result)).Normalize(); } return result; } public static float GetVerticalAxis() { if (!CanReadInput() || Keyboard.current == null) { return 0f; } Keyboard current = Keyboard.current; float num = 0f; if (((ButtonControl)current.spaceKey).isPressed) { num += 1f; } if (((ButtonControl)current.leftCtrlKey).isPressed || ((ButtonControl)current.cKey).isPressed) { num -= 1f; } return num; } public static bool IsSprintHeld() { if (!CanReadInput() || Keyboard.current == null) { return false; } if (!((ButtonControl)Keyboard.current.leftShiftKey).isPressed) { return ((ButtonControl)Keyboard.current.rightShiftKey).isPressed; } return true; } public static Vector2 GetLookDelta() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!CanReadInput() || Mouse.current == null) { return Vector2.zero; } return ((InputControl<Vector2>)(object)((Pointer)Mouse.current).delta).ReadValue(); } public static float GetScrollY() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!CanReadInput() || Mouse.current == null) { return 0f; } return ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y; } private static bool TryGetMouseButton(string binding, out ButtonControl control) { control = null; if (Mouse.current == null) { return false; } if (binding.Equals("Mouse0", StringComparison.OrdinalIgnoreCase) || binding.Equals("LeftClick", StringComparison.OrdinalIgnoreCase) || binding.Equals("LMB", StringComparison.OrdinalIgnoreCase)) { control = Mouse.current.leftButton; return true; } if (binding.Equals("Mouse1", StringComparison.OrdinalIgnoreCase) || binding.Equals("RightClick", StringComparison.OrdinalIgnoreCase) || binding.Equals("RMB", StringComparison.OrdinalIgnoreCase)) { control = Mouse.current.rightButton; return true; } if (binding.Equals("Mouse2", StringComparison.OrdinalIgnoreCase) || binding.Equals("MiddleClick", StringComparison.OrdinalIgnoreCase) || binding.Equals("MMB", StringComparison.OrdinalIgnoreCase)) { control = Mouse.current.middleButton; return true; } return false; } private static bool TryResolveKey(string binding, out Key key) { if (KeyCache.TryGetValue(binding, out key)) { return (int)key != 0; } string value = binding; if (binding.Equals("LShift", StringComparison.OrdinalIgnoreCase)) { value = "LeftShift"; } else if (binding.Equals("RShift", StringComparison.OrdinalIgnoreCase)) { value = "RightShift"; } else if (binding.Equals("LCtrl", StringComparison.OrdinalIgnoreCase)) { value = "LeftCtrl"; } else if (binding.Equals("RCtrl", StringComparison.OrdinalIgnoreCase)) { value = "RightCtrl"; } else if (binding.Equals("LAlt", StringComparison.OrdinalIgnoreCase)) { value = "LeftAlt"; } else if (binding.Equals("RAlt", StringComparison.OrdinalIgnoreCase)) { value = "RightAlt"; } if (!Enum.TryParse<Key>(value, ignoreCase: true, out key)) { key = (Key)0; } KeyCache[binding] = key; return (int)key != 0; } } public sealed class GhostStateController { private readonly EctoplasmManager _ectoplasm; private readonly TetherAnchorManager _tether; private float _yaw; private float _pitch; public bool IsLocalPlayerDead { get; private set; } public bool IsFreeFloating { get; private set; } public Vector3 GhostPosition { get; private set; } public Quaternion GhostRotation { get; private set; } public float LastAnchorDistance { get; private set; } public string CurrentAnchorLabel { get; private set; } = "None"; public bool IsAtTetherLimit { get; private set; } public string LastStatusToast { get; private set; } = string.Empty; public float ToastTimer { get; private set; } public GhostStateController(EctoplasmManager ectoplasm, TetherAnchorManager tether) { _ectoplasm = ectoplasm; _tether = tether; _ectoplasm.OnReachedFull += HandleEctoplasmFull; } public void Reset() { if (IsFreeFloating) { ExitFreeFloat(silent: true); } IsLocalPlayerDead = false; LastAnchorDistance = 0f; CurrentAnchorLabel = "None"; IsAtTetherLimit = false; LastStatusToast = string.Empty; ToastTimer = 0f; } public void Tick(float deltaTime) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 if (ToastTimer > 0f) { ToastTimer = Mathf.Max(0f, ToastTimer - deltaTime); } GameDirector instance = GameDirector.instance; SpectateCamera instance2 = SpectateCamera.instance; bool flag = (Object)(object)instance != (Object)null && (int)instance.currentState == 2 && SemiFunc.IsSpectating() && (Object)(object)instance2 != (Object)null && (int)instance2.currentState > 0; if (IsLocalPlayerDead && !flag) { ExitFreeFloat(silent: true); _ectoplasm.Reset(); } IsLocalPlayerDead = flag; _ectoplasm.Tick(deltaTime, IsLocalPlayerDead); if (!IsLocalPlayerDead) { return; } PoltergeistConfig configSettings = Plugin.ConfigSettings; if (!configSettings.FreeFloatEnabled.Value) { if (IsFreeFloating) { ExitFreeFloat(silent: true); } return; } if (GhostInput.WasPressedThisFrame(configSettings.ToggleGhostFloatKey.Value)) { if (IsFreeFloating) { ExitFreeFloat(silent: false); } else { EnterFreeFloat(); } } if (IsFreeFloating && GhostInput.WasPressedThisFrame(configSettings.ToggleAnchorKey.Value)) { GhostAnchorMode ghostAnchorMode = _tether.ToggleAnchor(); ShowToast("Anchor -> " + ((ghostAnchorMode == GhostAnchorMode.SeveredHead) ? "Severed Head" : "Spectated Teammate")); PlaySubtleCue(positive: true); } if (IsFreeFloating && GhostInput.WasPressedThisFrame("Mouse1")) { SpectateCamera instance3 = SpectateCamera.instance; if (instance3 != null) { instance3.PlayerSwitch(true); } ShowToast("Switched spectate anchor"); } } public void EnterFreeFloat() { //IL_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0063: 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_00b0: 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_00c0: Unknown result type (might be due to invalid IL or missing references) SpectateCamera instance = SpectateCamera.instance; if (!((Object)(object)instance == (Object)null) && IsLocalPlayerDead) { Transform val = (((Object)(object)instance.MainCamera != (Object)null) ? ((Component)instance.MainCamera).transform : ((Component)instance).transform); GhostPosition = val.position; Quaternion rotation = val.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; _yaw = eulerAngles.y; _pitch = NormalizePitch(eulerAngles.x); GhostRotation = Quaternion.Euler(_pitch, _yaw, 0f); if (_tether.TryGetAnchor(out var anchorPos, out var anchorLabel)) { CurrentAnchorLabel = anchorLabel; GhostPosition = _tether.MoveAndClamp(GhostPosition, GhostPosition, anchorPos, out var distToAnchor, out var wasClamped); LastAnchorDistance = distToAnchor; IsAtTetherLimit = wasClamped; } IsFreeFloating = true; ShowToast("Ghost Free-Float ON"); PlaySubtleCue(positive: true); } } public void ExitFreeFloat(bool silent) { if (IsFreeFloating) { IsFreeFloating = false; if (!silent) { ShowToast("Vanilla Spectate Restored"); PlaySubtleCue(positive: false); } } } public void LateUpdateCamera(SpectateCamera cam) { //IL_0088: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029a: 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_0168: 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_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_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_0184: 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_0190: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_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) if (!IsFreeFloating || (Object)(object)cam == (Object)null) { return; } PoltergeistConfig configSettings = Plugin.ConfigSettings; float deltaTime = Time.deltaTime; if (!Cursor.visible && GhostInput.CanReadInput()) { Vector2 lookDelta = GhostInput.GetLookDelta(); _yaw += lookDelta.x * 0.14f; _pitch = Mathf.Clamp(_pitch - lookDelta.y * 0.14f, -85f, 85f); } GhostRotation = Quaternion.Euler(_pitch, _yaw, 0f); if (_tether.TryGetAnchor(out var anchorPos, out var anchorLabel)) { CurrentAnchorLabel = anchorLabel; if (_tether.PendingSnapToAnchor) { Vector3 val = GhostPosition - anchorPos; float num = Mathf.Max(2f, configSettings.TetherRadius.Value * 0.45f); if (((Vector3)(ref val)).magnitude > num) { GhostPosition = anchorPos + ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val)).normalized : (-Vector3.forward)) * Mathf.Min(3.5f, num); } _tether.ClearSnapFlag(); } Vector2 moveAxes = GhostInput.GetMoveAxes(); float verticalAxis = GhostInput.GetVerticalAxis(); float num2 = (GhostInput.IsSprintHeld() ? configSettings.GhostSprintMultiplier.Value : 1f); Vector3 val2 = GhostRotation * Vector3.forward; Vector3 val3 = GhostRotation * Vector3.right; Vector3 val4 = (val2 * moveAxes.y + val3 * moveAxes.x) * (configSettings.GhostMoveSpeed.Value * num2); Vector3 val5 = Vector3.up * (verticalAxis * configSettings.GhostVerticalSpeed.Value * num2); Vector3 desiredPos = GhostPosition + (val4 + val5) * deltaTime; GhostPosition = _tether.MoveAndClamp(GhostPosition, desiredPos, anchorPos, out var distToAnchor, out var wasClamped); LastAnchorDistance = distToAnchor; IsAtTetherLimit = wasClamped; } else { CurrentAnchorLabel = "Unanchored"; LastAnchorDistance = 0f; IsAtTetherLimit = false; } ((Component)cam).transform.SetPositionAndRotation(GhostPosition, GhostRotation); if ((Object)(object)cam.MainCamera != (Object)null) { ((Component)cam.MainCamera).transform.SetPositionAndRotation(GhostPosition, GhostRotation); } if ((Object)(object)cam.normalTransformDistance != (Object)null) { cam.normalTransformDistance.SetPositionAndRotation(GhostPosition, GhostRotation); } } public void ShowToast(string message, float duration = 2f) { LastStatusToast = message; ToastTimer = duration; } public void PlaySubtleCue(bool positive) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0070: 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) PoltergeistConfig configSettings = Plugin.ConfigSettings; PlayerDeathHead val = PlayerAvatar.instance?.playerDeathHead; if ((Object)(object)val == (Object)null) { return; } if (configSettings.EnableAudioCues.Value) { Sound val2 = (positive ? val.eyeFlashPositiveSound : val.eyeFlashNegativeSound); if (val2 != null && val2.Sounds != null && val2.Sounds.Length != 0) { Vector3 val3 = (IsFreeFloating ? GhostPosition : ((Component)val).transform.position); val2.Play(val3, 0.35f, 1f, 1f, 1f); } } if (configSettings.EnableHeadEyeLightCues.Value && (Object)(object)val.eyeFlashLight != (Object)null) { val.eyeFlashLight.color = (positive ? val.eyeFlashPositiveColor : val.eyeFlashNegativeColor); val.eyeFlashLight.intensity = Mathf.Max(val.eyeFlashLight.intensity, 1.5f); } } private void HandleEctoplasmFull() { if (IsLocalPlayerDead) { PlaySubtleCue(positive: true); } } private static float NormalizePitch(float xAngle) { if (xAngle > 180f) { xAngle -= 360f; } return Mathf.Clamp(xAngle, -85f, 85f); } } public enum TargetCategory { Door, Valuable, Cart, MonsterBoop, MonsterOther, Head } public sealed class GuardrailRegistry { private readonly Dictionary<(TargetCategory, int), float> _cooldowns = new Dictionary<(TargetCategory, int), float>(); private readonly Dictionary<int, float> _protectedInstanceIds = new Dictionary<int, float>(); public void Reset() { _cooldowns.Clear(); _protectedInstanceIds.Clear(); } public bool TryConsumeTargetCooldown(TargetCategory category, int targetId, out float remainingSeconds) { float unscaledTime = Time.unscaledTime; (TargetCategory, int) key = (category, targetId); if (_cooldowns.TryGetValue(key, out var value) && unscaledTime < value) { remainingSeconds = value - unscaledTime; return false; } float categoryCooldown = GetCategoryCooldown(category); _cooldowns[key] = unscaledTime + categoryCooldown; remainingSeconds = 0f; return true; } public float GetRemainingCooldown(TargetCategory category, int targetId) { if (_cooldowns.TryGetValue((category, targetId), out var value)) { return Mathf.Max(0f, value - Time.unscaledTime); } return 0f; } public void ApplySafeLootProtection(PhysGrabObject pgo, float extraDuration = 0f, bool suppressEnemyInvestigate = false) { if ((Object)(object)pgo == (Object)null || !Plugin.ConfigSettings.SafeLootProtectionEnabled.Value) { return; } float num = Mathf.Max(0.2f, Plugin.ConfigSettings.SafeLootDurationBuffer.Value + extraDuration); pgo.OverrideIndestructible(num); pgo.OverrideBreakEffects(num); if ((Object)(object)pgo.impactDetector != (Object)null) { pgo.impactDetector.ImpactDisable(num); if (suppressEnemyInvestigate) { pgo.impactDetector.OverrideEnemyInvestigateDisable(num); } } int instanceID = ((Object)pgo).GetInstanceID(); float num2 = Time.unscaledTime + num; if (!_protectedInstanceIds.TryGetValue(instanceID, out var value) || num2 > value) { _protectedInstanceIds[instanceID] = num2; } } public bool IsObjectProtected(PhysGrabObject pgo) { if ((Object)(object)pgo == (Object)null || !Plugin.ConfigSettings.SafeLootProtectionEnabled.Value) { return false; } int instanceID = ((Object)pgo).GetInstanceID(); if (_protectedInstanceIds.TryGetValue(instanceID, out var value)) { if (Time.unscaledTime <= value) { return true; } _protectedInstanceIds.Remove(instanceID); } return false; } private static float GetCategoryCooldown(TargetCategory category) { PoltergeistConfig configSettings = Plugin.ConfigSettings; return category switch { TargetCategory.Door => configSettings.DoorTargetCooldown.Value, TargetCategory.Valuable => configSettings.ValuableTargetCooldown.Value, TargetCategory.Cart => configSettings.ValuableTargetCooldown.Value, TargetCategory.MonsterBoop => configSettings.MonsterBoopImmunitySeconds.Value, TargetCategory.MonsterOther => configSettings.MonsterAbilityTargetCooldown.Value, TargetCategory.Head => configSettings.HeadWiggleHonkCooldown.Value, _ => 3f, }; } } public sealed class TetherAnchorManager { private readonly RaycastHit[] _sphereHits = (RaycastHit[])(object)new RaycastHit[16]; public GhostAnchorMode ActiveMode { get; private set; } public bool PendingSnapToAnchor { get; private set; } public TetherAnchorManager() { ActiveMode = Plugin.ConfigSettings.DefaultAnchorMode.Value; } public void Reset() { ActiveMode = Plugin.ConfigSettings.DefaultAnchorMode.Value; PendingSnapToAnchor = false; } public GhostAnchorMode ToggleAnchor() { ActiveMode = ((ActiveMode == GhostAnchorMode.SpectatedTeammate) ? GhostAnchorMode.SeveredHead : GhostAnchorMode.SpectatedTeammate); PendingSnapToAnchor = true; return ActiveMode; } public void OnSpectateTargetSwitched(PlayerAvatar newTarget) { if (ActiveMode == GhostAnchorMode.SpectatedTeammate) { PendingSnapToAnchor = true; } } public void ClearSnapFlag() { PendingSnapToAnchor = false; } public bool TryGetAnchor(out Vector3 anchorPos, out string anchorLabel) { //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_00a5: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00fe: 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_010d: 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_0117: 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_0049: 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_005d: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; SpectateCamera instance2 = SpectateCamera.instance; if (ActiveMode == GhostAnchorMode.SpectatedTeammate && (Object)(object)instance2 != (Object)null && (Object)(object)instance2.player != (Object)null && !instance2.player.deadSet) { anchorPos = ((Component)instance2.player).transform.position + Vector3.up * 1.15f; string text = SemiFunc.PlayerGetName(instance2.player); anchorLabel = (string.IsNullOrEmpty(text) ? "Teammate" : text); return true; } if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerDeathHead != (Object)null) { anchorPos = ((Component)instance.playerDeathHead).transform.position + Vector3.up * 0.35f; anchorLabel = ((ActiveMode == GhostAnchorMode.SpectatedTeammate) ? "Severed Head (Fallback)" : "Severed Head"); return true; } if ((Object)(object)instance2 != (Object)null && (Object)(object)instance2.player != (Object)null) { anchorPos = ((Component)instance2.player).transform.position + Vector3.up * 1.15f; string text2 = SemiFunc.PlayerGetName(instance2.player); anchorLabel = (string.IsNullOrEmpty(text2) ? "Spectate Target" : text2); return true; } anchorPos = Vector3.zero; anchorLabel = "None"; return false; } public Vector3 MoveAndClamp(Vector3 currentPos, Vector3 desiredPos, Vector3 anchorPos, out float distToAnchor, out bool wasClamped) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000f: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_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) //IL_0070: 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_0037: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) PoltergeistConfig configSettings = Plugin.ConfigSettings; Vector3 val = currentPos; Vector3 delta = desiredPos - currentPos; if (((Vector3)(ref delta)).sqrMagnitude > 1E-06f) { val = ((!configSettings.GhostWallCollision.Value) ? desiredPos : SlideMove(currentPos, delta)); } float value = configSettings.TetherRadius.Value; Vector3 val2 = val - anchorPos; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude > value * value) { val = anchorPos + ((Vector3)(ref val2)).normalized * value; distToAnchor = value; wasClamped = true; } else { distToAnchor = Mathf.Sqrt(sqrMagnitude); wasClamped = false; } return val; } private Vector3 SlideMove(Vector3 origin, Vector3 delta) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_00e7: 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_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_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_0075: 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_0089: 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_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_00d9: 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_00dd: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) float magnitude = ((Vector3)(ref delta)).magnitude; if (magnitude < 0.0001f) { return origin; }