using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("DroneCam")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DroneCam")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ea282da8-693d-4cf1-bf7a-8ecac0827eaa")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace DroneCam; [BepInPlugin("com.oathorse.xdc", "Xpert's Drone Cam", "0.2.0")] [BepInProcess("valheim.exe")] public class DroneCamPlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func <>9__14_1; public static ConsoleEvent <>9__14_0; internal void b__14_0(ConsoleEventArgs args) { DroneCamCommands.Handle(DroneCamCommands.CollapseQuotedArgs((from s in args.Args.Skip(1) where !string.IsNullOrEmpty(s) select s).ToArray())); } internal bool b__14_1(string s) { return !string.IsNullOrEmpty(s); } } public const string PluginGUID = "com.oathorse.xdc"; public const string PluginName = "Xpert's Drone Cam"; public const string PluginVersion = "0.2.0"; internal static ManualLogSource Log; public static ConfigEntry FlySpeed; public static ConfigEntry FlySpeedFast; public static ConfigEntry RotationSpeed; public static ConfigEntry SmoothTime; public static ConfigEntry TeleportDetectionDistance; public static ConfigEntry ScrollSensitivity; public static ConfigEntry SelectPlayerConeAngle; public static ConfigEntry SelectEnemyConeAngle; private readonly Harmony _harmony = new Harmony("com.oathorse.xdc"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; FlySpeed = ((BaseUnityPlugin)this).Config.Bind("Camera", "FlySpeed", 10f, "Normal fly speed (units/sec)."); FlySpeedFast = ((BaseUnityPlugin)this).Config.Bind("Camera", "FlySpeedFast", 40f, "Fast fly speed (units/sec)."); RotationSpeed = ((BaseUnityPlugin)this).Config.Bind("Camera", "RotationSpeed", 90f, "Keyboard rotation speed (degrees/sec)."); SmoothTime = ((BaseUnityPlugin)this).Config.Bind("Camera", "SmoothTime", 0.25f, "Movement smoothing time for free-fly, orbit and security."); TeleportDetectionDistance = ((BaseUnityPlugin)this).Config.Bind("Camera", "TeleportDetectionDistance", 50f, "Distance delta that triggers portal follow detection."); ScrollSensitivity = ((BaseUnityPlugin)this).Config.Bind("Camera", "ScrollSensitivity", 0.5f, "Mouse wheel sensitivity for distance/radius adjustment."); SelectPlayerConeAngle = ((BaseUnityPlugin)this).Config.Bind("Camera", "SelectPlayerConeAngle", 5f, "Half-angle of the cone in degrees when selecting a player with Left Click."); SelectEnemyConeAngle = ((BaseUnityPlugin)this).Config.Bind("Camera", "SelectEnemyConeAngle", 3f, "Half-angle of the cone in degrees when targeting an enemy with T."); RegisterConsoleCommands(); _harmony.PatchAll(); Log.LogInfo((object)"Xpert's Drone Cam 0.2.0 loaded. Console: 'dc help' Chat: '/dc help'"); } private static void RegisterConsoleCommands() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown object obj = <>c.<>9__14_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { DroneCamCommands.Handle(DroneCamCommands.CollapseQuotedArgs((from s in args.Args.Skip(1) where !string.IsNullOrEmpty(s) select s).ToArray())); }; <>c.<>9__14_0 = val; obj = (object)val; } new ConsoleCommand("dc", "Xpert's Drone Cam control. Type 'dc help' for usage.", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private void OnDestroy() { _harmony.UnpatchSelf(); } } public enum StreamProtocol { Spout, NDI } public enum TargetType { None, Player, Enemy, Position } public class DroneCamTarget { public TargetType Type; public string Name; public Transform Transform; public Vector3 WorldPosition; public bool IsValid { get { if (Type != TargetType.Position) { if ((Object)(object)Transform != (Object)null && ((Component)Transform).gameObject.activeInHierarchy) { Character component = ((Component)Transform).GetComponent(); return component == null || !component.IsDead(); } return false; } return true; } } public Vector3 GetPosition() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (Type == TargetType.Position) { return WorldPosition; } if ((Object)(object)Transform != (Object)null) { return Transform.position; } return Vector3.zero; } public static DroneCamTarget ForEnemy(Character c) { return new DroneCamTarget { Type = TargetType.Enemy, Name = c.GetHoverName(), Transform = ((Component)c).transform }; } public static DroneCamTarget ForPosition(Vector3 pos) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return new DroneCamTarget { Type = TargetType.Position, WorldPosition = pos }; } } internal static class Btn { public const string Toggle = "DroneCam_Toggle"; public const string FreeFlyToggle = "DroneCam_FreeFlyToggle"; public const string SelectPlayer = "DroneCam_SelectPlayer"; public const string SelectEnemy = "DroneCam_SelectEnemy"; public const string Fast = "DroneCam_Fast"; public const string Forward = "DroneCam_Forward"; public const string Back = "DroneCam_Back"; public const string StrafeLeft = "DroneCam_StrafeLeft"; public const string StrafeRight = "DroneCam_StrafeRight"; public const string Up = "DroneCam_Up"; public const string Down = "DroneCam_Down"; public const string YawLeft = "DroneCam_YawLeft"; public const string YawRight = "DroneCam_YawRight"; public const string PitchUp = "DroneCam_PitchUp"; public const string PitchDown = "DroneCam_PitchDown"; public const string MouseLook = "DroneCam_MouseLook"; public const string WheelUp = "DroneCam_WheelUp"; public const string WheelDown = "DroneCam_WheelDown"; public const string ModHeight = "DroneCam_ModHeight"; public const string ModSpeed = "DroneCam_ModSpeed"; public const string NextPlayer = "DroneCam_NextPlayer"; public const string PrevPlayer = "DroneCam_PrevPlayer"; } [HarmonyPatch(typeof(ZInput), "Reset")] public static class ZInput_Reset_Patch { private static void Postfix(ZInput __instance) { __instance.AddButton("DroneCam_Toggle", "/f8", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_FreeFlyToggle", "/f7", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_SelectPlayer", "/leftButton", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_SelectEnemy", "/t", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_Fast", "/leftShift", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_Forward", "/w", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_Back", "/s", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_StrafeLeft", "/a", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_StrafeRight", "/d", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_Up", "/e", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_Down", "/q", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_YawLeft", "/leftArrow", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_YawRight", "/rightArrow", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_PitchUp", "/upArrow", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_PitchDown", "/downArrow", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_MouseLook", "/rightButton", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_WheelUp", "/scroll/up", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_WheelDown", "/scroll/down", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_ModHeight", "/leftAlt", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_ModSpeed", "/leftCtrl", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_NextPlayer", "/period", false, true, false, 0f, 0f); __instance.AddButton("DroneCam_PrevPlayer", "/comma", false, true, false, 0f, 0f); } } public enum DroneCamMode { Disabled, FreeSetup, Follow, Orbit, Security } public class DroneCamController : MonoBehaviour { private DroneCamTarget _anchor; private DroneCamTarget _lookTarget; private Vector3 _anchorLastPos = Vector3.zero; private Vector3 _anchorLastKnownPos = Vector3.zero; private Vector3 _anchorLastRelOffset = Vector3.zero; private Vector3 _anchorLastInfoPos = Vector3.zero; private bool _anchorWaiting; private float _focalOffsetY; private Vector3 _lastLookPosition = Vector3.zero; private Vector3 _lastSafeGroundPosition = Vector3.zero; private bool _waitingForTeleport; private DroneCamMode _lastTrackingMode; private string _lastTrackingTarget; private float _lastFollowDistance = 5f; private float _lastFollowHeight = 2f; private float _lastFollowSmooth = 0.1f; private float _lastOrbitRadius = 10f; private float _lastOrbitSpeed = 30f; private float _lastOrbitHeight = 4f; private string _selectCandidateName; private float _followDistance = 5f; private float _followSmoothTime = 0.1f; private Vector3 _followHeightOffset = new Vector3(0f, 2f, 0f); private float _orbitRadius = 10f; private float _orbitSpeed = 30f; private float _orbitHeight = 4f; private float _orbitAngle; private Vector3 _securityPos; private Vector3 _dronePos; private Quaternion _droneRot; private Vector3 _smoothVelocity = Vector3.zero; private Vector3 _smoothVelRef = Vector3.zero; private DroneCamMode _modeBeforeSleep; private GameObject _fakeAttachPoint; private bool _broadcastRealPosition; private bool _targetWasSleeping; private bool _hudHidden; private Camera _streamCamera; private RenderTexture _streamTexture; private Component _spoutSender; private Component _ndiSender; private bool _streamActive; private int _streamWidth = 1920; private int _streamHeight = 1080; private StreamProtocol _streamProtocol; private GameCamera _gameCamera; public static DroneCamController Instance { get; private set; } public DroneCamMode Mode { get; private set; } public bool WaitingForTeleport => _waitingForTeleport; public bool BroadcastRealPosition => _broadcastRealPosition; public bool HudHidden => _hudHidden; private void Awake() { Instance = this; _gameCamera = ((Component)this).GetComponent(); } private void Update() { //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_027a: 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_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) if (ZInput.instance == null) { return; } if (ZInput.GetButtonDown("DroneCam_Toggle")) { if (Mode == DroneCamMode.Disabled) { EnterFreeSetup(); } else { ExitDroneCam(); } return; } if (_waitingForTeleport) { if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((Character)Player.m_localPlayer).m_nview != (Object)null && ((Character)Player.m_localPlayer).m_nview.IsValid()) { ((Character)Player.m_localPlayer).SetVisible(false); ((Character)Player.m_localPlayer).m_body.position = ((Component)this).transform.position; } PollTeleportComplete(); return; } if (ZInput.GetButtonDown("DroneCam_FreeFlyToggle") && Mode != 0) { if (Mode == DroneCamMode.FreeSetup) { if (_lastTrackingMode != 0 && _lastTrackingTarget != null) { switch (_lastTrackingMode) { case DroneCamMode.Follow: SetFollow(_lastTrackingTarget, _lastFollowDistance, _lastFollowHeight, _lastFollowSmooth); break; case DroneCamMode.Orbit: SetOrbitPlayer(_lastTrackingTarget, _lastOrbitRadius, _lastOrbitSpeed, _lastOrbitHeight); break; case DroneCamMode.Security: SetSecurityPlayer(_lastTrackingTarget); break; } } else { Notify("No previous tracking mode to return to."); } } else { SaveTrackingState(); _dronePos = ((Component)this).transform.position; _droneRot = ((Component)this).transform.rotation; _smoothVelocity = Vector3.zero; Mode = DroneCamMode.FreeSetup; Notify("Free-fly - press F7 to return to tracking."); } return; } switch (Mode) { case DroneCamMode.FreeSetup: UpdateFreeSetup(); break; case DroneCamMode.Follow: UpdateFollow(); break; case DroneCamMode.Orbit: UpdateOrbit(); break; case DroneCamMode.Security: UpdateSecurity(); break; } if (Mode != 0) { HandleScrollWheel(); HandlePlayerCycle(); HandleSelectPlayer(); HandleSelectEnemy(); PollTargetSleepState(); } if (Mode == DroneCamMode.Disabled || !((Object)(object)Player.m_localPlayer != (Object)null) || !((Object)(object)((Character)Player.m_localPlayer).m_nview != (Object)null) || !((Character)Player.m_localPlayer).m_nview.IsValid()) { return; } ((Character)Player.m_localPlayer).m_body.position = ((Component)this).transform.position; ((Character)Player.m_localPlayer).SetVisible(false); if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.IsAreaReady(((Component)this).transform.position)) { Vector3 val = FindGroundPosition(((Component)this).transform.position); if (val != ((Component)this).transform.position) { _lastSafeGroundPosition = val; } } } private void LateUpdate() { //IL_0031: 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) if (_streamActive && !((Object)(object)_streamCamera == (Object)null) && Mode != 0) { ((Component)_streamCamera).transform.position = ((Component)this).transform.position; ((Component)_streamCamera).transform.rotation = ((Component)this).transform.rotation; GameCamera gameCamera = _gameCamera; Camera val = ((gameCamera != null) ? ((Component)gameCamera).GetComponent() : null); if ((Object)(object)val != (Object)null) { _streamCamera.fieldOfView = val.fieldOfView; } _streamCamera.Render(); } } private void SaveTrackingState() { if (Mode == DroneCamMode.Follow || Mode == DroneCamMode.Orbit || Mode == DroneCamMode.Security) { _lastTrackingMode = Mode; _lastTrackingTarget = _anchor?.Name; _lastFollowDistance = _followDistance; _lastFollowHeight = _followHeightOffset.y; _lastFollowSmooth = _followSmoothTime; _lastOrbitRadius = _orbitRadius; _lastOrbitSpeed = _orbitSpeed; _lastOrbitHeight = _orbitHeight; } } public void EnterFreeSetup() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) _dronePos = ((Component)this).transform.position; _droneRot = ((Component)this).transform.rotation; _smoothVelocity = Vector3.zero; Mode = DroneCamMode.FreeSetup; SetGameCameraEnabled(state: false); EnterDroneMode(); Notify("Free-fly active. WASD/QE move, Shift=fast, RMB/arrows rotate. F8 to exit."); } public void ExitDroneCam() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (_streamActive) { TeardownStreamCamera(); } _waitingForTeleport = false; Mode = DroneCamMode.Disabled; SetGameCameraEnabled(state: true); if (_hudHidden) { _hudHidden = false; Hud instance = Hud.instance; if (instance != null) { ((Component)instance).gameObject.SetActive(true); } } if ((Object)(object)Player.m_localPlayer != (Object)null) { Vector3 val = ((_lastSafeGroundPosition != Vector3.zero) ? _lastSafeGroundPosition : ((Component)Player.m_localPlayer).transform.position); ((Character)Player.m_localPlayer).m_body.position = val; ((Character)Player.m_localPlayer).m_body.velocity = Vector3.zero; ((Character)Player.m_localPlayer).SetVisible(true); ZNet.instance.SetReferencePosition(val); } Notify("Disabled - normal camera restored."); } public void ToggleHud() { _hudHidden = !_hudHidden; Hud instance = Hud.instance; if (instance != null) { ((Component)instance).gameObject.SetActive(!_hudHidden); } Notify(_hudHidden ? "HUD hidden." : "HUD visible."); } private void TravelToPosition(Vector3 targetPos) { //IL_0018: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null)) { DroneCamPlugin.Log.LogInfo((object)$"[DroneCam] TravelToPosition: {targetPos}"); if (((Character)Player.m_localPlayer).TeleportTo(targetPos, ((Component)Player.m_localPlayer).transform.rotation, true)) { _waitingForTeleport = true; Notify("Teleporting..."); return; } DroneCamPlugin.Log.LogInfo((object)"[DroneCam] TeleportTo on cooldown - snapping directly."); SnapDroneTo(targetPos); _anchorLastRelOffset = targetPos - _anchorLastKnownPos; _anchorWaiting = false; } } private void TravelToPlayer(string playerName, Vector3 targetPos) { //IL_0019: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null)) { DroneCamPlugin.Log.LogInfo((object)$"[DroneCam] TravelToPlayer: '{playerName}' at {targetPos}"); if (((Character)Player.m_localPlayer).TeleportTo(targetPos, ((Component)Player.m_localPlayer).transform.rotation, true)) { _waitingForTeleport = true; Notify("Teleporting to " + playerName + "..."); return; } DroneCamPlugin.Log.LogInfo((object)"[DroneCam] TeleportTo on cooldown - snapping directly."); Vector3 val = targetPos + _anchorLastRelOffset; SnapDroneTo(val); _anchorLastKnownPos = targetPos; _anchorLastPos = targetPos; _anchorLastRelOffset = val - targetPos; _anchorWaiting = false; } } private void PollTeleportComplete() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0091: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e8: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_00ff: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsTeleporting()) { return; } ((Character)Player.m_localPlayer).SetVisible(false); ((Character)Player.m_localPlayer).m_body.position = ((Component)this).transform.position; _waitingForTeleport = false; DroneCamPlugin.Log.LogInfo((object)"[DroneCam] Teleport complete - resuming tracking."); if (_anchor == null) { return; } PlayerInfo pi = FindPlayerInfo(_anchor.Name); Vector3 playerInfoPosition = GetPlayerInfoPosition(pi); Vector3 playerRealtimePosition = GetPlayerRealtimePosition(pi); Vector3 val = ((playerRealtimePosition != Vector3.zero) ? playerRealtimePosition : playerInfoPosition); if (val != Vector3.zero) { Vector3 position = ((Component)Player.m_localPlayer).transform.position; ((Component)this).transform.position = position; _dronePos = position; _smoothVelocity = Vector3.zero; _smoothVelRef = Vector3.zero; ((Character)Player.m_localPlayer).m_body.position = position; _anchorLastKnownPos = val; _anchorLastPos = val; _anchorLastInfoPos = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : val); _anchorLastRelOffset = position - val; _anchorWaiting = false; Player val2 = FindPlayerByZdo(FindPlayerZdo(pi)); if ((Object)(object)val2 != (Object)null) { _anchor.Transform = ((Component)val2).transform; } Notify("Now tracking " + _anchor.Name + "."); } else { _anchorWaiting = false; _anchorLastInfoPos = Vector3.zero; Notify("Arrived near " + _anchor.Name + " - acquiring target..."); } } public void OnPlayerSleep() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0061: 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) if (Mode != 0 && _modeBeforeSleep == DroneCamMode.Disabled) { _modeBeforeSleep = Mode; SetGameCameraEnabled(state: true); if ((Object)(object)Player.m_localPlayer != (Object)null) { _broadcastRealPosition = true; _fakeAttachPoint = new GameObject("DroneCam_FakeBed"); _fakeAttachPoint.transform.position = ((Component)Player.m_localPlayer).transform.position; ((Character)Player.m_localPlayer).AttachStart(_fakeAttachPoint.transform, (GameObject)null, false, true, false, "attach_bed", Vector3.zero, (Transform)null); Player.m_localPlayer.m_sleeping = true; ((Character)Player.m_localPlayer).m_nview.GetZDO().Set(ZDOVars.s_inBed, true); ZDOMan.instance.FlushClientObjects(); } Notify("Sleeping - drone suspended."); } } public void OnPlayerWake() { if (_modeBeforeSleep == DroneCamMode.Disabled) { return; } _broadcastRealPosition = false; if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).AttachStop(); Player.m_localPlayer.m_sleeping = false; if ((Object)(object)_fakeAttachPoint != (Object)null) { Object.Destroy((Object)(object)_fakeAttachPoint); _fakeAttachPoint = null; } } SetGameCameraEnabled(state: false); Mode = _modeBeforeSleep; _modeBeforeSleep = DroneCamMode.Disabled; Notify("Awake - drone resumed."); } private void PollTargetSleepState() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (_anchor == null || _anchor.Type != TargetType.Player) { return; } ZDO val = FindPlayerZdo(FindPlayerInfo(_anchor.Name)); if (val != null) { bool @bool = val.GetBool(ZDOVars.s_inBed, false); if (@bool && !_targetWasSleeping) { _targetWasSleeping = true; OnPlayerSleep(); } else if (!@bool && _targetWasSleeping) { _targetWasSleeping = false; OnPlayerWake(); } } } private void EnterDroneMode() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { Player.m_localPlayer.m_godMode = true; Player.m_localPlayer.m_ghostMode = true; SEMan seman = ((Character)Player.m_localPlayer).m_seman; if (seman != null) { seman.RemoveStatusEffect(SEMan.s_statusEffectWet, true); } SEMan seman2 = ((Character)Player.m_localPlayer).m_seman; if (seman2 != null) { seman2.RemoveStatusEffect(SEMan.s_statusEffectTared, true); } } } private void SetGameCameraEnabled(bool state) { if ((Object)(object)_gameCamera != (Object)null) { ((Behaviour)_gameCamera).enabled = state; } } private static Vector3 FindGroundPosition(Vector3 from) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(from, Vector3.down, ref val, 2000f, ZoneSystem.instance.m_solidRayMask)) { return ((RaycastHit)(ref val)).point + Vector3.up * 0.5f; } if (Physics.Raycast(from + Vector3.up * 500f, Vector3.down, ref val, 2000f, ZoneSystem.instance.m_solidRayMask)) { return ((RaycastHit)(ref val)).point + Vector3.up * 0.5f; } return from; } private void HandleScrollWheel() { if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return; } float num = 0f; if (ZInput.GetButton("DroneCam_WheelUp")) { num -= DroneCamPlugin.ScrollSensitivity.Value; } if (ZInput.GetButton("DroneCam_WheelDown")) { num += DroneCamPlugin.ScrollSensitivity.Value; } if (Mathf.Approximately(num, 0f)) { return; } bool button = ZInput.GetButton("DroneCam_ModHeight"); bool button2 = ZInput.GetButton("DroneCam_ModSpeed"); if (button && button2) { if (Mode == DroneCamMode.Orbit) { _orbitSpeed = Mathf.Max(1f, _orbitSpeed + num * 10f); } return; } if (button2) { _focalOffsetY += num; return; } switch (Mode) { case DroneCamMode.Follow: if (button) { _followHeightOffset.y = Mathf.Max(0f, _followHeightOffset.y + num); } else { _followDistance = Mathf.Max(1f, _followDistance + num); } break; case DroneCamMode.FreeSetup: _followDistance = Mathf.Max(1f, _followDistance + num); break; case DroneCamMode.Orbit: if (button) { _orbitHeight = Mathf.Max(0f, _orbitHeight + num); } else { _orbitRadius = Mathf.Max(1f, _orbitRadius + num); } break; case DroneCamMode.Security: if (button) { _securityPos.y = Mathf.Max(0f, _securityPos.y + num); } break; } } private void HandlePlayerCycle() { if (((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || _anchor == null || _anchor.Type != TargetType.Player) { return; } int num = 0; if (ZInput.GetButtonDown("DroneCam_NextPlayer")) { num = 1; } if (ZInput.GetButtonDown("DroneCam_PrevPlayer")) { num = -1; } if (num == 0) { return; } List list = GetPlayerNames().ToList(); if (list.Count >= 1) { int num2 = list.FindIndex((string n) => string.Equals(n, _anchor.Name, StringComparison.OrdinalIgnoreCase)); int index = ((num2 >= 0) ? ((num2 + num + list.Count) % list.Count) : 0); string text = list[index]; switch (Mode) { case DroneCamMode.Follow: SetFollow(text, _followDistance, _followHeightOffset.y, _followSmoothTime); break; case DroneCamMode.Orbit: SetOrbitPlayer(text, _orbitRadius, _orbitSpeed, _orbitHeight); break; case DroneCamMode.Security: SetSecurityPlayer(text); break; } } } private void HandleSelectPlayer() { if (((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || !ZInput.GetButtonDown("DroneCam_SelectPlayer") || Mode == DroneCamMode.Disabled) { return; } _selectCandidateName = null; Player val = FindPlayerInLookDirection(); string text = (((Object)(object)val != (Object)null) ? val.GetPlayerName() : _selectCandidateName); if (string.IsNullOrEmpty(text)) { Notify("No player found in look direction."); return; } DroneCamPlugin.Log.LogInfo((object)("[DroneCam] SelectPlayer: targeting '" + text + "'")); switch ((_lastTrackingMode != 0) ? _lastTrackingMode : DroneCamMode.Orbit) { case DroneCamMode.Follow: SetFollow(text, _lastFollowDistance, _lastFollowHeight, _lastFollowSmooth); break; case DroneCamMode.Orbit: SetOrbitPlayer(text, _lastOrbitRadius, _lastOrbitSpeed, _lastOrbitHeight); break; case DroneCamMode.Security: SetSecurityPlayer(text); break; default: SetOrbitPlayer(text, _lastOrbitRadius, _lastOrbitSpeed, _lastOrbitHeight); break; } } private Player FindPlayerInLookDirection() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_005e: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b8: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) Player result = null; float num = float.MaxValue; Vector3 position = ((Component)this).transform.position; Vector3 forward = ((Component)this).transform.forward; float value = DroneCamPlugin.SelectPlayerConeAngle.Value; Player localPlayer = Player.m_localPlayer; string b = ((localPlayer != null) ? localPlayer.GetPlayerName() : null); foreach (PlayerInfo player in ZNet.instance.m_players) { if (string.IsNullOrEmpty(player.m_name) || string.Equals(player.m_name, b, StringComparison.OrdinalIgnoreCase)) { continue; } Vector3 val = GetPlayerRealtimePosition(player); if (val == Vector3.zero) { val = GetPlayerInfoPosition(player); } if (val == Vector3.zero) { continue; } Vector3 val2 = val - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < 0.1f) { continue; } float num2 = Mathf.Acos(Mathf.Clamp(Vector3.Dot(forward, ((Vector3)(ref val2)).normalized), -1f, 1f)) * 57.29578f; if (num2 > value) { continue; } float num3 = num2 + magnitude * 0.01f; if (!(num3 >= num)) { num = num3; Player val3 = FindPlayerByZdo(FindPlayerZdo(player)); if ((Object)(object)val3 != (Object)null) { result = val3; continue; } result = null; _selectCandidateName = player.m_name; } } return result; } private void HandleSelectEnemy() { if (((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || !ZInput.GetButtonDown("DroneCam_SelectEnemy") || Mode == DroneCamMode.Disabled) { return; } Character val = FindEnemyInLookDirection(); if ((Object)(object)val == (Object)null) { if (_lookTarget != null) { ClearEnemyTarget(); } else { Notify("No enemy found in look direction."); } } else if (_lookTarget != null && string.Equals(_lookTarget.Name, val.GetHoverName(), StringComparison.OrdinalIgnoreCase) && (Object)(object)_lookTarget.Transform == (Object)(object)((Component)val).transform) { ClearEnemyTarget(); } else { _lookTarget = DroneCamTarget.ForEnemy(val); Notify("Enemy target: " + val.GetHoverName()); } } private Character FindEnemyInLookDirection() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Character result = null; float num = float.MaxValue; Vector3 position = ((Component)this).transform.position; Vector3 forward = ((Component)this).transform.forward; float value = DroneCamPlugin.SelectEnemyConeAngle.Value; foreach (Character allCharacter in Character.GetAllCharacters()) { if (allCharacter is Player || allCharacter.IsDead()) { continue; } Vector3 val = ((Component)allCharacter).transform.position - position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.1f) { continue; } float num2 = Mathf.Acos(Mathf.Clamp(Vector3.Dot(forward, ((Vector3)(ref val)).normalized), -1f, 1f)) * 57.29578f; if (!(num2 > value)) { float num3 = num2 + magnitude * 0.01f; if (!(num3 >= num)) { num = num3; result = allCharacter; } } } return result; } private void UpdateFreeSetup() { //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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) { float num = (ZInput.GetButton("DroneCam_Fast") ? DroneCamPlugin.FlySpeedFast.Value : DroneCamPlugin.FlySpeed.Value); float value = DroneCamPlugin.RotationSpeed.Value; float value2 = DroneCamPlugin.SmoothTime.Value; Vector3 val = Vector3.zero; if (ZInput.GetButton("DroneCam_Forward")) { val += _droneRot * Vector3.forward; } if (ZInput.GetButton("DroneCam_Back")) { val -= _droneRot * Vector3.forward; } if (ZInput.GetButton("DroneCam_StrafeLeft")) { val -= _droneRot * Vector3.right; } if (ZInput.GetButton("DroneCam_StrafeRight")) { val += _droneRot * Vector3.right; } if (ZInput.GetButton("DroneCam_Up")) { val += Vector3.up; } if (ZInput.GetButton("DroneCam_Down")) { val -= Vector3.up; } _smoothVelocity = Vector3.SmoothDamp(_smoothVelocity, ((Vector3)(ref val)).normalized * num, ref _smoothVelRef, value2); _dronePos += _smoothVelocity * Time.deltaTime; if (ZInput.GetButton("DroneCam_MouseLook")) { Vector2 mouseDelta = ZInput.GetMouseDelta(); Vector3 eulerAngles = ((Quaternion)(ref _droneRot)).eulerAngles; _droneRot = Quaternion.Euler(eulerAngles.x + (0f - mouseDelta.y) * value * Time.deltaTime, eulerAngles.y + mouseDelta.x * value * Time.deltaTime, 0f); } if (ZInput.GetButton("DroneCam_YawLeft")) { Vector3 eulerAngles2 = ((Quaternion)(ref _droneRot)).eulerAngles; _droneRot = Quaternion.Euler(eulerAngles2.x, eulerAngles2.y - value * Time.deltaTime, 0f); } if (ZInput.GetButton("DroneCam_YawRight")) { Vector3 eulerAngles3 = ((Quaternion)(ref _droneRot)).eulerAngles; _droneRot = Quaternion.Euler(eulerAngles3.x, eulerAngles3.y + value * Time.deltaTime, 0f); } if (ZInput.GetButton("DroneCam_PitchUp")) { Vector3 eulerAngles4 = ((Quaternion)(ref _droneRot)).eulerAngles; _droneRot = Quaternion.Euler(eulerAngles4.x - value * Time.deltaTime, eulerAngles4.y, 0f); } if (ZInput.GetButton("DroneCam_PitchDown")) { Vector3 eulerAngles5 = ((Quaternion)(ref _droneRot)).eulerAngles; _droneRot = Quaternion.Euler(eulerAngles5.x + value * Time.deltaTime, eulerAngles5.y, 0f); } ((Component)this).transform.position = _dronePos; ((Component)this).transform.rotation = _droneRot; } } private void UpdateFollow() { //IL_000f: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005f: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_007c: Unknown result type (might be due to invalid IL or missing references) RefreshTarget(); if (_anchor != null && !(_anchorLastKnownPos == Vector3.zero)) { Vector3 targetCenter = GetTargetCenter(); Vector3 val; if ((Object)(object)_anchor.Transform != (Object)null) { val = _anchor.Transform.forward; } else { Vector3 val2 = targetCenter - ((Component)this).transform.position; val = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : Vector3.forward); } Vector3 val3 = targetCenter + -val * _followDistance + _followHeightOffset; ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, val3, ref _smoothVelRef, _followSmoothTime); LookSmoothAt(GetLookTarget()); } } private void UpdateOrbit() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (_anchor != null && _anchor.Type != TargetType.Position) { RefreshTarget(); if (_anchor == null || _anchorLastKnownPos == Vector3.zero) { return; } } Vector3 targetCenter = GetTargetCenter(); _orbitAngle += _orbitSpeed * Time.deltaTime; float num = _orbitAngle * ((float)Math.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Sin(num) * _orbitRadius, _orbitHeight, Mathf.Cos(num) * _orbitRadius); ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, targetCenter + val, ref _smoothVelRef, DroneCamPlugin.SmoothTime.Value); LookSmoothAt(GetLookTarget()); } private void UpdateSecurity() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (_anchor != null && _anchor.Type != TargetType.Position) { RefreshTarget(); } ((Component)this).transform.position = _securityPos; LookSmoothAt(GetLookTarget(), 3f); } private void RefreshTarget() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_012d: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e0: 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_0109: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if (_anchor == null || _anchor.Type == TargetType.Position) { return; } if (_anchor.Type == TargetType.Player) { PlayerInfo pi = FindPlayerInfo(_anchor.Name); if (!IsValidPlayerInfo(pi)) { return; } Vector3 playerInfoPosition = GetPlayerInfoPosition(pi); Vector3 playerRealtimePosition = GetPlayerRealtimePosition(pi); Vector3 val = ((playerRealtimePosition != Vector3.zero) ? playerRealtimePosition : playerInfoPosition); if (val == Vector3.zero) { return; } if (playerInfoPosition != Vector3.zero) { float num = ((_anchorLastInfoPos != Vector3.zero) ? Vector3.Distance(playerInfoPosition, _anchorLastInfoPos) : 0f); if (num > DroneCamPlugin.TeleportDetectionDistance.Value) { DroneCamPlugin.Log.LogInfo((object)$"[DroneCam] Portal detected - dist={num}"); Vector3 val2 = playerInfoPosition + _anchorLastRelOffset; if (ZNetScene.instance.IsAreaReady(val2)) { SnapDroneTo(val2); _anchorLastRelOffset = val2 - playerInfoPosition; } else { TravelToPosition(val2); } _anchorLastInfoPos = playerInfoPosition; _anchorLastKnownPos = playerInfoPosition; _anchorLastPos = playerInfoPosition; return; } _anchorLastInfoPos = playerInfoPosition; } Player val3 = FindPlayerByZdo(FindPlayerZdo(pi)); if ((Object)(object)val3 != (Object)null) { _anchor.Transform = ((Component)val3).transform; } _anchorLastKnownPos = val; _anchorLastPos = val; _anchorWaiting = false; _anchorLastRelOffset = ((Component)this).transform.position - val; } else if (_anchor.IsValid) { Vector3 position = _anchor.GetPosition(); if (_anchorLastPos != Vector3.zero && Vector3.Distance(position, _anchorLastPos) > DroneCamPlugin.TeleportDetectionDistance.Value) { SnapRelativeToTarget(position); } _anchorLastPos = position; _anchorLastKnownPos = position; _anchorLastRelOffset = ((Component)this).transform.position - position; _anchorWaiting = false; } else { if (!_anchorWaiting && _anchorLastKnownPos != Vector3.zero) { _anchorLastRelOffset = ((Component)this).transform.position - _anchorLastKnownPos; _anchorWaiting = true; _anchorLastPos = Vector3.zero; DroneCamPlugin.Log.LogInfo((object)"[DroneCam] Enemy anchor lost - waiting."); } Character val4 = FindNearestCharacter(_anchor.Name, ((Component)this).transform.position); if (!((Object)(object)val4 == (Object)null)) { _anchor.Transform = ((Component)val4).transform; _anchorWaiting = false; _anchorLastPos = Vector3.zero; SnapRelativeToTarget(((Component)val4).transform.position); DroneCamPlugin.Log.LogInfo((object)"[DroneCam] Enemy anchor reacquired."); } } } private Vector3 GetTargetCenter() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_006c: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (_anchor == null) { return ((Component)this).transform.position; } Vector3 val = ((_anchor.Type == TargetType.Player) ? ((_anchorLastKnownPos != Vector3.zero) ? _anchorLastKnownPos : ((Component)this).transform.position) : ((!_anchor.IsValid) ? _anchorLastKnownPos : _anchor.GetPosition())); return val + Vector3.up * _focalOffsetY; } private Vector3 GetLookTarget() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_0037: Unknown result type (might be due to invalid IL or missing references) if (_lookTarget != null) { if (_lookTarget.Type == TargetType.Enemy && !_lookTarget.IsValid) { Character val = FindNearestCharacter(_lookTarget.Name, ((Component)this).transform.position); if ((Object)(object)val != (Object)null && !val.IsDead()) { _lookTarget.Transform = ((Component)val).transform; } else { Notify("Enemy target died - returning to anchor target."); _lookTarget = null; } } if (_lookTarget != null) { _lastLookPosition = _lookTarget.GetPosition() + Vector3.up * 1.5f; return _lastLookPosition; } } _lastLookPosition = GetTargetCenter() + Vector3.up * 1.5f; return _lastLookPosition; } private void SnapDroneTo(Vector3 pos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = pos; _dronePos = pos; _smoothVelocity = Vector3.zero; _smoothVelRef = Vector3.zero; if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).m_body.position = pos; } DroneCamPlugin.Log.LogInfo((object)$"[DroneCam] Drone snapped to {pos}"); } private void SnapRelativeToTarget(Vector3 targetPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: 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_003d: 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_004f: 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) _anchorLastKnownPos = targetPos; _anchorLastPos = targetPos; switch (Mode) { case DroneCamMode.Follow: SnapDroneTo(targetPos + _anchorLastRelOffset); break; case DroneCamMode.Orbit: _orbitAngle = 0f; SnapDroneTo(targetPos + ((Vector3)(ref _anchorLastRelOffset)).normalized * _orbitRadius); break; } } private void LookSmoothAt(Vector3 worldPoint, float lerpSpeed = 5f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = worldPoint - ((Component)this).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude < 0.001f)) { ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val), Time.deltaTime * lerpSpeed); } } private void ResetTargetState() { //IL_000f: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) _anchor = null; _lookTarget = null; _anchorLastPos = Vector3.zero; _anchorLastKnownPos = Vector3.zero; _anchorLastRelOffset = Vector3.zero; _anchorLastInfoPos = Vector3.zero; _anchorWaiting = false; _lastLookPosition = Vector3.zero; _targetWasSleeping = false; _focalOffsetY = 0f; _waitingForTeleport = false; } private static PlayerInfo FindPlayerInfo(string name) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0073: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(name)) { return default(PlayerInfo); } foreach (PlayerInfo player in ZNet.instance.m_players) { if (string.Equals(player.m_name?.Trim(), name.Trim(), StringComparison.OrdinalIgnoreCase)) { return player; } } return default(PlayerInfo); } private static bool IsValidPlayerInfo(PlayerInfo pi) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(pi.m_name)) { return !((ZDOID)(ref pi.m_characterID)).IsNone(); } return false; } private static ZDO FindPlayerZdo(PlayerInfo pi) { //IL_0015: 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) if (((ZDOID)(ref pi.m_characterID)).IsNone()) { return null; } return ZDOMan.instance.GetZDO(pi.m_characterID); } private static Player FindPlayerByZdo(ZDO zdo) { if (zdo == null) { return null; } foreach (Player allPlayer in Player.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)(object)Player.m_localPlayer) && (Object)(object)((Character)allPlayer).m_nview != (Object)null && ((Character)allPlayer).m_nview.GetZDO() == zdo) { return allPlayer; } } return null; } private Vector3 GetPlayerRealtimePosition(PlayerInfo pi) { //IL_001e: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; object obj; if (localPlayer == null) { obj = null; } else { ZNetView nview = ((Character)localPlayer).m_nview; obj = ((nview != null) ? nview.GetZDO() : null); } ZDO val = (ZDO)obj; ZDO val2 = FindPlayerZdo(pi); Player val3 = FindPlayerByZdo(val2); if ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)Player.m_localPlayer) { return ((Component)val3).transform.position; } if (val2 != null && val2 != val) { return val2.GetPosition(); } if (pi.m_publicPosition && pi.m_position != Vector3.zero) { return pi.m_position; } if (_anchorLastKnownPos != Vector3.zero) { return _anchorLastKnownPos; } return Vector3.zero; } private Vector3 GetPlayerInfoPosition(PlayerInfo pi) { //IL_0000: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (pi.m_publicPosition && pi.m_position != Vector3.zero) { return pi.m_position; } Player localPlayer = Player.m_localPlayer; object obj; if (localPlayer == null) { obj = null; } else { ZNetView nview = ((Character)localPlayer).m_nview; obj = ((nview != null) ? nview.GetZDO() : null); } ZDO val = (ZDO)obj; ZDO val2 = FindPlayerZdo(pi); if (val2 != null && val2 != val) { return val2.GetPosition(); } if (_anchorLastKnownPos != Vector3.zero) { return _anchorLastKnownPos; } return Vector3.zero; } private static Character FindNearestCharacter(string name, Vector3 near) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Character result = null; float num = float.MaxValue; foreach (Character allCharacter in Character.GetAllCharacters()) { if (!(allCharacter is Player) && !allCharacter.IsDead() && (string.IsNullOrEmpty(name) || string.Equals(allCharacter.GetHoverName(), name, StringComparison.OrdinalIgnoreCase))) { float num2 = Vector3.Distance(((Component)allCharacter).transform.position, near); if (num2 < num) { num = num2; result = allCharacter; } } } return result; } private static string PlayerNotFoundReason(string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerInfo player in ZNet.instance.m_players) { if (string.Equals(player.m_name?.Trim(), name.Trim(), StringComparison.OrdinalIgnoreCase)) { ZDOID characterID = player.m_characterID; return ((ZDOID)(ref characterID)).IsNone() ? ("Player '" + name + "' character not ready yet.") : ("Player '" + name + "' found but position unavailable."); } } return "Player '" + name + "' not connected."; } public Vector3 GetLookAtPosition() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) if (!(_lastLookPosition != Vector3.zero)) { return ((Component)this).transform.position + ((Component)this).transform.forward * _followDistance; } return _lastLookPosition; } private static void Notify(string msg) { Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString("[XDC] " + msg); } } public void SetFollow(string playerName, float distance, float heightOffset, float smoothTime) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) SaveTrackingState(); PlayerInfo pi = FindPlayerInfo(playerName); if (!IsValidPlayerInfo(pi)) { Notify(PlayerNotFoundReason(playerName)); return; } Vector3 playerInfoPosition = GetPlayerInfoPosition(pi); Vector3 playerRealtimePosition = GetPlayerRealtimePosition(pi); Vector3 val = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : playerRealtimePosition); Vector3 val2 = ((playerRealtimePosition != Vector3.zero) ? playerRealtimePosition : playerInfoPosition); if (val == Vector3.zero) { Notify("Player '" + playerName + "' position unavailable."); return; } ResetTargetState(); Player val3 = FindPlayerByZdo(FindPlayerZdo(pi)); _anchor = new DroneCamTarget { Type = TargetType.Player, Name = playerName, Transform = ((val3 != null) ? ((Component)val3).transform : null) }; _anchorLastKnownPos = ((val2 != Vector3.zero) ? val2 : val); _anchorLastInfoPos = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : val2); _followDistance = distance; _followHeightOffset = new Vector3(0f, heightOffset, 0f); _followSmoothTime = smoothTime; Mode = DroneCamMode.Follow; EnterDroneMode(); SetGameCameraEnabled(state: false); if (Vector3.Distance(((Component)this).transform.position, val) > DroneCamPlugin.TeleportDetectionDistance.Value) { TravelToPlayer(playerName, val); } else { Notify("Following " + playerName); } } public void SetFollowEnemy(string enemyName, float distance, float heightOffset, float smoothTime) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Character val = FindNearestCharacter(enemyName, ((Component)this).transform.position); if ((Object)(object)val == (Object)null) { Notify("No enemy '" + enemyName + "' found nearby."); return; } ResetTargetState(); _anchor = DroneCamTarget.ForEnemy(val); _followDistance = distance; _followHeightOffset = new Vector3(0f, heightOffset, 0f); _followSmoothTime = smoothTime; Mode = DroneCamMode.Follow; EnterDroneMode(); SetGameCameraEnabled(state: false); Notify("Following enemy " + val.GetHoverName()); } public void SetOrbitPlayer(string playerName, float radius, float speed, float height) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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) SaveTrackingState(); PlayerInfo pi = FindPlayerInfo(playerName); if (!IsValidPlayerInfo(pi)) { Notify(PlayerNotFoundReason(playerName)); return; } Vector3 playerInfoPosition = GetPlayerInfoPosition(pi); Vector3 playerRealtimePosition = GetPlayerRealtimePosition(pi); Vector3 val = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : playerRealtimePosition); Vector3 val2 = ((playerRealtimePosition != Vector3.zero) ? playerRealtimePosition : playerInfoPosition); if (val == Vector3.zero) { Notify("Player '" + playerName + "' position unavailable."); return; } ResetTargetState(); Player val3 = FindPlayerByZdo(FindPlayerZdo(pi)); _anchor = new DroneCamTarget { Type = TargetType.Player, Name = playerName, Transform = ((val3 != null) ? ((Component)val3).transform : null) }; _anchorLastKnownPos = ((val2 != Vector3.zero) ? val2 : val); _anchorLastInfoPos = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : val2); _orbitRadius = radius; _orbitSpeed = speed; _orbitHeight = height; _orbitAngle = 0f; Mode = DroneCamMode.Orbit; EnterDroneMode(); SetGameCameraEnabled(state: false); if (Vector3.Distance(((Component)this).transform.position, val) > DroneCamPlugin.TeleportDetectionDistance.Value) { TravelToPlayer(playerName, val); } else { Notify("Orbiting " + playerName); } } public void SetOrbitEnemy(string enemyName, float radius, float speed, float height) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Character val = FindNearestCharacter(enemyName, ((Component)this).transform.position); if ((Object)(object)val == (Object)null) { Notify("No enemy '" + enemyName + "' found nearby."); return; } ResetTargetState(); _anchor = DroneCamTarget.ForEnemy(val); _orbitRadius = radius; _orbitSpeed = speed; _orbitHeight = height; _orbitAngle = 0f; Mode = DroneCamMode.Orbit; EnterDroneMode(); SetGameCameraEnabled(state: false); Notify("Orbiting enemy " + val.GetHoverName()); } public void SetOrbitPosition(Vector3 pos, float radius, float speed, float height) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) ResetTargetState(); _anchor = DroneCamTarget.ForPosition(pos); _orbitRadius = radius; _orbitSpeed = speed; _orbitHeight = height; _orbitAngle = 0f; Mode = DroneCamMode.Orbit; EnterDroneMode(); SetGameCameraEnabled(state: false); Notify($"Orbiting position - radius={radius} speed={speed} height={height}"); } public void SetSecurityPlayer(string playerName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) SaveTrackingState(); PlayerInfo pi = FindPlayerInfo(playerName); if (!IsValidPlayerInfo(pi)) { Notify(PlayerNotFoundReason(playerName)); return; } Vector3 playerInfoPosition = GetPlayerInfoPosition(pi); Vector3 playerRealtimePosition = GetPlayerRealtimePosition(pi); Vector3 val = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : playerRealtimePosition); Vector3 val2 = ((playerRealtimePosition != Vector3.zero) ? playerRealtimePosition : playerInfoPosition); if (val == Vector3.zero) { Notify("Player '" + playerName + "' position unavailable."); return; } ResetTargetState(); Player val3 = FindPlayerByZdo(FindPlayerZdo(pi)); _anchor = new DroneCamTarget { Type = TargetType.Player, Name = playerName, Transform = ((val3 != null) ? ((Component)val3).transform : null) }; _anchorLastKnownPos = ((val2 != Vector3.zero) ? val2 : val); _anchorLastInfoPos = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : val2); _securityPos = ((Component)this).transform.position; Mode = DroneCamMode.Security; EnterDroneMode(); SetGameCameraEnabled(state: false); if (Vector3.Distance(((Component)this).transform.position, val) > DroneCamPlugin.TeleportDetectionDistance.Value) { TravelToPlayer(playerName, val); } else { Notify("Security cam tracking " + playerName); } } public void SetSecurityPosition(Vector3 pos) { //IL_0007: 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_001e: Unknown result type (might be due to invalid IL or missing references) ResetTargetState(); _anchor = DroneCamTarget.ForPosition(pos); _securityPos = ((Component)this).transform.position; Mode = DroneCamMode.Security; EnterDroneMode(); SetGameCameraEnabled(state: false); Notify("Security cam tracking look-at position"); } public void SetOrbitSpeed(float speed) { _orbitSpeed = speed; Notify($"Orbit speed set to {speed} deg/sec"); } public void SetEnemyTargetNearest() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Character val = FindNearestCharacter(null, ((Component)this).transform.position); if ((Object)(object)val == (Object)null) { Notify("No enemies nearby."); return; } _lookTarget = DroneCamTarget.ForEnemy(val); Notify("Enemy target: " + val.GetHoverName()); } public void SetEnemyTargetNamed(string name) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Character val = FindNearestCharacter(name, ((Component)this).transform.position); if ((Object)(object)val == (Object)null) { Notify("No enemy '" + name + "' found nearby."); return; } _lookTarget = DroneCamTarget.ForEnemy(val); Notify("Enemy target: " + val.GetHoverName()); } public void ClearEnemyTarget() { _lookTarget = null; Notify("Enemy target cleared."); } public void SnapToPlayer() { //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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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) if (_anchor == null || _anchor.Type != TargetType.Player) { Notify("No player target set."); return; } PlayerInfo pi = FindPlayerInfo(_anchor.Name); if (!IsValidPlayerInfo(pi)) { Notify(PlayerNotFoundReason(_anchor.Name)); return; } Vector3 playerInfoPosition = GetPlayerInfoPosition(pi); Vector3 playerRealtimePosition = GetPlayerRealtimePosition(pi); Vector3 val = ((playerRealtimePosition != Vector3.zero) ? playerRealtimePosition : playerInfoPosition); Vector3 val2 = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : val); if (val2 == Vector3.zero) { Notify("Player '" + _anchor.Name + "' position unavailable."); return; } if (Vector3.Distance(((Component)this).transform.position, val2) > DroneCamPlugin.TeleportDetectionDistance.Value) { TravelToPlayer(_anchor.Name, val2); return; } SnapDroneTo(val + _anchorLastRelOffset); _anchorLastKnownPos = val; _anchorLastPos = val; _anchorLastInfoPos = ((playerInfoPosition != Vector3.zero) ? playerInfoPosition : val); Notify("Snapped to " + _anchor.Name + "."); } public bool IsTargetPlayer(Player p) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (_anchor == null || _anchor.Type != TargetType.Player) { return false; } if ((Object)(object)((Character)(p?)).m_nview == (Object)null) { return false; } ZDO zDO = ((Character)p).m_nview.GetZDO(); if (zDO == null) { return false; } PlayerInfo val = FindPlayerInfo(_anchor.Name); if (!IsValidPlayerInfo(val)) { return false; } return zDO.m_uid == val.m_characterID; } public static IEnumerable GetPlayerNames() { Player localPlayer = Player.m_localPlayer; string localName = ((localPlayer != null) ? localPlayer.GetPlayerName() : null); foreach (PlayerInfo player in ZNet.instance.m_players) { if (!string.IsNullOrEmpty(player.m_name) && !string.Equals(player.m_name.Trim(), localName, StringComparison.OrdinalIgnoreCase)) { yield return player.m_name.Trim(); } } } public void StartStream(int width, int height, StreamProtocol protocol) { if (Mode == DroneCamMode.Disabled) { Notify("Enable drone cam before starting stream."); return; } _streamWidth = width; _streamHeight = height; if ((Object)(object)_streamCamera != (Object)null) { TeardownStreamCamera(); } SetupStreamCamera(protocol); if (!((protocol == StreamProtocol.Spout) ? ((Object)(object)_spoutSender != (Object)null) : ((Object)(object)_ndiSender != (Object)null))) { Notify($"Stream setup failed - Klak{protocol} not found. See log."); return; } _streamActive = true; Notify($"Streaming via {protocol} 'DroneCam' - {width}x{height}"); } public void StopStream() { TeardownStreamCamera(); Notify("Stream stopped."); } public void SetStreamResolution(int width, int height) { if (!_streamActive) { Notify("No active stream."); } else { StartStream(width, height, _streamProtocol); } } private void SetupStreamCamera(StreamProtocol protocol) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_streamCamera != (Object)null)) { _streamProtocol = protocol; GameObject val = new GameObject("DroneCam_StreamCamera"); Object.DontDestroyOnLoad((Object)(object)val); _streamCamera = val.AddComponent(); ((Behaviour)_streamCamera).enabled = false; GameCamera gameCamera = _gameCamera; Camera val2 = ((gameCamera != null) ? ((Component)gameCamera).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { _streamCamera.cullingMask = val2.cullingMask; _streamCamera.nearClipPlane = val2.nearClipPlane; _streamCamera.farClipPlane = val2.farClipPlane; _streamCamera.fieldOfView = val2.fieldOfView; _streamCamera.allowHDR = val2.allowHDR; _streamCamera.allowMSAA = val2.allowMSAA; _streamCamera.renderingPath = val2.renderingPath; } _streamTexture = new RenderTexture(_streamWidth, _streamHeight, 24, (RenderTextureFormat)0); _streamTexture.Create(); _streamCamera.targetTexture = _streamTexture; if (protocol == StreamProtocol.Spout) { TryAttachSpoutSender(val); } else { TryAttachNdiSender(val); } } } private void TryAttachSpoutSender(GameObject go) { try { Type type = Type.GetType("Klak.Spout.SpoutSender, Klak.Spout.Runtime"); if (type == null) { DroneCamPlugin.Log.LogWarning((object)"[DroneCam] KlakSpout not found. Place Klak.Spout.Runtime.dll and KlakSpout.dll in BepInEx/plugins/DroneCam/"); return; } _spoutSender = go.AddComponent(type); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { DroneCamPlugin.Log.LogInfo((object)("[DroneCam] SpoutSender." + propertyInfo.Name + " (" + propertyInfo.PropertyType.Name + ")")); } type.GetProperty("spoutName")?.SetValue(_spoutSender, "DroneCam"); PropertyInfo property = type.GetProperty("captureType"); if (property != null) { property.SetValue(_spoutSender, Enum.Parse(property.PropertyType, "Texture")); } type.GetProperty("sourceTexture")?.SetValue(_spoutSender, _streamTexture); DroneCamPlugin.Log.LogInfo((object)"[DroneCam] Spout sender attached."); } catch (Exception arg) { DroneCamPlugin.Log.LogError((object)$"[DroneCam] Spout setup failed: {arg}"); } } private void TryAttachNdiSender(GameObject go) { try { Type type = Type.GetType("Klak.Ndi.NdiSender, Klak.Ndi.Runtime"); if (type == null) { DroneCamPlugin.Log.LogWarning((object)"[DroneCam] KlakNDI not found. Place Klak.Ndi.Runtime.dll and KlakNDI.dll in BepInEx/plugins/DroneCam/ and install NDI Tools from ndi.video"); return; } _ndiSender = go.AddComponent(type); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { DroneCamPlugin.Log.LogInfo((object)("[DroneCam] NdiSender." + propertyInfo.Name + " (" + propertyInfo.PropertyType.Name + ")")); } type.GetProperty("ndiName")?.SetValue(_ndiSender, "DroneCam"); PropertyInfo property = type.GetProperty("captureType"); if (property != null) { property.SetValue(_ndiSender, Enum.Parse(property.PropertyType, "Texture")); } type.GetProperty("sourceTexture")?.SetValue(_ndiSender, _streamTexture); DroneCamPlugin.Log.LogInfo((object)"[DroneCam] NDI sender attached."); } catch (Exception arg) { DroneCamPlugin.Log.LogError((object)$"[DroneCam] NDI setup failed: {arg}"); } } private void TeardownStreamCamera() { if ((Object)(object)_streamCamera != (Object)null) { Object.Destroy((Object)(object)((Component)_streamCamera).gameObject); _streamCamera = null; } _spoutSender = null; _ndiSender = null; if ((Object)(object)_streamTexture != (Object)null) { _streamTexture.Release(); Object.Destroy((Object)(object)_streamTexture); _streamTexture = null; } _streamActive = false; } } [HarmonyPatch(typeof(GameCamera), "Awake")] public static class GameCamera_Awake_Patch { private static void Postfix(GameCamera __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(GameCamera), "LateUpdate")] public static class GameCamera_LateUpdate_Patch { private static bool Prefix() { if (!((Object)(object)DroneCamController.Instance == (Object)null)) { return DroneCamController.Instance.Mode == DroneCamMode.Disabled; } return true; } } [HarmonyPatch(typeof(Player), "TakeInput")] public static class Player_TakeInput_Patch { private static bool Prefix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if ((Object)(object)DroneCamController.Instance == (Object)null) { return true; } return DroneCamController.Instance.Mode == DroneCamMode.Disabled; } } [HarmonyPatch(typeof(Character), "Damage")] public static class Character_Damage_Patch { private static bool Prefix(Character __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if ((Object)(object)DroneCamController.Instance == (Object)null) { return true; } return DroneCamController.Instance.Mode == DroneCamMode.Disabled; } } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })] public static class SEMan_AddStatusEffect_Patch { private static bool Prefix(SEMan __instance, int nameHash) { if ((Object)(object)DroneCamController.Instance == (Object)null) { return true; } if (DroneCamController.Instance.Mode == DroneCamMode.Disabled) { return true; } if ((Object)(object)Player.m_localPlayer == (Object)null) { return true; } if (__instance != ((Character)Player.m_localPlayer).m_seman) { return true; } if (nameHash == SEMan.s_statusEffectWet || nameHash == SEMan.s_statusEffectTared) { return false; } return true; } } [HarmonyPatch(typeof(ZSyncTransform), "GetPosition")] public static class ZSyncTransform_GetPosition_Patch { private static bool Prefix(ZSyncTransform __instance, ref Vector3 __result) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)DroneCamController.Instance == (Object)null) { return true; } if (DroneCamController.Instance.Mode == DroneCamMode.Disabled) { return true; } if ((Object)(object)Player.m_localPlayer == (Object)null) { return true; } if ((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) { return true; } if (DroneCamController.Instance.BroadcastRealPosition) { return true; } if (DroneCamController.Instance.WaitingForTeleport) { __result = ((Character)Player.m_localPlayer).m_body.position; return false; } Vector3 position = ((Character)Player.m_localPlayer).m_body.position; __result = new Vector3(position.x + 101f, position.y, position.z); return false; } } [HarmonyPatch(typeof(Character), "SetVisible")] public static class Character_SetVisible_Patch { private static bool Prefix(Character __instance, ref bool visible) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if ((Object)(object)DroneCamController.Instance == (Object)null) { return true; } if (DroneCamController.Instance.Mode == DroneCamMode.Disabled) { return true; } visible = false; return true; } } [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] public static class Hud_UpdateCrosshair_Patch { private static void Postfix(Hud __instance) { if (!((Object)(object)DroneCamController.Instance == (Object)null) && DroneCamController.Instance.Mode != 0 && !DroneCamController.Instance.HudHidden) { ((Component)__instance.m_crosshair).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(Player), "SetSleeping")] public static class Player_SetSleeping_Patch { private static void Postfix(Player __instance, bool sleep) { if (!((Object)(object)DroneCamController.Instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { if (sleep) { DroneCamController.Instance.OnPlayerSleep(); } else { DroneCamController.Instance.OnPlayerWake(); } } } } [HarmonyPatch(typeof(Chat), "InputText")] public static class Chat_InputText_Patch { private static bool Prefix(Chat __instance) { string text = ((TMP_InputField)((Terminal)__instance).m_terminalInstance.m_input).text?.Trim(); if (string.IsNullOrEmpty(text)) { return true; } if (!text.StartsWith("/dronecam", StringComparison.OrdinalIgnoreCase) && !text.StartsWith("/dc ", StringComparison.OrdinalIgnoreCase) && !string.Equals(text, "/dc", StringComparison.OrdinalIgnoreCase)) { return true; } DroneCamCommands.HandleChat(text); return false; } } public static class DroneCamCommands { private delegate void CmdHandler(string[] args); private const string Help = "[XDC] Xpert's Drone Cam - console: 'dc (sub)' / chat: '/dc (sub)'\n help - show this help\n on / ff / freefly - enter free-fly\n off - exit drone cam\n hud - toggle HUD\n snap - snap drone to player target\n players - list players\n follow p (name) [dist] [h] [smooth] - follow player\n follow e (name) [dist] [h] [smooth] - follow enemy\n orbit p (name) [r] [spd] [h] - orbit player\n orbit e (name) [r] [spd] [h] - orbit enemy\n orbit pos [r] [spd] [h] - orbit look-at position\n orbit s (deg/sec) - set orbit speed\n security p (name) - security cam on player\n security pos - security cam on look-at position\n te - target nearest enemy for look-at\n te (name) - target named enemy for look-at\n te c - clear enemy look-at target\n stream on [spout|ndi] [w] [h] - start stream\n stream off - stop stream\n stream res (w) (h) - change stream resolution\nF8 toggle / F7 free-fly / Left Click select player / T target enemy\nWheel dist / Alt+wheel height / Ctrl+wheel focal / Alt+Ctrl+wheel orbit speed\n. , cycle players\nNames with spaces: use quotes e.g. follow p \"Big Viking\""; private static readonly Dictionary Commands = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "help", delegate { Msg("[XDC] Xpert's Drone Cam - console: 'dc (sub)' / chat: '/dc (sub)'\n help - show this help\n on / ff / freefly - enter free-fly\n off - exit drone cam\n hud - toggle HUD\n snap - snap drone to player target\n players - list players\n follow p (name) [dist] [h] [smooth] - follow player\n follow e (name) [dist] [h] [smooth] - follow enemy\n orbit p (name) [r] [spd] [h] - orbit player\n orbit e (name) [r] [spd] [h] - orbit enemy\n orbit pos [r] [spd] [h] - orbit look-at position\n orbit s (deg/sec) - set orbit speed\n security p (name) - security cam on player\n security pos - security cam on look-at position\n te - target nearest enemy for look-at\n te (name) - target named enemy for look-at\n te c - clear enemy look-at target\n stream on [spout|ndi] [w] [h] - start stream\n stream off - stop stream\n stream res (w) (h) - change stream resolution\nF8 toggle / F7 free-fly / Left Click select player / T target enemy\nWheel dist / Alt+wheel height / Ctrl+wheel focal / Alt+Ctrl+wheel orbit speed\n. , cycle players\nNames with spaces: use quotes e.g. follow p \"Big Viking\""); } }, { "on", delegate { Ctrl.EnterFreeSetup(); } }, { "off", delegate { Ctrl.ExitDroneCam(); } }, { "ff", delegate { Ctrl.EnterFreeSetup(); } }, { "freefly", delegate { Ctrl.EnterFreeSetup(); } }, { "hud", delegate { Ctrl.ToggleHud(); } }, { "snap", delegate { Ctrl.SnapToPlayer(); } }, { "players", delegate { Msg("[XDC] Players: " + string.Join(", ", DroneCamController.GetPlayerNames())); } }, { "follow", HandleFollow }, { "f", HandleFollow }, { "orbit", HandleOrbit }, { "o", HandleOrbit }, { "security", HandleSecurity }, { "s", HandleSecurity }, { "targetenemy", HandleTargetEnemy }, { "te", HandleTargetEnemy }, { "stream", HandleStream }, { "st", HandleStream } }; private static DroneCamController Ctrl => DroneCamController.Instance; public static void Handle(string[] args) { if ((Object)(object)Ctrl == (Object)null) { Msg("[XDC] Controller not ready."); return; } if (args == null || args.Length == 0) { Msg("[XDC] Xpert's Drone Cam - console: 'dc (sub)' / chat: '/dc (sub)'\n help - show this help\n on / ff / freefly - enter free-fly\n off - exit drone cam\n hud - toggle HUD\n snap - snap drone to player target\n players - list players\n follow p (name) [dist] [h] [smooth] - follow player\n follow e (name) [dist] [h] [smooth] - follow enemy\n orbit p (name) [r] [spd] [h] - orbit player\n orbit e (name) [r] [spd] [h] - orbit enemy\n orbit pos [r] [spd] [h] - orbit look-at position\n orbit s (deg/sec) - set orbit speed\n security p (name) - security cam on player\n security pos - security cam on look-at position\n te - target nearest enemy for look-at\n te (name) - target named enemy for look-at\n te c - clear enemy look-at target\n stream on [spout|ndi] [w] [h] - start stream\n stream off - stop stream\n stream res (w) (h) - change stream resolution\nF8 toggle / F7 free-fly / Left Click select player / T target enemy\nWheel dist / Alt+wheel height / Ctrl+wheel focal / Alt+Ctrl+wheel orbit speed\n. , cycle players\nNames with spaces: use quotes e.g. follow p \"Big Viking\""); return; } string text = args[0]; if (Commands.TryGetValue(text, out var value)) { value(args); } else { Msg("[XDC] Unknown command '" + text + "'. Type 'dc help'."); } } public static void HandleChat(string raw) { if ((Object)(object)Ctrl == (Object)null) { Msg("[XDC] Controller not ready."); return; } Handle(CollapseQuotedArgs(raw.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray())); } public static string[] CollapseQuotedArgs(string[] args) { List list = new List(); for (int i = 0; i < args.Length; i++) { string text = args[i]; if (text.StartsWith("\"")) { StringBuilder stringBuilder = new StringBuilder(); bool flag = text.Length > 1 && text.EndsWith("\""); stringBuilder.Append(text.Substring(1)); while (!flag && i + 1 < args.Length) { i++; text = args[i]; stringBuilder.Append(' '); stringBuilder.Append(text); flag = text.EndsWith("\""); } string text2 = stringBuilder.ToString(); if (text2.EndsWith("\"")) { text2 = text2.Substring(0, text2.Length - 1); } list.Add(text2); } else { list.Add(text); } } return list.ToArray(); } private static void HandleFollow(string[] args) { if (args.Length < 2) { Msg("Usage: follow p (player) / e (enemy) [dist] [h] [smooth]"); return; } switch (args[1].ToLower()) { case "p": case "player": if (args.Length < 3) { Msg("Usage: follow p (player) [dist] [h] [smooth]"); } else { Ctrl.SetFollow(args[2], F(args, 3, 5f), F(args, 4, 2f), F(args, 5, 0.1f)); } break; case "e": case "enemy": if (args.Length < 3) { Msg("Usage: follow e (enemy) [dist] [h] [smooth]"); } else { Ctrl.SetFollowEnemy(args[2], F(args, 3, 5f), F(args, 4, 2f), F(args, 5, 0.1f)); } break; default: Ctrl.SetFollow(args[1], F(args, 2, 5f), F(args, 3, 2f), F(args, 4, 0.1f)); break; } } private static void HandleOrbit(string[] args) { //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { Msg("Usage: orbit p (n) / e (n) / pos / s (val)"); return; } switch (args[1].ToLower()) { case "p": case "player": if (args.Length < 3) { Msg("Usage: orbit p (n) [r] [spd] [h]"); } else { Ctrl.SetOrbitPlayer(args[2], F(args, 3, 10f), F(args, 4, 30f), F(args, 5, 4f)); } break; case "e": case "enemy": if (args.Length < 3) { Msg("Usage: orbit e (n) [r] [spd] [h]"); } else { Ctrl.SetOrbitEnemy(args[2], F(args, 3, 10f), F(args, 4, 30f), F(args, 5, 4f)); } break; case "pos": Ctrl.SetOrbitPosition(Ctrl.GetLookAtPosition(), F(args, 2, 10f), F(args, 3, 30f), F(args, 4, 4f)); break; case "s": case "speed": if (args.Length < 3) { Msg("Usage: orbit s (deg/sec)"); } else { Ctrl.SetOrbitSpeed(F(args, 2, 30f)); } break; default: Msg("Unknown orbit sub-command '" + args[1] + "'."); break; } } private static void HandleSecurity(string[] args) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { Msg("Usage: security p (n) / pos"); return; } switch (args[1].ToLower()) { case "p": case "player": if (args.Length < 3) { Msg("Usage: security p (n)"); } else { Ctrl.SetSecurityPlayer(args[2]); } break; case "pos": Ctrl.SetSecurityPosition(Ctrl.GetLookAtPosition()); break; default: Msg("Unknown security sub-command '" + args[1] + "'."); break; } } private static void HandleTargetEnemy(string[] args) { if (args.Length < 2) { Ctrl.SetEnemyTargetNearest(); return; } switch (args[1].ToLower()) { case "c": case "clear": Ctrl.ClearEnemyTarget(); break; case "n": case "nearest": Ctrl.SetEnemyTargetNearest(); break; default: Ctrl.SetEnemyTargetNamed(args[1]); break; } } private static void HandleStream(string[] args) { if (args.Length < 2) { Msg("Usage: stream on [spout|ndi] [w] [h] / off / res (w) (h)"); return; } switch (args[1].ToLower()) { case "on": { StreamProtocol protocol = StreamProtocol.Spout; int num = 2; if (args.Length > 2) { if (string.Equals(args[2], "ndi", StringComparison.OrdinalIgnoreCase)) { protocol = StreamProtocol.NDI; num = 3; } else if (string.Equals(args[2], "spout", StringComparison.OrdinalIgnoreCase)) { protocol = StreamProtocol.Spout; num = 3; } } Ctrl.StartStream((int)F(args, num, 1920f), (int)F(args, num + 1, 1080f), protocol); break; } case "off": Ctrl.StopStream(); break; case "res": case "resolution": if (args.Length < 4) { Msg("Usage: stream res (width) (height)"); } else { Ctrl.SetStreamResolution((int)F(args, 2, 1920f), (int)F(args, 3, 1080f)); } break; default: Msg("Unknown stream sub-command '" + args[1] + "'."); break; } } private static float F(string[] args, int i, float fallback) { if (args.Length <= i || !float.TryParse(args[i], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return fallback; } return result; } private static void Msg(string s) { Console instance = Console.instance; if (instance != null) { instance.Print(s); } Chat instance2 = Chat.instance; if (instance2 != null) { ((Terminal)instance2).AddString(s); } DroneCamPlugin.Log.LogInfo((object)s); } }