Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RavenFlight v1.1.0
plugins/RavenFlight.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [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 RavenFlight { internal static class GameApi { private static ManualLogSource _log; private static Func<string, bool> _getButton; private static Func<string, bool> _getButtonDown; private static MethodInfo _getKey; private static MethodInfo _getKeyDown; private static object[] _keyArgs; private static object[] _keyDownArgs; private static PropertyInfo _locInstanceProp; private static FieldInfo _locInstanceField; private static MethodInfo _localize; private static readonly object[] OneArg = new object[1]; private static MethodInfo _takeInput; private static MethodInfo _attachStart; private static MethodInfo _getDoodad; private static FieldInfo _doodadField; public static bool InputReady => _getButton != null; public static void Init(ManualLogSource log) { _log = log; Type type = AccessTools.TypeByName("ZInput"); if (type != null) { _getButton = MakeStringBool(type, "GetButton"); _getButtonDown = MakeStringBool(type, "GetButtonDown"); _getKey = FindKeyMethod(type, "GetKey", out _keyArgs); _getKeyDown = FindKeyMethod(type, "GetKeyDown", out _keyDownArgs); } if (_getButton == null) { log.LogError((object)"ZInput.GetButton not found - flight keys will not work."); } Type type2 = AccessTools.TypeByName("Localization"); if (type2 != null) { _locInstanceProp = type2.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (_locInstanceProp == null) { _locInstanceField = type2.GetField("m_instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } _localize = type2.GetMethod("Localize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); } if (_localize == null) { log.LogWarning((object)"Localization.Localize not found - texts will show raw tokens."); } _takeInput = FindMethod(typeof(Player), "TakeInput", 0); _attachStart = FindMethod(typeof(Player), "AttachStart", -1); _getDoodad = FindMethod(typeof(Player), "GetDoodadController", 0); _doodadField = typeof(Player).GetField("m_doodadController", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (_attachStart == null) { log.LogError((object)"Player.AttachStart not found - mounting will not work."); } } private static MethodInfo FindMethod(Type type, string name, int paramCount) { Type type2 = type; while (type2 != null) { MethodInfo[] methods = type2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != name) && (paramCount < 0 || methodInfo.GetParameters().Length == paramCount)) { return methodInfo; } } type2 = type2.BaseType; } return null; } private static Func<string, bool> MakeStringBool(Type type, string name) { try { MethodInfo method = type.GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); if (method == null || method.ReturnType != typeof(bool)) { return null; } return (Func<string, bool>)Delegate.CreateDelegate(typeof(Func<string, bool>), method); } catch (Exception ex) { _log.LogWarning((object)("ZInput." + name + ": " + ex.Message)); return null; } } private static MethodInfo FindKeyMethod(Type type, string name, out object[] args) { args = null; MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name != name || methodInfo.ReturnType != typeof(bool)) { continue; } ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 0 || parameters[0].ParameterType != typeof(KeyCode)) { continue; } args = new object[parameters.Length]; for (int j = 1; j < parameters.Length; j++) { if (parameters[j].ParameterType == typeof(bool)) { args[j] = false; } else if (parameters[j].HasDefaultValue) { args[j] = parameters[j].DefaultValue; } else { args[j] = (parameters[j].ParameterType.IsValueType ? Activator.CreateInstance(parameters[j].ParameterType) : null); } } return methodInfo; } return null; } public static bool Button(string name) { if (_getButton != null) { return _getButton(name); } return false; } public static bool ButtonDown(string name) { if (_getButtonDown != null) { return _getButtonDown(name); } return false; } public static bool Key(KeyCode key) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return InvokeKey(_getKey, _keyArgs, key); } public static bool KeyDown(KeyCode key) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return InvokeKey(_getKeyDown, _keyDownArgs, key); } private static bool InvokeKey(MethodInfo method, object[] args, KeyCode key) { //IL_0009: 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) if (method == null || (int)key == 0) { return false; } try { args[0] = key; return (bool)method.Invoke(null, args); } catch { return false; } } public static string Loc(string text) { if (_localize == null || string.IsNullOrEmpty(text)) { return text; } try { object obj = ((_locInstanceProp != null) ? _locInstanceProp.GetValue(null, null) : ((_locInstanceField != null) ? _locInstanceField.GetValue(null) : null)); if (obj == null) { return text; } OneArg[0] = text; return (string)_localize.Invoke(obj, OneArg); } catch { return text; } } public static bool TakeInput(Player player) { if (_takeInput == null) { return true; } try { return (bool)_takeInput.Invoke(player, null); } catch { return true; } } public static bool AttachStart(Player player, Transform seat, GameObject colliderRoot, string animation, Vector3 detachOffset) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (_attachStart == null) { return false; } try { ParameterInfo[] parameters = _attachStart.GetParameters(); object[] array = new object[parameters.Length]; object[] array2 = new object[7] { seat, colliderRoot, true, false, false, animation, detachOffset }; for (int i = 0; i < parameters.Length; i++) { if (i < array2.Length && (array2[i] == null || parameters[i].ParameterType.IsInstanceOfType(array2[i]))) { array[i] = array2[i]; } else if (parameters[i].HasDefaultValue) { array[i] = parameters[i].DefaultValue; } else { array[i] = (parameters[i].ParameterType.IsValueType ? Activator.CreateInstance(parameters[i].ParameterType) : null); } } _attachStart.Invoke(player, array); return true; } catch (Exception ex) { _log.LogError((object)("AttachStart failed: " + (ex.InnerException ?? ex))); return false; } } public static object GetDoodadController(Player player) { try { if (_getDoodad != null) { return _getDoodad.Invoke(player, null); } if (_doodadField != null) { return _doodadField.GetValue(player); } } catch { } return null; } } internal static class Patches { private static readonly FieldInfo CamDistance = AccessTools.Field(typeof(GameCamera), "m_distance"); private static bool _cameraWasCarried; private static float _savedDistance = -1f; private static float _savedMaxDistance; private static readonly FieldInfo GridInventory = AccessTools.Field(typeof(InventoryGrid), "m_inventory"); private static readonly FieldInfo GridElements = AccessTools.Field(typeof(InventoryGrid), "m_elements"); private static FieldInfo _elPos; private static FieldInfo _elIcon; private static FieldInfo _elUsed; private static readonly Color Silhouette = new Color(0.75f, 0.72f, 0.66f, 0.28f); public static void Apply(Harmony harmony, ManualLogSource log) { Try(log, "Player.AttachStop", delegate { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(Player), "AttachStop"), new HarmonyMethod(typeof(Patches), "KeepCarried", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "Player.StopDoodadControl", delegate { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(Player), "StopDoodadControl"), new HarmonyMethod(typeof(Patches), "KeepCarried", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "Player.SetControls", delegate { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(Player), "SetControls"), new HarmonyMethod(typeof(Patches), "FilterControls", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "Player.InCutscene", delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(Player), "InCutscene"), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "NotACutscene", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "GameCamera.GetCameraBaseOffset", delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(GameCamera), "GetCameraBaseOffset"), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "RaiseCamera", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "GameCamera.UpdateCamera", delegate { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_004c: Expected O, but got Unknown harmony.Patch(Find(typeof(GameCamera), "UpdateCamera"), new HarmonyMethod(typeof(Patches), "BeforeCamera", (Type[])null), new HarmonyMethod(typeof(Patches), "AfterCamera", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "Game.Start", delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(Game), "Start"), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "AfterGameStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "Container.StackAll", delegate { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(Container), "StackAll"), new HarmonyMethod(typeof(Patches), "NoNetworkStack", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "InventoryGrid.UpdateGui", delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(InventoryGrid), "UpdateGui"), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "GearSlotSilhouettes", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try(log, "Piece.DropResources", delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown harmony.Patch(Find(typeof(Piece), "DropResources"), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "AfterDropResources", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); } private static void Try(ManualLogSource log, string what, Action patch) { try { patch(); } catch (Exception ex) { log.LogWarning((object)("Patch " + what + " not applied: " + ex.Message)); } } private static MethodBase Find(Type type, string name) { MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == name) { return methodInfo; } } throw new MissingMethodException(type.Name, name); } private static bool Carried(Player player) { if ((Object)(object)RavenMount.Local != (Object)null && (Object)(object)player != (Object)null) { return (Object)(object)player == (Object)(object)Player.m_localPlayer; } return false; } private static bool KeepCarried(Player __instance) { try { return KeepCarriedCore(__instance); } catch { return true; } } private static bool KeepCarriedCore(Player player) { if (!Carried(player) || RavenMount.AllowRelease) { return true; } if (((Character)player).IsDead()) { return true; } if (GameApi.ButtonDown("Use") || GameApi.ButtonDown("JoyUse")) { RavenMount.Local.RequestDismount(player); } return false; } private static void NotACutscene(Player __instance, ref bool __result) { try { if (__result && Carried(__instance) && !((Character)__instance).InIntro()) { __result = false; } } catch { } } private static void RaiseCamera(ref Vector3 __result) { //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_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_003c: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)RavenMount.Local == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { __result += Vector3.up * RavenFlightPlugin.CameraHeight.Value; } } catch { } } private static void BeforeCamera(GameCamera __instance) { try { bool flag = (Object)(object)RavenMount.Local != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null; if (flag && !_cameraWasCarried) { if (CamDistance != null) { _savedDistance = (float)CamDistance.GetValue(__instance); CamDistance.SetValue(__instance, RavenFlightPlugin.CameraDistance.Value); } } else if (!flag && _cameraWasCarried) { if (CamDistance != null && _savedDistance >= 0f) { CamDistance.SetValue(__instance, _savedDistance); } _savedDistance = -1f; } _cameraWasCarried = flag; _savedMaxDistance = __instance.m_maxDistance; if (flag) { __instance.m_maxDistance = Mathf.Max(__instance.m_maxDistance, RavenFlightPlugin.CameraMaxDistance.Value); } } catch { } } private static void AfterCamera(GameCamera __instance) { try { if (_savedMaxDistance > 0f) { __instance.m_maxDistance = _savedMaxDistance; } } catch { } } private static void FilterControls(Player __instance, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch) { bool flag; try { flag = Carried(__instance); } catch { return; } if (flag) { attack = false; attackHold = false; secondaryAttack = false; block = false; blockHold = false; jump = false; crouch = false; } } private static void AfterGameStart() { try { RavenNet.Register(); } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("Totem network setup: " + ex.Message)); } } private static bool NoNetworkStack(Container __instance) { return !(__instance is RavenEquip); } private static void GearSlotSilhouettes(InventoryGrid __instance) { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) try { object? obj = GridInventory?.GetValue(__instance); Inventory val = (Inventory)((obj is Inventory) ? obj : null); if (val == null || !RavenEquip.GearInventories.Contains(val) || !(GridElements?.GetValue(__instance) is IList list)) { return; } foreach (object item in list) { if (item == null) { continue; } if (_elPos == null) { Type type = item.GetType(); _elPos = AccessTools.Field(type, "m_pos"); _elIcon = AccessTools.Field(type, "m_icon"); _elUsed = AccessTools.Field(type, "m_used"); if (_elPos == null || _elIcon == null || _elUsed == null) { break; } } object? value = _elIcon.GetValue(item); Image val2 = (Image)((value is Image) ? value : null); if (val2 == null || (Object)(object)val2 == (Object)null) { continue; } if ((bool)_elUsed.GetValue(item)) { ((Graphic)val2).color = Color.white; continue; } Sprite val3 = RavenFlightPlugin.SlotHint(((Vector2i)_elPos.GetValue(item)).x); if (!((Object)(object)val3 == (Object)null)) { val2.sprite = val3; ((Graphic)val2).color = Silhouette; ((Behaviour)val2).enabled = true; } } } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("Gear slot hints: " + ex.Message)); _elPos = null; } } private static void AfterDropResources(Piece __instance) { try { if (!((Object)(object)__instance == (Object)null)) { RavenMount component = ((Component)__instance).GetComponent<RavenMount>(); if ((Object)(object)component != (Object)null) { component.DropExtras(); } } } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("DropExtras: " + ex.Message)); } } } public class RavenEquip : Container { public const string ZEquip = "rf_equip"; private static readonly FieldInfo FInventory = AccessTools.Field(typeof(Container), "m_inventory"); private static readonly FieldInfo FNview = AccessTools.Field(typeof(Container), "m_nview"); private ZNetView _view; private Inventory _inv; private bool _loading; private bool _fixing; private uint _lastRevision = uint.MaxValue; private float _nextPoll; internal static readonly HashSet<Inventory> GearInventories = new HashSet<Inventory>(); public bool Ready => _inv != null; public event Action Changed; private void Awake() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown _view = ((Component)this).GetComponentInParent<ZNetView>(); base.m_name = "$rf_equip"; base.m_width = 5; base.m_height = 1; _inv = new Inventory(base.m_name, base.m_bkg, base.m_width, base.m_height); _inv.m_onChanged = (Action)Delegate.Combine(_inv.m_onChanged, new Action(OnInventoryChanged)); GearInventories.Add(_inv); try { FInventory?.SetValue(this, _inv); FNview?.SetValue(this, _view); } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("Gear window setup: " + ex.Message)); } if ((Object)(object)_view == (Object)null || _view.GetZDO() == null) { ((Behaviour)this).enabled = false; } else { Load(force: true); } } private void OnDestroy() { if (_inv != null) { GearInventories.Remove(_inv); } } private void Update() { if (!((Object)(object)_view == (Object)null) && _view.IsValid() && !(Time.time < _nextPoll)) { _nextPoll = Time.time + 0.5f; if (!_view.IsOwner()) { Load(force: false); } } } private void Load(bool force) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown ZDO zDO = _view.GetZDO(); if (zDO == null || (!force && zDO.DataRevision == _lastRevision)) { return; } _lastRevision = zDO.DataRevision; byte[] byteArray = zDO.GetByteArray("rf_equip", (byte[])null); _loading = true; try { if (byteArray != null && byteArray.Length != 0) { _inv.Load(new ZPackage(byteArray)); } else if (_inv.NrOfItems() > 0) { _inv.RemoveAll(); } } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("Gear load: " + ex.Message)); } finally { _loading = false; } if (_view.IsOwner() && NeedsFix()) { FixSlots(); Save(); } this.Changed?.Invoke(); } private bool NeedsFix() { foreach (ItemData allItem in _inv.GetAllItems()) { UpgradeDef upgradeDef = Upgrades.Find(allItem); if (upgradeDef == null || upgradeDef.Slot != (UpgradeSlot)allItem.m_gridPos.x || allItem.m_gridPos.y != 0) { return true; } } return false; } private void Save() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown ZDO zDO = _view.GetZDO(); if (zDO != null) { ZPackage val = new ZPackage(); _inv.Save(val); zDO.Set("rf_equip", val.GetArray()); _lastRevision = zDO.DataRevision; } } private void OnInventoryChanged() { if (!_loading && !_fixing && !((Object)(object)_view == (Object)null) && _view.IsValid() && _view.IsOwner()) { FixSlots(); Save(); this.Changed?.Invoke(); } } private void FixSlots() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) _fixing = true; try { Player localPlayer = Player.m_localPlayer; foreach (ItemData item in new List<ItemData>(_inv.GetAllItems())) { UpgradeDef upgradeDef = Upgrades.Find(item); int x = item.m_gridPos.x; if (upgradeDef != null && upgradeDef.Slot == (UpgradeSlot)x && item.m_gridPos.y == 0 && item.m_stack == 1) { continue; } if (upgradeDef != null && item.m_stack == 1 && _inv.GetItemAt((int)upgradeDef.Slot, 0) == null) { item.m_gridPos = new Vector2i((int)upgradeDef.Slot, 0); continue; } _inv.RemoveItem(item); GiveBack(localPlayer, item); if ((Object)(object)localPlayer != (Object)null) { ((Character)localPlayer).Message((MessageType)2, "$rf_wrong_slot", 0, (Sprite)null, false); } } } finally { _fixing = false; } } private void GiveBack(Player player, ItemData item) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player != (Object)null) || !((Humanoid)player).GetInventory().AddItem(item)) { ItemDrop.DropItem(item, item.m_stack, ((Component)this).transform.position + Vector3.up * 0.5f, Quaternion.identity); } } internal UpgradeDef Get(UpgradeSlot slot) { if (_inv == null) { return null; } foreach (ItemData allItem in _inv.GetAllItems()) { UpgradeDef upgradeDef = Upgrades.Find(allItem); if (upgradeDef != null && upgradeDef.Slot == slot) { return upgradeDef; } } return null; } public void Open(Player player) { if (Ready && !((Object)(object)InventoryGui.instance == (Object)null)) { _view.ClaimOwnership(); Load(force: true); InventoryGui.instance.Show((Container)(object)this, 1); } } internal bool Fit(Player player, ItemData item, UpgradeDef def) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (!Ready || (Object)(object)player == (Object)null || item == null || def == null) { return false; } _view.ClaimOwnership(); Load(force: true); ItemData itemAt = _inv.GetItemAt((int)def.Slot, 0); _fixing = true; try { ItemData val = item.Clone(); val.m_stack = 1; if (!((Humanoid)player).GetInventory().RemoveItem(item, 1)) { return false; } if (itemAt != null) { _inv.RemoveItem(itemAt); GiveBack(player, itemAt); } _inv.AddItem(val, new Vector2i((int)def.Slot, 0)); } finally { _fixing = false; } Save(); this.Changed?.Invoke(); ((Character)player).Message((MessageType)2, (itemAt != null) ? "$rf_up_done ($rf_up_back)" : "$rf_up_done", 0, (Sprite)null, false); return true; } public bool Insert(string prefabName) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) UpgradeDef upgradeDef = Upgrades.FindByPrefab(prefabName); if (upgradeDef == null || !Ready || _inv.GetItemAt((int)upgradeDef.Slot, 0) != null) { return false; } GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(prefabName) : null); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null) { return false; } ItemData val3 = val2.m_itemData.Clone(); val3.m_stack = 1; val3.m_dropPrefab = val; _fixing = true; try { _inv.AddItem(val3, new Vector2i((int)upgradeDef.Slot, 0)); } finally { _fixing = false; } Save(); this.Changed?.Invoke(); return true; } public void DropAll(Vector3 at) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (!Ready) { return; } _fixing = true; try { foreach (ItemData item in new List<ItemData>(_inv.GetAllItems())) { ItemDrop.DropItem(item, item.m_stack, at + Random.insideUnitSphere * 0.4f, Quaternion.identity); } _inv.RemoveAll(); } finally { _fixing = false; } Save(); } } [BepInPlugin("blackflag.RavenFlight", "RavenFlight", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class RavenFlightPlugin : BaseUnityPlugin { public const string ModGuid = "blackflag.RavenFlight"; public const string ModName = "RavenFlight"; public const string ModVersion = "1.1.0"; public const string RavenPrefabName = "RF_Raven"; public const string SeatPilotName = "RF_SeatPilot"; public const string SeatPassengerName = "RF_SeatPassenger"; public const string BagName = "RF_Bag"; public const string LanternName = "RF_Lantern"; public const string EquipName = "RF_Equip"; internal static RavenFlightPlugin Instance; internal static ManualLogSource Log; internal static ConfigEntry<float> CruiseSpeed; internal static ConfigEntry<float> BoostMultiplier; internal static ConfigEntry<float> ClimbSpeed; internal static ConfigEntry<float> StrafeSpeed; internal static ConfigEntry<float> TurnRate; internal static ConfigEntry<float> Acceleration; internal static ConfigEntry<float> MaxAltitude; internal static ConfigEntry<bool> MouseSteering; internal static ConfigEntry<bool> PitchWithCamera; internal static ConfigEntry<float> Banking; internal static ConfigEntry<float> MaxStamina; internal static ConfigEntry<float> BoostDrain; internal static ConfigEntry<float> StaminaRegen; internal static ConfigEntry<float> HarnessBonusScale; internal static ConfigEntry<float> PlumageBonusScale; internal static ConfigEntry<float> WindDrift; internal static ConfigEntry<float> CallMaxDistance; internal static ConfigEntry<bool> ShowMapPins; internal static ConfigEntry<float> ModelScale; internal static ConfigEntry<string> AttachAnimation; internal static ConfigEntry<float> SeatForward; internal static ConfigEntry<float> SeatUp; internal static ConfigEntry<float> SeatSpacing; internal static ConfigEntry<float> SafeDismountHeight; internal static ConfigEntry<KeyCode> BagKey; internal static ConfigEntry<KeyCode> EquipKey; internal static ConfigEntry<KeyCode> CallKey; internal static ConfigEntry<float> CameraDistance; internal static ConfigEntry<float> CameraMaxDistance; internal static ConfigEntry<float> CameraHeight; internal static ConfigEntry<bool> ShowHud; internal static ConfigEntry<bool> ShowHints; private static readonly Dictionary<RiderResist, int> ResistHashes = new Dictionary<RiderResist, int>(); private static Sprite[] _slotHints; private static Sprite _pinIcon; private static readonly string[] SlotHintFiles = new string[5] { "harness.png", "plumage.png", "bags.png", "lantern.png", "totem.png" }; internal static Sprite PinIcon { get { if ((Object)(object)_pinIcon == (Object)null) { _pinIcon = LoadIcon("pin_raven.png"); } return _pinIcon; } } private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; BindConfig(); GameApi.Init(((BaseUnityPlugin)this).Logger); Patches.Apply(new Harmony("blackflag.RavenFlight"), ((BaseUnityPlugin)this).Logger); ((Component)this).gameObject.AddComponent<RavenHud>(); ((Component)this).gameObject.AddComponent<RavenControls>(); PrefabManager.OnVanillaPrefabsAvailable += RegisterContent; } private void BindConfig() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Expected O, but got Unknown //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Expected O, but got Unknown //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Expected O, but got Unknown //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Expected O, but got Unknown //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Expected O, but got Unknown //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Expected O, but got Unknown //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Expected O, but got Unknown //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Expected O, but got Unknown //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Expected O, but got Unknown CruiseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "CruiseSpeed", 13f, new ConfigDescription("Forward flight speed, m/s.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 60f), Array.Empty<object>())); BoostMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "BoostMultiplier", 1.8f, new ConfigDescription("Speed multiplier while sprinting (Run key).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f), Array.Empty<object>())); ClimbSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "ClimbSpeed", 8f, new ConfigDescription("Vertical speed for Jump / Crouch keys, m/s.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); StrafeSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "StrafeSpeed", 4f, new ConfigDescription("Sideways speed (A/D) when MouseSteering is on, m/s.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); TurnRate = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "TurnRate", 110f, new ConfigDescription("How fast the raven turns, degrees per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 360f), Array.Empty<object>())); Acceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "Acceleration", 9f, new ConfigDescription("How quickly the raven reaches the target speed, m/s^2.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); MaxAltitude = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "MaxAltitude", 400f, new ConfigDescription("Flight ceiling (world height, sea level is 30).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(60f, 2000f), Array.Empty<object>())); MouseSteering = ((BaseUnityPlugin)this).Config.Bind<bool>("Flight", "MouseSteering", true, "On: the raven flies where the camera looks while you hold Forward, A/D slide sideways. Off: A/D turn the raven, the camera is free."); PitchWithCamera = ((BaseUnityPlugin)this).Config.Bind<bool>("Flight", "PitchWithCamera", true, "With MouseSteering: looking clearly up or down while flying forward also climbs or dives."); Banking = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "Banking", 1f, new ConfigDescription("How strongly the raven leans into turns and climbs (0 = stays level).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); MaxStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "MaxStamina", 100f, new ConfigDescription("Raven stamina used by sprinting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 1000f), Array.Empty<object>())); BoostDrain = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "BoostDrain", 12f, new ConfigDescription("Stamina used per second of sprinting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); StaminaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Regen", 8f, new ConfigDescription("Stamina restored per second when not sprinting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); HarnessBonusScale = ((BaseUnityPlugin)this).Config.Bind<float>("Upgrades", "HarnessBonusScale", 1f, new ConfigDescription("Multiplies every harness speed bonus (1 = +20/40/60/80%, 0.5 = half of that).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); PlumageBonusScale = ((BaseUnityPlugin)this).Config.Bind<float>("Upgrades", "PlumageBonusScale", 1f, new ConfigDescription("Multiplies every plumage stamina bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); WindDrift = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "WindDrift", 3f, new ConfigDescription("How strongly the wind pushes a flying raven high up, m/s at full wind. The silver harness cancels it. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 15f), Array.Empty<object>())); CallMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Totem", "CallMaxDistance", 0f, new ConfigDescription("Hugin's totem: how far away a raven still hears the whistle, metres. 0 = anywhere in the world. Server setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20000f), Array.Empty<object>())); ShowMapPins = ((BaseUnityPlugin)this).Config.Bind<bool>("Totem", "ShowMapPins", true, "Hugin's totem: show your ravens on the map."); ModelScale = ((BaseUnityPlugin)this).Config.Bind<float>("Raven", "ModelScale", 1f, new ConfigDescription("Size multiplier of the raven model. Needs a game restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 3f), Array.Empty<object>())); AttachAnimation = ((BaseUnityPlugin)this).Config.Bind<string>("Raven", "AttachAnimation", "intro", "Player animation while carried. 'intro' is the pose from the arrival flight; 'attach_chair' is sitting."); SeatForward = ((BaseUnityPlugin)this).Config.Bind<float>("Raven", "SeatForward", 0f, "Moves the carried players forward (+) or back (-) relative to the claws, metres."); SeatUp = ((BaseUnityPlugin)this).Config.Bind<float>("Raven", "SeatUp", 0f, "Moves the carried players up (+) or down (-) relative to the claws, metres."); SeatSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("Raven", "SeatSpacing", 0.55f, new ConfigDescription("Sideways distance of each player from the centre when two are carried, metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); SafeDismountHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Raven", "SafeDismountHeight", 4f, new ConfigDescription("Above this height letting go needs a second key press.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); BagKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "BagKey", (KeyCode)98, "Opens the raven pack while you are carried."); EquipKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "GearKey", (KeyCode)103, "Opens the raven gear window (look at the raven, or while carried)."); CallKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "WhistleKey", (KeyCode)104, "Hugin's totem: whistle for your raven."); CameraDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Distance", 11f, new ConfigDescription("Camera distance when you grab on to the raven, metres. Mouse wheel still zooms in flight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), Array.Empty<object>())); CameraMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "MaxDistance", 30f, new ConfigDescription("How far the mouse wheel may zoom out while flying, metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 60f), Array.Empty<object>())); CameraHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Height", 3f, new ConfigDescription("Raises the camera above the carried player so the raven does not block the view, metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); ShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "ShowHud", true, "Show speed, height and raven stamina while flying."); ShowHints = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "ShowHints", true, "Show the control hints for a few seconds after take-off."); } private void RegisterContent() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterContent; try { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, Upgrades.English); text = "Russian"; localization.AddTranslation(ref text, Upgrades.Russian); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Localization failed: " + ex)); } try { RegisterUpgradeItems(); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Upgrade items failed: " + ex2)); } try { RegisterRiderEffects(); } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("Rider effects failed: " + ex3)); } try { RegisterRaven(); } catch (Exception ex4) { ((BaseUnityPlugin)this).Logger.LogError((object)("Raven prefab failed: " + ex4)); } } private void RegisterUpgradeItems() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0053: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown UpgradeDef[] all = Upgrades.All; foreach (UpgradeDef upgradeDef in all) { ItemConfig val = new ItemConfig { Name = "$" + upgradeDef.Token, Description = "$" + upgradeDef.Token + "_desc", CraftingStation = upgradeDef.Station, MinStationLevel = upgradeDef.StationLevel, Amount = 1, Weight = 2f, Requirements = upgradeDef.Cost }; val.StackSize = 1; Sprite val2 = LoadIcon(upgradeDef.IconFile); if ((Object)(object)val2 != (Object)null) { val.Icons = (Sprite[])(object)new Sprite[1] { val2 }; } CustomItem val3 = new CustomItem(upgradeDef.Prefab, upgradeDef.BasePrefab, val); if ((Object)(object)val3.ItemPrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not create item " + upgradeDef.Prefab + " from " + upgradeDef.BasePrefab)); } else { ItemManager.Instance.AddItem(val3); } } } private void RegisterRaven() { //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Expected O, but got Unknown //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Expected O, but got Unknown //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Expected O, but got Unknown //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Expected O, but got Unknown GameObject val = Cache.GetPrefab<GameObject>("Valkyrie"); if ((Object)(object)val == (Object)null) { val = FindValkyrieOnPlayer(); } if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Vanilla prefab 'Valkyrie' not found - the raven can not be created."); return; } GameObject val2 = PrefabManager.Instance.CreateClonedPrefab("RF_Raven", val); if ((Object)(object)val2 == (Object)null) { return; } Transform val3 = null; Vector3 seatBaseOffset = default(Vector3); ((Vector3)(ref seatBaseOffset))..ctor(0f, 0f, -1f); Component component = val2.GetComponent("Valkyrie"); if ((Object)(object)component != (Object)null) { Type type = ((object)component).GetType(); FieldInfo fieldInfo = AccessTools.Field(type, "m_attachPoint"); FieldInfo fieldInfo2 = AccessTools.Field(type, "m_attachOffset"); if (fieldInfo != null) { object? value = fieldInfo.GetValue(component); val3 = (Transform)((value is Transform) ? value : null); } if (fieldInfo2 != null && fieldInfo2.GetValue(component) is Vector3 val4) { seatBaseOffset = -val4; } } MonoBehaviour[] components = val2.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val5 in components) { if (!((Object)(object)val5 == (Object)null) && !(val5 is ZNetView) && !(val5 is ZSyncTransform)) { Object.DestroyImmediate((Object)(object)val5); } } if ((Object)(object)val3 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Valkyrie attach point not found, using the model root. Tune [Raven] SeatUp / SeatForward."); val3 = val2.transform; ((Vector3)(ref seatBaseOffset))..ctor(0f, -2.5f, 0f); } float num = Mathf.Clamp(ModelScale.Value, 0.3f, 3f); val2.transform.localScale = val2.transform.localScale * num; ZNetView val6 = val2.GetComponent<ZNetView>(); if ((Object)(object)val6 == (Object)null) { val6 = val2.AddComponent<ZNetView>(); } val6.m_persistent = true; Rigidbody val7 = val2.GetComponent<Rigidbody>(); if ((Object)(object)val7 == (Object)null) { val7 = val2.AddComponent<Rigidbody>(); } val7.isKinematic = true; val7.useGravity = false; val7.interpolation = (RigidbodyInterpolation)1; ZSyncTransform val8 = val2.GetComponent<ZSyncTransform>(); if ((Object)(object)val8 == (Object)null) { val8 = val2.AddComponent<ZSyncTransform>(); } val8.m_syncPosition = true; val8.m_syncRotation = true; NewChild(val3, "RF_SeatPilot"); NewChild(val3, "RF_SeatPassenger"); GameObject val9 = NewChild(val3, "RF_Bag"); Light obj = NewChild(val3, "RF_Lantern").AddComponent<Light>(); obj.color = new Color(1f, 0.74f, 0.42f); obj.range = 32f; obj.intensity = 1.7f; ((Behaviour)obj).enabled = false; RavenMount.SeatBaseOffset = seatBaseOffset; val2.AddComponent<RavenMount>(); FieldInfo fieldInfo3 = AccessTools.Field(typeof(Container), "m_rootObjectOverride"); Container val10 = ((fieldInfo3 != null) ? val9 : val2).AddComponent<Container>(); val10.m_name = "$rf_bag"; val10.m_width = 3; val10.m_height = 2; if (fieldInfo3 != null) { Type fieldType = fieldInfo3.FieldType; if (fieldType.IsInstanceOfType(val6)) { fieldInfo3.SetValue(val10, val6); } else if (fieldType.IsInstanceOfType(val2)) { fieldInfo3.SetValue(val10, val2); } else if (fieldType.IsInstanceOfType(val2.transform)) { fieldInfo3.SetValue(val10, val2.transform); } } RavenEquip ravenEquip = NewChild(val3, "RF_Equip").AddComponent<RavenEquip>(); ((Container)ravenEquip).m_name = "$rf_equip"; ((Container)ravenEquip).m_width = 5; ((Container)ravenEquip).m_height = 1; val2.AddComponent<Piece>(); PieceConfig val11 = new PieceConfig(); val11.Name = "$rf_raven"; val11.Description = "$rf_raven_desc"; val11.PieceTable = "Hammer"; val11.Category = "Misc"; val11.Icon = LoadIcon("raven.png"); val11.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 15, 0, true), new RequirementConfig("Resin", 6, 0, true), new RequirementConfig("LeatherScraps", 4, 0, true) }; PieceConfig val12 = val11; try { val12.Usage = new string[2] { "Transport", "Misc" }; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Build menu tags not set: " + ex.Message)); } PieceManager.Instance.AddPiece(new CustomPiece(val2, false, val12)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"RavenFlight 1.1.0: 'RF_Raven' registered (hammer -> Misc / Transport)."); } private void RegisterRiderEffects() { AddRiderEffect(RiderResist.Poison, "RF_SE_Poison", "rf_se_poison", "plumage_swamp.png", (DamageType)256); AddRiderEffect(RiderResist.Frost, "RF_SE_Frost", "rf_se_frost", "plumage_frost.png", (DamageType)64); AddRiderEffect(RiderResist.Fire, "RF_SE_Fire", "rf_se_fire", "plumage_ash.png", (DamageType)32); } private void AddRiderEffect(RiderResist kind, string name, string token, string icon, DamageType type) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = name; ((StatusEffect)val).m_name = "$" + token; ((StatusEffect)val).m_tooltip = "$" + token + "_tip"; ((StatusEffect)val).m_icon = LoadIcon(icon); ((StatusEffect)val).m_ttl = 3f; val.m_mods = new List<DamageModPair> { new DamageModPair { m_type = type, m_modifier = (DamageModifier)1 } }; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); ResistHashes[kind] = StringExtensionMethods.GetStableHashCode(name); } internal static void ApplyRiderResist(Player player, RiderResist kind) { try { if (!((Object)(object)player == (Object)null) && ResistHashes.TryGetValue(kind, out var value)) { ((Character)player).GetSEMan().AddStatusEffect(value, true, 0, 0f, (short)(-1)); } } catch (Exception ex) { Log.LogWarning((object)("Rider protection: " + ex.Message)); } } internal static Sprite SlotHint(int column) { if (_slotHints == null) { _slotHints = (Sprite[])(object)new Sprite[SlotHintFiles.Length]; for (int i = 0; i < SlotHintFiles.Length; i++) { _slotHints[i] = LoadIcon(SlotHintFiles[i]); } } if (column < 0 || column >= _slotHints.Length) { return null; } return _slotHints[column]; } private static GameObject FindValkyrieOnPlayer() { try { GameObject prefab = Cache.GetPrefab<GameObject>("Player"); Player val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Player>() : null); FieldInfo fieldInfo = AccessTools.Field(typeof(Player), "m_valkyrie"); return (GameObject)(((Object)(object)val != (Object)null && fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null); } catch { return null; } } private static GameObject NewChild(Transform parent, string name) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.layer = ((Component)parent).gameObject.layer; return val; } internal static Sprite LoadIcon(string file) { //IL_00c1: 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) try { if (GUIManager.IsHeadless()) { return null; } using Stream stream = typeof(RavenFlightPlugin).Assembly.GetManifestResourceStream("RavenFlight.icons." + file); if (stream == null) { Log.LogWarning((object)("Icon missing: " + file)); return null; } 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) { return null; } ((Object)val).name = "rf_" + file; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } catch (Exception ex) { Log.LogWarning((object)("Icon " + file + ": " + ex.Message)); return null; } } } public class RavenHud : MonoBehaviour { private GUIStyle _label; private GUIStyle _small; private int _styleHeight; private void Awake() { ((MonoBehaviour)this).useGUILayout = false; } private void OnGUI() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0227: 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_00ca: 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_00f0: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) RavenMount local = RavenMount.Local; if ((Object)(object)local == (Object)null || !RavenFlightPlugin.ShowHud.Value || (int)Event.current.type != 7) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !GameApi.TakeInput(localPlayer)) { return; } EnsureStyles(); float num = (float)Screen.height / 1080f; float num2 = 320f * num; float num3 = ((float)Screen.width - num2) * 0.5f; float num4 = (float)Screen.height - 210f * num; if (local.LocalSeat == RavenMount.Seat.Pilot) { float num5 = 9f * num; DrawRect(new Rect(num3 - 2f, num4 - 2f, num2 + 4f, num5 + 4f), new Color(0f, 0f, 0f, 0.55f)); Color color = (local.HudBoosting ? new Color(1f, 0.82f, 0.35f, 0.95f) : new Color(0.55f, 0.78f, 1f, 0.9f)); if (local.HudStamina01 < 0.25f) { ((Color)(ref color))..ctor(0.95f, 0.4f, 0.3f, 0.95f); } DrawRect(new Rect(num3, num4, num2 * local.HudStamina01, num5), color); string text = GameApi.Loc("$rf_hud_speed") + " " + local.HudSpeed.ToString("0") + " " + GameApi.Loc("$rf_hud_alt") + " " + Mathf.Max(0f, local.HudHeight).ToString("0"); Shadowed(new Rect(num3 - 100f * num, num4 - 30f * num, num2 + 200f * num, 26f * num), text, _label); } else { Shadowed(new Rect(num3 - 100f * num, num4 - 30f * num, num2 + 200f * num, 26f * num), GameApi.Loc("$rf_hud_passenger"), _label); } if (RavenFlightPlugin.ShowHints.Value && local.SeatedFor < 14f) { string text2 = ((object)RavenFlightPlugin.BagKey.Value/*cast due to .constrained prefix*/).ToString() + " - " + GameApi.Loc("$rf_hint_bag") + " " + ((object)RavenFlightPlugin.EquipKey.Value/*cast due to .constrained prefix*/).ToString() + " - " + GameApi.Loc("$rf_hint_equip"); string text3 = ((local.LocalSeat == RavenMount.Seat.Pilot) ? (GameApi.Loc("$rf_hint_move") + "\n" + GameApi.Loc("$rf_hint_vert") + "\n" + GameApi.Loc("$rf_hint_misc") + " " + text2) : (GameApi.Loc("$rf_hint_misc") + " " + text2)); Shadowed(new Rect(num3 - 300f * num, num4 - 110f * num, num2 + 600f * num, 76f * num), text3, _small); } } private void EnsureStyles() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown if (_label == null || _styleHeight != Screen.height) { _styleHeight = Screen.height; float num = (float)Screen.height / 1080f; _label = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = Mathf.RoundToInt(17f * num), fontStyle = (FontStyle)1 }; _small = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)7, fontSize = Mathf.RoundToInt(14f * num) }; } } private static void DrawRect(Rect rect, Color color) { //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_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = color2; } private static void Shadowed(Rect rect, string text, GUIStyle style) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0075: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.8f); GUI.Label(new Rect(((Rect)(ref rect)).x + 1.5f, ((Rect)(ref rect)).y + 1.5f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style); GUI.color = new Color(1f, 0.96f, 0.86f, 1f); GUI.Label(rect, text, style); GUI.color = color; } } public class RavenMount : MonoBehaviour, IDoodadController { public enum Seat { None, Pilot, Passenger } private sealed class PassengerControl : IDoodadController { private readonly RavenMount _mount; public PassengerControl(RavenMount mount) { _mount = mount; } public void OnUseStop(Player player) { } public void ApplyControlls(Vector3 moveDir, Vector3 lookDir, bool run, bool autoRun, bool block) { } public Component GetControlledComponent() { return (Component)(object)_mount; } public Vector3 GetPosition() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _mount.GetPosition(); } public bool IsValid() { return (Object)(object)_mount != (Object)null; } } public const int BagBaseWidth = 3; public const int BagBaseHeight = 2; public const int BagBigWidth = 4; public const int BagBigHeight = 3; public const float WaterLevel = 30f; private const string ZPilot = "rf_pilot"; private const string ZPassenger = "rf_pass"; private const string ZLegacyUpgrades = "rf_up"; public const string RpcSummon = "RF_Summon"; private const string RpcPassenger = "RF_Passenger"; internal static Vector3 SeatBaseOffset = new Vector3(0f, 0f, -1f); public static RavenMount Local; public static bool AllowRelease; private static readonly FieldInfo InvWidth = AccessTools.Field(typeof(Inventory), "m_width"); private static readonly FieldInfo InvHeight = AccessTools.Field(typeof(Inventory), "m_height"); private ZNetView _nview; private Rigidbody _body; private Container _bag; private RavenEquip _equip; private UpgradeDef _harness; private UpgradeDef _plumage; private UpgradeDef _bags; private UpgradeDef _lanternGear; private UpgradeDef _totem; private float _nextResist; private long _summonPlayer; private float _summonUntil; private Light _lantern; private readonly List<Behaviour> _sounds = new List<Behaviour>(); private int _soundState = -1; private Transform _pilotSeat; private Transform _passengerSeat; private Transform _seatParent; private PassengerControl _passengerControl; private GameObject _colliders; private int _lastDismountFrame = -1; private int _solidMask; private int _terrainMask; private bool _ready; private long _pilotId; private long _passengerId; private float _nextPoll; private float _sideBlend; private Seat _seat; private float _seatTime; private float _nextVerify; private int _passengerRetries; private float _warnTime = -100f; private int _lastInteractFrame = -1; private Vector3 _inMove; private Vector3 _inLook = Vector3.forward; private bool _inRun; private float _inVertical; private float _inputTime; private float _yaw; private float _forwardSpeed; private float _sideSpeed; private float _verticalSpeed; private float _roll; private float _pitch; private float _stamina; private bool _exhausted; private float _foreignPilotTime; private float _nextHousekeeping; public float HudSpeed { get; private set; } public float HudHeight { get; private set; } public float HudStamina01 { get; private set; } public bool HudBoosting { get; private set; } public Seat LocalSeat => _seat; public float SeatedFor => Time.time - _seatTime; public bool HasPassenger => _passengerId != 0; private float SpeedFactor => 1f + ((_harness != null) ? (_harness.SpeedBonus * RavenFlightPlugin.HarnessBonusScale.Value) : 0f); private float StaminaFactor => 1f + ((_plumage != null) ? (_plumage.StaminaBonus * RavenFlightPlugin.PlumageBonusScale.Value) : 0f); private float MaxStamina => RavenFlightPlugin.MaxStamina.Value * StaminaFactor; private void Awake() { //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) _nview = ((Component)this).GetComponent<ZNetView>(); _body = ((Component)this).GetComponent<Rigidbody>(); Container[] componentsInChildren = ((Component)this).GetComponentsInChildren<Container>(true); foreach (Container val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { if (val is RavenEquip equip) { _equip = equip; } else if ((Object)(object)_bag == (Object)null) { _bag = val; } } } _pilotSeat = FindDeep(((Component)this).transform, "RF_SeatPilot"); _passengerSeat = FindDeep(((Component)this).transform, "RF_SeatPassenger"); Transform val2 = FindDeep(((Component)this).transform, "RF_Lantern"); if ((Object)(object)val2 != (Object)null) { _lantern = ((Component)val2).GetComponent<Light>(); } Behaviour[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Behaviour>(true); foreach (Behaviour val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null)) { string name = ((object)val3).GetType().Name; if (name == "AudioSource" || name == "ZSFX") { _sounds.Add(val3); } } } if ((Object)(object)_nview == (Object)null || _nview.GetZDO() == null || (Object)(object)_pilotSeat == (Object)null || (Object)(object)_passengerSeat == (Object)null) { ((Behaviour)this).enabled = false; return; } _seatParent = _pilotSeat.parent; _solidMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" }); _terrainMask = LayerMask.GetMask(new string[1] { "terrain" }); _stamina = MaxStamina; _yaw = ((Component)this).transform.eulerAngles.y; _passengerControl = new PassengerControl(this); _nview.Register<long, bool>("RF_Passenger", (Action<long, long, bool>)RPC_Passenger); _nview.Register<Vector3, long>("RF_Summon", (Action<long, Vector3, long>)RPC_Summon); PlaceSeats(0f); Transform val4 = FindDeep(((Component)this).transform, "RF_Bag"); if ((Object)(object)val4 != (Object)null) { val4.localPosition = _pilotSeat.localPosition; } if ((Object)(object)val2 != (Object)null) { val2.localPosition = _pilotSeat.localPosition + ToSeatLocal(new Vector3(0f, 1.2f, 1.4f)); } if ((Object)(object)_equip != (Object)null) { Transform transform = ((Component)_equip).transform; if ((Object)(object)transform != (Object)(object)((Component)this).transform) { transform.localPosition = _pilotSeat.localPosition; } _equip.Changed += OnEquipChanged; } OnEquipChanged(); ReadState(force: true); _ready = true; } private void Start() { if (_ready) { BuildColliders(); MigrateLegacyUpgrades(); } } private void MigrateLegacyUpgrades() { try { if ((Object)(object)_equip == (Object)null || !_nview.IsOwner()) { return; } ZDO zDO = _nview.GetZDO(); int num = zDO.GetInt("rf_up", 0); if (num == 0) { return; } KeyValuePair<int, string>[] legacyBits = Upgrades.LegacyBits; for (int i = 0; i < legacyBits.Length; i++) { KeyValuePair<int, string> keyValuePair = legacyBits[i]; if ((num & keyValuePair.Key) != 0) { _equip.Insert(keyValuePair.Value); } } zDO.Set("rf_up", 0); RavenFlightPlugin.Log.LogInfo((object)"Moved 1.0 upgrades of a raven into its gear window."); } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("Upgrade migration: " + ex.Message)); } } private void OnDestroy() { if ((Object)(object)Local == (Object)(object)this) { Leave(notifyNetwork: false); } } private static Transform FindDeep(Transform root, string name) { if (((Object)root).name == name) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindDeep(root.GetChild(i), name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private Vector3 ToSeatLocal(Vector3 metres) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0043: 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_005f: 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) Vector3 val = (((Object)(object)_seatParent != (Object)null) ? _seatParent.lossyScale : Vector3.one); return new Vector3(metres.x / Mathf.Max(Mathf.Abs(val.x), 0.001f), metres.y / Mathf.Max(Mathf.Abs(val.y), 0.001f), metres.z / Mathf.Max(Mathf.Abs(val.z), 0.001f)); } private void PlaceSeats(float sideBlend) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = SeatBaseOffset + new Vector3(0f, RavenFlightPlugin.SeatUp.Value, RavenFlightPlugin.SeatForward.Value); float value = RavenFlightPlugin.SeatSpacing.Value; _pilotSeat.localPosition = ToSeatLocal(val + new Vector3((0f - value) * sideBlend, 0f, 0f)); _passengerSeat.localPosition = ToSeatLocal(val + new Vector3(value, 0f, 0f)); } private void BuildColliders() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_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_009b: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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) int num = LayerMask.NameToLayer("vehicle"); if (num < 0) { num = LayerMask.NameToLayer("piece"); } if (num < 0) { num = 0; } GameObject val = (_colliders = new GameObject("RF_Colliders")); val.layer = num; val.transform.SetParent(((Component)this).transform, false); val.AddComponent<RavenPart>(); float num2 = Mathf.Max(Mathf.Abs(((Component)this).transform.lossyScale.x), 0.001f); Vector3 val2 = SeatCentreWorld(); SphereCollider obj = val.AddComponent<SphereCollider>(); obj.center = val.transform.InverseTransformPoint(val2 + Vector3.up * 0.9f); obj.radius = 1.05f / num2; Vector3 val3 = val2 + Vector3.up * 2.6f; float num3 = 1.2f; bool flag = false; Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(((Component)this).transform.position, Vector3.zero); SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val4 in componentsInChildren) { if (!flag) { bounds = ((Renderer)val4).bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(((Renderer)val4).bounds); } } if (flag && ((Bounds)(ref bounds)).extents.y > 0.3f && ((Bounds)(ref bounds)).extents.y < 40f) { Vector3 center = ((Bounds)(ref bounds)).center; Vector3 val5 = center - val2; if (((Vector3)(ref val5)).magnitude < 12f) { val3 = center; num3 = Mathf.Clamp(Mathf.Min(((Bounds)(ref bounds)).extents.y, ((Bounds)(ref bounds)).extents.z) * 0.8f, 0.8f, 2f); } } SphereCollider obj2 = val.AddComponent<SphereCollider>(); obj2.center = val.transform.InverseTransformPoint(val3); obj2.radius = num3 / num2; } private Vector3 SeatCentreWorld() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Vector3 metres = SeatBaseOffset + new Vector3(0f, RavenFlightPlugin.SeatUp.Value, RavenFlightPlugin.SeatForward.Value); return _seatParent.TransformPoint(ToSeatLocal(metres)); } private void OnEquipChanged() { if ((Object)(object)_equip != (Object)null && _equip.Ready) { _harness = _equip.Get(UpgradeSlot.Harness); _plumage = _equip.Get(UpgradeSlot.Plumage); _bags = _equip.Get(UpgradeSlot.Bags); _lanternGear = _equip.Get(UpgradeSlot.Lantern); _totem = _equip.Get(UpgradeSlot.Totem); } else { _harness = (_plumage = (_bags = (_lanternGear = (_totem = null)))); } ApplyBagSize(); _stamina = Mathf.Min(_stamina, MaxStamina); if ((Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner()) { return; } ZDO zDO = _nview.GetZDO(); long num = zDO.GetLong("rf_totem_owner", 0L); bool flag = _totem != null && _totem.Totem; if (flag && num == 0L) { long num2 = LocalPlayerId(); if (num2 != 0L) { zDO.Set("rf_totem_owner", num2); } } else if (!flag && num != 0L) { zDO.Set("rf_totem_owner", 0L); } } private void ReadState(bool force) { ZDO zDO = _nview.GetZDO(); if (zDO == null) { return; } _pilotId = zDO.GetLong("rf_pilot", 0L); _passengerId = zDO.GetLong("rf_pass", 0L); if (force) { ApplyBagSize(); } bool flag = _pilotId != 0L || _passengerId != 0; if ((Object)(object)_lantern != (Object)null) { ((Behaviour)_lantern).enabled = _lanternGear != null && _lanternGear.Light && flag; } int num = (flag ? 1 : 0); if (num == _soundState) { return; } _soundState = num; for (int i = 0; i < _sounds.Count; i++) { if ((Object)(object)_sounds[i] != (Object)null) { _sounds[i].enabled = flag; } } } private void ApplyBagSize() { //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_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) if ((Object)(object)_bag == (Object)null) { return; } int num = ((_bags != null) ? _bags.BagWidth : 3); int num2 = ((_bags != null) ? _bags.BagHeight : 2); _bag.m_width = num; _bag.m_height = num2; try { Inventory inventory = _bag.GetInventory(); if (inventory == null || InvWidth == null || InvHeight == null || (inventory.GetWidth() == num && inventory.GetHeight() == num2)) { return; } InvWidth.SetValue(inventory, num); InvHeight.SetValue(inventory, num2); if (!_nview.IsValid() || !_nview.IsOwner()) { return; } bool flag = false; foreach (ItemData item in new List<ItemData>(inventory.GetAllItems())) { if (item.m_gridPos.x >= num || item.m_gridPos.y >= num2) { inventory.RemoveItem(item); if (!inventory.AddItem(item)) { ItemDrop.DropItem(item, item.m_stack, SeatCentreWorld() + Vector3.up * 0.5f, Quaternion.identity); flag = true; } } } if (flag && (Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, "$rf_pack_spill", 0, (Sprite)null, false); } } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("Pack resize failed: " + ex.Message)); } } private void RPC_Passenger(long sender, long playerId, bool enter) { if (!_nview.IsValid() || !_nview.IsOwner()) { return; } ZDO zDO = _nview.GetZDO(); long num = zDO.GetLong("rf_pass", 0L); if (enter) { if (num == 0L || num == playerId) { zDO.Set("rf_pass", playerId); } } else if (num == playerId) { zDO.Set("rf_pass", 0L); } ReadState(force: false); } public string HoverText() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!_ready) { return string.Empty; } string text = "[<color=yellow><b>" + ((object)RavenFlightPlugin.EquipKey.Value/*cast due to .constrained prefix*/).ToString() + "</b></color>] "; string text2 = "$rf_raven"; if ((Object)(object)Local == (Object)(object)this) { text2 += "\n[<color=yellow><b>$KEY_Use</b></color>] $rf_dismount"; } else { long num = LocalPlayerId(); bool num2 = _pilotId == 0L || _pilotId == num; bool flag = _passengerId == 0L || _passengerId == num; text2 = (num2 ? (text2 + "\n[<color=yellow><b>$KEY_Use</b></color>] $rf_ride_pilot") : ((!flag) ? (text2 + "\n$rf_full") : (text2 + "\n[<color=yellow><b>$KEY_Use</b></color>] $rf_ride_pass"))); } text2 += "\n[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] $rf_open_bag"; text2 = text2 + "\n" + text + "$rf_open_equip"; string text3 = string.Empty; UpgradeDef[] array = new UpgradeDef[5] { _harness, _plumage, _bags, _lanternGear, _totem }; foreach (UpgradeDef upgradeDef in array) { if (upgradeDef != null) { text3 = text3 + ((text3.Length > 0) ? ", " : string.Empty) + "$" + upgradeDef.Token; } } text2 = text2 + "\n<color=#c8b48c>$rf_upgrades: " + ((text3.Length > 0) ? text3 : "$rf_none") + "</color>"; return GameApi.Loc(text2); } public string HoverName() { return GameApi.Loc("$rf_raven"); } public bool OnInteract(Humanoid user, bool hold, bool alt) { if (hold || !_ready) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return false; } if (Time.frameCount == _lastInteractFrame) { return true; } _lastInteractFrame = Time.frameCount; if (alt) { OpenBag(val); return true; } if ((Object)(object)Local == (Object)(object)this) { RequestDismount(val); } else { TryMount(val); } return true; } public bool OnUseItem(Humanoid user, ItemData item) { if (!_ready || item == null || (Object)(object)_equip == (Object)null) { return false; } UpgradeDef upgradeDef = Upgrades.Find(item); if (upgradeDef == null) { return false; } ReadState(force: false); long num = LocalPlayerId(); if (_pilotId != 0L && _pilotId != num) { ((Character)user).Message((MessageType)2, "$rf_busy", 0, (Sprite)null, false); return true; } _equip.Fit((Player)(object)((user is Player) ? user : null), item, upgradeDef); return true; } public void OpenEquip(Player player) { if (_ready && !((Object)(object)_equip == (Object)null) && !((Object)(object)player == (Object)null)) { ReadState(force: false); long num = LocalPlayerId(); if (_pilotId != 0L && _pilotId != num) { ((Character)player).Message((MessageType)2, "$rf_bag_busy", 0, (Sprite)null, false); } else { _equip.Open(player); } } } public void OpenBag(Player player) { if (!((Object)(object)_bag == (Object)null)) { ReadState(force: false); long num = LocalPlayerId(); if (_pilotId != 0L && _pilotId != num) { ((Character)player).Message((MessageType)2, "$rf_bag_busy", 0, (Sprite)null, false); return; } ApplyBagSize(); _bag.Interact((Humanoid)(object)player, false, false); } } private static long LocalPlayerId() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer != (Object)null)) { return 0L; } return localPlayer.GetPlayerID(); } private void TryMount(Player player) { if ((Object)(object)Local != (Object)null) { return; } if (((Character)player).IsAttached()) { ((Character)player).Message((MessageType)2, "$rf_already_seated", 0, (Sprite)null, false); return; } ReadState(force: false); long playerID = player.GetPlayerID(); long num = ((_pilotId == playerID) ? 0 : _pilotId); long num2 = ((_passengerId == playerID) ? 0 : _passengerId); if (num == 0L) { _nview.ClaimOwnership(); ZDO zDO = _nview.GetZDO(); zDO.Set("rf_pilot", playerID); if (_passengerId == playerID) { zDO.Set("rf_pass", 0L); } Sit(player, Seat.Pilot); } else if (num2 == 0L) { _passengerRetries = 0; _nview.InvokeRPC("RF_Passenger", new object[2] { playerID, true }); Sit(player, Seat.Passenger); } else { ((Character)player).Message((MessageType)2, "$rf_full", 0, (Sprite)null, false); } } private void Sit(Player player, Seat seat) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) Transform seat2 = ((seat == Seat.Pilot) ? _pilotSeat : _passengerSeat); string text = RavenFlightPlugin.AttachAnimation.Value; if (string.IsNullOrEmpty(text)) { text = "intro"; } if (!GameApi.AttachStart(player, seat2, ((Component)this).gameObject, text, ToSeatLocal(new Vector3(0f, 0.15f, 0f))) || !((Character)player).IsAttached()) { if (seat == Seat.Pilot && _nview.IsOwner()) { _nview.GetZDO().Set("rf_pilot", 0L); } if (seat == Seat.Passenger) { _nview.InvokeRPC("RF_Passenger", new object[2] { player.GetPlayerID(), false }); } return; } _seat = seat; Local = this; if ((Object)(object)_colliders != (Object)null) { _colliders.SetActive(false); } _seatTime = Time.time; _nextVerify = Time.time + 3f; _warnTime = -100f; _inMove = Vector3.zero; _inVertical = 0f; _inRun = false; if (seat == Seat.Pilot) { _yaw = ((Component)this).transform.eulerAngles.y; _forwardSpeed = (_sideSpeed = (_verticalSpeed = 0f)); player.StartDoodadControl((IDoodadController)(object)this); } else { player.StartDoodadControl((IDoodadController)(object)_passengerControl); } ReadState(force: false); } public void RequestDismount(Player player) { if (Time.frameCount != _lastDismountFrame) { _lastDismountFrame = Time.frameCount; if (HeightAboveSurface() > RavenFlightPlugin.SafeDismountHeight.Value && Time.time - _warnTime > 2.5f) { _warnTime = Time.time; ((Character)player).Message((MessageType)2, "$rf_too_high", 0, (Sprite)null, false); } else { Leave(notifyNetwork: true); } } } public void Leave(bool notifyNetwork) { //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) Seat seat = _seat; _seat = Seat.None; if ((Object)(object)Local == (Object)(object)this) { Local = null; } if ((Object)(object)_colliders != (Object)null) { _colliders.SetActive(true); } Player localPlayer = Player.m_localPlayer; AllowRelease = true; try { if ((Object)(object)localPlayer != (Object)null) { localPlayer.StopDoodadControl(); if (((Character)localPlayer).IsAttached()) { ((Character)localPlayer).AttachStop(); } } } catch (Exception ex) { RavenFlightPlugin.Log.LogWarning((object)("Detach: " + ex.Message)); } finally { AllowRelease = false; } _inMove = Vector3.zero; _inVertical = 0f; _inRun = false; if (!notifyNetwork || (Object)(object)_nview == (Object)null || !_nview.IsValid() || (Object)(object)localPlayer == (Object)null) { return; } switch (seat) { case Seat.Pilot: if (_nview.IsOwner()) { _nview.GetZDO().Set("rf_pilot", 0L); } break; case Seat.Passenger: _nview.InvokeRPC("RF_Passenger", new object[2] { localPlayer.GetPlayerID(), false }); break; } ReadState(force: false); } public void OnUseStop(Player player) { } public void ApplyControlls(Vector3 moveDir, Vector3 lookDir, bool run, bool autoRun, bool block) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (autoRun && moveDir.z < 0.5f) { moveDir.z = 1f; } _inMove = moveDir; if (((Vector3)(ref lookDir)).sqrMagnitude > 0.01f) { _inLook = lookDir; } _inRun = run; _inputTime = Time.time; } public Component GetControlledComponent() { return (Component)(object)this; } public Vector3 GetPosition() { //IL_0021: 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) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer != (Object)null)) { return ((Component)this).transform.position; } return ((Component)localPlayer).transform.position; } public bool IsValid() { return (Object)(object)this != (Object)null; } private void Update() { //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) if (!_ready || !_nview.IsValid()) { return; } if (Time.time >= _nextPoll) { _nextPoll = Time.time + 0.5f; ReadState(force: false); } float num = ((_passengerId != 0L) ? 1f : 0f); if (!Mathf.Approximately(_sideBlend, num)) { _sideBlend = Mathf.MoveTowards(_sideBlend, num, Time.deltaTime * 1.5f); PlaceSeats(_sideBlend); } if ((Object)(object)Local != (Object)(object)this) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !((Character)localPlayer).IsAttached()) { Leave((Object)(object)localPlayer != (Object)null); return; } if (GameApi.GetDoodadController(localPlayer) == null) { if (_seat == Seat.Pilot) { localPlayer.StartDoodadControl((IDoodadController)(object)this); } else { localPlayer.StartDoodadControl((IDoodadController)(object)_passengerControl); } } if (Time.time >= _nextVerify) { _nextVerify = Time.time + 1f; if (!VerifySeat(localPlayer)) { return; } } if (Time.time >= _nextResist) { _nextResist = Time.time + 1f; if (_plumage != null && _plumage.Resist != RiderResist.None) { RavenFlightPlugin.ApplyRiderResist(localPlayer, _plumage.Resist); } } bool flag = GameApi.TakeInput(localPlayer); if (_seat == Seat.Pilot) { float num2 = ((flag && (GameApi.Button("Jump") || GameApi.Button("JoyJump"))) ? 1f : 0f); float num3 = ((flag && (GameApi.Button("Crouch") || GameApi.Button("JoyCrouch"))) ? 1f : 0f); _inVertical = num2 - num3; if (!flag || Time.time - _inputTime > 0.4f) { _inMove = Vector3.zero; _inRun = false; } } if (flag) { if (GameApi.KeyDown(RavenFlightPlugin.BagKey.Value)) { OpenBag(localPlayer); } else if ((GameApi.ButtonDown("Use") || GameApi.ButtonDown("JoyUse")) && (Object)(object)((Humanoid)localPlayer).GetHoverObject() == (Object)null && Time.frameCount != _lastInteractFrame) { _lastInteractFrame = Time.frameCount; RequestDismount(localPlayer); } } } private bool VerifySeat(Player player) { ReadState(force: false); long playerID = player.GetPlayerID(); if (_seat == Seat.Pilot) { if (_pilotId == playerID) { return true; } if (_nview.IsOwner() && _pilotId == 0L) { _nview.GetZDO().Set("rf_pilot", playerID); return true; } if (_pilotId != 0L) { Leave(notifyNetwork: false); ((Character)player).Message((MessageType)2, "$rf_seat_lost", 0, (Sprite)null, false); return false; } return true; } if (_passengerId == playerID) { return true; } if (_passengerRetries++ < 3) { _nview.InvokeRPC("RF_Passenger", new object[2] { playerID, true }); return true; } Leave(notifyNetwork: false); ((Character)player).Message((MessageType)2, "$rf_seat_lost", 0, (Sprite)null, false); return false; } private void FixedUpdate() { if (!_ready || !_nview.IsValid()) { return; } bool flag = (Object)(object)Local == (Object)(object)this && _seat == Seat.Pilot; if (flag && !_nview.IsOwner()) { _nview.ClaimOwnership(); } if (_nview.IsOwner()) { float fixedDeltaTime = Time.fixedDeltaTime; if (Time.time >= _nextHousekeeping) { _nextHousekeeping = Time.time + 1f; Housekeeping(flag); } if (flag) { SimulatePiloted(fixedDeltaTime); } else { SimulateIdle(fixedDeltaTime); } } } private void Housekeeping(bool piloting) { ZDO zDO = _nview.GetZDO(); if (piloting && zDO.GetLong("rf_sum", 0L) != 0L) { EndSummon(); } else if (!piloting) { ReadSummon(); } long num = zDO.GetLong("rf_pilot", 0L); long num2 = zDO.GetLong("rf_pass", 0L); if (piloting) { _foreignPilotTime = 0f; long num3 = LocalPlayerId(); if (num == 0L && num3 != 0L) { zDO.Set("rf_pilot", num3); } } else if (num != 0L) { _foreignPilotTime += 1f; if ((Object)(object)Player.GetPlayer(num) == (Object)null || _foreignPilotTime > 4f) { zDO.Set("rf_pilot", 0L); _foreignPilotTime = 0f; } } if (num2 != 0L && (Object)(object)Player.GetPlayer(num2) == (Object)null) { zDO.Set("rf_pass", 0L); } } private void SimulatePiloted(float dt) { //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: 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_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) float speedFactor = SpeedFactor; float num = Mathf.Clamp(_inMove.z, -1f, 1f); float num2 = Mathf.Clamp(_inMove.x, -1f, 1f); float maxStamina = MaxStamina; bool flag = _inRun && num > 0.1f; if (_exhausted && _stamina > maxStamina * 0.25f) { _exhausted = false; } bool flag2 = flag && !_exhausted && _stamina > 0f; if (flag2) { _stamina -= RavenFlightPlugin.BoostDrain.Value * dt; if (_stamina <= 0f) { _stamina = 0f; _exhausted = true; } } else if (!flag || _exhausted) { _stamina = Mathf.Min(maxStamina, _stamina + RavenFlightPlugin.StaminaRegen.Value * StaminaFactor * dt); } float value = RavenFlightPlugin.TurnRate.Value; float yaw = _yaw; float num3 = 0f; if (RavenFlightPlugin.MouseSteering.Value) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(_inLook.x, 0f, _inLook.z); if ((Mathf.Abs(num) > 0.1f || Mathf.Abs(num2) > 0.1f) && ((Vector3)(ref val)).sqrMagnitude > 0.0001f) { float num4 = Mathf.Atan2(val.x, val.z) * 57.29578f; _yaw = Mathf.MoveTowardsAngle(_yaw, num4, value * dt); } num3 = num2 * RavenFlightPlugin.StrafeSpeed.Value * speedFactor; } else { _yaw += num2 * value * 0.75f * dt; } float yawRate = Mathf.DeltaAngle(yaw, _yaw) / dt; float num5 = RavenFlightPlugin.CruiseSpeed.Value * speedFactor; float num6 = ((!(num > 0f)) ? (num5 * 0.3f * num) : (num5 * num * (flag2 ? RavenFlightPlugin.BoostMultiplier.Value : 1f))); float num7 = _inVertical * RavenFlightPlugin.ClimbSpeed.Value * Mathf.Sqrt(speedFactor); if (RavenFlightPlugin.MouseSteering.Value && RavenFlightPlugin.PitchWithCamera.Value && num > 0.1f) { float num8 = Mathf.Clamp(((Vector3)(ref _inLook)).normalized.y, -0.85f, 0.85f); float num9 = Mathf.Abs(num8); if (num9 > 0.34f) { num7 += Mathf.Sign(num8) * (num9 - 0.34f) / 0.51f * Mathf.Max(_forwardSpeed, 0f) * 0.8f; } } float value2 = RavenFlightPlugin.Acceleration.Value; _forwardSpeed = Mathf.MoveTowards(_forwardSpeed, num6, value2 * (flag2 ? 1.6f : 1f) * dt); _sideSpeed = Mathf.MoveTowards(_sideSpeed, num3, value2 * dt); _verticalSpeed = Mathf.MoveTowards(_verticalSpeed, num7, value2 * 1.5f * dt); Quaternion val2 = Quaternion.Euler(0f, _yaw, 0f); Vector3 val3 = val2 * new Vector3(_sideSpeed, 0f, _forwardSpeed) + Vector3.up * _verticalSpeed; if (_harness == null || !_harness.WindProof) { val3 += WindDrift(); } Vector3 val4 = Move(val3 * dt) / dt; Vector3 val5 = Quaternion.Inverse(val2) * val4; if (Mathf.Abs(val5.z) < Mathf.Abs(_forwardSpeed)) { _forwardSpeed = Mathf.Lerp(_forwardSpeed, val5.z, 0.5f); } if (Mathf.Abs(val4.y) < Mathf.Abs(_verticalSpeed)) { _verticalSpeed = Mathf.Lerp(_verticalSpeed, v