using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; 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 Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ValkyrieFlightPaths")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ValkyrieFlightPaths")] [assembly: AssemblyTitle("ValkyrieFlightPaths")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ValkyrieFlightPaths { internal static class FlightPathAdminMode { internal static bool Enabled { get; private set; } internal static void Update() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && IsDown(ModConfig.ToggleAdminMapModeShortcut.Value)) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.LocalPlayerIsAdminOrHost()) { Enabled = false; ((Character)Player.m_localPlayer).Message((MessageType)2, "$vfp_admin_required", 0, (Sprite)null); } else { Enabled = !Enabled; ((Character)Player.m_localPlayer).Message((MessageType)2, Enabled ? "$vfp_admin_map_enabled" : "$vfp_admin_map_disabled", 0, (Sprite)null); } } } private static bool IsDown(KeyboardShortcut shortcut) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0) { return ((KeyboardShortcut)(ref shortcut)).IsDown(); } return false; } } internal static class FlightPathClearance { private static readonly int ObstacleMask = LayerMask.GetMask(new string[9] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "blocker", "pathblocker", "viewblock" }); internal static bool HasOpenSky(Vector3 position, Transform ignoredRoot, out Collider obstruction) { //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_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_0039: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_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) float value = ModConfig.ClearanceRadius.Value; float num = Mathf.Max(ModConfig.ClearanceHeight.Value, value * 2f); Vector3 val = position + Vector3.up * (value + 0.5f); Vector3 val2 = position + Vector3.up * (num - value); Collider[] array = Physics.OverlapCapsule(val, val2, value, ObstacleMask, (QueryTriggerInteraction)1); foreach (Collider val3 in array) { if (!((Object)(object)val3 == (Object)null)) { Transform transform = ((Component)val3).transform; if (!((Object)(object)ignoredRoot != (Object)null) || (!((Object)(object)transform == (Object)(object)ignoredRoot) && !transform.IsChildOf(ignoredRoot))) { obstruction = val3; return false; } } } obstruction = null; return true; } } internal sealed class FlightPathDestination { internal ZDOID Id; internal string Name; internal Vector3 Position; internal bool IsOrigin; internal bool AdminOnly; } internal static class FlightPathMapSelection { private static readonly List Pins = new List(); private static readonly Dictionary Destinations = new Dictionary(); private static readonly Dictionary DisabledControls = new Dictionary(); private static readonly Dictionary HiddenGraphics = new Dictionary(); private static bool _active; private static int _requestId; private static int _suppressInputThroughFrame = -1; private static ZDOID _originId; private static Vector3 _playerPositionWhenOpened; internal static bool IsActive => _active; internal static bool ShouldSuppressMapInput { get { if (!_active) { return Time.frameCount <= _suppressInputThroughFrame; } return true; } } internal static void Open(int requestId, ZDOID originId, List destinations) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_00ca: 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_00f8: Unknown result type (might be due to invalid IL or missing references) Clear(); if ((Object)(object)Minimap.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } _active = true; _requestId = requestId; _originId = originId; _playerPositionWhenOpened = ((Component)Player.m_localPlayer).transform.position; Minimap.instance.SetMapMode((MapMode)2); if ((int)Minimap.instance.m_mode != 2) { Clear(); ((Character)Player.m_localPlayer).Message((MessageType)2, "$vfp_map_unavailable", 0, (Sprite)null); return; } HideLargeMapControls(); foreach (FlightPathDestination destination in destinations) { string text = (destination.IsOrigin ? (destination.Name + " (" + Localization.instance.Localize("$vfp_current") + ")") : destination.Name); PinData val = Minimap.instance.AddPin(destination.Position, (PinType)(destination.IsOrigin ? 6 : (destination.AdminOnly ? 2 : 3)), text, false, destination.IsOrigin, 0L, default(PlatformUserID)); Pins.Add(val); Destinations.Add(val, destination); } ((Character)Player.m_localPlayer).Message((MessageType)2, (destinations.Count > 1) ? "$vfp_select_destination" : "$vfp_no_destinations", 0, (Sprite)null); } internal static bool TrySelect(Vector3 worldPosition) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (!_active || (Object)(object)Minimap.instance == (Object)null) { return false; } float num = Minimap.instance.m_removeRadius * (Minimap.instance.m_largeZoom * 2f); PinData val = null; float num2 = num; foreach (PinData pin in Pins) { float num3 = Utils.DistanceXZ(pin.m_pos, worldPosition); if (num3 < num2) { val = pin; num2 = num3; } } if (val == null || !Destinations.TryGetValue(val, out var value)) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "$vfp_click_destination_pin", 0, (Sprite)null); } return false; } if (value.IsOrigin) { Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)2, "$vfp_same_destination", 0, (Sprite)null); } return false; } int requestId = _requestId; ZDOID originId = _originId; _suppressInputThroughFrame = Time.frameCount + 1; Clear(); Minimap.instance.SetMapMode((MapMode)1); FlightPathRpc.SelectDestination(requestId, originId, value.Id, FlightPathAdminMode.Enabled); return true; } internal static void CancelForMovement() { if (_active && !((Object)(object)Minimap.instance == (Object)null)) { _suppressInputThroughFrame = Time.frameCount + 1; Minimap.instance.SetMapMode((MapMode)1); } } internal static void MonitorPlayerMovement() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (_active && !((Object)(object)Player.m_localPlayer == (Object)null)) { Vector3 val = ((Component)Player.m_localPlayer).transform.position - _playerPositionWhenOpened; if (((Vector3)(ref val)).sqrMagnitude > 0.040000003f) { CancelForMovement(); } } } internal static void Clear() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance != (Object)null) { foreach (PinData pin in Pins) { Minimap.instance.RemovePin(pin); } } Pins.Clear(); Destinations.Clear(); RestoreLargeMapControls(); if ((Object)(object)Minimap.instance != (Object)null) { Minimap.instance.m_pinUpdateRequired = true; } _active = false; _requestId = 0; _originId = ZDOID.None; _playerPositionWhenOpened = Vector3.zero; } internal static bool IsFlightPathPin(PinData pin) { if (pin != null) { return Destinations.ContainsKey(pin); } return false; } internal static List GetPinsForRendering() { return new List(Pins); } private static void HideLargeMapControls() { DisabledControls.Clear(); HiddenGraphics.Clear(); if ((Object)(object)Minimap.instance?.m_largeRoot == (Object)null) { return; } Selectable[] componentsInChildren = Minimap.instance.m_largeRoot.GetComponentsInChildren(true); foreach (Selectable val in componentsInChildren) { if (!DisabledControls.ContainsKey(val)) { DisabledControls.Add(val, val.interactable); val.interactable = false; } } Graphic[] componentsInChildren2 = Minimap.instance.m_largeRoot.GetComponentsInChildren(true); foreach (Graphic val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)(object)Minimap.instance.m_mapImageLarge) && !HiddenGraphics.ContainsKey(val2)) { HiddenGraphics.Add(val2, ((Behaviour)val2).enabled); ((Behaviour)val2).enabled = false; } } } private static void RestoreLargeMapControls() { foreach (KeyValuePair disabledControl in DisabledControls) { if ((Object)(object)disabledControl.Key != (Object)null) { disabledControl.Key.interactable = disabledControl.Value; } } foreach (KeyValuePair hiddenGraphic in HiddenGraphics) { if ((Object)(object)hiddenGraphic.Key != (Object)null) { ((Behaviour)hiddenGraphic.Key).enabled = hiddenGraphic.Value; } } DisabledControls.Clear(); HiddenGraphics.Clear(); } } public sealed class FlightPathNode : MonoBehaviour, Hoverable, Interactable, TextReceiver, IPlaced { private ZNetView _networkView; private Piece _piece; private void Awake() { _networkView = ((Component)this).GetComponent(); _piece = ((Component)this).GetComponent(); if ((Object)(object)_networkView == (Object)null || !_networkView.IsValid()) { ((Behaviour)this).enabled = false; } } public string GetHoverName() { return Localization.instance.Localize("$vfp_piece_name"); } public string GetHoverText() { //IL_00b2: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_networkView == (Object)null || !_networkView.IsValid() || (Object)(object)Player.m_localPlayer == (Object)null) { return string.Empty; } Player localPlayer = Player.m_localPlayer; bool flag = IsCreator(localPlayer.GetPlayerID()); bool flag2 = IsGlobal(); bool flag3 = FlightPathAdminMode.Enabled && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.LocalPlayerIsAdminOrHost(); bool num = flag2 || flag || IsPermitted(localPlayer.GetPlayerID()) || flag3; bool flag4 = IsRegistrationOpen(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("$vfp_piece_name"); if (num) { stringBuilder.Append("\n[$KEY_Use]"); AppendOptionalShortcut(stringBuilder, ModConfig.UseFlightPathShortcut.Value); stringBuilder.Append(" $vfp_open_map"); int requiredGoldCost = FlightPayment.GetRequiredGoldCost(localPlayer); if (requiredGoldCost > 0) { stringBuilder.Append(" (").Append(requiredGoldCost).Append(" $item_coins)"); } else { stringBuilder.Append(" ($vfp_flight_free)"); } } else { stringBuilder.Append("\n$vfp_no_access"); } if (flag || flag3) { AppendShortcutLine(stringBuilder, ModConfig.RenameFlightPathShortcut.Value, "$vfp_rename"); if (!flag2) { AppendShortcutLine(stringBuilder, ModConfig.ManageAccessShortcut.Value, flag4 ? "$vfp_close_registration" : "$vfp_open_registration"); } } else if (!flag2 && flag4) { AppendShortcutLine(stringBuilder, ModConfig.ManageAccessShortcut.Value, IsPermitted(localPlayer.GetPlayerID()) ? "$vfp_unregister" : "$vfp_register"); } if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.LocalPlayerIsAdminOrHost()) { AppendShortcutLine(stringBuilder, ModConfig.ToggleGlobalShortcut.Value, flag2 ? "$vfp_make_private" : "$vfp_make_global"); } AppendAccessSummary(stringBuilder, flag2); return Localization.instance.Localize(stringBuilder.ToString()); } public void OnPlaced() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_networkView == (Object)null) && _networkView.IsValid() && _networkView.IsOwner() && !((Object)(object)Player.m_localPlayer == (Object)null)) { ZDO zDO = _networkView.GetZDO(); zDO.Set(ZDOVars.s_creatorName, Player.m_localPlayer.GetPlayerName()); ZDOMan.instance.ForceSendZDO(zDO.m_uid); } } public bool Interact(Humanoid user, bool hold, bool alt) { if (!hold) { Player val = (Player)(object)((user is Player) ? user : null); if (val != null && !((Object)(object)_networkView == (Object)null) && _networkView.IsValid()) { UseFlightPath(val); return true; } } return false; } internal void UseFlightPath(Player player) { //IL_007c: 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_00ab: Unknown result type (might be due to invalid IL or missing references) long playerID = player.GetPlayerID(); bool flag = FlightPathAdminMode.Enabled && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.LocalPlayerIsAdminOrHost(); Collider obstruction; if (!IsGlobal() && !IsCreator(playerID) && !IsPermitted(playerID) && !flag) { ((Character)player).Message((MessageType)2, "$vfp_no_access", 0, (Sprite)null); } else if (FlightPathWorldRegistry.ExceedsRegistrationLimit(_networkView.GetZDO())) { ((Character)player).Message((MessageType)2, "$vfp_departure_registration_over_limit", 0, (Sprite)null); } else if (!FlightPathClearance.HasOpenSky(((Component)this).transform.position, ((Component)this).transform, out obstruction)) { Plugin.Instance.Log.LogDebug((object)$"Flight path blocked by '{((Object)obstruction).name}' at {((Component)obstruction).transform.position}"); ((Character)player).Message((MessageType)2, "$vfp_departure_blocked", 0, (Sprite)null); } else { FlightPathRpc.RequestDestinations(_networkView.GetZDO().m_uid); } } internal void ManageAccess(Player player) { //IL_0039: 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) if (IsGlobal()) { ((Character)player).Message((MessageType)2, "$vfp_global_registration_unavailable", 0, (Sprite)null); return; } long playerID = player.GetPlayerID(); if (IsCreator(playerID) || HasAdminManagementAccess()) { FlightPathRpc.ToggleRegistration(_networkView.GetZDO().m_uid); } else if (IsRegistrationOpen()) { FlightPathRpc.TogglePermitted(_networkView.GetZDO().m_uid, player.GetPlayerName()); } else { ((Character)player).Message((MessageType)2, "$vfp_registration_closed", 0, (Sprite)null); } } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetText() { ZNetView networkView = _networkView; object obj; if (networkView == null) { obj = null; } else { ZDO zDO = networkView.GetZDO(); obj = ((zDO != null) ? zDO.GetString("vfp_name", string.Empty) : null); } if (obj == null) { obj = string.Empty; } return (string)obj; } public void SetText(string text) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_networkView != (Object)null && _networkView.IsValid()) { FlightPathRpc.RenameFlightPath(_networkView.GetZDO().m_uid, text); } } internal void BeginRename(Player player) { if (!IsCreator(player.GetPlayerID()) && !HasAdminManagementAccess()) { ((Character)player).Message((MessageType)2, "$vfp_rename_owner_only", 0, (Sprite)null); } else { TextInput.instance.RequestText((TextReceiver)(object)this, "$vfp_rename", 50); } } private static bool HasAdminManagementAccess() { if (FlightPathAdminMode.Enabled && (Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.LocalPlayerIsAdminOrHost(); } return false; } internal void ToggleGlobal(Player player) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.LocalPlayerIsAdminOrHost()) { ((Character)player).Message((MessageType)2, "$vfp_admin_required", 0, (Sprite)null); } else { FlightPathRpc.ToggleGlobal(_networkView.GetZDO().m_uid); } } internal bool IsGlobal() { if ((Object)(object)_networkView != (Object)null && _networkView.IsValid()) { return _networkView.GetZDO().GetBool("vfp_global", false); } return false; } private bool IsCreator(long playerId) { if ((Object)(object)_piece != (Object)null) { return _piece.GetCreator() == playerId; } return false; } private static void AppendOptionalShortcut(StringBuilder text, KeyboardShortcut shortcut) { //IL_0002: 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 ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0) { text.Append(" / "); text.Append(shortcut); text.Append(""); } } private static void AppendShortcutLine(StringBuilder text, KeyboardShortcut shortcut, string action) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0) { text.Append("\n["); text.Append(shortcut); text.Append("] "); text.Append(action); } } private void AppendAccessSummary(StringBuilder text, bool global) { text.Append("\n\n"); if (global) { text.Append("$vfp_global_access"); return; } ZDO zDO = _networkView.GetZDO(); long playerId = (((Object)(object)_piece != (Object)null) ? _piece.GetCreator() : 0); string name = zDO.GetString(ZDOVars.s_creatorName, string.Empty); name = FilterCharacterName(name, playerId); text.Append("$vfp_owner: "); text.Append(string.IsNullOrWhiteSpace(name) ? "$vfp_unknown" : name); text.Append("\n$vfp_registered:"); List> permittedPlayers = GetPermittedPlayers(); if (permittedPlayers.Count == 0) { text.Append(" $vfp_none"); return; } foreach (KeyValuePair item in permittedPlayers) { string text2 = FilterCharacterName(item.Value, item.Key); text.Append("\n- "); text.Append(string.IsNullOrWhiteSpace(text2) ? "$vfp_unknown" : text2); } } private static string FilterCharacterName(string name, long playerId) { return CensorShittyWords.FilterUGC(name ?? string.Empty, (UGCType)2, playerId); } private bool IsRegistrationOpen() { return _networkView.GetZDO().GetBool("vfp_registration_open", false); } private bool IsPermitted(long playerId) { foreach (KeyValuePair permittedPlayer in GetPermittedPlayers()) { if (permittedPlayer.Key == playerId) { return true; } } return false; } private List> GetPermittedPlayers() { ZDO zDO = _networkView.GetZDO(); int num = zDO.GetInt("vfp_permitted_count", 0); List> list = new List>(num); for (int i = 0; i < num; i++) { long num2 = zDO.GetLong("vfp_permitted_id_" + i, 0L); if (num2 != 0L) { list.Add(new KeyValuePair(num2, zDO.GetString("vfp_permitted_name_" + i, string.Empty))); } } return list; } } internal static class FlightPathPlacementAuthorization { private static int _nextRequestId; private static int _pendingRequestId; private static Vector3 _pendingPosition; private static bool _approved; private static Vector3 _approvedPosition; private static float _approvalExpiresAt; private static float _nextRequestAt; internal static void UpdateCandidate(Vector3 position) { //IL_003b: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNet.instance == (Object)null) && !ZNet.instance.IsServer() && ZRoutedRpc.instance != null && (_pendingRequestId == 0 || !(Vector3.Distance(position, _pendingPosition) <= 0.25f)) && !IsApproved(position) && !(Time.time < _nextRequestAt)) { _pendingRequestId = ++_nextRequestId; _pendingPosition = position; _approved = false; _nextRequestAt = Time.time + 0.2f; FlightPathRpc.RequestPlacement(_pendingRequestId, position); } } internal static bool IsApproved(Vector3 position) { //IL_0013: 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) if (_approved && Time.time <= _approvalExpiresAt) { return Vector3.Distance(position, _approvedPosition) <= 0.25f; } return false; } internal static void Complete(int requestId, bool approved, string message) { //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) if (requestId == _pendingRequestId) { _pendingRequestId = 0; if (!approved) { _approved = false; return; } _approved = true; _approvedPosition = _pendingPosition; _approvalExpiresAt = Time.time + 1f; } } } internal static class FlightPathRpc { private sealed class ActiveFlight { internal int Id; internal float ExpiresAt; } private const string RequestDestinationsRpc = "VFP_RequestDestinations_v1"; private const string ReplyDestinationsRpc = "VFP_ReplyDestinations_v1"; private const string SelectDestinationRpc = "VFP_SelectDestination_v1"; private const string SelectionResultRpc = "VFP_SelectionResult_v1"; private const string RequestPlacementRpc = "VFP_RequestPlacement_v1"; private const string PlacementResultRpc = "VFP_PlacementResult_v1"; private const string CompleteFlightRpc = "VFP_CompleteFlight_v1"; private const string ToggleGlobalRpc = "VFP_ToggleGlobal_v1"; private const string RenameFlightPathRpc = "VFP_RenameFlightPath_v2"; private const string ManagementResultRpc = "VFP_ManagementResult_v1"; private const string ToggleRegistrationRpc = "VFP_ToggleRegistration_v3"; private const string TogglePermittedRpc = "VFP_TogglePermitted_v2"; private static int _nextRequestId; private static int _pendingRequestId; private static int _nextFlightId; private static readonly Dictionary ActiveFlights = new Dictionary(); internal static void Register() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null && !instance.m_functions.ContainsKey(StringExtensionMethods.GetStableHashCode("VFP_RequestDestinations_v1"))) { instance.Register("VFP_RequestDestinations_v1", (Action)OnRequestDestinations); instance.Register("VFP_ReplyDestinations_v1", (Action)OnReplyDestinations); instance.Register("VFP_SelectDestination_v1", (Action)OnSelectDestination); instance.Register("VFP_SelectionResult_v1", (Action)OnSelectionResult); instance.Register("VFP_RequestPlacement_v1", (Action)OnRequestPlacement); instance.Register("VFP_PlacementResult_v1", (Action)OnPlacementResult); instance.Register("VFP_CompleteFlight_v1", (Action)OnCompleteFlight); instance.Register("VFP_ToggleGlobal_v1", (Action)OnToggleGlobal); instance.Register("VFP_RenameFlightPath_v2", (Action)OnRenameFlightPath); instance.Register("VFP_ManagementResult_v1", (Action)OnManagementResult); instance.Register("VFP_ToggleRegistration_v3", (Action)OnToggleRegistration); instance.Register("VFP_TogglePermitted_v2", (Action)OnTogglePermitted); } } internal static void RequestDestinations(ZDOID originId) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (ZRoutedRpc.instance != null && !((Object)(object)Player.m_localPlayer == (Object)null)) { int num = (_pendingRequestId = ++_nextRequestId); ZPackage val = new ZPackage(); val.Write(num); val.Write(originId); val.Write(FlightPathAdminMode.Enabled); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_RequestDestinations_v1", new object[1] { val }); } } internal static void ToggleGlobal(ZDOID nodeId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(nodeId); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_ToggleGlobal_v1", new object[1] { val }); } internal static void ToggleRegistration(ZDOID nodeId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(nodeId); val.Write(FlightPathAdminMode.Enabled); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_ToggleRegistration_v3", new object[1] { val }); } internal static void TogglePermitted(ZDOID nodeId, string playerName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(nodeId); val.Write(playerName ?? string.Empty); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_TogglePermitted_v2", new object[1] { val }); } internal static void RenameFlightPath(ZDOID nodeId, string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(nodeId); val.Write(name ?? string.Empty); val.Write(FlightPathAdminMode.Enabled); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_RenameFlightPath_v2", new object[1] { val }); } internal static void SelectDestination(int requestId, ZDOID originId, ZDOID destinationId, bool requestAdminOverride) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(requestId); val.Write(originId); val.Write(destinationId); val.Write(requestAdminOverride); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_SelectDestination_v1", new object[1] { val }); } internal static void RequestPlacement(int requestId, Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(requestId); val.Write(position); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_RequestPlacement_v1", new object[1] { val }); } internal static void CompleteFlight(int flightId) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown if (ZRoutedRpc.instance != null) { ZPackage val = new ZPackage(); val.Write(flightId); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VFP_CompleteFlight_v1", new object[1] { val }); } } private static void OnRequestDestinations(long sender, ZPackage package) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003c: 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_0074: 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_00d8: 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_0134: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } int num = package.ReadInt(); ZDOID val = package.ReadZDOID(); bool num2 = package.ReadBool(); ZPackage val2 = new ZPackage(); val2.Write(num); val2.Write(val); bool flag = num2 && IsSenderAdmin(sender); if (!TryResolveSender(sender, out var playerId, out var character) || !FlightPathWorldRegistry.TryGetNode(val, out var node) || (!FlightPathWorldRegistry.HasAccess(node, playerId) && !flag) || Vector3.Distance(character.GetPosition(), node.GetPosition()) > 8f) { val2.Write("$vfp_invalid_origin"); val2.Write(0); Send(sender, "VFP_ReplyDestinations_v1", val2); return; } if (FlightPathWorldRegistry.ExceedsRegistrationLimit(node)) { val2.Write("$vfp_departure_registration_over_limit"); val2.Write(0); Send(sender, "VFP_ReplyDestinations_v1", val2); return; } bool includeAll = flag; List accessibleNodes = FlightPathWorldRegistry.GetAccessibleNodes(playerId, val, includeAll); val2.Write(string.Empty); val2.Write(accessibleNodes.Count); foreach (FlightPathDestination item in accessibleNodes) { val2.Write(item.Id); val2.Write(item.Name ?? string.Empty); val2.Write(item.Position); val2.Write(item.IsOrigin); val2.Write(item.AdminOnly); } Send(sender, "VFP_ReplyDestinations_v1", val2); } private static void OnReplyDestinations(long sender, ZPackage package) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) int num = package.ReadInt(); ZDOID originId = package.ReadZDOID(); string text = package.ReadString(); int num2 = package.ReadInt(); if (num != _pendingRequestId || (Object)(object)Player.m_localPlayer == (Object)null) { return; } if (!string.IsNullOrEmpty(text)) { ((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null); return; } List list = new List(num2); for (int i = 0; i < num2; i++) { list.Add(new FlightPathDestination { Id = package.ReadZDOID(), Name = package.ReadString(), Position = package.ReadVector3(), IsOrigin = package.ReadBool(), AdminOnly = package.ReadBool() }); } FlightPathMapSelection.Open(num, originId, list); } private static void OnSelectDestination(long sender, ZPackage package) { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0114: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { int num = package.ReadInt(); ZDOID val = package.ReadZDOID(); ZDOID val2 = package.ReadZDOID(); bool num2 = package.ReadBool(); bool flag = false; int num3 = 0; Vector3 val3 = Vector3.zero; Vector3 val4 = Vector3.zero; bool flag2 = num2 && IsSenderAdmin(sender); string text; long playerId; ZDO character; ZDO node; ZDO node2; if (ActiveFlights.TryGetValue(sender, out var value) && Time.time <= value.ExpiresAt) { text = "$vfp_flight_already_active"; } else if (!TryResolveSender(sender, out playerId, out character) || !FlightPathWorldRegistry.TryGetNode(val, out node) || !FlightPathWorldRegistry.TryGetNode(val2, out node2) || (!FlightPathWorldRegistry.HasAccess(node, playerId) && !flag2) || (!FlightPathWorldRegistry.HasAccess(node2, playerId) && !flag2)) { text = "$vfp_invalid_destination"; } else if (val == val2) { text = "$vfp_same_destination"; } else if (FlightPathWorldRegistry.ExceedsRegistrationLimit(node)) { text = "$vfp_departure_registration_over_limit"; } else if (Vector3.Distance(character.GetPosition(), node.GetPosition()) > 8f) { text = "$vfp_too_far_from_origin"; } else if (!HasServerSideDepartureClearance(val, node.GetPosition())) { text = "$vfp_departure_blocked"; } else { string text2 = $"Flight Path ({node2.GetPosition().x:0}, {node2.GetPosition().z:0})"; string text3 = node2.GetString("vfp_name", text2); text = "$vfp_destination_confirmed " + text3; flag = true; num3 = ++_nextFlightId; val3 = node.GetPosition(); val4 = node2.GetPosition(); ActiveFlights[sender] = new ActiveFlight { Id = num3, ExpiresAt = Time.time + 600f }; } ZPackage val5 = new ZPackage(); val5.Write(num); val5.Write(flag); val5.Write(text); if (flag) { val5.Write(num3); val5.Write(val); val5.Write(val3); val5.Write(val2); val5.Write(val4); } Send(sender, "VFP_SelectionResult_v1", val5); } } private static void OnSelectionResult(long sender, ZPackage package) { //IL_003d: 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_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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_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) int num = package.ReadInt(); bool flag = package.ReadBool(); string text = package.ReadString(); if (num != _pendingRequestId) { return; } Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, text, 0, (Sprite)null); } if (!flag) { return; } int flightId = package.ReadInt(); ZDOID originId = package.ReadZDOID(); Vector3 origin = package.ReadVector3(); ZDOID destinationId = package.ReadZDOID(); Vector3 destination = package.ReadVector3(); if (!FlightPayment.TryCharge(Player.m_localPlayer, out var error, out var _)) { Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)2, error, 0, (Sprite)null); } CompleteFlight(flightId); } else { Game instance = Game.instance; if (instance != null) { instance.SavePlayerProfile(true); } ValkyrieTaxiSpawner.Spawn(flightId, originId, origin, destinationId, destination); } } private static void OnCompleteFlight(long sender, ZPackage package) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { int num = package.ReadInt(); if (ActiveFlights.TryGetValue(sender, out var value) && value.Id == num) { ActiveFlights.Remove(sender); } } } internal static void HandlePeerDisconnected(long peerId) { ActiveFlights.Remove(peerId); } private static void OnToggleGlobal(long sender, ZPackage package) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } ZDOID val = package.ReadZDOID(); if (!IsSenderAdmin(sender) || !FlightPathWorldRegistry.TryGetNode(val, out var node)) { SendManagementResult(sender, "$vfp_admin_required"); return; } bool flag = !FlightPathWorldRegistry.IsGlobal(node); node.SetOwner(ZDOMan.GetSessionID()); node.Set("vfp_global", flag); if (flag) { node.Set("vfp_registration_open", false); } ZDOMan.instance.ForceSendZDO(val); SendManagementResult(sender, flag ? "$vfp_global_enabled" : "$vfp_global_disabled"); } private static void OnRenameFlightPath(long sender, ZPackage package) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } ZDOID val = package.ReadZDOID(); string text = package.ReadString().Trim(); bool flag = package.ReadBool(); if (!TryResolveSender(sender, out var playerId, out var _) || !FlightPathWorldRegistry.TryGetNode(val, out var node) || (node.GetLong(ZDOVars.s_creator, 0L) != playerId && (!flag || !IsSenderAdmin(sender)))) { SendManagementResult(sender, "$vfp_rename_owner_only"); return; } if (text.Length > 50) { text = text.Substring(0, 50); } node.Set("vfp_name", text); ZDOMan.instance.ForceSendZDO(val); SendManagementResult(sender, "$vfp_name_updated"); } private static void OnManagementResult(long sender, ZPackage package) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, package.ReadString(), 0, (Sprite)null); } } internal static void SendManagementResult(long peer, string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(message); Send(peer, "VFP_ManagementResult_v1", val); } private static void OnToggleRegistration(long sender, ZPackage package) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { ZDOID val = package.ReadZDOID(); bool flag = package.ReadBool(); if (TryResolveSender(sender, out var playerId, out var character) && FlightPathWorldRegistry.TryGetNode(val, out var node) && !FlightPathWorldRegistry.IsGlobal(node) && (node.GetLong(ZDOVars.s_creator, 0L) == playerId || (flag && IsSenderAdmin(sender))) && !(Vector3.Distance(character.GetPosition(), node.GetPosition()) > 8f)) { node.SetOwner(ZDOMan.GetSessionID()); bool flag2 = !node.GetBool("vfp_registration_open", false); node.Set("vfp_registration_open", flag2); ZDOMan.instance.ForceSendZDO(val); } } } private static void OnTogglePermitted(long sender, ZPackage package) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_01b2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } ZDOID val = package.ReadZDOID(); string value = package.ReadString(); if (!TryResolveSender(sender, out var playerId, out var character) || !FlightPathWorldRegistry.TryGetNode(val, out var node) || !node.GetBool("vfp_registration_open", false) || Vector3.Distance(character.GetPosition(), node.GetPosition()) > 8f) { return; } int num = node.GetInt("vfp_permitted_count", 0); List> list = new List>(num + 1); bool flag = false; for (int i = 0; i < num; i++) { long num2 = node.GetLong("vfp_permitted_id_" + i, 0L); if (num2 == playerId) { flag = true; } else if (num2 != 0L) { list.Add(new KeyValuePair(num2, node.GetString("vfp_permitted_name_" + i, string.Empty))); } } if (!flag) { int value2 = ModConfig.MaximumRegistrationsPerFlightPath.Value; if (value2 <= 0 || list.Count >= value2) { SendManagementResult(sender, "$vfp_registration_limit_reached"); return; } list.Add(new KeyValuePair(playerId, value)); } node.SetOwner(ZDOMan.GetSessionID()); node.Set("vfp_permitted_count", list.Count); for (int j = 0; j < list.Count; j++) { node.Set("vfp_permitted_id_" + j, list[j].Key); node.Set("vfp_permitted_name_" + j, list[j].Value); } ZDOMan.instance.ForceSendZDO(val); } internal static bool IsSenderAdmin(long sender) { if (sender == ZRoutedRpc.instance.GetServerPeerID()) { return true; } ZNetPeer peer = ZRoutedRpc.instance.GetPeer(sender); if (peer != null && peer.m_socket != null) { return ZNet.instance.IsAdmin(peer.m_socket.GetHostName()); } return false; } private static void OnRequestPlacement(long sender, ZPackage package) { //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0047: 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_005e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { int num = package.ReadInt(); Vector3 val = package.ReadVector3(); long playerId; ZDO character; Collider obstruction; bool flag = TryResolveSender(sender, out playerId, out character) && Vector3.Distance(character.GetPosition(), val) <= 12f && !FlightPathWorldRegistry.HasNodeWithin(val, ModConfig.MinimumFlightPathDistance.Value, ZDOID.None) && FlightPathClearance.HasOpenSky(val, null, out obstruction); ZPackage val2 = new ZPackage(); val2.Write(num); val2.Write(flag); val2.Write(flag ? string.Empty : "$vfp_placement_rejected"); Send(sender, "VFP_PlacementResult_v1", val2); } } private static void OnPlacementResult(long sender, ZPackage package) { FlightPathPlacementAuthorization.Complete(package.ReadInt(), package.ReadBool(), package.ReadString()); } private static bool TryResolveSender(long sender, out long playerId, out ZDO character) { //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) //IL_0047: 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) playerId = 0L; character = null; ZDOID val; if (sender == ZRoutedRpc.instance.GetServerPeerID()) { val = ZNet.instance.LocalPlayerCharacterID; } else { ZNetPeer peer = ZRoutedRpc.instance.GetPeer(sender); if (peer == null || !peer.IsReady()) { return false; } val = peer.m_characterID; } character = ZDOMan.instance.GetZDO(val); if (character == null) { return false; } playerId = character.GetLong(ZDOVars.s_playerID, 0L); return playerId != 0; } private static bool HasServerSideDepartureClearance(ZDOID originId, Vector3 position) { //IL_000c: 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) ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.FindInstance(originId) : null); Transform ignoredRoot = (((Object)(object)val != (Object)null) ? val.transform : null); Collider obstruction; return FlightPathClearance.HasOpenSky(position, ignoredRoot, out obstruction); } private static void Send(long peer, string method, ZPackage package) { ZRoutedRpc.instance.InvokeRoutedRPC(peer, method, new object[1] { package }); } } internal static class FlightPathWorldRegistry { internal static bool TryGetNode(ZDOID id, out ZDO node) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) ZDOMan instance = ZDOMan.instance; node = ((instance != null) ? instance.GetZDO(id) : null); return IsFlightPath(node); } internal static List GetAccessibleNodes(long playerId, ZDOID originId, bool includeAll = false) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_00ba: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_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) List list = new List(); if (ZDOMan.instance == null) { return list; } foreach (ZDO value in ZDOMan.instance.m_objectsByID.Values) { bool flag = HasAccess(value, playerId); if (IsFlightPath(value) && (flag || includeAll)) { Vector3 position = value.GetPosition(); string text = $"({position.x:0}, {position.z:0})"; string text2 = value.GetString("vfp_name", string.Empty); string name = (string.IsNullOrWhiteSpace(text2) ? ("Flight Path " + text) : (text2 + " " + text)); list.Add(new FlightPathDestination { Id = value.m_uid, Name = name, Position = position, IsOrigin = (value.m_uid == originId), AdminOnly = !flag }); } } list.Sort((FlightPathDestination left, FlightPathDestination right) => string.CompareOrdinal(left.Name, right.Name)); return list; } internal static bool HasAccess(ZDO node, long playerId) { if (!IsFlightPath(node)) { return false; } if (node.GetBool("vfp_global", false)) { return true; } if (node.GetLong(ZDOVars.s_creator, 0L) == playerId) { return true; } int num = node.GetInt("vfp_permitted_count", 0); for (int i = 0; i < num; i++) { if (node.GetLong("vfp_permitted_id_" + i, 0L) == playerId) { return true; } } return false; } internal static bool IsGlobal(ZDO node) { if (IsFlightPath(node)) { return node.GetBool("vfp_global", false); } return false; } internal static bool ExceedsRegistrationLimit(ZDO node) { if (!IsFlightPath(node) || IsGlobal(node)) { return false; } return node.GetInt("vfp_permitted_count", 0) > ModConfig.MaximumRegistrationsPerFlightPath.Value; } internal static bool HasNodeWithin(Vector3 position, float minimumDistance, ZDOID ignoredId) { //IL_003d: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (ZDOMan.instance == null || minimumDistance <= 0f) { return false; } float num = minimumDistance * minimumDistance; foreach (ZDO value in ZDOMan.instance.m_objectsByID.Values) { if (IsFlightPath(value) && !(value.m_uid == ignoredId)) { Vector3 val = value.GetPosition() - position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < num) { return true; } } } return false; } private static bool IsFlightPath(ZDO zdo) { if (zdo != null && zdo.IsValid()) { return zdo.GetPrefab() == StringExtensionMethods.GetStableHashCode("VFP_ValkyrieFlightPath"); } return false; } } internal static class FlightPathZdoKeys { internal const string Name = "vfp_name"; internal const string Global = "vfp_global"; internal const string RegistrationOpen = "vfp_registration_open"; internal const string PermittedCount = "vfp_permitted_count"; internal const string PermittedIdPrefix = "vfp_permitted_id_"; internal const string PermittedNamePrefix = "vfp_permitted_name_"; } internal static class FlightPayment { internal static int GetRequiredGoldCost(Player player) { if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null) { return 0; } int value = ModConfig.RestrictedCargoGoldPerItem.Value; int value2 = ModConfig.RestrictedCargoMaximumGold.Value; Inventory inventory = ((Humanoid)player).GetInventory(); if (value <= 0 || value2 <= 0 || inventory.IsTeleportable()) { return 0; } long num = 0L; foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem != null && allItem.m_shared != null && !allItem.m_shared.m_teleportable) { num += Mathf.Max(0, allItem.m_stack); } } long num2 = num * value; if (num2 < value2) { return (int)num2; } return value2; } internal static bool TryCharge(Player player, out string error, out int chargedAmount) { error = string.Empty; chargedAmount = 0; if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null) { error = "$vfp_payment_failed"; return false; } Inventory inventory = ((Humanoid)player).GetInventory(); int requiredGoldCost = GetRequiredGoldCost(player); if (requiredGoldCost <= 0) { return true; } ObjectDB instance = ObjectDB.instance; GameObject obj = ((instance != null) ? instance.GetItemPrefab("Coins") : null); string text = ((obj != null) ? obj.GetComponent() : null)?.m_itemData?.m_shared?.m_name; if (string.IsNullOrEmpty(text)) { error = "$vfp_payment_failed"; return false; } if (inventory.CountItems(text, -1, false) < requiredGoldCost) { error = "$vfp_not_enough_gold " + requiredGoldCost; return false; } inventory.RemoveItem(text, requiredGoldCost, -1, false); chargedAmount = requiredGoldCost; ((Character)player).Message((MessageType)1, "$vfp_gold_paid " + requiredGoldCost, 0, (Sprite)null); return true; } } internal enum PortalPolicy { FullyFunctional, BuildableButDisabled, DisabledAndHidden } internal enum ValkyrieStatuePose { Embrace, Wingspan, Soaring, Perched } internal static class ModConfig { internal static ConfigEntry ClearanceHeight { get; private set; } internal static ConfigEntry ClearanceRadius { get; private set; } internal static ConfigEntry UseFlightPathShortcut { get; private set; } internal static ConfigEntry ManageAccessShortcut { get; private set; } internal static ConfigEntry RenameFlightPathShortcut { get; private set; } internal static ConfigEntry ToggleGlobalShortcut { get; private set; } internal static ConfigEntry ToggleAdminMapModeShortcut { get; private set; } internal static ConfigEntry MinimumFlightPathDistance { get; private set; } internal static ConfigEntry MaximumRegistrationsPerFlightPath { get; private set; } internal static ConfigEntry RestrictedCargoGoldPerItem { get; private set; } internal static ConfigEntry RestrictedCargoMaximumGold { get; private set; } internal static ConfigEntry PortalMode { get; private set; } internal static ConfigEntry StatuePose { get; private set; } internal static void Bind(ConfigFile config) { //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) AcceptableValueBase val = (AcceptableValueBase)(object)new AcceptableValueRange(10f, 100f); ClearanceHeight = ConfigFileExtensions.BindConfig(config, "Flight Paths", "Clearance Height", 30f, "Required open-air height above a flight path.", true, (int?)null, val, (Action)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange(1f, 10f); ClearanceRadius = ConfigFileExtensions.BindConfig(config, "Flight Paths", "Clearance Radius", 2.5f, "Radius of the open-air corridor above a flight path.", true, (int?)null, val, (Action)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2000f); MinimumFlightPathDistance = ConfigFileExtensions.BindConfig(config, "Flight Paths", "Minimum Flight Path Distance", 100f, "Minimum horizontal distance between any two flight paths.", true, (int?)null, val, (Action)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000); MaximumRegistrationsPerFlightPath = ConfigFileExtensions.BindConfig(config, "Flight Paths", "Maximum Registrations Per Flight Path", 10, "Maximum number of players that may register at one private flight path. Set to 0 to disable new registrations.", true, (int?)null, val, (Action)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange(0, 10000); RestrictedCargoGoldPerItem = ConfigFileExtensions.BindConfig(config, "Flight Costs", "Restricted Cargo Gold Per Item", 1, "Gold charged for each individual non-teleportable item carried by the player. Set to 0 to make restricted cargo free.", true, (int?)null, val, (Action)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000000); RestrictedCargoMaximumGold = ConfigFileExtensions.BindConfig(config, "Flight Costs", "Restricted Cargo Maximum Gold", 100, "Maximum total gold charged for restricted cargo on one flight. Set to 0 to make restricted cargo free.", true, (int?)null, val, (Action)null, (ConfigurationManagerAttributes)null); PortalMode = ConfigFileExtensions.BindConfig(config, "Portals", "Portal Policy", PortalPolicy.FullyFunctional, "FullyFunctional keeps portals unchanged. BuildableButDisabled allows building and tagging portals but blocks travel. DisabledAndHidden also removes portal pieces from build menus.", true, (int?)null, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); StatuePose = ConfigFileExtensions.BindConfig(config, "Visuals", "Statue Pose", ValkyrieStatuePose.Embrace, "Static Valkyrie pose used for flight paths. Embrace folds the wings around the approaching player; Wingspan opens them broadly toward the player; Soaring uses the smooth original backward pose; Perched uses the partially folded pose from before custom wing posing. Requires a game restart after changing.", false, (int?)null, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); UseFlightPathShortcut = config.Bind("Controls", "Use Flight Path Shortcut", new KeyboardShortcut((KeyCode)0, Array.Empty()), "Optional shortcut for using the flight path currently under the crosshair. Valheim's configurable Use binding always remains available."); ManageAccessShortcut = config.Bind("Controls", "Manage Access Shortcut", new KeyboardShortcut((KeyCode)118, Array.Empty()), "Opens or closes registration for the owner, or registers/unregisters another player."); RenameFlightPathShortcut = config.Bind("Controls", "Rename Flight Path Shortcut", new KeyboardShortcut((KeyCode)110, Array.Empty()), "Renames the flight path under the crosshair when you own it."); ToggleGlobalShortcut = config.Bind("Controls", "Toggle Global Flight Path Shortcut", new KeyboardShortcut((KeyCode)103, Array.Empty()), "Lets a server admin toggle global access for the flight path under the crosshair."); ToggleAdminMapModeShortcut = config.Bind("Controls", "Toggle Admin Map Mode Shortcut", new KeyboardShortcut((KeyCode)289, Array.Empty()), "Lets a server admin show all flight paths during destination selection."); } } [BepInPlugin("icecub.ValkyrieFlightPaths", "Valkyrie Flight Paths", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private struct LocalBonePose { internal Transform Bone; internal Vector3 Position; internal Quaternion Rotation; internal Vector3 Scale; } public const string PluginGuid = "icecub.ValkyrieFlightPaths"; public const string PluginName = "Valkyrie Flight Paths"; public const string PluginVersion = "0.2.0"; internal const string FlightPathPrefabName = "VFP_ValkyrieFlightPath"; private const string FlightPathIconResourceName = "ValkyrieFlightPaths.Assets.valkyrie_flight_path_icon.png"; private Harmony _harmony; internal static Plugin Instance { get; private set; } internal ManualLogSource Log => ((BaseUnityPlugin)this).Logger; private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown Instance = this; ModConfig.Bind(((BaseUnityPlugin)this).Config); PrefabManager.OnVanillaPrefabsAvailable += RegisterValkyrieFlightPathPiece; _harmony = new Harmony("icecub.ValkyrieFlightPaths"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Valkyrie Flight Paths 0.2.0 loaded"); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterValkyrieFlightPathPiece; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } Instance = null; } private void Update() { FlightPathMapSelection.MonitorPlayerMovement(); FlightPathAdminMode.Update(); } private static PieceConfig CreatePieceConfig() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_001b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown PieceConfig val = new PieceConfig { Name = "$vfp_piece_name", Description = "$vfp_piece_description", PieceTable = PieceTables.Hammer, CraftingStation = CraftingStations.Workbench, Category = PieceCategories.Misc }; val.AddRequirement("GreydwarfEye", 10, true); val.AddRequirement("FineWood", 20, true); val.AddRequirement("SurtlingCore", 2, true); return val; } private void RegisterValkyrieFlightPathPiece() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= RegisterValkyrieFlightPathPiece; GameObject prefab = PrefabManager.Instance.GetPrefab("Valkyrie"); if ((Object)(object)prefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Vanilla prefab 'Valkyrie' was not found; the flight-path build piece cannot be registered"); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("VFP_ValkyrieFlightPath", "wood_floor"); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("Vanilla prefab 'wood_floor' could not be cloned for the flight path"); } RemoveBasePieceGeometry(val); AddStaticValkyrieVisual(val.transform, prefab); ConfigurePhysicalStatue(val); Piece component = val.GetComponent(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("The flight-path donor prefab does not contain a Piece component"); } component.m_icon = LoadFlightPathIcon(); if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } PieceManager.Instance.AddPiece(new CustomPiece(val, false, CreatePieceConfig())); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered the static vanilla 'Valkyrie' prefab as the flight-path model"); } private static Sprite LoadFlightPathIcon() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ValkyrieFlightPaths.Assets.valkyrie_flight_path_icon.png"); if (stream == null) { throw new InvalidDataException("Embedded flight-path icon 'ValkyrieFlightPaths.Assets.valkyrie_flight_path_icon.png' was not found"); } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num == 0) { break; } } Texture2D val = AssetUtils.LoadImage(array); if ((Object)(object)val == (Object)null) { throw new InvalidDataException("The embedded flight-path icon is not a valid PNG image"); } ((Object)val).name = "VFP_ValkyrieFlightPathIcon"; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)obj).name = "VFP_ValkyrieFlightPathIcon"; return obj; } private static void RemoveBasePieceGeometry(GameObject prefab) { Renderer[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } MeshFilter[] componentsInChildren2 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Collider[] componentsInChildren3 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Rigidbody[] componentsInChildren4 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } } private static void AddStaticValkyrieVisual(Transform parent, GameObject vanillaValkyrie) { //IL_0025: 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_0045: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(vanillaValkyrie); ((Object)val).name = "StaticValkyrieVisual"; val.transform.SetParent(parent, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one * 0.35f; FreezeValkyrieFlightPose(val); val.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); AlignVisualToGround(val); Transform transform = val.transform; transform.localPosition += Vector3.down * 0.52f; CenterVisualOverBuildPoint(parent, val); MirrorSmoothWingPoseForward(val); MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } AudioSource[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } ParticleSystem[] componentsInChildren3 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Animator[] componentsInChildren4 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { ((Behaviour)componentsInChildren4[i]).enabled = false; } Rigidbody[] componentsInChildren5 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren5.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren5[i]); } Collider[] componentsInChildren6 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren6.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren6[i]); } val.SetActive(true); } private static void FreezeValkyrieFlightPose(GameObject visual) { //IL_0110: 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_011d: Unknown result type (might be due to invalid IL or missing references) Animator componentInChildren = visual.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.runtimeAnimatorController == (Object)null) { Instance.Log.LogWarning((object)"The Valkyrie prototype has no animation controller; using its bind pose"); return; } AnimationClip val = null; AnimationClip[] animationClips = componentInChildren.runtimeAnimatorController.animationClips; AnimationClip[] array = animationClips; foreach (AnimationClip val2 in array) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.IndexOf("fly", StringComparison.OrdinalIgnoreCase) >= 0) { val = val2; break; } } if ((Object)(object)val == (Object)null && animationClips.Length != 0) { val = animationClips[0]; } if ((Object)(object)val == (Object)null) { Instance.Log.LogWarning((object)"The Valkyrie animation controller contains no clips; using its bind pose"); return; } List poses = CaptureGroundedLegPose(componentInChildren); List poses2 = CaptureHeadPose(componentInChildren); float[] array2 = new float[121]; float[] array3 = new float[121]; float[] array4 = new float[121]; float num = float.MaxValue; float num2 = float.MinValue; for (int j = 0; j < 121; j++) { float num3 = (float)j / 120f; val.SampleAnimation(((Component)componentInChildren).gameObject, val.length * num3); Bounds val3 = MeasureSkeletonBounds(visual); array2[j] = ((Bounds)(ref val3)).size.x; array3[j] = MeasureWingElbowAngle(visual); array4[j] = MeasureWingDropAfterUprightRotation(visual); num = Mathf.Min(num, array2[j]); num2 = Mathf.Max(num2, array2[j]); } float num4 = Mathf.Lerp(num, num2, 0.4f); int num5 = 0; float num6 = float.MaxValue; float num7 = Mathf.Max(0.01f, num2 - num); bool flag = ModConfig.StatuePose.Value == ValkyrieStatuePose.Perched; for (int k = 0; k < 121; k++) { float num8 = Mathf.Abs(array2[k] - num4) / num7; if (flag) { if (!(num8 >= num6)) { num6 = num8; num5 = k; } } else if (!(num8 > 0.15f) && !(array3[k] < 0f)) { float num9 = array3[k] + num8 * 10f; if (num9 < num6) { num6 = num9; num5 = k; } } } float num10 = (float)num5 / 120f; val.SampleAnimation(((Component)componentInChildren).gameObject, val.length * num10); RestoreBonePoses(poses); RestoreBonePoses(poses2); ((Behaviour)componentInChildren).enabled = false; Instance.Log.LogInfo((object)($"Frozen Valkyrie statue on smooth frame {num10:P1} " + $"(joint angle {array3[num5]:0.0} degrees, " + $"span range {num:0.00}-{num2:0.00}m)")); } private static float MeasureWingDropAfterUprightRotation(GameObject visual) { //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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Euler(-90f, 0f, 0f); float num = 0f; int num2 = 0; string[] array = new string[2] { "l", "r" }; foreach (string text in array) { Transform val2 = FindRigTransform(visual.transform, text + "_arm0"); Transform val3 = FindRigTransform(visual.transform, text + "_arm2"); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null)) { Vector3 val4 = visual.transform.InverseTransformPoint(val2.position); Vector3 val5 = visual.transform.InverseTransformPoint(val3.position); num += (val * val5).y - (val * val4).y; num2++; } } if (num2 <= 0) { return float.MaxValue; } return num / (float)num2; } private static float MeasureWingElbowAngle(GameObject visual) { //IL_0096: 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_00a2: 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_00ab: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) float num = 0f; int num2 = 0; string[] array = new string[2] { "l", "r" }; foreach (string text in array) { Transform val = FindRigTransform(visual.transform, text + "_arm0"); Transform val2 = FindRigTransform(visual.transform, text + "_arm1"); Transform val3 = FindRigTransform(visual.transform, text + "_arm2"); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null)) { Vector3 val4 = val2.position - val.position; Vector3 val5 = val3.position - val2.position; if (!(((Vector3)(ref val4)).sqrMagnitude < 0.0001f) && !(((Vector3)(ref val5)).sqrMagnitude < 0.0001f)) { num += Vector3.Angle(val4, val5); num2++; } } } if (num2 <= 0) { return -1f; } return num / (float)num2; } private static Transform FindRigTransform(Transform root, string exactName) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name.Equals(exactName, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static void MirrorSmoothWingPoseForward(GameObject visual) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_013e: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) ValkyrieStatuePose value = ModConfig.StatuePose.Value; if (value == ValkyrieStatuePose.Soaring || value == ValkyrieStatuePose.Perched) { return; } Transform parent = visual.transform.parent; Vector3 val; Vector3 val2; if (!((Object)(object)parent != (Object)null)) { val = Vector3.forward; } else { val2 = parent.forward; val = ((Vector3)(ref val2)).normalized; } Vector3 val3 = val; string[] array = new string[2] { "l", "r" }; foreach (string text in array) { Transform val4 = FindRigTransform(visual.transform, text + "_arm0"); Transform val5 = FindRigTransform(visual.transform, text + "_arm1"); Transform val6 = FindRigTransform(visual.transform, text + "_arm2"); if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)val6 == (Object)null) { continue; } val2 = val5.position - val4.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val7 = normalized - 2f * Vector3.Dot(normalized, val3) * val3; if (value == ValkyrieStatuePose.Wingspan) { val4.rotation = Quaternion.FromToRotation(normalized, ((Vector3)(ref val7)).normalized) * val4.rotation; continue; } float num = Mathf.Sign(Vector3.Dot(val7, val3)); if (Mathf.Approximately(num, 0f)) { num = 1f; } Vector3 val8 = val3 * num; val2 = Vector3.Slerp(((Vector3)(ref val7)).normalized, val8, 0.35f) + Vector3.down * 0.12f; Vector3 normalized2 = ((Vector3)(ref val2)).normalized; val4.rotation = Quaternion.FromToRotation(normalized, normalized2) * val4.rotation; val2 = val6.position - val5.position; Vector3 normalized3 = ((Vector3)(ref val2)).normalized; val2 = (((Object)(object)parent != (Object)null) ? parent.position : visual.transform.position) + val8 * 1f - val5.position; Vector3 normalized4 = ((Vector3)(ref val2)).normalized; val2 = Vector3.Slerp(normalized3, normalized4, 0.75f) + Vector3.down * 0.05f; Vector3 normalized5 = ((Vector3)(ref val2)).normalized; val5.rotation = Quaternion.FromToRotation(normalized3, normalized5) * val5.rotation; } } private static List CaptureGroundedLegPose(Animator animator) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) List list = new List(); HashSet hashSet = new HashSet(); if (animator.isHuman) { HumanBodyBones[] array = new HumanBodyBones[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); HumanBodyBones[] array2 = (HumanBodyBones[])(object)array; foreach (HumanBodyBones val in array2) { Transform boneTransform = animator.GetBoneTransform(val); if ((Object)(object)boneTransform != (Object)null) { hashSet.Add(boneTransform); } } } string[] array3 = new string[10] { "leg", "foot", "toe", "thigh", "calf", "shin", "knee", "ankle", "talon", "claw" }; Transform[] componentsInChildren = ((Component)animator).GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { string text = ((Object)val2).name.ToLowerInvariant(); string[] array4 = array3; foreach (string value in array4) { if (text.Contains(value)) { hashSet.Add(val2); break; } } } foreach (Transform item in hashSet) { list.Add(new LocalBonePose { Bone = item, Position = item.localPosition, Rotation = item.localRotation, Scale = item.localScale }); } Instance.Log.LogInfo((object)($"Captured the original Valkyrie leg pose for {list.Count} rig transforms: " + string.Join(", ", list.ConvertAll((LocalBonePose pose) => ((Object)pose.Bone).name).ToArray()))); return list; } private static List CaptureHeadPose(Animator animator) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e3: 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) HashSet hashSet = new HashSet(); if (animator.isHuman) { Transform boneTransform = animator.GetBoneTransform((HumanBodyBones)9); Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)10); if ((Object)(object)boneTransform != (Object)null) { hashSet.Add(boneTransform); } if ((Object)(object)boneTransform2 != (Object)null) { hashSet.Add(boneTransform2); } } Transform[] componentsInChildren = ((Component)animator).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { string text = ((Object)val).name.ToLowerInvariant(); if (text.Contains("neck") || text.Contains("head")) { hashSet.Add(val); } } List list = new List(); foreach (Transform item in hashSet) { list.Add(new LocalBonePose { Bone = item, Position = item.localPosition, Rotation = item.localRotation, Scale = item.localScale }); } Instance.Log.LogInfo((object)($"Captured the original Valkyrie head pose for {list.Count} rig transforms: " + string.Join(", ", list.ConvertAll((LocalBonePose pose) => ((Object)pose.Bone).name).ToArray()))); return list; } private static void RestoreBonePoses(List poses) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) foreach (LocalBonePose pose in poses) { if (!((Object)(object)pose.Bone == (Object)null)) { pose.Bone.localPosition = pose.Position; pose.Bone.localRotation = pose.Rotation; pose.Bone.localScale = pose.Scale; } } } private static void AlignVisualToGround(GameObject visual) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Bounds val = MeasureSkeletonBounds(visual); Vector3 localPosition = visual.transform.localPosition; localPosition.y += 0.15f - ((Bounds)(ref val)).min.y; visual.transform.localPosition = localPosition; } private static void CenterVisualOverBuildPoint(Transform prefabRoot, GameObject visual) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = FindTorsoPosition(prefabRoot); Vector3 localPosition = visual.transform.localPosition; localPosition.x -= val.x; localPosition.z -= val.z; visual.transform.localPosition = localPosition; Instance.Log.LogInfo((object)$"Recentered the Valkyrie statue by local XZ ({0f - val.x:0.00}, {0f - val.z:0.00})"); } private static Bounds MeasureSkeletonBounds(GameObject visual) { //IL_000e: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_007c: 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_006c: Unknown result type (might be due to invalid IL or missing references) Transform parent = visual.transform.parent; Bounds result = default(Bounds); bool flag = false; SkinnedMeshRenderer[] componentsInChildren = visual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Transform[] bones = componentsInChildren[i].bones; foreach (Transform val in bones) { if (!((Object)(object)val == (Object)null)) { Vector3 val2 = (((Object)(object)parent != (Object)null) ? parent.InverseTransformPoint(val.position) : val.position); if (!flag) { ((Bounds)(ref result))..ctor(val2, Vector3.zero); flag = true; } else { ((Bounds)(ref result)).Encapsulate(val2); } } } } return result; } private static void ConfigurePhysicalStatue(GameObject prefab) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003b: 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_006a: 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_00b7: 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_00cb: Unknown result type (might be due to invalid IL or missing references) Vector3 val = FindTorsoPosition(prefab.transform); CapsuleCollider val2 = prefab.AddComponent(); val2.radius = 0.48f; val2.height = 2.2f; val2.center = new Vector3(val.x, 1.1f, val.z); Instance.Log.LogInfo((object)("Centered the Valkyrie statue collider at local XZ " + $"({val2.center.x:0.00}, {val2.center.z:0.00})")); BoxCollider obj = prefab.AddComponent(); obj.center = new Vector3(0f, 0.02f, 0f); obj.size = new Vector3(0.9f, 0.2f, 0.9f); GameObject val3 = new GameObject("KinematicPhysicsAnchor"); val3.transform.SetParent(prefab.transform, false); Rigidbody obj2 = val3.AddComponent(); obj2.isKinematic = true; obj2.useGravity = false; } private static Vector3 FindTorsoPosition(Transform prefabRoot) { //IL_00f6: 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_00ee: Unknown result type (might be due to invalid IL or missing references) Animator componentInChildren = ((Component)prefabRoot).GetComponentInChildren(true); Transform val = null; if ((Object)(object)componentInChildren != (Object)null && componentInChildren.isHuman) { val = componentInChildren.GetBoneTransform((HumanBodyBones)8) ?? componentInChildren.GetBoneTransform((HumanBodyBones)7) ?? componentInChildren.GetBoneTransform((HumanBodyBones)0); } if ((Object)(object)componentInChildren != (Object)null && (Object)(object)val == (Object)null) { string[] obj = new string[6] { "chest", "spine2", "spine1", "spine", "pelvis", "hips" }; Transform[] componentsInChildren = ((Component)componentInChildren).GetComponentsInChildren(true); string[] array = obj; foreach (string value in array) { Transform[] array2 = componentsInChildren; foreach (Transform val2 in array2) { if (((Object)val2).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { val = val2; break; } } if ((Object)(object)val != (Object)null) { break; } } } if (!((Object)(object)val != (Object)null)) { return Vector3.zero; } return prefabRoot.InverseTransformPoint(val.position); } } internal sealed class ValkyrieTaxiController : MonoBehaviour { private enum FlightState { Takeoff, Cruise, Landing, Returning, FlyAway } private const float CruiseSpeed = 20f; private const float TakeoffSpeed = 9f; private const float LandingSpeed = 13f; private const float CruiseHeight = 36f; private const float TerrainClearance = 20f; private const float DestinationLoadDistance = 120f; private const float BeginLandingDistance = 110f; private const float PlayerReleaseHeight = 8f; private const float NetworkSyncInterval = 0.2f; private const float ClearanceScanInterval = 0.15f; private const float TerrainLookAheadDistance = 180f; private const float ObjectLookAheadDistance = 90f; private const float MaximumFlightSeconds = 600f; private static ValkyrieTaxiController _activeTaxi; private int _flightId; private ZDOID _originId; private ZDOID _destinationId; private Vector3 _origin; private Vector3 _destination; private Vector3 _departureRecoveryPosition; private Vector3 _currentTarget; private Vector3 _travelDirection; private Vector3 _routeStart; private Vector3 _takeoffStart; private Vector3 _landingPosition; private float _landingGroundHeight; private float _baseCruiseY; private float _smoothedCruiseY; private float _variationPhase; private float _cruiseStartTime; private float _currentSpeed; private float _flightTime; private float _nextNetworkSync; private float _nextClearanceScan; private float _cachedSafeCruiseY; private float _flyAwayTime; private float _nextLandingCheck; private bool _reportedNoSafeLanding; private bool _initialized; private bool _completionSent; private FlightState _state; private Player _player; private Valkyrie _valkyrie; private ZNetView _networkView; private ZSyncTransform _taxiSync; private ZSyncTransform _playerSync; private bool _hangApplied; private bool _previousUseGravity; internal static bool HasActiveTaxi { get; private set; } internal static bool KeepHudVisible { get; private set; } internal static void EndHudOverride() { KeepHudVisible = false; } internal static bool PrepareLocalPlayerDeath(Player player) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_006f: 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_0095: 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_00a2: 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_0113: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveTaxi || (Object)(object)_activeTaxi == (Object)null || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return false; } Vector3 position = ((Component)player).transform.position; float num = ((Character)player).GetCenterPoint().y - ((Component)player).transform.position.y; float num2 = (((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.GetGroundHeight(position) : position.y); float num3 = (((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.m_waterLevel : 30f); float liquidLevel = Floating.GetLiquidLevel(new Vector3(position.x, num3, position.z), 1f, (LiquidType)0); if (liquidLevel > -1000f) { num3 = liquidLevel; } float num4 = ((num3 > num2 + 0.5f) ? (num3 + 0.5f) : (num2 + 0.5f)); position.y = num4 - num; _activeTaxi.CancelForDeath(); ((Component)player).transform.position = position; if ((Object)(object)((Character)player).m_body != (Object)null) { ((Character)player).m_body.position = position; ((Character)player).m_body.linearVelocity = Vector3.zero; ((Character)player).m_body.angularVelocity = Vector3.zero; } ZNet instance = ZNet.instance; if (instance != null) { instance.SetReferencePosition(position); } ZSyncTransform component = ((Component)player).GetComponent(); if (component != null) { component.SyncNow(); } return true; } internal static bool TryGetLogoutRecoveryPoint(out Vector3 position) { //IL_0027: 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_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) if (HasActiveTaxi && (Object)(object)_activeTaxi != (Object)null) { position = _activeTaxi._departureRecoveryPosition; return true; } position = Vector3.zero; return false; } internal void Initialize(int flightId, ZDOID originId, Vector3 origin, ZDOID destinationId, Vector3 destination, Vector3 departureRecoveryPosition) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_0138: Unknown result type (might be due to invalid IL or missing references) _flightId = flightId; _originId = originId; _origin = origin; _destinationId = destinationId; _destination = destination; _departureRecoveryPosition = departureRecoveryPosition; _currentTarget = destination; _routeStart = origin; _takeoffStart = ((Component)this).transform.position; _player = Player.m_localPlayer; _valkyrie = ((Component)this).GetComponent(); _networkView = ((Component)this).GetComponent(); _taxiSync = ((Component)this).GetComponent(); Player player = _player; _playerSync = ((player != null) ? ((Component)player).GetComponent() : null); if ((Object)(object)_player == (Object)null || (Object)(object)_valkyrie == (Object)null || (Object)(object)_networkView == (Object)null || !_networkView.IsValid() || !_networkView.IsOwner()) { FailAndDestroy("$vfp_valkyrie_spawn_failed"); return; } Vector3 val = destination - origin; val.y = 0f; _travelDirection = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((Component)this).transform.forward); _baseCruiseY = Mathf.Max(((Component)this).transform.position.y + 36f, origin.y + 36f); _smoothedCruiseY = _baseCruiseY; _cachedSafeCruiseY = _baseCruiseY; _variationPhase = Mathf.Abs((float)flightId * 0.6180339f) % ((float)Math.PI * 2f); ApplyHangState(enabled: true); SEMan seman = ((Character)_player).m_seman; if (seman != null) { seman.RemoveStatusEffect(SEMan.s_statusEffectFreezing, true); } SyncPlayerToValkyrie(updateRigidbody: true); HasActiveTaxi = true; KeepHudVisible = true; _activeTaxi = this; _state = FlightState.Takeoff; _initialized = true; ((Character)_player).Message((MessageType)2, "$vfp_takeoff", 0, (Sprite)null); } private void Update() { if (_initialized && !((Object)(object)_networkView == (Object)null) && _networkView.IsValid() && _networkView.IsOwner()) { float deltaTime = Time.deltaTime; _flightTime += deltaTime; if (_flightTime > 600f && _state != FlightState.Returning && _state != FlightState.Landing && _state != FlightState.FlyAway) { BeginReturn("$vfp_flight_timeout"); } switch (_state) { case FlightState.Takeoff: UpdateTakeoff(deltaTime); break; case FlightState.Cruise: case FlightState.Returning: UpdateCruise(deltaTime); break; case FlightState.Landing: UpdateLanding(deltaTime); break; case FlightState.FlyAway: UpdateFlyAway(deltaTime); break; } if (_state != FlightState.FlyAway && (Object)(object)_player != (Object)null) { SyncPlayerToValkyrie(updateRigidbody: false); SyncNetworkPosition(); } } } private void FixedUpdate() { if (_initialized && _state != FlightState.FlyAway && (Object)(object)_player != (Object)null) { SyncPlayerRigidbody(); } } private void LateUpdate() { if (_initialized && _state != FlightState.FlyAway && (Object)(object)_player != (Object)null) { SyncPlayerToValkyrie(updateRigidbody: false); } } private void UpdateTakeoff(float deltaTime) { //IL_0023: 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_0068: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) float num = Mathf.Max(1f, _baseCruiseY - _takeoffStart.y); float num2 = Mathf.Clamp01((((Component)this).transform.position.y - _takeoffStart.y) / num); float num3 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.65f, 1f, num2)); Vector3 val = _takeoffStart + _travelDirection * (18f * num3); val.y = _baseCruiseY; MoveTowards(val, 9f, deltaTime, enforceTerrainClearance: false, 5f, keepLevel: true); if (Vector3.Distance(((Component)this).transform.position, val) < 1f) { _state = FlightState.Cruise; _cruiseStartTime = _flightTime; } } private void UpdateCruise(float deltaTime) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: 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_002f: 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_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_0054: 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_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_007c: 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_008c: 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_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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0264: 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) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _currentTarget - _routeStart; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 val2 = ((magnitude > 0.1f) ? (val / magnitude) : _travelDirection); float num = Mathf.Clamp(Vector3.Dot(((Component)this).transform.position - _routeStart, val2), 0f, magnitude); Vector3 val3 = _currentTarget - ((Component)this).transform.position; Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(val3.x, 0f, val3.z); float magnitude2 = ((Vector3)(ref val4)).magnitude; float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((_flightTime - _cruiseStartTime) / 7f)); float num3 = Mathf.Clamp01((magnitude2 - 110f) / 70f); float num4 = num2 * num3; float num5 = Mathf.Min(magnitude, num + 40f); Vector3 val5 = Vector3.Cross(Vector3.up, val2); float num6 = Mathf.Sin(num5 / 70f + _variationPhase) * 24f * num4; Vector3 val6 = _routeStart + val2 * num5 + val5 * num6 - ((Component)this).transform.position; val6.y = 0f; if (((Vector3)(ref val6)).sqrMagnitude > 0.01f) { _travelDirection = ((Vector3)(ref val6)).normalized; } float num7 = (0f - Mathf.Clamp01(0.5f + Mathf.Sin(num / 62f + _variationPhase) * 0.35f + Mathf.Sin(num / 117f + _variationPhase * 0.7f) * 0.15f)) * 32f * num4; float num8 = Mathf.Max(_baseCruiseY + num7, ComputeSafeCruiseHeight(_travelDirection)); _smoothedCruiseY = Mathf.MoveTowards(_smoothedCruiseY, num8, 8f * deltaTime); Vector3 target = ((Component)this).transform.position + _travelDirection * Mathf.Min(40f, magnitude2); target.y = _smoothedCruiseY; MoveTowards(target, 20f, deltaTime, enforceTerrainClearance: true, 5f); if (magnitude2 < 120f && (Object)(object)ZNet.instance != (Object)null) { ZNet.instance.SetReferencePosition(_currentTarget); } if (!(magnitude2 <= 110f) || !(Time.time >= _nextLandingCheck) || !ZNetScene.instance.IsAreaReady(_currentTarget)) { return; } ZDOID nodeId = ((_state == FlightState.Returning) ? _originId : _destinationId); if (!IsLandingCorridorClear(nodeId, _currentTarget)) { if (_state == FlightState.Returning) { if (TryFindEmergencyLanding(_origin, out _landingPosition)) { _landingGroundHeight = _landingPosition.y; float num9 = (((Object)(object)_player != (Object)null) ? (((Component)_player).transform.position.y - ((Component)this).transform.position.y) : (-2f)); _landingPosition.y = _landingGroundHeight + 8f - num9; _state = FlightState.Landing; Player player = _player; if (player != null) { ((Character)player).Message((MessageType)2, "$vfp_emergency_landing", 0, (Sprite)null); } return; } _nextLandingCheck = Time.time + 2f; if (!_reportedNoSafeLanding) { _reportedNoSafeLanding = true; Player player2 = _player; if (player2 != null) { ((Character)player2).Message((MessageType)2, "$vfp_no_safe_landing", 0, (Sprite)null); } } } else { BeginReturn("$vfp_destination_blocked_returning"); } } else { _landingPosition = _currentTarget; float landingGroundHeight = default(float); if (ZoneSystem.instance.GetGroundHeight(_landingPosition, ref landingGroundHeight)) { _landingGroundHeight = landingGroundHeight; } else { _landingGroundHeight = _currentTarget.y; } float num10 = (((Object)(object)_player != (Object)null) ? (((Component)_player).transform.position.y - ((Component)this).transform.position.y) : (-2f)); _landingPosition.y = _landingGroundHeight + 8f - num10; _state = FlightState.Landing; Player player3 = _player; if (player3 != null) { ((Character)player3).Message((MessageType)2, "$vfp_landing", 0, (Sprite)null); } } } private void UpdateLanding(float deltaTime) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ea: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) _currentSpeed = Mathf.MoveTowards(_currentSpeed, 13f, 5f * deltaTime); Vector3 val = _landingPosition - ((Component)this).transform.position; Vector3 val2 = ((Component)this).transform.position + ((Vector3)(ref val)).normalized * 25f; float num = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val2, ref num)) { val2.y = Mathf.Max(val2.y, num + 10f); } Vector3 val3 = val2 - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val3)).normalized; Quaternion val4 = Quaternion.LookRotation(normalized, Vector3.up); Vector3 val5 = normalized; val5.y = 0f; ((Vector3)(ref val5)).Normalize(); Vector3 forward = ((Component)this).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); float num2 = Mathf.Clamp(Vector3.SignedAngle(forward, val5, Vector3.up), -30f, 30f) / 30f; val4 = Quaternion.Euler(0f, 0f, num2 * 35f) * val4; ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val4, 35f * deltaTime); Vector3 val6 = ((Component)this).transform.position + ((Component)this).transform.forward * (_currentSpeed * deltaTime); float num3 = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val6, ref num3)) { val6.y = Mathf.Max(val6.y, num3 + 10f); } ((Component)this).transform.position = val6; if (Utils.DistanceXZ(((Component)this).transform.position, _landingPosition) < 0.75f) { ReleasePlayer(); } } private void UpdateFlyAway(float deltaTime) { //IL_001a: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) _flyAwayTime += deltaTime; KeepReleasedPlayerUpright(); Vector3 target = ((Component)this).transform.position + ((Component)this).transform.forward * 20f + Vector3.up * 10f; MoveTowards(target, 20f, deltaTime); if (_flyAwayTime >= 3f) { DestroyTaxi(); } } private float ComputeSafeCruiseHeight(Vector3 direction) { //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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_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_0155: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _nextClearanceScan) { return _cachedSafeCruiseY; } _nextClearanceScan = Time.time + 0.15f; float num = _baseCruiseY - 16f; if ((Object)(object)ZoneSystem.instance != (Object)null) { float num3 = default(float); for (float num2 = 30f; num2 <= 180f; num2 += 30f) { Vector3 val = ((Component)this).transform.position + direction * num2; if (ZoneSystem.instance.GetGroundHeight(val, ref num3)) { num = Mathf.Max(num, num3 + 20f); } } } int mask = LayerMask.GetMask(new string[8] { "Default", "static_solid", "Default_small", "piece", "terrain", "blocker", "pathblocker", "viewblock" }); RaycastHit[] array = Physics.SphereCastAll(((Component)this).transform.position + Vector3.up * 1.5f, 3.25f, direction, 90f, mask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)this).transform)) { float num4 = num; Bounds bounds = ((RaycastHit)(ref val2)).collider.bounds; num = Mathf.Max(num4, ((Bounds)(ref bounds)).max.y + 14f); } } _cachedSafeCruiseY = num; return _cachedSafeCruiseY; } private bool IsLandingCorridorClear(ZDOID nodeId, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) GameObject val = ZNetScene.instance.FindInstance(nodeId); Collider obstruction; if ((Object)(object)val != (Object)null) { return FlightPathClearance.HasOpenSky(position, val.transform, out obstruction); } return false; } private bool TryFindEmergencyLanding(Vector3 center, out Vector3 landingPosition) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0073: 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) float y = default(float); for (int i = 1; i <= 3; i++) { float num = (float)i * 10f; for (int j = 0; j < 12; j++) { float num2 = (float)j * (float)Math.PI * 2f / 12f; Vector3 val = center + new Vector3(Mathf.Sin(num2), 0f, Mathf.Cos(num2)) * num; if (ZoneSystem.instance.GetGroundHeight(val, ref y)) { val.y = y; if (FlightPathClearance.HasOpenSky(val, null, out var _)) { landingPosition = val; return true; } } } } landingPosition = Vector3.zero; return false; } private void BeginReturn(string message) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) _currentTarget = _origin; _routeStart = ((Component)this).transform.position; _cruiseStartTime = _flightTime; _state = FlightState.Returning; _baseCruiseY = Mathf.Max(_baseCruiseY, ((Component)this).transform.position.y); _reportedNoSafeLanding = false; Player player = _player; if (player != null) { ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } } private void MoveTowards(Vector3 target, float speed, float deltaTime, bool enforceTerrainClearance = false, float acceleration = 10f, bool keepLevel = false) { //IL_0016: 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_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_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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d0: Unknown result type (might be due to invalid IL or missing references) _currentSpeed = Mathf.MoveTowards(_currentSpeed, speed, acceleration * deltaTime); Vector3 val = target - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { Vector3 val2 = val; if (keepLevel) { val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude <= 0.001f) { val2 = _travelDirection; } } Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val3, 90f * deltaTime); } Vector3 val4 = Vector3.MoveTowards(((Component)this).transform.position, target, _currentSpeed * deltaTime); float num = default(float); if (enforceTerrainClearance && (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val4, ref num)) { val4.y = Mathf.Max(val4.y, num + 20f); } ((Component)this).transform.position = val4; } private void SyncPlayerToValkyrie(bool updateRigidbody) { //IL_0048: 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_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) if (!((Object)(object)_player == (Object)null) && !((Object)(object)_valkyrie == (Object)null) && !((Object)(object)_valkyrie.m_attachPoint == (Object)null)) { Transform attachPoint = _valkyrie.m_attachPoint; ((Component)_player).transform.rotation = attachPoint.rotation; ((Component)_player).transform.position = attachPoint.position - ((Component)_player).transform.TransformVector(_valkyrie.m_attachOffset); if (updateRigidbody && (Object)(object)((Character)_player).m_body != (Object)null) { SyncPlayerRigidbody(); } } } private void SyncPlayerRigidbody() { //IL_0038: 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_0062: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_player == (Object)null) && !((Object)(object)((Character)_player).m_body == (Object)null)) { ((Character)_player).m_body.position = ((Component)_player).transform.position; ((Character)_player).m_body.linearVelocity = Vector3.zero; ((Character)_player).m_body.angularVelocity = Vector3.zero; } } private void ApplyHangState(bool enabled) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_player == (Object)null) { return; } ZSyncAnimation component = ((Component)_player).GetComponent(); if (component != null) { component.SetBool("intro", enabled); } if ((Object)(object)((Character)_player).m_body == (Object)null) { return; } if (enabled) { if (!_hangApplied) { _previousUseGravity = ((Character)_player).m_body.useGravity; _hangApplied = true; } ((Character)_player).m_body.useGravity = false; ((Character)_player).m_body.linearVelocity = Vector3.zero; ((Character)_player).m_body.angularVelocity = Vector3.zero; } else if (_hangApplied) { ((Character)_player).m_body.useGravity = _previousUseGravity; ((Character)_player).m_body.linearVelocity = Vector3.zero; ((Character)_player).m_body.angularVelocity = Vector3.zero; ((Character)_player).m_body.WakeUp(); _hangApplied = false; } } private void SyncNetworkPosition() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time < _nextNetworkSync)) { _nextNetworkSync = Time.time + 0.2f; ZNet instance = ZNet.instance; if (instance != null) { instance.SetReferencePosition(((Component)_player).transform.position); } ZSyncTransform playerSync = _playerSync; if (playerSync != null) { playerSync.SyncNow(); } ZSyncTransform taxiSync = _taxiSync; if (taxiSync != null) { taxiSync.SyncNow(); } } } private void ReleasePlayer() { //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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_player != (Object)null) { ApplyHangState(enabled: false); Vector3 forward = ((Component)this).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude > 0.01f) { Quaternion rotation = Quaternion.LookRotation(((Vector3)(ref forward)).normalized, Vector3.up); ((Component)_player).transform.rotation = rotation; if ((Object)(object)((Character)_player).m_body != (Object)null) { ((Character)_player).m_body.rotation = rotation; ((Character)_player).m_body.angularVelocity = Vector3.zero; } if ((Object)(object)((Character)_player).m_eye != (Object)null) { ((Character)_player).m_eye.rotation = rotation; } } } Animator componentInChildren = ((Component)this).GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.SetBool("dropped", true); } SendCompletion(); HasActiveTaxi = false; _state = FlightState.FlyAway; _flyAwayTime = 0f; } private void KeepReleasedPlayerUpright() { //IL_0027: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_007f: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_player == (Object)null || _flyAwayTime > 2f) { return; } Vector3 forward = ((Component)_player).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude <= 0.001f) { forward = ((Component)this).transform.forward; forward.y = 0f; } if (!(((Vector3)(ref forward)).sqrMagnitude <= 0.001f)) { Quaternion rotation = Quaternion.LookRotation(((Vector3)(ref forward)).normalized, Vector3.up); ((Component)_player).transform.rotation = rotation; if ((Object)(object)((Character)_player).m_body != (Object)null) { ((Character)_player).m_body.rotation = rotation; ((Character)_player).m_body.angularVelocity = Vector3.zero; } } } private void FailAndDestroy(string message) { Player player = _player; if (player != null) { ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } ApplyHangState(enabled: false); HasActiveTaxi = false; SendCompletion(); DestroyTaxi(); } private void CancelForDeath() { ApplyHangState(enabled: false); HasActiveTaxi = false; KeepHudVisible = false; SendCompletion(); _initialized = false; if ((Object)(object)_activeTaxi == (Object)(object)this) { _activeTaxi = null; } DestroyTaxi(); } private void SendCompletion() { if (!_completionSent) { _completionSent = true; FlightPathRpc.CompleteFlight(_flightId); } } private void DestroyTaxi() { if ((Object)(object)_networkView != (Object)null && _networkView.IsValid() && _networkView.IsOwner()) { _networkView.Destroy(); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void OnDestroy() { if ((Object)(object)_activeTaxi == (Object)(object)this) { _activeTaxi = null; } if (_initialized && _state != FlightState.FlyAway) { ApplyHangState(enabled: false); HasActiveTaxi = false; SendCompletion(); } } } internal static class ValkyrieTaxiSpawnContext { internal static bool Active; } internal static class ValkyrieTaxiSpawner { internal static void Spawn(int flightId, ZDOID originId, Vector3 origin, ZDOID destinationId, Vector3 destination) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_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_0100: 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_0103: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab("Valkyrie") : null); if ((Object)(object)localPlayer == (Object)null || (Object)(object)val == (Object)null || ValkyrieTaxiController.HasActiveTaxi) { if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "$vfp_valkyrie_spawn_failed", 0, (Sprite)null); } FlightPathRpc.CompleteFlight(flightId); return; } Vector3 val2 = destination - origin; val2.y = 0f; val2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : ((Component)localPlayer).transform.forward); Vector3 position = ((Component)localPlayer).transform.position; Vector3 val3 = ((Component)localPlayer).transform.position + Vector3.up * 2f; Quaternion val4 = Quaternion.LookRotation(val2, Vector3.up); ValkyrieTaxiSpawnContext.Active = true; GameObject val5; try { val5 = Object.Instantiate(val, val3, val4); } finally { ValkyrieTaxiSpawnContext.Active = false; } Valkyrie component = val5.GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } val5.AddComponent().Initialize(flightId, originId, origin, destinationId, destination, position); } } } namespace ValkyrieFlightPaths.Patches { [HarmonyPatch(typeof(PlayerProfile), "SaveLogoutPoint")] internal static class FlightLogoutPointPatch { private static bool Prefix(PlayerProfile __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!ValkyrieTaxiController.TryGetLogoutRecoveryPoint(out var position)) { return true; } __instance.SetLogoutPoint(position); return false; } } [HarmonyPatch(typeof(ZNet), "Disconnect", new Type[] { typeof(ZNetPeer) })] internal static class FlightPeerDisconnectPatch { private static void Prefix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer() && peer != null) { FlightPathRpc.HandlePeerDisconnected(peer.m_uid); } } } [HarmonyPatch(typeof(WearNTear), "HaveSupport")] internal static class FlightPathSupportPatch { private static readonly Collider[] NearbySupports = (Collider[])(object)new Collider[64]; private static void Postfix(WearNTear __instance, ref bool __result) { //IL_0024: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) if (__result || (Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).GetComponent() == (Object)null) { return; } Transform transform = ((Component)__instance).transform; Vector3 val = transform.position + transform.up * -0.05f; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0.42f, 0.2f, 0.42f); int num = Physics.OverlapBoxNonAlloc(val, val2, NearbySupports, transform.rotation, WearNTear.s_rayMask, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val3 = NearbySupports[i]; NearbySupports[i] = null; if (!((Object)(object)val3 == (Object)null) && !val3.isTrigger && !((Component)val3).transform.IsChildOf(transform)) { __result = true; break; } } } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] internal static class GlobalFlightPathDamagePatch { private static bool Prefix(WearNTear __instance) { return !IsProtectedGlobal(__instance); } private static bool IsProtectedGlobal(WearNTear wearNTear) { ZNetView val = wearNTear?.m_nview; if ((Object)(object)val != (Object)null && val.IsValid()) { return FlightPathWorldRegistry.IsGlobal(val.GetZDO()); } return false; } } [HarmonyPatch(typeof(WearNTear), "RPC_Remove")] internal static class GlobalFlightPathRemovePatch { private static bool Prefix(WearNTear __instance, long sender) { ZNetView val = __instance?.m_nview; if ((Object)(object)val == (Object)null || !val.IsValid() || !FlightPathWorldRegistry.IsGlobal(val.GetZDO())) { return true; } if (FlightPathRpc.IsSenderAdmin(sender)) { return true; } FlightPathRpc.SendManagementResult(sender, "$vfp_global_remove_admin_only"); return false; } } [HarmonyPatch(typeof(Player), "Update")] internal static class InteractionHotkeyPatch { private static void Postfix(Player __instance) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !((Character)__instance).TakeInput() || Hud.InRadial()) { return; } GameObject hovering = __instance.m_hovering; if ((Object)(object)hovering == (Object)null) { return; } FlightPathNode componentInParent = hovering.GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { if (IsDown(ModConfig.ManageAccessShortcut.Value)) { componentInParent.ManageAccess(__instance); ((Humanoid)__instance).DoInteractAnimation(((Component)componentInParent).gameObject); } else if (IsDown(ModConfig.RenameFlightPathShortcut.Value)) { componentInParent.BeginRename(__instance); } else if (IsDown(ModConfig.ToggleGlobalShortcut.Value)) { componentInParent.ToggleGlobal(__instance); } else if (IsDown(ModConfig.UseFlightPathShortcut.Value)) { componentInParent.UseFlightPath(__instance); ((Humanoid)__instance).DoInteractAnimation(((Component)componentInParent).gameObject); } } } private static bool IsDown(KeyboardShortcut shortcut) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0) { return ((KeyboardShortcut)(ref shortcut)).IsDown(); } return false; } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] internal static class LocalizationPatch { private static void Postfix(Localization __instance) { __instance.AddWord("vfp_piece_name", "Valkyrie Flight Path"); __instance.AddWord("vfp_piece_description", "A Valkyrie shrine from which you can travel to another flight path."); __instance.AddWord("vfp_open_map", "Choose destination"); __instance.AddWord("vfp_no_access", "You do not have access to this flight path"); __instance.AddWord("vfp_open_registration", "Open registration"); __instance.AddWord("vfp_close_registration", "Close registration"); __instance.AddWord("vfp_register", "Register"); __instance.AddWord("vfp_unregister", "Unregister"); __instance.AddWord("vfp_registration_closed", "Registration is closed"); __instance.AddWord("vfp_registration_limit_reached", "This flight path has reached its registration limit"); __instance.AddWord("vfp_departure_registration_over_limit", "This flight path has more registered players than the current server limit. Remove registrations before departing"); __instance.AddWord("vfp_owner", "Owner"); __instance.AddWord("vfp_registered", "Registered"); __instance.AddWord("vfp_none", "None"); __instance.AddWord("vfp_unknown", "Unknown"); __instance.AddWord("vfp_global_access", "Global Flight Path"); __instance.AddWord("vfp_global_registration_unavailable", "Global flight paths do not use registrations"); __instance.AddWord("vfp_departure_blocked", "The air above this flight path is blocked"); __instance.AddWord("vfp_invalid_origin", "This flight path is no longer available"); __instance.AddWord("vfp_invalid_destination", "That destination is no longer available"); __instance.AddWord("vfp_same_destination", "You are already at this flight path"); __instance.AddWord("vfp_too_far_from_origin", "Move closer to the flight path"); __instance.AddWord("vfp_destination_confirmed", "Destination selected:"); __instance.AddWord("vfp_map_unavailable", "The map is unavailable in this world"); __instance.AddWord("vfp_current", "current"); __instance.AddWord("vfp_select_destination", "Select a flight path destination"); __instance.AddWord("vfp_no_destinations", "Build or register at another flight path before travelling"); __instance.AddWord("vfp_click_destination_pin", "Click a flight path marker to select it"); __instance.AddWord("vfp_too_close_to_flight_path", "Another flight path is too close"); __instance.AddWord("vfp_placement_rejected", "The server rejected this flight path location"); __instance.AddWord("vfp_waiting_for_server", "Waiting for the server to validate this location"); __instance.AddWord("vfp_flight_already_active", "A Valkyrie flight is already active"); __instance.AddWord("vfp_valkyrie_spawn_failed", "The Valkyrie could not be summoned"); __instance.AddWord("vfp_takeoff", "The Valkyrie takes flight"); __instance.AddWord("vfp_landing", "The Valkyrie is landing"); __instance.AddWord("vfp_flight_timeout", "The flight took too long; returning to the departure point"); __instance.AddWord("vfp_destination_blocked_returning", "The destination is blocked; returning to the departure point"); __instance.AddWord("vfp_return_blocked", "Both flight paths are blocked; emergency release"); __instance.AddWord("vfp_emergency_landing", "The departure point is blocked; landing nearby"); __instance.AddWord("vfp_no_safe_landing", "Searching for a safe landing area"); __instance.AddWord("vfp_not_enough_gold", "Not enough gold. Required:"); __instance.AddWord("vfp_gold_paid", "Gold paid for restricted cargo:"); __instance.AddWord("vfp_payment_failed", "The Valkyrie could not process the cargo payment"); __instance.AddWord("vfp_flight_free", "Free"); __instance.AddWord("vfp_portals_disabled", "Portals are disabled on this server"); __instance.AddWord("vfp_admin_required", "Server administrator privileges are required"); __instance.AddWord("vfp_admin_map_enabled", "Admin flight-path map mode enabled"); __instance.AddWord("vfp_admin_map_disabled", "Admin flight-path map mode disabled"); __instance.AddWord("vfp_make_global", "Make global"); __instance.AddWord("vfp_make_private", "Remove global status"); __instance.AddWord("vfp_global_enabled", "This flight path is now global"); __instance.AddWord("vfp_global_disabled", "This flight path is no longer global"); __instance.AddWord("vfp_global_remove_admin_only", "Global flight paths can only be destroyed by server administrators"); __instance.AddWord("vfp_rename", "Rename flight path"); __instance.AddWord("vfp_rename_owner_only", "Only the owner can rename this flight path"); __instance.AddWord("vfp_name_updated", "Flight path name updated"); } } [HarmonyPatch(typeof(Minimap), "SetMapMode")] internal static class MinimapModePatch { private static void Postfix(MapMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)mode != 2 && FlightPathMapSelection.IsActive) { FlightPathMapSelection.Clear(); } } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] internal static class MinimapLeftClickPatch { private static bool Prefix(Minimap __instance) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!FlightPathMapSelection.IsActive) { return true; } FlightPathMapSelection.TrySelect(__instance.ScreenToWorldPoint(ZInput.mousePosition)); return false; } } [HarmonyPatch(typeof(Minimap), "OnMapDblClick")] internal static class MinimapDoubleClickPatch { private static bool Prefix() { return !FlightPathMapSelection.ShouldSuppressMapInput; } } [HarmonyPatch(typeof(Minimap), "OnMapRightClick")] internal static class MinimapRightClickPatch { private static bool Prefix() { return !FlightPathMapSelection.IsActive; } } [HarmonyPatch(typeof(Minimap), "OnMapMiddleClick")] internal static class MinimapMiddleClickPatch { private static bool Prefix() { return !FlightPathMapSelection.IsActive; } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] internal static class MinimapPinVisibilityPatch { private static void Prefix(Minimap __instance, out List __state) { __state = null; if (!FlightPathMapSelection.IsActive) { return; } __state = __instance.m_pins; foreach (PinData item in __state) { if (!FlightPathMapSelection.IsFlightPathPin(item)) { __instance.DestroyPinMarker(item); } } __instance.m_pins = FlightPathMapSelection.GetPinsForRendering(); } private static void Postfix(Minimap __instance, List __state) { if (__state != null) { __instance.m_pins = __state; } } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class NetworkPatch { private static void Postfix() { FlightPathRpc.Register(); } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] internal static class PlacementPatches { private static void Postfix(Player __instance) { //IL_0020: 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_0057: 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_0044: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) GameObject placementGhost = __instance.m_placementGhost; if ((Object)(object)placementGhost == (Object)null || (Object)(object)placementGhost.GetComponent() == (Object)null || (int)__instance.m_placementStatus != 0) { return; } if (!FlightPathClearance.HasOpenSky(placementGhost.transform.position, placementGhost.transform, out var _)) { __instance.m_placementStatus = (PlacementStatus)1; __instance.SetPlacementGhostValid(false); } else if (FlightPathWorldRegistry.HasNodeWithin(placementGhost.transform.position, ModConfig.MinimumFlightPathDistance.Value, ZDOID.None)) { __instance.m_placementStatus = (PlacementStatus)1; __instance.SetPlacementGhostValid(false); } else if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer()) { FlightPathPlacementAuthorization.UpdateCandidate(placementGhost.transform.position); if (!FlightPathPlacementAuthorization.IsApproved(placementGhost.transform.position)) { __instance.m_placementStatus = (PlacementStatus)1; __instance.SetPlacementGhostValid(false); } } } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] internal static class PlacePieceValidationPatch { private static bool Prefix(Player __instance, Piece piece, ref bool __result) { //IL_0067: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) GameObject placementGhost = __instance.m_placementGhost; if ((Object)(object)piece != (Object)null && ModConfig.PortalMode.Value == PortalPolicy.DisabledAndHidden && (Object)(object)((Component)piece).GetComponentInChildren(true) != (Object)null) { ((Character)__instance).Message((MessageType)2, "$vfp_portals_disabled", 0, (Sprite)null); __result = false; return false; } if ((Object)(object)placementGhost == (Object)null || (Object)(object)piece == (Object)null || (Object)(object)((Component)piece).GetComponent() == (Object)null) { return true; } if (FlightPathWorldRegistry.HasNodeWithin(placementGhost.transform.position, ModConfig.MinimumFlightPathDistance.Value, ZDOID.None)) { ((Character)__instance).Message((MessageType)2, "$vfp_too_close_to_flight_path", 0, (Sprite)null); __result = false; return false; } if (!FlightPathClearance.HasOpenSky(placementGhost.transform.position, placementGhost.transform, out var _)) { ((Character)__instance).Message((MessageType)2, "$vfp_departure_blocked", 0, (Sprite)null); __result = false; return false; } if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { return true; } if (FlightPathPlacementAuthorization.IsApproved(placementGhost.transform.position)) { return true; } ((Character)__instance).Message((MessageType)2, "$vfp_waiting_for_server", 0, (Sprite)null); __result = false; return false; } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] internal static class PortalTravelPatch { private static bool Prefix(Player player) { if (ModConfig.PortalMode.Value == PortalPolicy.FullyFunctional) { return true; } if (player != null) { ((Character)player).Message((MessageType)2, "$vfp_portals_disabled", 0, (Sprite)null); } return false; } } [HarmonyPatch(typeof(TeleportWorld), "TargetFound")] internal static class PortalActivationPatch { private static void Postfix(ref bool __result) { if (ModConfig.PortalMode.Value != PortalPolicy.FullyFunctional) { __result = false; } } } [HarmonyPatch(typeof(TeleportWorld), "GetHoverText")] internal static class PortalHoverPatch { private static void Postfix(ref string __result) { if (ModConfig.PortalMode.Value != PortalPolicy.FullyFunctional) { __result = Localization.instance.Localize("$piece_portal\n$vfp_portals_disabled"); } } } [HarmonyPatch(typeof(PieceTable), "UpdateAvailable")] internal static class PortalBuildMenuPatch { private static void Postfix(PieceTable __instance) { if (ModConfig.PortalMode.Value != PortalPolicy.DisabledAndHidden) { return; } foreach (List availablePiece in __instance.m_availablePieces) { availablePiece.RemoveAll((Piece piece) => (Object)(object)piece != (Object)null && (Object)(object)((Component)piece).GetComponentInChildren(true) != (Object)null); } } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class TaxiDeathPatch { private static void Prefix(Player __instance) { ValkyrieTaxiController.PrepareLocalPlayerDeath(__instance); } } [HarmonyPatch(typeof(Player), "InCutscene")] internal static class TaxiCutscenePatch { private static void Postfix(Player __instance, ref bool __result) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && ValkyrieTaxiController.KeepHudVisible) { bool flag = __result; __result = false; if (!ValkyrieTaxiController.HasActiveTaxi && !flag) { ValkyrieTaxiController.EndHudOverride(); } } } } [HarmonyPatch(typeof(Player), "SetControls")] internal static class TaxiControlsPatch { private static void Prefix(Player __instance, ref Vector3 movedir, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && ValkyrieTaxiController.HasActiveTaxi) { movedir = Vector3.zero; jump = false; crouch = false; run = false; autoRun = false; dodge = false; } } } [HarmonyPatch(typeof(Character), "UpdateGroundContact")] internal static class TaxiFallDamagePatch { private static void Prefix(Character __instance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && ValkyrieTaxiController.KeepHudVisible) { __instance.m_maxAirAltitude = ((Component)__instance).transform.position.y; } } } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })] internal static class TaxiFreezingPatch { private static bool Prefix(SEMan __instance, int nameHash, ref StatusEffect __result) { if (nameHash == SEMan.s_statusEffectFreezing && (Object)(object)__instance.m_character == (Object)(object)Player.m_localPlayer && ValkyrieTaxiController.KeepHudVisible) { __result = null; return false; } return true; } } [HarmonyPatch(typeof(Valkyrie), "Awake")] internal static class ValkyrieAwakePatch { private static void Prefix(Valkyrie __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (ValkyrieTaxiSpawnContext.Active && !((Object)(object)Player.m_localPlayer == (Object)null)) { __instance.m_startDistance = 0f; __instance.m_startDescentDistance = 0f; __instance.m_startAltitude = ((Component)__instance).transform.position.y; __instance.m_descentAltitude = ((Component)__instance).transform.position.y; } } } }