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 CarVehicleMod v1.0.0
plugins/Carvehiclemod/CarVehicleMod.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("CarVehicleMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CarVehicleMod")] [assembly: AssemblyTitle("CarVehicleMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HmmwvMod { internal static class AbramsShellAssets { internal static void Initialize() { GunRoundAssets.Initialize(); } internal static GameObject Prefab(bool incendiary) { return GunRoundAssets.Shell120(incendiary); } } internal class AbramsShellVisual : MonoBehaviour { private Vector3 _dir; private float _speed; private float _life; private Transform _ignoreRoot; private TankTurret _turret; private Player _attacker; private bool _incendiary; private bool _armed; private bool _dead; private LineRenderer _trail; private LineRenderer _trailGlow; internal static AbramsShellVisual Spawn(Vector3 origin, Vector3 dir, bool incendiary, Transform ignoreRoot, TankTurret host) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref dir)).sqrMagnitude < 0.0001f) { dir = Vector3.forward; } ((Vector3)(ref dir)).Normalize(); GunRoundAssets.Initialize(); GameObject val = GunRoundAssets.MakeShell(incendiary, origin, dir); if ((Object)(object)val == (Object)null) { val = MakeFallback(incendiary); } val.transform.SetPositionAndRotation(origin, Quaternion.LookRotation(dir, Vector3.up)); AbramsShellVisual abramsShellVisual = val.AddComponent<AbramsShellVisual>(); float num = (incendiary ? 88f : 165f); float num2 = (incendiary ? 420f : 500f); abramsShellVisual._dir = dir; abramsShellVisual._speed = num; abramsShellVisual._life = num2 / Mathf.Max(1f, num); abramsShellVisual._ignoreRoot = ignoreRoot; abramsShellVisual._turret = host; abramsShellVisual._incendiary = incendiary; EnsureTrail(val, dir, incendiary, out abramsShellVisual._trail, out abramsShellVisual._trailGlow); return abramsShellVisual; } internal void Arm(TankTurret turret, Player attacker) { _turret = turret; _attacker = attacker; _armed = true; } private void Update() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00aa: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if (_dead) { return; } float deltaTime = Time.deltaTime; float num = _speed * deltaTime; Vector3 position = ((Component)this).transform.position; float num2 = (_incendiary ? 0.18f : 0.1f); RaycastHit val = default(RaycastHit); if (Physics.SphereCast(position, num2, _dir, ref val, num + 0.1f, -1, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val)).collider != (Object)null && ((Object)(object)_ignoreRoot == (Object)null || (Object)(object)((Component)((RaycastHit)(ref val)).collider).transform.root != (Object)(object)_ignoreRoot)) { Impact(((RaycastHit)(ref val)).point); return; } ((Component)this).transform.position = position + _dir * num; _life -= deltaTime; float num3 = (_incendiary ? 12f : 18f); Vector3 val2 = ((Component)this).transform.position - _dir * num3; if ((Object)(object)_trail != (Object)null) { _trail.SetPosition(0, ((Component)this).transform.position); _trail.SetPosition(1, val2); } if ((Object)(object)_trailGlow != (Object)null) { _trailGlow.SetPosition(0, ((Component)this).transform.position); _trailGlow.SetPosition(1, ((Component)this).transform.position - _dir * (num3 + 4f)); } if (_life <= 0f) { Impact(((Component)this).transform.position); } } private void Impact(Vector3 point) { //IL_002c: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (_dead) { return; } _dead = true; if ((Object)(object)_turret != (Object)null) { if (_incendiary) { _turret.DetonateIncendiary(point, _armed ? _attacker : null, _armed); } if (_armed) { _turret.DetonateApfsds(point, _dir, _attacker); } else { _turret.PlayMissileBlast(point); } } Object.Destroy((Object)(object)((Component)this).gameObject); } private static void StripPhysics(GameObject go) { Collider[] componentsInChildren = go.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { Object.Destroy((Object)(object)componentsInChildren[i]); } } Rigidbody[] componentsInChildren2 = go.GetComponentsInChildren<Rigidbody>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if ((Object)(object)componentsInChildren2[j] != (Object)null) { Object.Destroy((Object)(object)componentsInChildren2[j]); } } } private static void FitShellScale(GameObject go, bool incendiary) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0090: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } } Vector3 size = ((Bounds)(ref bounds)).size; float magnitude = ((Vector3)(ref size)).magnitude; if (!(magnitude < 0.04f) && !(magnitude > 80f)) { float num = (incendiary ? 0.55f : 0.82f); if (magnitude > 2.4f) { Transform transform = go.transform; transform.localScale *= num / magnitude; } } } private static GameObject MakeFallback(bool incendiary) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(incendiary ? "m1a2_shell_incendiary" : "m1a2_shell_apfsds"); GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2); Object.Destroy((Object)(object)val2.GetComponent<Collider>()); val2.transform.SetParent(val.transform, false); val2.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); if (incendiary) { val2.transform.localScale = new Vector3(0.11f, 0.22f, 0.11f); Tint(val2, new Color(0.72f, 0.32f, 0.08f)); } else { val2.transform.localScale = new Vector3(0.045f, 0.38f, 0.045f); Tint(val2, new Color(0.62f, 0.64f, 0.58f)); for (int i = 0; i < 4; i++) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.transform.SetParent(val.transform, false); float num = (float)i * 90f; obj.transform.localRotation = Quaternion.Euler(0f, num, 0f); obj.transform.localPosition = new Vector3(0f, 0f, -0.28f); obj.transform.localScale = new Vector3(0.16f, 0.012f, 0.1f); Tint(obj, new Color(0.45f, 0.46f, 0.42f)); } } return val; } private static void Tint(GameObject go, Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) MaterialShaderFixer.ApplySolid(((Object)(object)go != (Object)null) ? go.GetComponent<Renderer>() : null, color, "m1a2_shell"); } private static void EnsureTrail(GameObject go, Vector3 dir, bool incendiary, out LineRenderer core, out LineRenderer glow) { //IL_0032: 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) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0108: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) Color val = (incendiary ? new Color(1f, 0.42f, 0.08f, 1f) : new Color(1f, 0.96f, 0.72f, 0.95f)); float startW = (incendiary ? 0.72f : 0.48f); float endW = (incendiary ? 0.14f : 0.1f); float startW2 = (incendiary ? 1.35f : 0.95f); float endW2 = (incendiary ? 0.28f : 0.18f); float num = (incendiary ? 12f : 18f); core = MakeTrailLine(go, "trail_core", dir, num, startW, endW, val); glow = MakeTrailLine(go, "trail_glow", dir, num + 4f, startW2, endW2, incendiary ? new Color(1f, 0.55f, 0.12f, 0.55f) : new Color(1f, 0.92f, 0.45f, 0.45f)); AbramsBurnZone.AttachBlob(go.transform, Vector3.zero, incendiary ? 0.55f : 0.32f, val); if (incendiary) { AbramsBurnZone.AttachBlob(go.transform, Vector3.back * 0.35f, 0.85f, new Color(1f, 0.28f, 0.04f, 0.9f)); } GameObject val2 = new GameObject(incendiary ? "incendiary_glow" : "apfsds_glow"); val2.transform.SetParent(go.transform, false); Light obj = val2.AddComponent<Light>(); obj.type = (LightType)2; obj.color = (incendiary ? new Color(1f, 0.45f, 0.08f) : new Color(1f, 0.92f, 0.55f)); obj.range = (incendiary ? 9f : 6.5f); obj.intensity = (incendiary ? 8f : 5.5f); } private static LineRenderer MakeTrailLine(GameObject parent, string name, Vector3 dir, float length, float startW, float endW, Color col) { //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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent.transform, false); LineRenderer obj = val.AddComponent<LineRenderer>(); obj.useWorldSpace = true; obj.positionCount = 2; obj.numCapVertices = 4; obj.numCornerVertices = 2; obj.alignment = (LineAlignment)0; obj.startWidth = startW; obj.endWidth = endW; MaterialShaderFixer.ApplyLine(obj, col, new Color(col.r, col.g, col.b, 0f)); obj.SetPosition(0, parent.transform.position); obj.SetPosition(1, parent.transform.position - dir * length); return obj; } } internal class AbramsBurnZone : MonoBehaviour { private TankTurret _turret; private Player _attacker; private float _life; private float _nextTick; internal static void Spawn(Vector3 point, TankTurret turret, Player attacker, bool applyDamage) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_004b: 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) GameObject val = new GameObject("m1a2_burn_zone"); val.transform.position = point; AbramsBurnZone abramsBurnZone = val.AddComponent<AbramsBurnZone>(); abramsBurnZone._turret = (applyDamage ? turret : null); abramsBurnZone._attacker = attacker; abramsBurnZone._life = 12f; abramsBurnZone._nextTick = 0f; SpawnFireFx(val, point); TryValheimFireVfx(point); if (applyDamage) { StokeNearbyFires(point, turret, attacker); } } private void Update() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) _life -= Time.deltaTime; if (_life <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); } else if (!(Time.time < _nextTick)) { _nextTick = Time.time + 0.4f; _turret?.ApplyBurnTick(((Component)this).transform.position, _attacker); } } private static void SpawnFireFx(GameObject go, Vector3 point) { //IL_001d: 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_0047: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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_0202: 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_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) Light obj = go.AddComponent<Light>(); obj.type = (LightType)2; obj.color = new Color(1f, 0.48f, 0.12f); obj.range = 12f; obj.intensity = 11f; GameObject val = new GameObject("flame"); val.transform.SetParent(go.transform, false); ParticleSystem val2 = val.AddComponent<ParticleSystem>(); MainModule main = val2.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).duration = 1f; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.15f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1.4f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(2.4f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.45f, 0.08f, 0.95f)); ((MainModule)(ref main)).maxParticles = 96; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.35f); EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(48f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 1.65f; ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(new Color(1f, 0.85f, 0.25f), 0f), new GradientColorKey(new Color(1f, 0.28f, 0.04f), 0.45f), new GradientColorKey(new Color(0.12f, 0.08f, 0.06f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0.15f, 0f), new GradientAlphaKey(0.9f, 0.12f), new GradientAlphaKey(0.55f, 0.55f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3); ParticleSystemRenderer component = go.GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component == (Object)null) { component = val.GetComponent<ParticleSystemRenderer>(); } if ((Object)(object)component != (Object)null) { component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; } MaterialShaderFixer.ApplyParticle(val2, new Color(1f, 0.5f, 0.1f, 0.8f), additive: true); val2.Play(); AddFireBlob(go.transform, Vector3.up * 0.4f, 2.8f, new Color(1f, 0.85f, 0.25f, 1f)); AddFireBlob(go.transform, Vector3.up * 1.1f, 3.6f, new Color(1f, 0.35f, 0.05f, 0.95f)); AddFireBlob(go.transform, Vector3.up * 1.9f, 2.4f, new Color(1f, 0.18f, 0.02f, 0.8f)); } private static void StokeNearbyFires(Vector3 point, TankTurret turret, Player attacker) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 6; i++) { float num = (float)i * 60f * ((float)Math.PI / 180f); SpawnEmber(point + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * 2.35f + Vector3.up * 0.08f, null); } Collider[] array = Physics.OverlapSphere(point, 6.8f, -1, (QueryTriggerInteraction)1); if (array == null) { return; } int num2 = 0; HashSet<int> hashSet = new HashSet<int>(); for (int j = 0; j < array.Length; j++) { if (num2 >= 16) { break; } Collider val = array[j]; if (!((Object)(object)val == (Object)null) && (!((Object)(object)turret != (Object)null) || !((Object)(object)((Component)val).transform.root == (Object)(object)((Component)turret).transform.root))) { int instanceID = ((Object)((Component)val).transform.root).GetInstanceID(); if (hashSet.Add(instanceID)) { Vector3 val2 = val.ClosestPoint(point); SpawnEmber(follow: IsTerrain(val) ? null : ((Component)val).transform, point: val2 + Vector3.up * 0.15f); TryValheimFireVfx(val2); num2++; } } } } private static bool IsTerrain(Collider col) { if ((Object)(object)col == (Object)null) { return false; } if (((object)col).GetType().Name == "TerrainCollider") { return true; } if (!((Object)(object)((Component)col).GetComponent<Heightmap>() != (Object)null)) { return (Object)(object)((Component)((Component)col).transform.root).GetComponent<Heightmap>() != (Object)null; } return true; } internal static void AttachFire(Transform host, Vector3 worldPoint) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)host == (Object)null) { return; } for (int i = 0; i < host.childCount; i++) { if (((Object)host.GetChild(i)).name == "m1a2_ember") { return; } } SpawnEmber(worldPoint, host); } internal static void AttachBlob(Transform parent, Vector3 localPos, float size, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) AddFireBlob(parent, localPos, size, color); } private static void SpawnEmber(Vector3 point, Transform follow) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("m1a2_ember"); val.transform.position = point; if ((Object)(object)follow != (Object)null) { val.transform.SetParent(follow, true); } Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = new Color(1f, 0.4f, 0.08f); obj.range = 5.5f; obj.intensity = 5.5f; AddFireBlob(val.transform, Vector3.up * 0.25f, 1.8f, new Color(1f, 0.7f, 0.15f, 1f)); AddFireBlob(val.transform, Vector3.up * 0.85f, 2.4f, new Color(1f, 0.28f, 0.04f, 0.9f)); Object.Destroy((Object)(object)val, 12f); } private static void AddFireBlob(Transform parent, Vector3 localPos, float size, Color color) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)obj.GetComponent<Collider>()); ((Object)obj).name = "fire_blob"; obj.transform.SetParent(parent, false); obj.transform.localPosition = localPos; obj.transform.localScale = Vector3.one * size; MeshRenderer component = obj.GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; Material val = MaterialShaderFixer.MakeFx(color, additive: true); if ((Object)(object)val != (Object)null) { ((Renderer)component).material = val; } } } private static void TryValheimFireVfx(Vector3 point) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if (!((Object)(object)instance == (Object)null)) { GameObject val = instance.GetPrefab("vfx_FireWork") ?? instance.GetPrefab("vfx_Fire") ?? instance.GetPrefab("vfx_burning") ?? instance.GetPrefab("vfx_foresttroll_hit") ?? instance.GetPrefab("fx_fireball_explosion"); if (!((Object)(object)val == (Object)null)) { Object.Destroy((Object)(object)Object.Instantiate<GameObject>(val, point, Quaternion.identity), 12.5f); } } } } internal static class ArmorHullColliders { internal struct Profile { internal string Label; internal string[] HullObjects; internal string[] TurretObjects; internal float BellyAboveHub; internal float DeckSlice; internal float DeckLengthFrac; internal float HullShrink; internal float WidthShrink; internal float TurretShrink; } internal static bool Apply(Transform root, BoxCollider body, BoxCollider hood, BoxCollider trunk, WheelCollider[] wheels, Transform visualRoot, Profile p) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0253: 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_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null || (Object)(object)visualRoot == (Object)null || (Object)(object)body == (Object)null) { return false; } if (!TryUnion(root, visualRoot, p.HullObjects, out var min, out var max)) { Plugin.Log.LogWarning((object)(p.Label + " hull meshes not found — keeping wheelbase colliders.")); return false; } float num = min.y; if (wheels != null && wheels.Length != 0) { float num2 = 0f; int num3 = 0; foreach (WheelCollider val in wheels) { if (!((Object)(object)val == (Object)null)) { num2 += root.InverseTransformPoint(((Component)val).transform.position).y; num3++; } } if (num3 > 0) { num = num2 / (float)num3; } } float num4 = (max.x - min.x) * ((p.WidthShrink > 0f) ? p.WidthShrink : p.HullShrink); float num5 = (max.z - min.z) * p.HullShrink; float num6 = (min.x + max.x) * 0.5f; float num7 = (min.z + max.z) * 0.5f; float num8 = Mathf.Max(min.y, num + p.BellyAboveHub); float num9 = max.y; if (num9 - num8 < 0.5f) { num9 = num8 + 0.5f; } float num10 = Mathf.Clamp(p.DeckSlice, 0f, (num9 - num8) * 0.6f); float num11 = num9 - num10; body.center = new Vector3(num6, (num8 + num11) * 0.5f, num7); body.size = new Vector3(num4, num11 - num8, num5); if ((Object)(object)hood != (Object)null) { hood.center = new Vector3(num6, (num11 + num9) * 0.5f, num7); hood.size = new Vector3(num4 * 0.96f, Mathf.Max(0.05f, num10), num5 * p.DeckLengthFrac); } if ((Object)(object)trunk != (Object)null) { if (TryUnion(root, visualRoot, p.TurretObjects, out var min2, out var max2) && max2.y > num9) { float num12 = num9 - 0.05f; trunk.center = new Vector3((min2.x + max2.x) * 0.5f, (num12 + max2.y) * 0.5f, (min2.z + max2.z) * 0.5f); trunk.size = new Vector3((max2.x - min2.x) * p.TurretShrink, max2.y - num12, (max2.z - min2.z) * p.TurretShrink); } else { trunk.center = body.center; trunk.size = body.size * 0.5f; } } Plugin.Log.LogInfo((object)$"{p.Label} hull colliders: body={body.size} c={body.center} deck={(((Object)(object)hood != (Object)null) ? hood.size : Vector3.zero)} turret={(((Object)(object)trunk != (Object)null) ? trunk.size : Vector3.zero)}"); return true; } internal static bool TryHullWorldBounds(Transform root, Transform visualRoot, Profile p, WheelCollider[] wheels, out Bounds bounds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); if ((Object)(object)root == (Object)null || (Object)(object)visualRoot == (Object)null) { return false; } if (!TryUnion(root, visualRoot, p.HullObjects, out var min, out var max)) { return false; } Vector3 val = (min + max) * 0.5f; Vector3 val2 = max - min; Vector3 val3 = root.TransformPoint(val); Vector3 val4 = root.TransformVector(val2); bounds = new Bounds(val3, new Vector3(Mathf.Abs(val4.x), Mathf.Abs(val4.y), Mathf.Abs(val4.z))); return true; } internal static bool TryUnion(Transform root, Transform visualRoot, string[] names, out Vector3 min, out Vector3 max) { //IL_0010: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); max = new Vector3(float.MinValue, float.MinValue, float.MinValue); if (names == null) { return false; } bool flag = false; Vector3 val3 = default(Vector3); foreach (string name in names) { Transform val = TrackedVehicleSetup.FindChildByName(visualRoot, name); if ((Object)(object)val == (Object)null) { continue; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !(val2 is ParticleSystemRenderer)) { Bounds bounds = val2.bounds; for (int k = 0; k < 8; k++) { ((Vector3)(ref val3))..ctor(((k & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((k & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((k & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z); Vector3 val4 = root.InverseTransformPoint(val3); min = Vector3.Min(min, val4); max = Vector3.Max(max, val4); flag = true; } } } } if (flag) { return max.z > min.z; } return false; } } internal class C130CargoWalk : MonoBehaviour { private HumveeVehicleController _controller; private C130Ramp _ramp; private Transform _hold; private bool _walking; private Player _player; internal bool IsLocalWalking { get { if (_walking) { return (Object)(object)_player == (Object)(object)Player.m_localPlayer; } return false; } } internal void Initialize(HumveeVehicleController controller) { _controller = controller; _ramp = ((Component)this).GetComponent<C130Ramp>(); _hold = ((Component)this).transform.Find("c130_cargo_hold"); } private void Update() { //IL_00c2: 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) if ((Object)(object)_hold == (Object)null) { _hold = ((Component)this).transform.Find("c130_cargo_hold"); } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } if (HumveeSeating.IsLocalPlayerSeatedNow()) { if (_walking) { StopWalk(toRamp: false); } } else if (_walking) { TickWalk(localPlayer); if (HumveeInput.WasUsePressed() && (Object)(object)_ramp != (Object)null && _ramp.IsOpen && NearAperture(((Component)localPlayer).transform.position)) { StopWalk(toRamp: true); } } else if (!((Object)(object)_ramp == (Object)null) && _ramp.IsOpen && !HumveeTrunk.IsLocalGuiOpen && NearAperture(((Component)localPlayer).transform.position) && HumveeInput.WasUsePressed()) { StartWalk(localPlayer); } } private void OnGUI() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!_walking && !((Object)(object)_ramp == (Object)null) && _ramp.IsOpen) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !HumveeSeating.IsLocalPlayerSeatedNow() && NearAperture(((Component)localPlayer).transform.position)) { HumveeInteractPrompt.Draw("[E] Cargo bay"); } } } internal void ReleaseLocal() { if (_walking) { StopWalk(toRamp: false); } } private void StartWalk(Player player) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_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_0087: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !((Object)(object)_hold == (Object)null)) { _player = player; _walking = true; HumveeSeating.BlockDetach = true; HumveePlayerUtil.SetPlayerPhysicsLocked(player, locked: true); HumveePlayerUtil.SetCollidersEnabled(player, enabled: false); HumveePlayerUtil.SetSeatedPose(player, seated: false); HumveePlayerUtil.SetPlayerBodyVisible(player, visible: true); Vector3 position = _hold.position + _hold.up * 0.95f - _hold.forward * 1.8f; ((Component)player).transform.SetParent(_hold, true); HumveePlayerUtil.SetTransformDirect(player, position, Quaternion.LookRotation(_hold.forward, _hold.up)); HumveeHud.Center("Cargo — WASD walk, Shift run, [E] at ramp to exit"); } } private void StopWalk(bool toRamp) { //IL_0056: 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_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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) Player val = (((Object)(object)_player != (Object)null) ? _player : Player.m_localPlayer); _walking = false; HumveeSeating.BlockDetach = false; if ((Object)(object)val != (Object)null) { ((Component)val).transform.SetParent((Transform)null, true); HumveePlayerUtil.SetPlayerPhysicsLocked(val, locked: false); HumveePlayerUtil.SetCollidersEnabled(val, enabled: true); if (toRamp) { Vector3 position = ((Component)this).transform.position - ((Component)this).transform.forward * 8f + ((Component)this).transform.up * 0.4f; HumveePlayerUtil.SetTransformDirect(val, position, Quaternion.LookRotation(-((Component)this).transform.forward, Vector3.up)); } } _player = null; } private void TickWalk(Player player) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !((Object)(object)_hold == (Object)null)) { Vector3 val = Vector3.zero; if (Input.GetKey((KeyCode)119) || ZInput.GetKey((KeyCode)119, true)) { val += Vector3.forward; } if (Input.GetKey((KeyCode)115) || ZInput.GetKey((KeyCode)115, true)) { val += Vector3.back; } if (Input.GetKey((KeyCode)97) || ZInput.GetKey((KeyCode)97, true)) { val += Vector3.left; } if (Input.GetKey((KeyCode)100) || ZInput.GetKey((KeyCode)100, true)) { val += Vector3.right; } float num = ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) ? 7.2f : 4.6f); if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { ((Vector3)(ref val)).Normalize(); Vector3 val2 = _hold.rotation * val * (num * Time.deltaTime); Vector3 val3 = ((Component)player).transform.position + val2; Vector3 val4 = _hold.InverseTransformPoint(val3); val4.x = Mathf.Clamp(val4.x, -1.55f, 1.55f); val4.y = 0.95f; val4.z = Mathf.Clamp(val4.z, -8.5f, 6.5f); val3 = _hold.TransformPoint(val4); Vector3 val5 = Vector3.ProjectOnPlane(_hold.rotation * val, _hold.up); Quaternion rotation = ((((Vector3)(ref val5)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(val5, _hold.up) : ((Component)player).transform.rotation); HumveePlayerUtil.SetTransformDirect(player, val3, rotation); } else { Vector3 val6 = _hold.InverseTransformPoint(((Component)player).transform.position); val6.y = 0.95f; HumveePlayerUtil.SyncPositionOnly(player, _hold.TransformPoint(val6)); } } } private bool NearAperture(Vector3 pos) { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ramp != (Object)null) { return _ramp.IsPlayerAtAperture(pos); } Vector3 val = ((Component)this).transform.position - ((Component)this).transform.forward * 10f; return Vector3.Distance(pos, val) < 5.4f; } private void OnDestroy() { if (_walking) { StopWalk(toRamp: false); } } } internal class C130CockpitAudio : MonoBehaviour { private HumveeVehicleController _controller; private C130Flight _flight; private C130Gear _gear; private C130Ramp _ramp; private AudioSource _sfx; private AudioSource _voice; private AudioSource _bell; private AudioClip _gearRetract; private AudioClip _gearExtend; private AudioClip _gearNoseTouch; private AudioClip _gearMainTouch; private AudioClip _gearWind; private AudioClip _alertStall; private AudioClip _alertOverspeed; private AudioClip _alertBank; private AudioClip _alertSink; private AudioClip _alertPullUp; private AudioClip _alertTerrain; private AudioClip _alertAltitude; private AudioClip _alertCheckAlt; private AudioClip _alertMinimums; private AudioClip _alertGear; private AudioClip _alertFlaps; private AudioClip _alertTooLowFlaps; private AudioClip _alertCaution; private AudioClip _alertAdvisory; private AudioClip _alertAp; private AudioClip _alertAt; private AudioClip _bellClip; private AudioClip _rwrNew; private AudioClip _rwrWarn; private AudioClip _rwrLock; private bool _wasAirborne; private bool _wasGearUp; private bool _wasAp; private bool _altCalled; private bool _minsCalled; private float _voiceCd; private float _touchDelay = -1f; private bool _pendingMainTouch; private int _lastPriority; internal void Initialize(HumveeVehicleController controller) { _controller = controller; _flight = ((Component)this).GetComponent<C130Flight>(); _gear = ((Component)this).GetComponent<C130Gear>(); _ramp = ((Component)this).GetComponent<C130Ramp>(); _sfx = MakeSrc(loop: false); _voice = MakeSrc(loop: false); _bell = MakeSrc(loop: true); string vehicleId = "c-130"; _gearRetract = Load(vehicleId, "herc_gearretract", "gearretract"); _gearExtend = Load(vehicleId, "herc_gearextend", "gearextend"); _gearNoseTouch = Load(vehicleId, "herc_gearnosetouch", "gearnosetouch"); _gearMainTouch = Load(vehicleId, "herc_gearmaintouch", "gearmaintouch"); _gearWind = Load(vehicleId, "herc_gearwindfadeout", "gearwindfadeout"); _alertStall = Load(vehicleId, "herc_alertstall", "alertstall"); _alertOverspeed = Load(vehicleId, "herc_alertoverspeed", "alertoverspeed"); _alertBank = Load(vehicleId, "herc_alertbankangle", "alertbankangle", "alertbank"); _alertSink = Load(vehicleId, "herc_alertsinkrate", "alertsinkrate"); _alertPullUp = Load(vehicleId, "herc_alertpullup", "alertpullup"); _alertTerrain = Load(vehicleId, "herc_alertterrain", "alertterrain"); _alertAltitude = Load(vehicleId, "herc_alertaltitude", "alertaltitude"); _alertCheckAlt = Load(vehicleId, "herc_alertcheckaltitude", "alertcheckaltitude"); _alertMinimums = Load(vehicleId, "herc_alertminimums", "alertminimums"); _alertGear = Load(vehicleId, "herc_alertgear", "alertgear"); _alertFlaps = Load(vehicleId, "herc_alertflaps", "alertflaps"); _alertTooLowFlaps = Load(vehicleId, "herc_alerttoolowflaps", "alerttoolowflaps"); _alertCaution = Load(vehicleId, "herc_alertcaution", "alertcaution"); _alertAdvisory = Load(vehicleId, "herc_alertadvisory", "alertadvisory"); _alertAp = Load(vehicleId, "herc_alertautopilot", "alertautopilot"); _alertAt = Load(vehicleId, "herc_alertautothrottle", "alertautothrottle"); _bellClip = Load(vehicleId, "herc_bell_alarm", "bell_alarm", "herc_bell"); _rwrNew = Load(vehicleId, "rwr_new_contact", "rwr_new"); _rwrWarn = Load(vehicleId, "rwr_warn"); _rwrLock = Load(vehicleId, "rwr_lock"); if ((Object)(object)_bell != (Object)null && (Object)(object)_bellClip != (Object)null) { _bell.clip = _bellClip; _bell.loop = true; _bell.volume = 0.55f; } _wasAirborne = (Object)(object)_flight != (Object)null && _flight.Airborne; _wasGearUp = (Object)(object)_gear != (Object)null && _gear.CommandUp; _wasAp = (Object)(object)_flight != (Object)null && _flight.Autopilot; Plugin.Log.LogInfo((object)"C-130 cockpit audio loaded"); } private AudioSource MakeSrc(bool loop) { AudioSource obj = ((Component)this).gameObject.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.loop = loop; obj.spatialBlend = 0.35f; obj.minDistance = 4f; obj.maxDistance = 60f; obj.rolloffMode = (AudioRolloffMode)1; obj.dopplerLevel = 0f; return obj; } private static AudioClip Load(string vehicleId, params string[] keys) { return HumveeEngineAudio.TryLoadPackClip(vehicleId, keys); } private void Update() { if ((Object)(object)_flight == (Object)null) { _flight = ((Component)this).GetComponent<C130Flight>(); } if ((Object)(object)_gear == (Object)null) { _gear = ((Component)this).GetComponent<C130Gear>(); } if ((Object)(object)_ramp == (Object)null) { _ramp = ((Component)this).GetComponent<C130Ramp>(); } if ((Object)(object)_flight == (Object)null) { return; } if (!((Object)(object)_controller != (Object)null) || (!_controller.IsDriverSeated() && (!((Object)(object)_controller.Seating != (Object)null) || !_controller.Seating.IsLocalPlayerCommander()))) { StopBell(); return; } _voiceCd = Mathf.Max(0f, _voiceCd - Time.deltaTime); if ((Object)(object)_bell != (Object)null && _bell.isPlaying) { _bell.volume = HumveeGameAudio.Scale(0.55f); } TickGearSfx(); TickTouchdown(); TickAutopilotCallouts(); TickGpws(); } private void TickGearSfx() { if ((Object)(object)_gear == (Object)null) { return; } bool commandUp = _gear.CommandUp; if (commandUp != _wasGearUp) { bool flag = commandUp && !_wasGearUp; _wasGearUp = commandUp; PlaySfx(flag ? _gearRetract : _gearExtend, 0.95f); if (flag && (Object)(object)_flight != (Object)null && _flight.Airborne) { PlaySfx(_gearWind, 0.55f); } } } private void TickTouchdown() { bool airborne = _flight.Airborne; if (_wasAirborne && !airborne) { PlaySfx(_gearNoseTouch, 0.9f); _pendingMainTouch = true; _touchDelay = 0.28f; } _wasAirborne = airborne; if (_pendingMainTouch) { _touchDelay -= Time.deltaTime; if (_touchDelay <= 0f) { _pendingMainTouch = false; PlaySfx(_gearMainTouch, 0.92f); } } } private void TickAutopilotCallouts() { bool autopilot = _flight.Autopilot; if (autopilot != _wasAp) { _wasAp = autopilot; if (autopilot) { Speak(_alertAp, 6); Speak(_alertAt, 5, 0.85f); } else { Speak(_alertAdvisory, 2); } } } private void TickGpws() { float altitudeM = _flight.AltitudeM; float verticalSpeedMs = _flight.VerticalSpeedMs; float airspeedMs = _flight.AirspeedMs; float num = Mathf.Abs(_flight.RollDeg); bool airborne = _flight.Airborne; bool stallWarn = _flight.StallWarn; bool flag = airspeedMs > 158.65f; bool flag2 = (Object)(object)_gear != (Object)null && _gear.Retracted; bool flag3 = (Object)(object)_ramp != (Object)null && _ramp.IsOpen; bool flag4 = airborne && altitudeM < 55f && verticalSpeedMs < -8f; bool flag5 = airborne && altitudeM < 35f && verticalSpeedMs < -3f; bool flag6 = airborne && verticalSpeedMs < -12f; bool flag7 = airborne && num > 45f; bool flag8 = airborne && flag2 && altitudeM < 90f && verticalSpeedMs < -1.5f; bool flag9 = airborne && flag3 && altitudeM < 90f; bool flag10 = airborne && flag3 && altitudeM < 35f; if (stallWarn || flag4 || flag || flag5) { StartBell(); } else { StopBell(); } if (flag4) { Speak(_alertPullUp, 10); } else if (stallWarn) { Speak(_alertStall, 9); } else if (flag5) { Speak(_alertTerrain, 8); } else if (flag) { Speak(_alertOverspeed, 7); } else if (flag6) { Speak(_alertSink, 6); } else if (flag7) { Speak(_alertBank, 5); } else if (flag8) { Speak(_alertGear, 5); } else if (flag10) { Speak(_alertTooLowFlaps, 4); } else if (flag9) { Speak(_alertFlaps, 3); } if (airborne && verticalSpeedMs < -1f) { if (!_altCalled && altitudeM < 120f && altitudeM > 45f) { _altCalled = true; Speak(((Object)(object)_alertAltitude != (Object)null) ? _alertAltitude : _alertCheckAlt, 4); } if (!_minsCalled && altitudeM < 45f) { _minsCalled = true; Speak(_alertMinimums, 5); } } else if (altitudeM > 160f) { _altCalled = false; _minsCalled = false; } _ = _rwrNew; _ = _rwrWarn; _ = _rwrLock; _ = _alertCaution; } private void Speak(AudioClip clip, int priority, float delay = 0f) { if (!((Object)(object)clip == (Object)null) && !((Object)(object)_voice == (Object)null) && (!(_voiceCd > 0f) || priority >= _lastPriority) && (!_voice.isPlaying || priority >= _lastPriority) && (!(_voiceCd > 0f) || priority != _lastPriority || !_voice.isPlaying)) { if (delay > 0.01f) { ((MonoBehaviour)this).StartCoroutine(SpeakDelayed(delay, Play)); } else { Play(); } } void Play() { if (!((Object)(object)_voice == (Object)null) && !((Object)(object)clip == (Object)null)) { _voice.Stop(); _voice.PlayOneShot(clip, HumveeGameAudio.Scale(0.88f)); _voiceCd = 4.5f; _lastPriority = priority; } } } private IEnumerator SpeakDelayed(float delay, Action play) { yield return (object)new WaitForSeconds(delay); play?.Invoke(); } private void PlaySfx(AudioClip clip, float vol) { if (!((Object)(object)clip == (Object)null) && !((Object)(object)_sfx == (Object)null)) { _sfx.PlayOneShot(clip, HumveeGameAudio.Scale(vol)); } } private void StartBell() { if (!((Object)(object)_bell == (Object)null) && !((Object)(object)_bellClip == (Object)null) && !_bell.isPlaying) { _bell.Play(); } } private void StopBell() { if ((Object)(object)_bell != (Object)null && _bell.isPlaying) { _bell.Stop(); } } internal void PlayRwrNew() { PlaySfx(_rwrNew, 0.7f); } internal void PlayRwrWarn() { Speak(_rwrWarn, 7); } internal void PlayRwrLock() { Speak(_rwrLock, 9); } } internal static class C130Config { internal const string VehicleId = "c-130"; internal const string DisplayName = "C-130 Hercules"; internal const float SpawnScale = 1.22f; internal const float TargetLength = 34f; internal const float Mass = 22000f; internal const float CenterOfMassY = 1.25f; internal const float CenterOfMassZ = 0.2f; internal const float AngularDamping = 2.4f; internal const float MaxAngularVelocity = 4.8f; internal const float VisualChassisLift = 0.04f; internal const float WheelGroundClearance = 0.03f; internal const float WheelExtraVisualLiftRatio = 0f; internal const float BellyClearance = 0.04f; internal const float GearRadius = 0.62f; internal const float WheelRadiusMin = 0.55f; internal const float WheelRadiusMax = 0.85f; internal const float WheelSuspensionDistance = 0.22f; internal const float WheelMass = 90f; internal const float WheelSpring = 145000f; internal const float WheelDamper = 78000f; internal const float WheelSpringTarget = 0.48f; internal const float WheelVerticalLift = 0.04f; internal const float SpawnGroundOffset = 0.06f; internal const float SpawnForwardPad = 8f; internal const float MotorTorque = 42000f; internal const float LowEndBoostUntilKmh = 55f; internal const float LowEndTorqueMult = 2.1f; internal const float GroundThrustFrac = 0.92f; internal const float AirborneEnterAgl = 2.8f; internal const float AirborneExitAgl = 1.6f; internal const float AirborneFastAgl = 0.7f; internal const float BrakeForce = 28000f; internal const float TaxiMaxSpeedMs = 95f; internal const float MaxReverseMs = 6f; internal const float NoseSteerAngle = 52f; internal const float ParkingBrakeTorqueMult = 4.2f; internal const float CollisionMinSpeedKmh = 0.35f; internal const float CollisionDamageMult = 55f; internal const float PushForceMult = 0.72f; internal const float CollisionEnterCooldown = 0.04f; internal const float CollisionStayCooldown = 0.05f; internal const float StumpNudgeForce = 0f; internal const float VegetationMinSpeedKmh = 0.12f; internal const float VegetationBaseDamage = 9000f; internal const float VegetationDamagePerKmh = 280f; internal const float VegetationHitCooldown = 0.05f; internal const float StumpMinSpeedKmh = 0.04f; internal const float StumpBaseDamage = 12000f; internal const float StumpHitCooldown = 0.05f; internal const bool BulldozeOnCollisionStay = true; internal const float MobCrushMinSpeedKmh = 2f; internal const float MobCrushDamage = 9999f; internal const float MobCrushRadiusScale = 1.35f; internal const float MobCrushCooldown = 0.12f; internal const float SeatHeightFromBottom = 0.38f; internal const float SeatSideOffset = 0.62f; internal const float SeatFrontZ = 0.42f; internal const float SeatInteractDistance = 4.8f; internal const float SeatInteractMaxVertical = 5.4f; internal const float ExitSideDistance = 3.4f; internal const float ExitUp = 0.4f; internal const float CargoHalfWidth = 1.55f; internal const float CargoHalfHeight = 1.35f; internal const float CargoDeckHeight = 1.05f; internal const float CargoFloorThickness = 0.22f; internal const float CargoWalkSpeed = 4.6f; internal const float CargoRunSpeed = 7.2f; internal const float CargoEnterDistance = 5.4f; internal const KeyCode RampKey = (KeyCode)107; internal const KeyCode GearKey = (KeyCode)121; internal const KeyCode YawLeftKey = (KeyCode)102; internal const KeyCode YawRightKey = (KeyCode)114; internal const KeyCode PowerKey = (KeyCode)104; internal const KeyCode AutopilotKey = (KeyCode)117; internal const float AutopilotMinAgl = 18f; internal const float AutopilotHeadingGain = 0.045f; internal const float AutopilotBankLimit = 22f; internal const float AutopilotAltGain = 0.55f; internal const float AutopilotSpeedGain = 0.12f; internal const float AlertBankDeg = 45f; internal const float AlertSinkMs = -12f; internal const float AlertPullUpAgl = 55f; internal const float AlertPullUpSinkMs = -8f; internal const float AlertTerrainAgl = 35f; internal const float AlertMinimumsAgl = 45f; internal const float AlertAltCallAgl = 120f; internal const float AlertGearUnsafeAgl = 90f; internal const float AlertVoiceCooldown = 4.5f; internal const float RampOpenAngle = -28f; internal const float RampUpperOpenAngle = 48f; internal const float RampAnimTime = 2.2f; internal const float GearRetractTime = 1.85f; internal const float GearRetractUp = 1.55f; internal const float GearNoseAft = 0.85f; internal const float GearMainInboard = 1.05f; internal const float GearNoseFoldDeg = -75f; internal const float GearMainFoldDeg = 70f; internal const float GearDoorOpenDeg = 90f; internal const float GearNoseDoorOpenDeg = 95f; internal const float GearDoorLead = 0.16f; internal const string GearNoseName = "c130_gear_nose"; internal const string GearMainLName = "c130_gear_main_l"; internal const string GearMainRName = "c130_gear_main_r"; internal const string GearDoorLName = "c130_gear_door_l"; internal const string GearDoorRName = "c130_gear_door_r"; internal const string GearNoseDoorLName = "c130_gear_nose_door_l"; internal const string GearNoseDoorRName = "c130_gear_nose_door_r"; internal const int PowerModeCount = 5; internal static readonly float[] PowerPreset = new float[5] { 0.18f, 0.48f, 0.78f, 0.86f, 1f }; internal static readonly string[] PowerNames = new string[5] { "IDLE", "TAXI", "T/O", "CRUISE", "MAX" }; internal const float StallMs = 55f; internal const float RotateMs = 58f; internal const float CruiseMs = 150f; internal const float MaxSpeedMs = 167f; internal const float RotatePitch = 11f; internal const float RotateLiftWeight = 1.05f; internal const float MaxClimbPitchDeg = 18f; internal const float ClimbKeyLift = 3.1f; internal const float DescendKeyLiftMul = 1.55f; internal const float ClimbKeyPitch = 38f; internal const float CameraMaxDistance = 48f; internal const float WingArea = 162f; internal const float AirDensity = 1.2f; internal const float Cl0 = 0.48f; internal const float ClPerRad = 4.8f; internal const float ClMax = 1.7f; internal const float Cd0 = 0.028f; internal const float InducedK = 0.042f; internal const float MaxThrust = 210000f; internal const float StaticThrustBonus = 0.1f; internal const float LevelFlightLift = 1f; internal const float LevelVsDamp = 2.6f; internal const float PitchRate = 0.85f; internal const float RollRate = 9.5f; internal const float YawRate = 2.4f; internal const float CoordYaw = 0.55f; internal const float AutoLevel = 0.1f; internal const float YawSnap = 1.35f; internal const float StickSmooth = 12f; internal const float RollSnap = 2.8f; internal const float AirThrottleRate = 0.7f; internal const float AirSpeedTrack = 0.85f; internal const float GroundSettleSpeedMs = 9f; internal const float GroundSettleVyDamp = 0.38f; internal const float GroundSettleAngDamp = 0.42f; internal const float GroundLiftScale = 0.18f; internal const float PropMaxRpm = 3800f; internal const float PropIdleFrac = 0.62f; internal const float VertArea = 38f; internal const float StallAoaRad = 0.28f; internal const float SideslipCl = 1.15f; internal const float DragAoaK = 0.1f; internal const float DragBetaK = 0.08f; internal const float PitchStability = 0.0065f; internal const float YawStability = 0.004f; internal const float Dihedral = 0.0012f; internal const float AeroDamp = 0.55f; internal const float MinThrustSpeedMs = 12f; internal const float EnginePowerW = 9800000f; internal const float DensityScaleH = 8800f; internal const float GravityMs2 = 9.81f; internal const float IdleRPM = 650f; internal const float MaxRPM = 4200f; internal const float NavLightRange = 14f; internal const float NavLightIntensity = 2.55f; internal const float BeaconIntensity = 3.15f; internal const float BeaconRange = 12f; internal const float BeaconHz = 1.15f; internal const float StrobeHz = 2.35f; internal const float StrobeIntensity = 3.8f; internal static float SpawnForwardDistance => 25.68f; internal static HumveeConfig.DriveProfile DriveProfile => new HumveeConfig.DriveProfile { Mass = 22000f, CenterOfMassY = 1.25f, MotorTorque = 42000f, BrakeForce = 28000f, MaxSpeedMs = 95f, MaxReverseMs = 6f, CollisionMinSpeedKmh = 0.35f, CollisionDamageMult = 55f, PushForceMult = 0.72f, VegetationMinSpeedKmh = 0.12f, VegetationBaseDamage = 9000f, VegetationDamagePerKmh = 280f, VegetationHitCooldown = 0.05f, StumpMinSpeedKmh = 0.04f, StumpBaseDamage = 12000f, StumpHitCooldown = 0.05f, AngularDamping = 2.4f, CollisionEnterCooldown = 0.04f, CollisionStayCooldown = 0.05f, StumpNudgeForce = 0f, BulldozeOnCollisionStay = true, WheelExtraVisualLiftRatio = 0f, WheelGroundClearance = 0.03f, WheelVisualsStayOnHub = true }; internal static bool IsC130(string vehicleId) { if (HumveeSounds.NormalizeVehicleId(vehicleId) == "c-130") { return true; } if (string.IsNullOrEmpty(vehicleId)) { return false; } string text = vehicleId.Trim().ToLowerInvariant().Replace('_', '-'); switch (text) { default: if (!text.StartsWith("c-130")) { return text.StartsWith("c130"); } break; case "c130": case "c-130": case "c130j": case "hercules": break; } return true; } } internal class C130Flight : MonoBehaviour { private HumveeVehicleController _controller; private Rigidbody _rb; private Transform[] _props; private Vector3[] _propAxes; private int _powerMode = 1; private float _throttle = 0.34f; private bool _airborne; private float _aoa; private float _beta; private float _stallWarn; private Vector3 _prevVel; private bool _hasPrevVel; private Collider _wingCol; private float _rollSmooth; private float _yawSmooth; private bool _autopilot; private float _apHeading; private float _apAltitude; private float _apSpeed; private float[] _noseSpringRest; internal bool Airborne => _airborne; internal float Throttle01 => _throttle; internal int PowerMode => _powerMode; internal string PowerName => C130Config.PowerNames[Mathf.Clamp(_powerMode, 0, 4)]; internal float AngleOfAttackDeg => _aoa * 57.29578f; internal float SideslipDeg => _beta * 57.29578f; internal float AltitudeM { get; private set; } internal float AirspeedMs { get; private set; } internal float GroundSpeedMs { get; private set; } internal float VerticalSpeedMs { get; private set; } internal float LoadFactorG { get; private set; } internal float PropRpm { get; private set; } internal bool StallWarn => _stallWarn > 0.35f; internal bool RotateCue { get; private set; } internal float PitchDeg { get; private set; } internal float RollDeg { get; private set; } internal int Heading { get; private set; } internal bool Autopilot => _autopilot; internal bool AutoThrottle => _autopilot; internal void Initialize(HumveeVehicleController controller, Transform visual) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) _controller = controller; _rb = ((Component)this).GetComponent<Rigidbody>(); _props = C130VehicleSetup.FindPropTransforms(visual); _propAxes = (Vector3[])(object)new Vector3[(_props != null) ? _props.Length : 0]; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < _propAxes.Length; i++) { _propAxes[i] = LocalPropSpinAxis(_props[i]); if (i > 0) { stringBuilder.Append(','); } stringBuilder.Append(((Object)(object)_props[i] != (Object)null) ? ((Object)_props[i]).name : "?"); } Plugin.Log.LogInfo((object)$"C-130 props spinning n={_propAxes.Length} [{stringBuilder}]"); Transform val = ((Component)this).transform.Find("c130_wing"); _wingCol = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Collider>() : null); if ((Object)(object)_rb != (Object)null) { _rb.maxAngularVelocity = 4.8f; _rb.angularDamping = 2.4f; _rb.centerOfMass = C130VehicleSetup.ComputeCenterOfMass(((Component)this).transform, ((Object)(object)_controller != (Object)null) ? _controller.WheelColliders : null); } } private void Update() { if ((Object)(object)_controller == (Object)null) { return; } TickAltitude(); SpinProps(); if (!_controller.IsDriverSeated()) { if (_controller.EngineOn) { _throttle = Mathf.MoveTowards(_throttle, C130Config.PowerPreset[Mathf.Clamp(_powerMode, 0, 4)], Time.deltaTime * 0.35f); } else { _throttle = Mathf.MoveTowards(_throttle, 0f, Time.deltaTime * 0.4f); } _controller.NotifyC130Flight(_throttle, _airborne, AirspeedMs); HoldLevelOnGround(); } else { if (HumveeTrunk.IsLocalGuiOpen || ((Object)(object)HumveeGarageMenu.Instance != (Object)null && HumveeGarageMenu.Instance.IsOpen)) { return; } if (Input.GetKeyDown((KeyCode)104) || ZInput.GetKeyDown((KeyCode)104, true)) { _powerMode = (_powerMode + 1) % 5; _throttle = C130Config.PowerPreset[_powerMode]; HumveeHud.Center($"POWER {PowerName} — props {_throttle * 100f:0}%"); } if (Input.GetKeyDown((KeyCode)117) || ZInput.GetKeyDown((KeyCode)117, true)) { ToggleAutopilot(); } if (_autopilot && PilotOverrideStick()) { DisengageAutopilot(fromStick: true); } float num = C130Config.PowerPreset[Mathf.Clamp(_powerMode, 0, 4)]; if (_controller.EngineOn) { if (_airborne || AltitudeM > 1.8f || (!_controller.IsOnGround() && AirspeedMs > 12f)) { if (!_autopilot) { bool num2 = Input.GetKey((KeyCode)119) || ZInput.GetKey((KeyCode)119, true); bool flag = Input.GetKey((KeyCode)115) || ZInput.GetKey((KeyCode)115, true); if (num2) { _throttle = Mathf.Clamp01(_throttle + Time.deltaTime * 0.7f); } if (flag) { _throttle = Mathf.Clamp01(_throttle - Time.deltaTime * 0.7f); } } } else { _throttle = Mathf.MoveTowards(_throttle, num, Time.deltaTime * 0.55f); } } else { _throttle = Mathf.MoveTowards(_throttle, 0f, Time.deltaTime * 0.4f); } _controller.NotifyC130Flight(_throttle, _airborne, AirspeedMs); HoldLevelOnGround(); } } private void FixedUpdate() { //IL_004e: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: 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_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rb == (Object)null || (Object)(object)_controller == (Object)null) { return; } HoldLevelOnGround(); SettleOnUnevenGround(); if (_rb.isKinematic) { return; } bool flag = _controller.IsOnGround(); float num = (AltitudeM = Mathf.Max(0f, ((Component)this).transform.position.y - SampleGroundY())); bool flag2 = AirspeedMs > 46.75f; float num3 = (flag2 ? 0.7f : 2.8f); if (flag && !flag2 && VerticalSpeedMs < 0.8f) { _airborne = false; } if (!flag && num > num3 && AirspeedMs > 22f) { _airborne = true; } if (!flag && num > 8f) { _airborne = true; } if (_airborne && flag && !flag2 && num < 1.6f && VerticalSpeedMs < 0.3f) { _airborne = false; } PitchDeg = (0f - Mathf.Asin(Mathf.Clamp(((Component)this).transform.forward.y, -1f, 1f))) * 57.29578f; Vector3 right = ((Component)this).transform.right; RollDeg = Mathf.Asin(Mathf.Clamp(right.y, -1f, 1f)) * 57.29578f; Vector3 val = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up); Heading = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? Mathf.RoundToInt((Mathf.Atan2(val.x, val.z) * 57.29578f + 360f) % 360f) : 0); Vector3 linearVelocity = _rb.linearVelocity; AirspeedMs = ((Vector3)(ref linearVelocity)).magnitude; Vector3 val2 = new Vector3(linearVelocity.x, 0f, linearVelocity.z); GroundSpeedMs = ((Vector3)(ref val2)).magnitude; VerticalSpeedMs = linearVelocity.y; Vector3 val3 = ((Component)this).transform.InverseTransformDirection(linearVelocity); float num4 = AirspeedMs + 0.1f; _aoa = 0f - Mathf.Asin(Mathf.Clamp(val3.y / num4, -1f, 1f)); _beta = Mathf.Asin(Mathf.Clamp(val3.x / num4, -1f, 1f)); if (AirspeedMs < 0.4f) { _aoa = 0f; _beta = 0f; } Vector3 val4 = (_hasPrevVel ? ((linearVelocity - _prevVel) / Mathf.Max(0.0001f, Time.fixedDeltaTime)) : Vector3.zero); _prevVel = linearVelocity; _hasPrevVel = true; LoadFactorG = Vector3.Dot(val4 - Physics.gravity, ((Component)this).transform.up) / 9.81f; if (!_controller.EngineOn) { _throttle = Mathf.MoveTowards(_throttle, 0f, Time.fixedDeltaTime * 0.25f); } if (_airborne) { SetGearSoft(soft: false); ApplyAero(Time.fixedDeltaTime); if (_autopilot) { ApplyAutopilot(Time.fixedDeltaTime); } else { ApplyClimbKeys(); } } else { if (_autopilot) { DisengageAutopilot(fromStick: false); } ApplyGroundLiftBleed(); if (AirspeedMs >= 26.099998f) { ApplyAero(Time.fixedDeltaTime, groundAssist: true); } ApplyClimbKeys(); } bool num5 = _airborne && _aoa > 0.2464f; bool flag3 = _airborne && AirspeedMs < 55f; float num6 = ((num5 || flag3) ? 1f : 0f); _stallWarn = Mathf.MoveTowards(_stallWarn, num6, Time.fixedDeltaTime * 3f); } private void HoldLevelOnGround() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rb == (Object)null) { return; } if ((Object)(object)_wingCol != (Object)null) { _wingCol.enabled = _airborne; } if (_airborne || _rb.isKinematic || (_rb.constraints & 0x7E) == 126) { return; } Vector3 val = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up); Vector3 val2 = _rb.angularVelocity; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { val2 -= Vector3.Project(val2, ((Vector3)(ref val)).normalized); } float num = Mathf.Asin(Mathf.Clamp(((Component)this).transform.right.y, -1f, 1f)); if (Mathf.Abs(num) > 0.06f && ((Vector3)(ref val)).sqrMagnitude > 0.0001f) { val2 += -((Vector3)(ref val)).normalized * (num * 3.2f); } if (!(GroundSpeedMs >= 26.099998f) && !(AirspeedMs >= 26.099998f)) { float num2 = 0f - Mathf.Asin(Mathf.Clamp(((Component)this).transform.forward.y, -1f, 1f)); if (Mathf.Abs(num2) > 0.05f) { val2 += -((Component)this).transform.right * (num2 * 2.8f); } } _rb.angularVelocity = val2; } private void SettleOnUnevenGround() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_rb == (Object)null) && !_airborne && !_rb.isKinematic && !(GroundSpeedMs > 9f) && (_rb.constraints & 0x7E) != 126) { Vector3 linearVelocity = _rb.linearVelocity; linearVelocity.y *= 0.38f; bool flag = (Object)(object)_controller != (Object)null && _controller.IsDriverSeated(); if ((!flag || !_controller.EngineOn || (!(Mathf.Abs(_throttle) > 0.2f) && !Input.GetKey((KeyCode)119) && !ZInput.GetKey((KeyCode)119, true) && !Input.GetKey((KeyCode)115) && !ZInput.GetKey((KeyCode)115, true))) && GroundSpeedMs < 1.8f) { float num = ((flag && GroundSpeedMs < 2.5f) ? 0.88f : 0.95f); linearVelocity.x *= num; linearVelocity.z *= num; } _rb.linearVelocity = linearVelocity; Vector3 val = _rb.angularVelocity; float num2 = 0.42f; if (flag && GroundSpeedMs < 3.5f) { num2 *= 0.55f; } if (flag && GroundSpeedMs < 1.5f) { Vector3 val2 = ((Component)this).transform.InverseTransformDirection(val); val2.x *= 0.25f; val2.z *= 0.25f; val = ((Component)this).transform.TransformDirection(val2); } _rb.angularVelocity = val * num2; } } private void ApplyAero(float dt, bool groundAssist = false) { //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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_012b: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: 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_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0500: 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_050a: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_0605: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_066d: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_06