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 Core Gyro v0.1.12
BepInEx/plugins/CoreGyro/CoreGyro.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyInformationalVersion("0.1.12")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.1.12.0")] namespace CoreGyro; [BepInPlugin("arioh.valheim.coregyro", "Core Gyro", "0.1.12")] [BepInDependency("com.jotunn.jotunn", "2.30.2")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class GyroPlugin : BaseUnityPlugin { public const string Id = "arioh.valheim.coregyro"; public const string Version = "0.1.12"; public const string PrefabName = "Arioh_CoreGyro"; internal static GyroPlugin Instance; internal ConfigEntry<float> MaxSpeed; internal ConfigEntry<float> Acceleration; internal ConfigEntry<float> Braking; internal ConfigEntry<float> DescentRate; internal ConfigEntry<float> ClimbRate; internal ConfigEntry<float> YawRate; internal ConfigEntry<float> BankAngle; internal ConfigEntry<float> ThrottleUpRate; internal ConfigEntry<float> ThrottleDownRate; internal ConfigEntry<float> PitchRate; internal ConfigEntry<float> PitchLimit; internal ConfigEntry<float> HoverRate; internal ConfigEntry<float> CameraDistance; internal ConfigEntry<float> AirbrakeRate; internal ConfigEntry<float> RudderRate; internal ConfigEntry<KeyboardShortcut> Accelerate; internal ConfigEntry<KeyboardShortcut> Brake; internal ConfigEntry<KeyboardShortcut> Left; internal ConfigEntry<KeyboardShortcut> Right; internal ConfigEntry<KeyboardShortcut> Reverse; internal ConfigEntry<KeyboardShortcut> Headlights; internal ConfigEntry<KeyboardShortcut> Exit; internal ConfigEntry<KeyboardShortcut> PitchUp; internal ConfigEntry<KeyboardShortcut> PitchDown; internal ConfigEntry<KeyboardShortcut> Hover; internal ConfigEntry<KeyboardShortcut> VerticalUp; internal ConfigEntry<KeyboardShortcut> VerticalDown; internal ConfigEntry<KeyboardShortcut> RudderLeft; internal ConfigEntry<KeyboardShortcut> RudderRight; private Harmony harmony; private bool registered; internal static bool Headless => (int)SystemInfo.graphicsDeviceType == 4; internal float ForwardLimit => MaxSpeed.Value; private void Awake() { //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Expected O, but got Unknown //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Expected O, but got Unknown Instance = this; MaxSpeed = Setting("MaximumSpeedMpsV3", 22f, 5f, 22f, "Maximum horizontal powered speed in metres per second. Default 22 m/s = 79.2 km/h; old km/h keys are ignored."); Acceleration = Setting("Acceleration", 3f, 1f, 8f, "Forward acceleration while Shift is held."); Braking = Setting("Braking", 5f, 1f, 12f, "Response rate when commanded motor speed decreases. Ctrl now reduces stored throttle, not a direct descent command."); DescentRate = Setting("PoweredSinkLimit", 6f, 0.5f, 8f, "Maximum powered sink rate from low throttle and nose-down pitch. Engine-off fall is not limited by this value."); ClimbRate = Setting("PoweredClimbLimit", 6f, 0.5f, 8f, "Maximum powered climb target from throttle and pitch."); ThrottleUpRate = Setting("ThrottleIncreasePerSecond", 30f, 5f, 100f, "Throttle percentage points gained per second while Shift is held."); ThrottleDownRate = Setting("ThrottleDecreasePerSecond", 40f, 5f, 100f, "Throttle percentage points removed per second while Ctrl is held; at zero the engine stops."); PitchRate = Setting("PitchRate", 25f, 5f, 60f, "Nose pitch angle change per second while W/S is held."); PitchLimit = Setting("MaximumPitchAngle", 35f, 10f, 45f, "Maximum manual pitch angle in degrees."); YawRate = Setting("TurnRate", 35f, 10f, 60f, "Steering degrees per second."); AirbrakeRate = Setting("AirbrakeDeceleration", 8f, 2f, 20f, "Horizontal braking acceleration while the right mouse button is held. Stored throttle and vertical lift are not changed."); BankAngle = Setting("MaximumBankAngleV2", 55f, 10f, 65f, "Cruise A/D roll target limit in degrees. Actual bank also supplies bounded lateral acceleration and coordinated heading change."); RudderRate = Setting("RudderTurnRateV2", 60f, 10f, 100f, "Q/E rudder heading rate in degrees per second; separate from A/D banking."); Accelerate = Key("Accelerate", (KeyCode)304); Brake = Key("Brake", (KeyCode)306); Left = Key("Left", (KeyCode)97); Right = Key("Right", (KeyCode)100); RudderLeft = Key("RudderLeft", (KeyCode)113); RudderRight = Key("RudderRight", (KeyCode)101); Reverse = Key("Reverse", (KeyCode)114); Headlights = Key("Headlights", (KeyCode)104); Exit = Key("ExitSeatHoldV2", (KeyCode)101); PitchUp = Key("PitchUp", (KeyCode)115); PitchDown = Key("PitchDown", (KeyCode)119); Hover = Key("HoverMode", (KeyCode)118); VerticalUp = Key("VerticalUp", (KeyCode)32); VerticalDown = Key("VerticalDown", (KeyCode)99); HoverRate = Setting("HoverVerticalSpeedV2", 5f, 0.5f, 10f, "Vertical speed in hover mode while Space/C is held. New default 5 m/s replaces the previous 2.5 m/s setting."); CameraDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "SeatedDistance", 8f, new ConfigDescription("Local orbit camera distance while seated in Core Gyro.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 20f), Array.Empty<object>())); if (!Headless) { ((Component)this).gameObject.AddComponent<GyroHUD>(); } Translate(); harmony = new Harmony("arioh.valheim.coregyro"); harmony.PatchAll(typeof(GyroPlugin).Assembly); PrefabManager.OnVanillaPrefabsAvailable += Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Core Gyro loading: centered pilot seat, standing mast passenger, native cargo chest, Surtling core, a forward-down 45-degree survey light and sound."); } private ConfigEntry<float> Setting(string key, float value, float min, float max, string description) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind<float>("Flight", key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } private ConfigEntry<KeyboardShortcut> Key(string name, KeyCode key) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", name, new KeyboardShortcut(key, Array.Empty<KeyCode>()), "Local keyboard binding; active only while seated in this gyro."); } internal static GameObject Native(string name) { GameObject prefab = PrefabManager.Instance.GetPrefab(name); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Required native prefab missing: " + name); } return prefab; } private void Register() { //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Expected O, but got Unknown //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) if (registered) { return; } PrefabManager.OnVanillaPrefabsAvailable -= Register; try { foreach (NativePart item in ModelSpec.Parts()) { if (!Object.op_Implicit((Object)(object)Native(item.Prefab).transform.Find(item.Path))) { throw new InvalidOperationException("Native visual path missing: " + item.Prefab + "/" + item.Path); } } GameObject val = PrefabManager.Instance.CreateClonedPrefab("Arioh_CoreGyro", Native("Cart")); if (val.activeInHierarchy) { throw new InvalidOperationException("Gyro prefab configured while active."); } MonoBehaviour[] components = val.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val2 in components) { if (!(val2 is ZNetView) && !(val2 is ZSyncTransform) && !(val2 is Piece) && !(val2 is WearNTear)) { Object.DestroyImmediate((Object)(object)val2); } } Joint[] components2 = val.GetComponents<Joint>(); for (int i = 0; i < components2.Length; i++) { Object.DestroyImmediate((Object)(object)components2[i]); } LODGroup[] componentsInChildren = val.GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } for (int num = val.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(num)).gameObject); } Collider[] components3 = val.GetComponents<Collider>(); for (int i = 0; i < components3.Length; i++) { Object.DestroyImmediate((Object)(object)components3[i]); } Rigidbody component = val.GetComponent<Rigidbody>(); component.constraints = (RigidbodyConstraints)0; component.mass = 600f; component.useGravity = true; component.isKinematic = false; component.linearDamping = 0.15f; component.angularDamping = 2f; component.interpolation = (RigidbodyInterpolation)1; component.collisionDetectionMode = (CollisionDetectionMode)3; component.centerOfMass = new Vector3(0f, 0.65f, 0f); ZNetView component2 = val.GetComponent<ZNetView>(); component2.m_persistent = true; component2.m_distant = true; ZSyncTransform val3 = val.GetComponent<ZSyncTransform>(); if (!Object.op_Implicit((Object)(object)val3)) { val3 = val.AddComponent<ZSyncTransform>(); } val3.m_syncPosition = true; val3.m_syncRotation = true; val3.m_syncBodyVelocity = true; Piece component3 = val.GetComponent<Piece>(); component3.m_name = "$cg_name"; component3.m_description = "$cg_description"; component3.m_craftingStation = Native("piece_workbench").GetComponent<CraftingStation>(); component3.m_noInWater = false; component3.m_comfort = 0; component3.m_comfortObject = null; component3.m_canBeRemoved = true; component3.m_resources = Array.ConvertAll(RecipeSpec.Items, (BuildCost c) => Cost(c.Item, c.Amount)); Container val4 = val.GetComponent<Container>(); if (!Object.op_Implicit((Object)(object)val4)) { val4 = val.AddComponent<Container>(); } Container componentInChildren = Native("Cart").GetComponentInChildren<Container>(true); if (!Object.op_Implicit((Object)(object)componentInChildren)) { throw new InvalidOperationException("Native cart container unavailable."); } val4.m_bkg = componentInChildren.m_bkg; val4.m_openEffects = componentInChildren.m_openEffects; val4.m_closeEffects = componentInChildren.m_closeEffects; val4.m_defaultItems = componentInChildren.m_defaultItems; val4.m_destroyedLootPrefab = componentInChildren.m_destroyedLootPrefab; val4.m_name = "$cg_cargo"; val4.m_width = 4; val4.m_height = 2; val4.m_wagon = null; val4.m_rootObjectOverride = null; val4.m_open = (val4.m_closed = null); val4.m_checkGuardStone = true; val4.m_privacy = (PrivacySetting)2; val4.m_autoDestroyEmpty = false; GyroController controller = val.AddComponent<GyroController>(); GameObject val5 = NativeModel.Build(val, controller); WearNTear component4 = val.GetComponent<WearNTear>(); component4.m_new = (component4.m_worn = (component4.m_broken = val5)); component4.m_wet = null; component4.m_snow = (component4.m_snowWorn = (component4.m_snowBroken = null)); component4.m_noSupportWear = false; component4.m_noRoofWear = false; component4.m_supports = false; component4.m_staticPosition = false; component4.m_snowDamageImmune = true; component4.m_ashDamageImmune = true; component4.m_burnable = false; component4.m_health = 1500f; component4.m_fragmentRoots = (GameObject[])(object)new GameObject[1] { val5 }; component4.m_nonSolidRenderers = new List<Renderer>(); if (!Headless) { try { Sprite val6 = RenderManager.Instance.Render(val5, RenderManager.IsometricRotation); if (Object.op_Implicit((Object)(object)val6)) { component3.m_icon = val6; } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Gyro icon render: " + ex.Message)); } } CustomPiece val7 = new CustomPiece(val, "Hammer", false); val7.Usage = new string[1] { "Crafting" }; CustomPiece val8 = val7; if (!PieceManager.Instance.AddPiece(val8)) { throw new InvalidOperationException("Could not register Core Gyro build piece."); } registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Core Gyro ready: Arioh_CoreGyro, 1 pilot seat, 1 standing passenger, 8 cargo slots, Shift throttle increase, Ctrl throttle decrease, R toggle surface reverse, 22 m/s (79.2 km/h) maximum, persistent 0-100% throttle, W/S pitch, flight HUD, water buoyancy and combat-only durability."); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Core Gyro registration failed: " + ex2)); } } private static Requirement Cost(string name, int amount) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return new Requirement { m_resItem = Native(name).GetComponent<ItemDrop>(), m_amount = amount, m_recover = true }; } private void Translate() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string[,] array = new string[15, 2] { { "cg_name", "Core Gyro" }, { "cg_description", "A Surtling-core-assisted gyrocopter with a centered pilot seat, standing mast passenger, cargo and a central forward-down 45-degree Surtling Core survey light. Shift starts/increases throttle; Ctrl decreases throttle; W/S pitch; A/D bank and turn; Q/E rudder; V hover; Space/C vertical; hold right mouse to brake; hold E with engine off on a surface to exit; R toggles surface reverse/forward; Shift starts; H survey light. Build on land." }, { "cg_pilot", "Core Gyro - Pilot" }, { "cg_passenger", "Core Gyro - Mast passenger" }, { "cg_cargo", "Core Gyro - Cargo (8 slots)" }, { "cg_enter", "Sit" }, { "cg_grip", "Hold mast" }, { "cg_full", "This crew position is occupied." }, { "cg_land", "To leave: stop on land or water, shut the engine down to 0%, then hold E for 1.5 seconds." }, { "cg_started", "Core Gyro engine started. Shift: throttle +; Ctrl: throttle -; W/S: pitch; A/D: bank and turn; Q/E: rudder; H: survey light." }, { "cg_stopped", "Core Gyro engine stopped." }, { "cg_stopland", "The engine can only be stopped while safely on the ground." }, { "cg_lightson", "Survey light on" }, { "cg_lightsoff", "Survey light off" }, { "cg_nopower", "Start the engine first." } }; for (int i = 0; i < array.GetLength(0); i++) { string text = "English"; localization.AddTranslation(ref text, ref array[i, 0], array[i, 1]); text = "Thai"; localization.AddTranslation(ref text, ref array[i, 0], array[i, 1]); } } internal static void LogInfo(string message) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } internal static void Error(string message, Exception e) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogError((object)(message + ": " + e)); } } private void OnDestroy() { GyroCamera.Release(); PrefabManager.OnVanillaPrefabsAvailable -= Register; if (harmony != null) { harmony.UnpatchSelf(); } Instance = null; } } [HarmonyPatch(typeof(Player), "SetControls")] internal static class SeatedInputPatch { private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (__instance.GetDoodadController() is GyroSeat) { movedir = Vector3.zero; attack = (attackHold = (secondaryAttack = (secondaryAttackHold = (block = (blockHold = (jump = (crouch = (run = (autoRun = (dodge = false)))))))))); } } } [HarmonyPatch(typeof(WearNTear), "CanBeRemoved")] internal static class OccupiedRemovalPatch { private static void Postfix(WearNTear __instance, ref bool __result) { GyroController component = ((Component)__instance).GetComponent<GyroController>(); if (Object.op_Implicit((Object)(object)component) && component.Occupied) { __result = false; } } } public sealed class GyroController : MonoBehaviour { private const string PilotKey = "cg_pilot_v1"; private const string PassengerKey = "cg_passenger_v1"; private const string EngineKey = "cg_engine_v1"; private const string LightsKey = "cg_lights_v1"; private const string SpeedKey = "cg_speed_v1"; private const string GroundKey = "cg_ground_v1"; private const string PowerKey = "cg_power_v2"; private const string PitchKey = "cg_pitch_v2"; private const string HoverKey = "cg_hover_v1"; [SerializeField] private Transform rotor; [SerializeField] private Transform pusher; [SerializeField] private Transform stick; [SerializeField] private Light[] surveyLights = (Light[])(object)new Light[0]; [SerializeField] private AudioSource sound; [SerializeField] private GyroSeat[] seats = new GyroSeat[0]; [SerializeField] private Transform[] wheels = (Transform[])(object)new Transform[0]; private ZNetView view; private Rigidbody body; private Container cargo; private readonly WaterVolume[] floatVolumes = (WaterVolume[])(object)new WaterVolume[4]; private readonly Vector3[] floatPoints = (Vector3[])(object)new Vector3[4] { new Vector3(-0.72f, 0.08f, -0.8f), new Vector3(0.72f, 0.08f, -0.8f), new Vector3(-0.72f, 0.08f, 0.8f), new Vector3(0.72f, 0.08f, 0.8f) }; private readonly RaycastHit[] groundHits = (RaycastHit[])(object)new RaycastHit[24]; private readonly float[] lease = new float[2]; private float inputAt; private float sweepAt; private float stateAt; private float heading; private float speed; private float rpm; private float actionAt; private float rotorSpin; private float diagnosticAt; private float power; private float pitchAngle; private float pitchCommand; private float verticalCommand; private float lastVertical; private float rudderCommand; private Vector3 hoverPoint; private bool hoverLocked; private bool parked; private float parkSince = -1f; private int inputSequence = -1; private int pending = -1; private long inputActor; private Vector3 command; private float pendingUntil; private bool wasOwner; private readonly RaycastHit[] altitudeHits = (RaycastHit[])(object)new RaycastHit[64]; internal bool Valid { get { if (Object.op_Implicit((Object)(object)view)) { return view.IsValid(); } return false; } } public bool Occupied { get { if (Occupant(0) == 0L) { return Occupant(1) != 0; } return true; } } internal bool EngineOn { get { if (Valid) { return view.GetZDO().GetBool("cg_engine_v1", false); } return false; } } internal bool LampsOn { get { if (Valid) { return view.GetZDO().GetBool("cg_lights_v1", false); } return false; } } internal bool Grounded { get { if (Valid) { return view.GetZDO().GetBool("cg_ground_v1", false); } return false; } } internal float DisplaySpeed { get { if (!Valid) { return 0f; } return Mathf.Max(0f, view.GetZDO().GetFloat("cg_speed_abs_v2", Mathf.Abs(view.GetZDO().GetFloat("cg_speed_v1", 0f)))); } } internal float PowerPercent { get { if (!Valid) { return 0f; } return Mathf.Clamp01(view.GetZDO().GetFloat("cg_power_v2", 0f)) * 100f; } } internal float DisplayPitch { get { if (!Valid) { return 0f; } return view.GetZDO().GetFloat("cg_pitch_v2", 0f); } } internal float HeightAboveSurface { get { if (!Valid) { return 0f; } return view.GetZDO().GetFloat("cg_agl_v2", 0f); } } internal bool SpunUp { get { if (Valid) { return view.GetZDO().GetFloat("cg_spin_v2", 0f) >= 0.999f; } return false; } } internal float HullPercent { get { WearNTear component = ((Component)this).GetComponent<WearNTear>(); if (!Object.op_Implicit((Object)(object)component)) { return 0f; } return component.GetHealthPercentage() * 100f; } } internal bool Parked { get { if (Valid) { return view.GetZDO().GetBool("cg_parked_v1", false); } return false; } } internal bool ReverseSelected { get { if (Valid) { return view.GetZDO().GetBool("cg_reverse_selected_v2", false); } return false; } } internal bool ReverseOn { get { if (Valid) { return view.GetZDO().GetBool("cg_reverse_v1", false); } return false; } } internal bool AirbrakeOn { get { if (Valid) { return view.GetZDO().GetBool("cg_airbrake_v1", false); } return false; } } internal bool HoverOn { get { if (Valid) { return view.GetZDO().GetBool("cg_hover_v1", false); } return false; } } internal bool HoverLocked { get { if (Valid) { return view.GetZDO().GetBool("cg_hover_lock_v1", false); } return false; } } internal void Configure(Transform r, Transform p, Light[] lights, AudioSource audio, GyroSeat[] crew, Transform[] wheelParts, Transform controlStick) { rotor = r; pusher = p; surveyLights = lights; sound = audio; seats = crew; wheels = wheelParts; stick = controlStick; } private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) view = ((Component)this).GetComponent<ZNetView>(); body = ((Component)this).GetComponent<Rigidbody>(); cargo = ((Component)this).GetComponent<Container>(); heading = ((Component)this).transform.eulerAngles.y; if (Object.op_Implicit((Object)(object)view) && view.IsValid()) { view.Register<long, int>("cg_seat", (Action<long, long, int>)RPC_Seat); view.Register<long, int, bool>("cg_seat_reply", (Action<long, long, int, bool>)RPC_SeatReply); view.Register<long, int>("cg_release", (Action<long, long, int>)RPC_Release); view.Register<long, int>("cg_lease", (Action<long, long, int>)RPC_Lease); view.Register<long, int, Vector3, Vector3>("cg_controls_v5", (Method<long, int, Vector3, Vector3>)RPC_Input); view.Register<long, int>("cg_action", (Action<long, long, int>)RPC_Action); } } internal long Occupant(int index) { if (!Valid) { return 0L; } return view.GetZDO().GetLong((index == 0) ? "cg_pilot_v1" : "cg_passenger_v1", 0L); } private Player Actor(long sender, long actor) { Player player = Player.GetPlayer(actor); if (!Object.op_Implicit((Object)(object)player) || ((Character)player).GetOwner() != sender || ((Character)player).IsDead() || ((Character)player).IsTeleporting()) { return null; } return player; } private bool IsCrew(long sender, long actor, int index, out Player player) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) player = Actor(sender, actor); if (Object.op_Implicit((Object)(object)player) && index >= 0 && index < 2) { return FlightRules.CommandAllowed(actor, Occupant(index), sender, ((Character)player).GetOwner(), Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position), alive: true); } return false; } internal void RequestSeat(Player player, int index) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (Valid && index >= 0 && index <= 1 && Object.op_Implicit((Object)(object)player) && !((Character)player).IsAttached() && PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false) && (!(Time.time < pendingUntil) || pending < 0)) { pending = index; pendingUntil = Time.time + 5f; view.InvokeRPC("cg_seat", new object[2] { player.GetPlayerID(), index }); } } private void RPC_Seat(long sender, long actor, int index) { //IL_004d: 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_0077: Unknown result type (might be due to invalid IL or missing references) if (Valid && view.IsOwner() && index >= 0 && index <= 1) { Player val = Actor(sender, actor); bool flag = Object.op_Implicit((Object)(object)val) && FlightRules.SeatAllowed(actor, Occupant(index), Occupant(1 - index), sender, ((Character)val).GetOwner(), Vector3.Distance(((Component)val).transform.position, seats[index].Anchor.position), alive: true) && WardAccess.Allowed(((Component)this).transform.position, actor); if (flag) { view.GetZDO().Set((index == 0) ? "cg_pilot_v1" : "cg_passenger_v1", actor); lease[index] = Time.time; } view.InvokeRPC(sender, "cg_seat_reply", new object[3] { actor, index, flag }); } } private void RPC_SeatReply(long sender, long actor, int index, bool allowed) { Player localPlayer = Player.m_localPlayer; if (Valid && sender == view.GetZDO().GetOwner() && Object.op_Implicit((Object)(object)localPlayer) && localPlayer.GetPlayerID() == actor && pending == index && !(Time.time > pendingUntil)) { pending = -1; pendingUntil = 0f; if (allowed && !((Character)localPlayer).IsAttached()) { seats[index].BeginLocal(localPlayer); } else if (!allowed) { ((Character)localPlayer).Message((MessageType)2, "$cg_full", 0, (Sprite)null, false); } } } internal void Release(Player player, int index) { if (Valid && Object.op_Implicit((Object)(object)player)) { view.InvokeRPC("cg_release", new object[2] { player.GetPlayerID(), index }); } } private void RPC_Release(long sender, long actor, int index) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (Valid && view.IsOwner() && IsCrew(sender, actor, index, out var _)) { view.GetZDO().Set((index == 0) ? "cg_pilot_v1" : "cg_passenger_v1", 0L); lease[index] = 0f; if (index == 0) { command = Vector3.zero; inputAt = 0f; inputActor = 0L; inputSequence = -1; } } } internal void Ping(Player player, int index) { if (Valid) { view.InvokeRPC("cg_lease", new object[2] { player.GetPlayerID(), index }); } } private void RPC_Lease(long sender, long actor, int index) { if (Valid && view.IsOwner() && IsCrew(sender, actor, index, out var _)) { lease[index] = Time.time; } } internal void SendInput(Player player, int sequence, int adjustment, bool reverse, float turn, float pitch, float vertical, float rudder, bool airbrake) { //IL_0040: 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) if (Valid) { view.InvokeRPC("cg_controls_v5", new object[4] { player.GetPlayerID(), sequence, (object)new Vector3((float)adjustment, (float)FlightRules.DriveFlags(reverse, airbrake), turn), (object)new Vector3(pitch, vertical, rudder) }); } } private void RPC_Input(long sender, long actor, int sequence, Vector3 value, Vector3 axes) { //IL_0023: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (Valid && view.IsOwner() && IsCrew(sender, actor, 0, out var _) && FlightRules.Finite(value.x) && FlightRules.Finite(value.y) && FlightRules.Finite(value.z) && FlightRules.Finite(axes.x) && FlightRules.Finite(axes.y) && FlightRules.Finite(axes.z) && !(Mathf.Abs(value.x) > 1f) && FlightRules.ValidDriveFlags(value.y) && !(Mathf.Abs(value.z) > 1f) && !(Mathf.Abs(axes.x) > 1f) && !(Mathf.Abs(axes.y) > 1f) && !(Mathf.Abs(axes.z) > 1f) && (actor != inputActor || sequence > inputSequence)) { inputActor = actor; inputSequence = sequence; command = value; pitchCommand = axes.x; verticalCommand = axes.y; rudderCommand = axes.z; inputAt = Time.time; lease[0] = Time.time; } } internal void Action(Player player, int action) { if (Valid) { if (action == 1 && !EngineOn) { ((Character)player).Message((MessageType)2, "$cg_nopower", 0, (Sprite)null, false); return; } if (action == 2 && !HoverOn && !FlightRules.CanHover(EngineOn, PowerPercent * 0.01f)) { ((Character)player).Message((MessageType)2, "Set throttle to at least 50% to engage hover.", 0, (Sprite)null, false); return; } view.InvokeRPC("cg_action", new object[2] { player.GetPlayerID(), action }); } } private void RPC_Action(long sender, long actor, int action) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!Valid || !view.IsOwner() || !IsCrew(sender, actor, 0, out var _) || Time.time - actionAt < 0.25f) { return; } actionAt = Time.time; if (action == 1 && EngineOn) { view.GetZDO().Set("cg_lights_v1", !LampsOn); } if (action == 2) { if (HoverOn) { view.GetZDO().Set("cg_hover_v1", false); } else if (FlightRules.CanHover(EngineOn, power)) { hoverPoint = ((Component)this).transform.position; Vector3 val = Vector3.ProjectOnPlane(body.linearVelocity, Vector3.up); hoverLocked = ((Vector3)(ref val)).magnitude < 0.2f; lastVertical = 0f; pitchAngle = 0f; view.GetZDO().Set("cg_hover_v1", true); view.GetZDO().Set("cg_hover_point_v1", hoverPoint); view.GetZDO().Set("cg_hover_lock_v1", hoverLocked); } } } private bool GroundCheck() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) int num = Physics.RaycastNonAlloc(((Component)this).transform.position + Vector3.up * 0.5f, Vector3.down, groundHits, 1.15f, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider collider = ((RaycastHit)(ref groundHits[i])).collider; if (Object.op_Implicit((Object)(object)collider) && !((Component)collider).transform.IsChildOf(((Component)this).transform) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Character>())) { return true; } } return false; } private bool WaterColumnContains(WaterVolume volume, Vector3 point) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)volume) || !((Behaviour)volume).isActiveAndEnabled || (int)volume.GetLiquidType() != 0) { return false; } Collider component = ((Component)volume).GetComponent<Collider>(); if (!Object.op_Implicit((Object)(object)component) || !component.enabled) { return false; } Bounds bounds = component.bounds; return FlightRules.WaterColumn(point.x, point.z, ((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).min.z, ((Bounds)(ref bounds)).max.z); } private float WaterLevel(Vector3 point, int index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) float liquidLevel = Floating.GetLiquidLevel(point, 1f, (LiquidType)0); if (FlightRules.ValidWaterLevel(liquidLevel)) { return liquidLevel; } WaterVolume val = floatVolumes[index]; if (WaterColumnContains(val, point)) { float waterSurface = val.GetWaterSurface(point, 1f); if (FlightRules.ValidWaterLevel(waterSurface) && Mathf.Abs(waterSurface - point.y) < 128f) { return waterSurface; } } floatVolumes[index] = null; float result = -10000f; float num = float.MaxValue; List<WaterVolume> instances = WaterVolume.Instances; for (int i = 0; i < instances.Count; i++) { WaterVolume val2 = instances[i]; if (!WaterColumnContains(val2, point)) { continue; } float waterSurface2 = val2.GetWaterSurface(point, 1f); if (FlightRules.ValidWaterLevel(waterSurface2)) { float num2 = Mathf.Abs(waterSurface2 - point.y); if (num2 < num) { num = num2; result = waterSurface2; floatVolumes[index] = val2; } } } return result; } private bool FloatOnWater() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) bool result = false; for (int i = 0; i < floatPoints.Length; i++) { Vector3 val = ((Component)this).transform.TransformPoint(floatPoints[i]); float num = WaterLevel(val, i); float depth = num - val.y; if (FlightRules.ValidWaterLevel(num)) { float num2 = FlightRules.Buoyancy(depth, body.GetPointVelocity(val).y); if (num2 > 0f) { body.AddForceAtPosition(Vector3.up * (num2 * body.mass / (float)floatPoints.Length), val, (ForceMode)0); } if (FlightRules.WaterContact(depth)) { result = true; } } } return result; } private float MeasureHeight() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + Vector3.up * 0.2f; float num = Mathf.Max(val.y - 1000f, WaterLevel(((Component)this).transform.position, 0)); int num2 = Physics.RaycastNonAlloc(val, Vector3.down, altitudeHits, 1000f, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num2; i++) { Collider collider = ((RaycastHit)(ref altitudeHits[i])).collider; if (Object.op_Implicit((Object)(object)collider) && !((Component)collider).transform.IsChildOf(((Component)this).transform) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Character>())) { WaterVolume component = ((Component)collider).GetComponent<WaterVolume>(); if (Object.op_Implicit((Object)(object)component) && (int)component.GetLiquidType() == 0) { num = Mathf.Max(num, component.GetWaterSurface(((RaycastHit)(ref altitudeHits[i])).point, 1f)); } else if (!collider.isTrigger) { num = Mathf.Max(num, ((RaycastHit)(ref altitudeHits[i])).point.y); } } } return Mathf.Clamp(((Component)this).transform.position.y - num, 0f, 1000f); } private bool ParkingSupport() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) int num = 0; Transform[] array = wheels; foreach (Transform val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } SphereCollider component = ((Component)val).GetComponent<SphereCollider>(); if (!Object.op_Implicit((Object)(object)component)) { continue; } int num2 = Physics.RaycastNonAlloc(val.position + Vector3.up * 0.04f, Vector3.down, groundHits, component.radius + 0.12f, -1, (QueryTriggerInteraction)1); bool flag = false; for (int j = 0; j < num2; j++) { Collider collider = ((RaycastHit)(ref groundHits[j])).collider; if (Object.op_Implicit((Object)(object)collider) && !((Component)collider).transform.IsChildOf(((Component)this).transform) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Character>()) && !(((RaycastHit)(ref groundHits[j])).normal.y < 0.6f)) { if (Object.op_Implicit((Object)(object)collider.attachedRigidbody)) { return false; } flag = true; } } if (flag) { num++; } } return num >= 2; } private void SetParking(bool engage) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (parked != engage) { parked = engage; if (engage) { body.linearVelocity = Vector3.zero; body.angularVelocity = Vector3.zero; body.constraints = (RigidbodyConstraints)126; } else { body.constraints = (RigidbodyConstraints)0; body.WakeUp(); parkSince = -1f; Quaternion rotation = body.rotation; heading = ((Quaternion)(ref rotation)).eulerAngles.y; } } } private void UpdateParking(bool water, bool engine, bool hover) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0081: 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_0010: 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) bool flag = !water && !engine && !hover && WaterLevel(((Component)this).transform.position, 0) < ((Component)this).transform.position.y && ParkingSupport(); if (parked) { if (!flag) { SetParking(engage: false); } return; } Vector3 val = Vector3.ProjectOnPlane(body.linearVelocity, Vector3.up); float magnitude = ((Vector3)(ref val)).magnitude; float y = body.linearVelocity.y; val = body.angularVelocity; if (!FlightRules.ParkEligible(flag, water, engine, hover, magnitude, y, ((Vector3)(ref val)).magnitude)) { parkSince = -1f; return; } if (parkSince < 0f) { parkSince = Time.time; } if (Time.time - parkSince >= 0.75f) { SetParking(engage: true); } } private void FixedUpdate() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_089f: Unknown result type (might be due to invalid IL or missing references) //IL_08a4: Unknown result type (might be due to invalid IL or missing references) //IL_08a8: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0882: Unknown result type (might be due to invalid IL or missing references) //IL_0889: Unknown result type (might be due to invalid IL or missing references) //IL_08f6: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_0900: Unknown result type (might be due to invalid IL or missing references) //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_07f5: Unknown result type (might be due to invalid IL or missing references) //IL_0808: Unknown result type (might be due to invalid IL or missing references) //IL_09b6: Unknown result type (might be due to invalid IL or missing references) //IL_09c1: Unknown result type (might be due to invalid IL or missing references) //IL_09c6: Unknown result type (might be due to invalid IL or missing references) //IL_09cb: Unknown result type (might be due to invalid IL or missing references) //IL_09d0: Unknown result type (might be due to invalid IL or missing references) //IL_09f8: Unknown result type (might be due to invalid IL or missing references) //IL_0a06: Unknown result type (might be due to invalid IL or missing references) //IL_0a14: Unknown result type (might be due to invalid IL or missing references) //IL_0d81: Unknown result type (might be due to invalid IL or missing references) //IL_0d86: Unknown result type (might be due to invalid IL or missing references) //IL_0a28: Unknown result type (might be due to invalid IL or missing references) //IL_0a38: Unknown result type (might be due to invalid IL or missing references) //IL_0a43: Unknown result type (might be due to invalid IL or missing references) //IL_0a4d: Unknown result type (might be due to invalid IL or missing references) //IL_0a52: Unknown result type (might be due to invalid IL or missing references) //IL_0bfc: Unknown result type (might be due to invalid IL or missing references) if (!Valid || !Object.op_Implicit((Object)(object)body)) { return; } if (!view.IsOwner()) { if (parked) { SetParking(engage: false); } wasOwner = false; return; } Quaternion rotation; if (!wasOwner) { power = Mathf.Clamp01(view.GetZDO().GetFloat("cg_power_v2", 0f)); pitchAngle = view.GetZDO().GetFloat("cg_pitch_v2", 0f); hoverPoint = view.GetZDO().GetVec3("cg_hover_point_v1", ((Component)this).transform.position); hoverLocked = view.GetZDO().GetBool("cg_hover_lock_v1", false); wasOwner = true; body.constraints = (RigidbodyConstraints)0; body.WakeUp(); rotorSpin = (EngineOn ? 1 : 0); rotation = body.rotation; heading = ((Quaternion)(ref rotation)).eulerAngles.y; speed = view.GetZDO().GetFloat("cg_speed_v1", 0f); if (!FlightRules.Finite(speed)) { speed = 0f; } speed = Mathf.Clamp(speed, -1.388889f, GyroPlugin.Instance.ForwardLimit); lease[0] = (lease[1] = Time.time); inputAt = 0f; inputSequence = -1; inputActor = 0L; } if (body.isKinematic) { return; } GyroPlugin instance = GyroPlugin.Instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } float fixedDeltaTime = Time.fixedDeltaTime; bool flag = FloatOnWater(); bool flag2 = GroundCheck() || flag; bool engineOn = EngineOn; bool flag3 = Occupant(0) != 0L && FlightRules.Fresh(Time.time, inputAt); int adjustment = (flag3 ? ((command.x > 0.5f) ? 1 : ((command.x < -0.5f) ? (-1) : 0)) : 0); power = FlightRules.Throttle(power, adjustment, flag3, fixedDeltaTime, instance.ThrottleUpRate.Value, instance.ThrottleDownRate.Value); engineOn = power > 0f; if (engineOn != EngineOn) { view.GetZDO().Set("cg_engine_v1", engineOn); if (!engineOn) { view.GetZDO().Set("cg_lights_v1", false); } } if (!engineOn && HoverOn) { view.GetZDO().Set("cg_hover_v1", false); } bool hoverOn = HoverOn; UpdateParking(flag, engineOn, hoverOn); bool flag4 = flag3 && FlightRules.AirbrakeHeld(command.y); bool flag5 = engineOn && flag2 && flag3 && FlightRules.ReverseHeld(command.y) && !hoverOn; float num = (flag3 ? command.z : 0f); float num2 = (flag3 ? pitchCommand : 0f); float rudder = (flag3 ? rudderCommand : 0f); pitchAngle = (hoverOn ? 0f : FlightRules.Pitch(pitchAngle, num2, fixedDeltaTime, instance.PitchRate.Value, flag ? 0f : (flag2 ? 8f : instance.PitchLimit.Value))); rotorSpin = Mathf.MoveTowards(rotorSpin, (float)(engineOn ? 1 : 0), fixedDeltaTime / 1.2f); bool flag6 = FlightRules.RotorReady(engineOn, rotorSpin); speed = FlightRules.DriveSpeed(speed, power, engineOn, flag5, fixedDeltaTime, instance.ForwardLimit, instance.Acceleration.Value, instance.Braking.Value); Vector3 val = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 linearVelocity = body.linearVelocity; Vector3 val2 = Vector3.ProjectOnPlane(linearVelocity, Vector3.up); if (flag) { body.AddForce(-val2 * 1.5f, (ForceMode)5); body.AddTorque(-body.angularVelocity * 1.5f, (ForceMode)5); } float num3 = Vector3.Dot(val2, normalized); float forwardSpeed = Mathf.Max(0f, num3); if (flag4) { float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > 0.0001f) { body.AddForce(val2 / magnitude * FlightRules.AirbrakeAcceleration(magnitude, instance.AirbrakeRate.Value, fixedDeltaTime), (ForceMode)5); } if (hoverOn) { hoverPoint.x = ((Component)this).transform.position.x; hoverPoint.z = ((Component)this).transform.position.z; hoverLocked = magnitude < 0.2f; } } if (engineOn && !hoverOn && !flag4) { Vector3 val3 = Vector3.ClampMagnitude(normalized * speed - val2, (instance.Acceleration.Value + 5f * power) * fixedDeltaTime); body.AddForce(val3 / Mathf.Max(0.001f, fixedDeltaTime), (ForceMode)5); } float num4 = (flag5 ? 0f : FlightRules.PoweredVertical(power, pitchAngle, forwardSpeed, instance.ClimbRate.Value, instance.DescentRate.Value)); if (hoverOn && flag6) { float num5 = (flag3 ? verticalCommand : 0f); Vector3 position = ((Component)this).transform.position; if (!flag4) { if (!hoverLocked) { body.AddForce(Vector3.ClampMagnitude(-val2 * 3f, instance.Braking.Value), (ForceMode)5); hoverPoint.x = position.x; hoverPoint.z = position.z; if (((Vector3)(ref val2)).magnitude < 0.2f) { hoverLocked = true; } } else { Vector3 val4 = Vector3.ProjectOnPlane(hoverPoint - position, Vector3.up); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(FlightRules.HoverHorizontal(val4.x, val2.x), 0f, FlightRules.HoverHorizontal(val4.z, val2.z)); body.AddForce(Vector3.ClampMagnitude(val5, 6f), (ForceMode)5); } } if (Mathf.Abs(num5) > 0.1f || Mathf.Abs(lastVertical) > 0.1f) { hoverPoint.y = position.y; } lastVertical = num5; hoverPoint.y = Mathf.Min(500f, hoverPoint.y); float num6 = FlightRules.HoverVertical(hoverPoint.y - position.y, num5, instance.HoverRate.Value); if (power < 0.5f) { num6 = Mathf.Min(num6, FlightRules.PoweredVertical(power, 0f, 0f, instance.ClimbRate.Value, instance.DescentRate.Value)); hoverPoint.y = position.y; } if ((!flag && !(MeasureHeight() < 0.1f)) || num6 > 0f) { float num7 = 0f - Physics.gravity.y + Mathf.Clamp((num6 - linearVelocity.y) * 3f, -8f, 8f); body.AddForce(Vector3.up * num7, (ForceMode)5); } else { hoverPoint.y = position.y; } } if (!hoverOn && flag6 && (!flag2 || num4 > 0f)) { if (((Component)this).transform.position.y > 500f) { num4 = Mathf.Min(0f, num4); } float num8 = 0f - Physics.gravity.y + Mathf.Clamp((num4 - linearVelocity.y) * 3f, -8f, 8f); body.AddForce(Vector3.up * num8, (ForceMode)5); } rotation = body.rotation; float angle = Mathf.DeltaAngle(0f, ((Quaternion)(ref rotation)).eulerAngles.z); float num9 = ((engineOn && flag6 && !flag2 && !hoverOn) ? FlightRules.BankAcceleration(angle, Physics.gravity.y) : 0f); if (num9 != 0f) { Rigidbody obj = body; val = Vector3.ProjectOnPlane(((Component)this).transform.right, Vector3.up); obj.AddForce(((Vector3)(ref val)).normalized * num9, (ForceMode)5); } float num10 = FlightRules.CombinedYaw((!flag2 && !hoverOn && flag6) ? FlightRules.BankYaw(num9, ((Vector3)(ref val2)).magnitude) : (num * instance.YawRate.Value), rudder, instance.RudderRate.Value); if (engineOn || !flag2) { heading += num10 * fixedDeltaTime * (flag2 ? 0.55f : 1f); } float num11 = (hoverOn ? 0f : FlightRules.Bank(num, forwardSpeed, flag2, instance.BankAngle.Value)); Quaternion val6 = Quaternion.Euler(0f - pitchAngle, heading, num11) * Quaternion.Inverse(body.rotation); float num12 = default(float); Vector3 val7 = default(Vector3); ((Quaternion)(ref val6)).ToAngleAxis(ref num12, ref val7); if (num12 > 180f) { num12 -= 360f; } if (!parked && FlightRules.Finite(val7.x) && FlightRules.Finite(val7.y) && FlightRules.Finite(val7.z)) { body.AddTorque(val7 * (num12 * ((float)Math.PI / 180f) * 8f) - body.angularVelocity * 3f, (ForceMode)5); } if (Time.time >= stateAt) { stateAt = Time.time + 0.1f; view.GetZDO().Set("cg_airbrake_v1", flag4); view.GetZDO().Set("cg_parked_v1", parked); view.GetZDO().Set("cg_reverse_v1", flag5); view.GetZDO().Set("cg_reverse_selected_v2", flag2 && flag3 && !hoverOn && FlightRules.ReverseHeld(command.y)); view.GetZDO().Set("cg_speed_v1", num3); view.GetZDO().Set("cg_speed_abs_v2", ((Vector3)(ref val2)).magnitude); view.GetZDO().Set("cg_ground_v1", flag2); view.GetZDO().Set("cg_steer_v1", num); view.GetZDO().Set("cg_power_v2", power); view.GetZDO().Set("cg_pitch_v2", pitchAngle); view.GetZDO().Set("cg_spin_v2", rotorSpin); view.GetZDO().Set("cg_agl_v2", MeasureHeight()); view.GetZDO().Set("cg_stickpitch_v2", hoverOn ? 0f : num2); if (hoverOn) { view.GetZDO().Set("cg_hover_point_v1", hoverPoint); view.GetZDO().Set("cg_hover_lock_v1", hoverLocked); } } if (Occupied && engineOn && flag3 && Time.time >= diagnosticAt) { diagnosticAt = Time.time + 5f; GyroPlugin.LogInfo("Drive: throttle=" + (power * 100f).ToString("F1") + "%, adjust=" + adjustment + ", pitch=" + pitchAngle.ToString("F1") + ", turn=" + num.ToString("F2") + ", target=" + speed.ToString("F2") + ", actual=" + ((Vector3)(ref val2)).magnitude.ToString("F2") + "m/s, vy=" + linearVelocity.y.ToString("F2") + ", ready=" + flag6 + ", water=" + flag + ", reverse=" + flag5 + ", surface=" + flag2 + ", constraints=" + ((object)body.constraints/*cast due to .constrained prefix*/).ToString() + ", kinematic=" + body.isKinematic); } if (!(Time.time >= sweepAt)) { return; } sweepAt = Time.time + 1f; for (int i = 0; i < 2; i++) { long num13 = Occupant(i); if (num13 != 0L) { Player player = Player.GetPlayer(num13); if (Time.time - lease[i] > 5f || ((!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead()) && Time.time - lease[i] > 2f)) { view.GetZDO().Set((i == 0) ? "cg_pilot_v1" : "cg_passenger_v1", 0L); } } } if (!Occupied && flag2 && ((Vector3)(ref val2)).magnitude < 1f) { view.GetZDO().Set("cg_engine_v1", false); view.GetZDO().Set("cg_lights_v1", false); speed = 0f; power = 0f; view.GetZDO().Set("cg_power_v2", 0f); } if (Object.op_Implicit((Object)(object)cargo) && cargo.GetInventory() != null) { body.mass = 600f + Mathf.Clamp(cargo.GetInventory().GetTotalWeight() * 0.5f, 0f, 600f); } } private void Update() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) if (!Valid) { return; } bool engineOn = EngineOn; float num = PowerPercent * 0.01f; rpm = Mathf.MoveTowards(rpm, engineOn ? (240f + num * 220f) : 0f, Time.deltaTime * 150f); if (Object.op_Implicit((Object)(object)stick)) { stick.localRotation = Quaternion.Slerp(stick.localRotation, Quaternion.Euler((0f - view.GetZDO().GetFloat("cg_stickpitch_v2", 0f)) * 12f, 0f, (0f - view.GetZDO().GetFloat("cg_steer_v1", 0f)) * 12f), Time.deltaTime * 8f); } if (Object.op_Implicit((Object)(object)rotor)) { rotor.Rotate(Vector3.up, rpm * 6f * Time.deltaTime, (Space)1); } if (Object.op_Implicit((Object)(object)pusher)) { pusher.Rotate(Vector3.forward, rpm * 12f * Time.deltaTime, (Space)1); } Transform[] array = wheels; foreach (Transform val in array) { if (Object.op_Implicit((Object)(object)val)) { val.Rotate(Vector3.right, view.GetZDO().GetFloat("cg_speed_v1", 0f) * Time.deltaTime * 160f, (Space)1); } } Light[] array2 = surveyLights; foreach (Light val2 in array2) { if (Object.op_Implicit((Object)(object)val2)) { Vector3 val3 = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up); if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f) * Vector3.forward; } ((Component)val2).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized + Vector3.down, Vector3.up); ((Behaviour)val2).enabled = engineOn && LampsOn; } } if (Object.op_Implicit((Object)(object)sound)) { if (engineOn && !sound.isPlaying) { sound.Play(); } sound.volume = Mathf.MoveTowards(sound.volume, engineOn ? 0.32f : 0f, Time.deltaTime * 0.35f); sound.pitch = 0.62f + num * 0.9f; if (!engineOn && sound.volume <= 0.001f && sound.isPlaying) { sound.Stop(); } } } private void OnDestroy() { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && Object.op_Implicit((Object)(object)localPlayer.GetAttachPoint()) && localPlayer.GetAttachPoint().IsChildOf(((Component)this).transform)) { ((Character)localPlayer).AttachStop(); localPlayer.StopDoodadControl(); } } } public sealed class GyroSeat : MonoBehaviour, Hoverable, Interactable, IDoodadController { [SerializeField] private int index; [SerializeField] private Transform anchor; [SerializeField] private string animation = "attach_chair"; private bool exitArmed; private bool steeringArmed; private bool rudderArmed; private bool lastAirbrake; private bool reverseSelected; private bool reverseArmed; private bool lastReverse; private GyroController vehicle; private float graceUntil; private float inputAt; private float leaseAt; private float heldAt = -1f; private float hintAt; private int sequence; internal GyroController Vehicle => vehicle; internal Transform Anchor => anchor; internal void Configure(int seat, Transform point, string pose) { index = seat; anchor = point; animation = pose; } private void Awake() { vehicle = ((Component)this).GetComponentInParent<GyroController>(); } internal void BeginLocal(Player player) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)vehicle)) { vehicle = ((Component)this).GetComponentInParent<GyroController>(); } graceUntil = Time.time + 2f; exitArmed = false; steeringArmed = false; rudderArmed = false; lastAirbrake = false; reverseSelected = false; reverseArmed = false; lastReverse = false; heldAt = -1f; Vector3 val = ((Component)vehicle).transform.TransformPoint(new Vector3((index == 0) ? 1.65f : (-1.65f), 0.25f, (index == 0) ? 0.52f : 0f)); Vector3 val2 = anchor.InverseTransformPoint(val); ((Character)player).AttachStart(anchor, ((Component)vehicle).gameObject, true, false, true, animation, val2, (Transform)null); player.StartDoodadControl((IDoodadController)(object)this); if (index == 0) { ((Character)player).Message((MessageType)2, "Shift: throttle + | Ctrl: throttle - | S: nose up | W: nose down | A/D: bank | Q/E: rudder | R: reverse/forward | RMB: brake | V: hover | Space/C: vertical | Hold E parked, engine off: exit", 0, (Sprite)null, false); } } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)vehicle)) { vehicle.RequestSeat(val, index); } return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverName() { return Localization.instance.Localize((index == 0) ? "$cg_pilot" : "$cg_passenger"); } public float GetHoverOffset() { return 0f; } public string GetHoverText() { string text = GetHoverName() + "\n[<color=yellow><b>$KEY_Use</b></color>] " + ((index == 0) ? "$cg_enter" : "$cg_grip"); if (Object.op_Implicit((Object)(object)vehicle)) { text = text + "\n" + Mathf.RoundToInt(vehicle.DisplaySpeed * 3.6f) + " km/h | " + (vehicle.EngineOn ? "Engine on" : "Engine off"); } return Localization.instance.Localize(text); } public bool IsValid() { if (Object.op_Implicit((Object)(object)this) && Object.op_Implicit((Object)(object)vehicle)) { return vehicle.Valid; } return false; } public Component GetControlledComponent() { return (Component)(object)this; } public Vector3 GetPosition() { //IL_001f: 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) if (!Object.op_Implicit((Object)(object)anchor)) { return ((Component)this).transform.position; } return anchor.position; } public void ApplyControlls(Vector3 moveDir, Vector3 lookDir, bool run, bool autoRun, bool block) { } public void OnUseStop(Player player) { GyroInputBlock.MarkSeatFrame(); if (Object.op_Implicit((Object)(object)vehicle)) { vehicle.Release(player, index); } ((Character)player).AttachStop(); heldAt = -1f; } private bool InputBlocked() { if ((!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !TextInput.IsVisible() && !InventoryGui.IsVisible()) { return Menu.IsVisible(); } return true; } private void Update() { //IL_00dd: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_023b: 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_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0393: 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_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)vehicle) || !vehicle.Valid || !Object.op_Implicit((Object)(object)anchor) || (Object)(object)localPlayer.GetAttachPoint() != (Object)(object)anchor) { return; } if (((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || (Time.time > graceUntil && vehicle.Occupant(index) != localPlayer.GetPlayerID())) { ((Character)localPlayer).AttachStop(); localPlayer.StopDoodadControl(); return; } GyroInputBlock.MarkSeatFrame(); GyroPlugin instance = GyroPlugin.Instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } if (Time.time >= leaseAt) { leaseAt = Time.time + 0.5f; vehicle.Ping(localPlayer, index); } bool flag = InputBlocked(); if (!GyroKeys.Held(instance.RudderLeft.Value) && !GyroKeys.Held(instance.RudderRight.Value)) { rudderArmed = true; } if (!GyroKeys.Held(instance.Left.Value) && !GyroKeys.Held(instance.Right.Value)) { steeringArmed = true; } bool flag2 = GyroKeys.Held(instance.Exit.Value); if (!flag2) { exitArmed = true; } if (!flag && exitArmed && flag2) { if (FlightRules.CanDismount(vehicle.Grounded, vehicle.EngineOn, vehicle.DisplaySpeed)) { if (heldAt < 0f) { heldAt = Time.time; } if (Time.time - heldAt >= 1.5f) { localPlayer.StopDoodadControl(); return; } } else { heldAt = -1f; if (!vehicle.EngineOn && Time.time > hintAt) { hintAt = Time.time + 3f; ((Character)localPlayer).Message((MessageType)2, "$cg_land", 0, (Sprite)null, false); } } } else { heldAt = -1f; } if (index == 0) { if (!flag && GyroKeys.Down(instance.Headlights.Value)) { vehicle.Action(localPlayer, 1); } if (!flag && GyroKeys.Down(instance.Hover.Value)) { vehicle.Action(localPlayer, 2); } if (!GyroKeys.Held(instance.Reverse.Value)) { reverseArmed = true; } bool flag3 = !flag && reverseArmed && GyroKeys.Down(instance.Reverse.Value); bool flag4 = FlightRules.ReverseSelection(reverseSelected, flag3, vehicle.Grounded, vehicle.HoverOn); if (flag4 != reverseSelected && flag3) { ((Character)localPlayer).Message((MessageType)2, flag4 ? "Reverse selected - Shift to increase throttle" : "Forward selected", 0, (Sprite)null, false); } reverseSelected = flag4; bool flag5 = !flag && GyroKeys.RightMouseHeld(); if (Time.time >= inputAt || flag5 != lastAirbrake || reverseSelected != lastReverse) { inputAt = Time.time + 0.1f; lastAirbrake = flag5; lastReverse = reverseSelected; float turn = ((!flag && steeringArmed) ? ((GyroKeys.Held(instance.Right.Value) ? 1 : 0) - (GyroKeys.Held(instance.Left.Value) ? 1 : 0)) : 0); int adjustment = ((!flag) ? (GyroKeys.Held(instance.Brake.Value) ? (-1) : (GyroKeys.Held(instance.Accelerate.Value) ? 1 : 0)) : 0); float pitch = ((!flag) ? ((GyroKeys.Held(instance.PitchUp.Value) ? 1 : 0) - (GyroKeys.Held(instance.PitchDown.Value) ? 1 : 0)) : 0); float vertical = ((!flag) ? ((GyroKeys.Held(instance.VerticalUp.Value) ? 1 : 0) - (GyroKeys.Held(instance.VerticalDown.Value) ? 1 : 0)) : 0); vehicle.SendInput(localPlayer, ++sequence, adjustment, reverseSelected, turn, pitch, vertical, (!flag && rudderArmed) ? ((GyroKeys.Held(instance.RudderRight.Value) ? 1 : 0) - (GyroKeys.Held(instance.RudderLeft.Value) ? 1 : 0)) : 0, flag5); } } } } public sealed class GyroCargo : MonoBehaviour, Hoverable, Interactable { private Container cargo; private void Awake() { cargo = ((Component)this).GetComponentInParent<Container>(); } public bool Interact(Humanoid user, bool hold, bool alt) { if (Object.op_Implicit((Object)(object)cargo)) { return cargo.Interact(user, hold, alt); } return false; } public bool UseItem(Humanoid user, ItemData item) { if (Object.op_Implicit((Object)(object)cargo)) { return cargo.UseItem(user, item); } return false; } public string GetHoverName() { if (!Object.op_Implicit((Object)(object)cargo)) { return "Core Gyro Cargo"; } return cargo.GetHoverName(); } public string GetHoverText() { if (!Object.op_Implicit((Object)(object)cargo)) { return ""; } return cargo.GetHoverText(); } public float GetHoverOffset() { return 0f; } } internal static class FlightRules { internal const float DefaultMaximumSpeedMps = 22f; internal const float ReverseLimit = 1.388889f; internal const float ReverseCreep = 5f / 9f; internal const float DismountHoldSeconds = 1.5f; internal const float EmptyMass = 600f; internal static bool Finite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } internal static float Approach(float current, float target, float step) { if (!(current < target)) { return Math.Max(target, current - step); } return Math.Min(target, current + step); } internal static float Throttle(float power, int adjustment, bool fresh, float dt, float increase, float decrease) { if (!Finite(power)) { power = 0f; } power = Math.Max(0f, Math.Min(1f, power)); if (!Finite(dt) || dt <= 0f) { return power; } dt = Math.Min(0.1f, dt); if (!fresh || adjustment < 0) { return Approach(power, 0f, decrease * 0.01f * dt); } if (adjustment <= 0) { return power; } return Approach(power, 1f, increase * 0.01f * dt); } internal static float DriveSpeed(float current, float power, bool engine, bool reverse, float dt, float max, float acceleration, float braking) { if (!Finite(current)) { current = 0f; } if (!Finite(power)) { power = 0f; } power = Math.Max(0f, Math.Min(1f, power)); current = Math.Max(-1.388889f, Math.Min(max, current)); if (!Finite(dt) || dt <= 0f) { return current; } dt = Math.Min(dt, 0.1f); float num = ((!engine) ? 0f : (reverse ? (0f - Math.Max(5f / 9f, 1.388889f * power)) : (max * power))); if (current * num < 0f) { return Approach(current, 0f, braking * dt); } return Approach(current, num, ((Math.Abs(num) > Math.Abs(current)) ? acceleration : braking) * dt); } internal static float Pitch(float angle, float input, float dt, float rate, float limit) { if (!Finite(angle)) { angle = 0f; } if (!Finite(input)) { input = 0f; } if (!Finite(dt) || dt <= 0f) { return angle; } return Math.Max(0f - limit, Math.Min(limit, angle + Math.Max(-1f, Math.Min(1f, input)) * rate * Math.Min(dt, 0.1f))); } internal static float Buoyancy(float depth, float verticalVelocity) { if (!Finite(depth) || !Finite(verticalVelocity) || depth <= 0f) { return 0f; } return Math.Max(0f, Math.Min(60f, Math.Min(depth, 0.65f) * 60f - verticalVelocity * 10f)); } internal static bool WaterColumn(float x, float z, float minX, float maxX, float minZ, float maxZ) { if (Finite(x) && Finite(z) && x >= minX && x <= maxX && z >= minZ) { return z <= maxZ; } return false; } internal static bool ValidWaterLevel(float level) { if (Finite(level)) { return level > -9999f; } return false; } internal static bool Wet(float depth) { if (Finite(depth)) { return depth > 0f; } return false; } internal static bool WaterContact(float depth) { if (Finite(depth)) { return depth > -0.2f; } return false; } internal static bool ReverseSelection(bool current, bool pressed, bool surface, bool hover) { if (surface && !hover) { if (!pressed) { return current; } return !current; } return false; } internal static bool CommandAllowed(long actor, long pilot, long sender, long actorOwner, float distance, bool alive) { if (actor != 0L && actor == pilot && sender == actorOwner && alive && Finite(distance)) { return distance <= 12f; } return false; } internal static bool SeatAllowed(long actor, long occupant, long other, long sender, long actorOwner, float distance, bool alive) { if (actor != 0L && sender == actorOwner && alive && Finite(distance) && distance <= 3.5f && (occupant == 0L || occupant == actor)) { return other != actor; } return false; } internal static bool Fresh(float now, float received) { if (Finite(now) && Finite(received) && received > 0f && now >= received) { return now - received <= 1.2f; } return false; } internal static bool RotorReady(bool engine, float spin) { if (engine && Finite(spin)) { return spin >= 1f; } return false; } internal static float PoweredVertical(float power, float pitch, float forwardSpeed, float climb, float descend) { power = Math.Max(0f, Math.Min(1f, power)); float num = (power - 0.5f) * 2f * 2.5f; float num2 = (float)Math.Sin((double)pitch * Math.PI / 180.0) * Math.Max(0f, forwardSpeed); return Math.Max(0f - descend, Math.Min(climb, num + num2)); } internal static int DriveFlags(bool reverse, bool airbrake) { return (reverse ? 1 : 0) | (airbrake ? 2 : 0); } internal static bool ValidDriveFlags(float value) { if (Finite(value) && value >= 0f && value <= 3f) { return value == (float)(int)value; } return false; } internal static bool ReverseHeld(float flags) { if (ValidDriveFlags(flags)) { return ((int)flags & 1) != 0; } return false; } internal static bool AirbrakeHeld(float flags) { if (ValidDriveFlags(flags)) { return ((int)flags & 2) != 0; } return false; } internal static float AirbrakeAcceleration(float velocity, float deceleration, float dt) { if (!Finite(velocity) || !Finite(deceleration) || !Finite(dt) || deceleration <= 0f || dt <= 0f) { return 0f; } return (float)(-Math.Sign(velocity)) * Math.Min(deceleration, Math.Abs(velocity) / dt); } internal static bool CanDismount(bool surface, bool engine, float speed) { if (surface && !engine && Finite(speed) && speed >= 0f) { return speed < 1f; } return false; } internal static bool BlockNativeAction(string name, bool seated) { if (!seated) { return false; } switch (name) { default: return name == "JoyAutoPickup"; case "Hide": case "JoyHide": case "Block": case "JoyBlock": case "Use": case "JoyUse": case "AutoRun": case "JoyAutoRun": case "ToggleWalk": case "AutoPickup": return true; } } internal static float OrbitZoom(float distance, float scroll) { if (!Finite(distance)) { distance = 8f; } if (!Finite(scroll)) { scroll = 0f; } return Math.Max(5f, Math.Min(20f, distance - scroll * 10f)); } internal static bool CanHover(bool engine, float power) { if (engine && Finite(power)) { return power >= 0.5f; } return false; } internal static float HoverHorizontal(float error, float velocity) { if (!Finite(error) || !Finite(velocity)) { return 0f; } float num = Math.Max(-3f, Math.Min(3f, error * 1.6f)); return Math.Max(-6f, Math.Min(6f, (num - velocity) * 3f)); } internal static float HoverVertical(float heightError, float input, float limit) { if (!Finite(heightError) || !Finite(input) || !Finite(limit) || limit <= 0f) { return 0f; } if (Math.Abs(input) > 0.1f) { return Math.Max(-1f, Math.Min(1f, input)) * limit; } return Math.Max(0f - limit, Math.Min(limit, heightError * 1.8f)); } internal static bool ParkEligible(bool supported, bool water, bool engine, bool hover, float speed, float verticalSpeed, float angularSpeed) { if (supported && !water && !engine && !hover && Finite(speed) && Finite(verticalSpeed) && Finite(angularSpeed) && speed < 0.35f && Math.Abs(verticalSpeed) < 0.25f) { return angularSpeed < 0.35f; } return false; } internal static float BankAcceleration(float angle, float gravity) { if (!Finite(angle) || !Finite(gravity)) { return 0f; } angle = Math.Max(-65f, Math.Min(65f, angle)); return Math.Max(-18f, Math.Min(18f, (0f - (float)Math.Tan((double)angle * Math.PI / 180.0)) * Math.Abs(gravity))); } internal static float BankYaw(float lateralAcceleration, float speed) { if (!Finite(lateralAcceleration) || !Finite(speed)) { return 0f; } return Math.Max(-60f, Math.Min(60f, lateralAcceleration / Math.Max(5f, Math.Abs(speed)) * 180f / (float)Math.PI)); } internal static float CombinedYaw(float bankYaw, float rudder, float rudderRate) { if (!Finite(bankYaw) || !Finite(rudder) || !Finite(rudderRate)) { return 0f; } return Math.Max(-120f, Math.Min(120f, bankYaw + Math.Max(-1f, Math.Min(1f, rudder)) * rudderRate)); } internal static float Bank(float turn, float speed, bool grounded, float maxBank) { if (!grounded) { return (0f - Math.Max(-1f, Math.Min(1f, turn))) * maxBank * Math.Min(1f, Math.Max(0f, speed) / 5f); } return 0f; } } internal static class GyroKeys { private static bool Modifiers(KeyboardShortcut key) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) foreach (KeyCode modifier in ((KeyboardShortcut)(ref key)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } internal static bool Held(KeyboardShortcut key) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref key)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref key)).MainKey)) { return Modifiers(key); } return false; } internal static bool RightMouseHeld() { return Input.GetMouseButton(1); } internal static bool Down(KeyboardShortcut key) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref key)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref key)).MainKey)) { return Modifiers(key); } return false; } } internal static class NativeModel { private sealed class Fit { internal GameObject Holder; internal Transform Content; internal Bounds Bounds; internal Transform SourceRoot; } private static PhysicsMaterial wheelMaterial; private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>(); private static AudioClip engineClip; internal static Vector3 V(P p) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(p.X, p.Y, p.Z); } private static GameObject Child(Transform parent, string name, Vector3 position) { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = position; val.layer = LayerMask.NameToLayer("piece"); return val; } private static PhysicsMaterial RollingContact() { //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_0021: 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_0037: 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_004a: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)wheelMaterial)) { wheelMaterial = new PhysicsMaterial("CoreGyro_RollingContact") { staticFriction = 0.03f, dynamicFriction = 0.03f, bounciness = 0f, frictionCombine = (PhysicsMaterialCombine)2, bounceCombine = (PhysicsMaterialCombine)2 }; } return wheelMaterial; } private static Fit Copy(NativePart part, Transform parent) { //IL_0026: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0377: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ee: 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_00e3: Unknown result type (might be due to invalid IL or missing references) GameObject val = GyroPlugin.Native(part.Prefab); MeshFilter[] componentsInChildren = ((Component)val.transform.Find(part.Path)).GetComponentsInChildren<MeshFilter>(true); Bounds bounds = default(Bounds); bool flag = false; MeshFilter[] array = componentsInChildren; foreach (MeshFilter val2 in array) { MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>(); if (!Object.op_Implicit((Object)(object)val2.sharedMesh) || !Object.op_Implicit((Object)(object)component)) { continue; } Matrix4x4 val3 = val.transform.worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix; Bounds bounds2 = val2.sharedMesh.bounds; for (int j = 0; j < 8; j++) { Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(((Bounds)(ref bounds2)).center + Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))))); if (flag) { ((Bounds)(ref bounds)).Encapsulate(val4); continue; } ((Bounds)(ref bounds))..ctor(val4, Vector3.zero); flag = true; } } if (!flag) { throw new InvalidOperationException("Native mesh missing: " + part.Prefab + "/" + part.Path); } GameObject val5 = Child(parent, part.Name, V(part.Position)); val5.transform.localRotation = Quaternion.Euler(V(part.Rotation)); GameObject val6 = Child(val5.transform, "Native visual", Vector3.zero); Vector3 val7 = default(Vector3); ((Vector3)(ref val7))..ctor(part.Size.X / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.x), part.Size.Y / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.y), part.Size.Z / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.z)); val6.transform.localScale = val7; val6.transform.localPosition = -Vector3.Scale(((Bounds)(ref bounds)).center, val7); array = componentsInChildren; foreach (MeshFilter val8 in array) { MeshRenderer component2 = ((Component)val8).GetComponent<MeshRenderer>(); if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)val8.sharedMesh)) { Matrix4x4 val9 = val.transform.worldToLocalMatrix * ((Component)val8).transform.localToWorldMatrix; GameObject obj = Child(val6.transform, ((Object)val8).name, Vector3.zero); obj.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val9)).GetColumn(3)); obj.transform.localRotation = ((Matrix4x4)(ref val9)).rotation; obj.transform.localScale = ((Matrix4x4)(ref val9)).lossyScale; obj.AddComponent<MeshFilter>().sharedMesh = val8.sharedMesh; MeshRenderer obj2 = obj.AddComponent<MeshRenderer>(); ((Renderer)obj2).sharedMaterials = ((part.Name == "Engine core" || part.Name == "Survey core") ? ((Renderer)component2).sharedMaterials : Styled(((Renderer)component2).sharedMaterials, part.Tone)); ((Renderer)obj2).enabled = !GyroPlugin.Headless; ((Renderer)obj2).shadowCastingMode = ((Renderer)component2).shadowCastingMode; ((Renderer)obj2).receiveShadows = true; } } return new Fit { Holder = val5, Content = val6.transform, Bounds = bounds, SourceRoot = val.transform }; } private static Material[] Styled(Material[] source, string tone) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) Material[] array = (Material[])(object)new Material[source.Length]; for (int i = 0; i < source.Length; i++) { Material val = source[i]; if (!Object.op_Implicit((Object)(object)val)) { array[i] = val; continue; } string key = ((Object)val).GetInstanceID() + ":" + tone; if (!Materials.TryGetValue(key, out var value)) { value = new Material(val); ((Object)value).name = "CoreGyro_" + tone + "_" + ((Object)val).name; Color val2 = (Color)(tone switch { "Timber" => new Color(0.85f, 0.65f, 0.39f), "Iron" => new Color(0.16f, 0.17f, 0.18f), "Leather" => new Color(0.37f, 0.17f, 0.075f), "Brass" => new Color(0.64f, 0.39f, 0.17f), _ => new Color(0.32f, 0.29f, 0.24f), }); if (value.HasProperty("_Color")) { value.SetColor("_Color", val2); } if (tone == "Brass" || tone == "Iron") { if (value.HasProperty("_Metallic")) { value.SetFloat("_Metallic", 0.8f); } if (value.HasProperty("_Glossiness")) { value.SetFloat("_Glossiness", 0.45f); } } Materials[key] = value; } array[i] = value; } return array; } internal static GameObject Build(GameObject root, GyroController controller) { //IL_000b: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_036f: 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_0396: 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_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) GameObject val = Child(root.transform, "GyroModel", Vector3.zero); GameObject val2 = Child(val.transform, "MainRotor", new Vector3(0f, 3.5f, -0.46f)); GameObject val3 = Child(val.transform, "RearPropeller", new Vector3(0f, 1.8f, -1.85f)); GameObject val4 = Child(val.transform, "PilotControlStick", V(ModelSpec.StickPivot)); Dictionary<string, Transform> dictionary = new Dictionary<string, Transform> { { "Body", val.transform }, { "Rotor", val2.transform }, { "Pusher", val3.transform }, { "Stick", val4.transform } }; GyroSeat[] array = new GyroSeat[2]; List<Transform> list = new List<Transform>(); foreach (NativePart item in ModelSpec.Parts()) { Fit fit = Copy(item, dictionary[item.Group]); if (item.Name.Contains("wheel")) { list.Add(fit.Holder.transform); SphereCollider obj = fit.Holder.AddComponent<SphereCollider>(); obj.radius = item.Size.Y * 0.49f; ((Collider)obj).sharedMater