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 Gj HMMWV v0.0.8
GJ_MilitaryTruck.dll
Decompiled 5 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 System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GJ_MilitaryTruck")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1")] [assembly: AssemblyProduct("GJ_MilitaryTruck")] [assembly: AssemblyTitle("GJ_MilitaryTruck")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.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 GJ.MilitaryTruck { [HarmonyPatch(typeof(GrabbableObject), "GetItemFloorPosition")] internal static class CargoDropPatch { private static void Postfix(GrabbableObject __instance, Vector3 __0, ref Vector3 __result) { //IL_00d3: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0050: 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_00a0: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) TruckController current = TruckController.Current; if (!((Object)(object)current == (Object)null) && !((Object)(object)__instance == (Object)null)) { Vector3 start = ((__0 == Vector3.zero) ? ((Component)__instance).transform.position : __0); PlayerControllerB playerHeldBy = __instance.playerHeldBy; Vector3 world2; bool shelf; if ((Object)(object)playerHeldBy != (Object)null && current.LookCargoSpot(playerHeldBy, out var world)) { world2 = world; } else if (!current.CargoLanding(start, out world2, out shelf)) { return; } float num = (((Object)(object)__instance.itemProperties != (Object)null) ? __instance.itemProperties.verticalOffset : 0.1f); try { Vector3 val = (((Object)(object)__instance.itemProperties != (Object)null) ? __instance.itemProperties.restingRotation : Vector3.zero); num = Mathf.Max(num, TruckController.LowestBelowPivot(__instance, ((Component)current).transform.rotation * Quaternion.Euler(val))); } catch { } __result = world2 + ((Component)current).transform.up * (num + 0.025f); } } } [HarmonyPatch(typeof(PlayerControllerB), "Crouch")] internal static class CrouchPatch { private static bool Prefix(PlayerControllerB __instance, bool __0) { if (__0) { return true; } TruckController current = TruckController.Current; if (!((Object)(object)current == (Object)null)) { return !current.HoldsCrouched(__instance); } return true; } } internal static class CruiserParts { internal static GameObject CloneVisual(GameObject src, string name, bool keepLights = false) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if ((Object)(object)src == (Object)null) { return null; } GameObject val = new GameObject("GJ_CloneHolder"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(src, val.transform, false); ((Object)val2).name = name; Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true); Renderer[] components; foreach (Component val3 in componentsInChildren) { if ((Object)(object)val3 == (Object)null || (keepLights && (val3 is Light || ((object)val3).GetType().Name.Contains("Light") || ((object)val3).GetType().Name.Contains("Flare")))) { continue; } if (!(val3 is InteractTrigger)) { Collider val4 = (Collider)(object)((val3 is Collider) ? val3 : null); if ((val4 == null || !val4.isTrigger) && !((Object)val3.gameObject).name.ToLowerInvariant().Contains("trigger")) { continue; } } components = val3.GetComponents<Renderer>(); for (int j = 0; j < components.Length; j++) { Object.DestroyImmediate((Object)(object)components[j]); } MeshFilter[] components2 = val3.GetComponents<MeshFilter>(); for (int j = 0; j < components2.Length; j++) { Object.DestroyImmediate((Object)(object)components2[j]); } } components = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val5 in components) { if (!val5.enabled) { Object.DestroyImmediate((Object)(object)val5); } } for (int k = 0; k < 3; k++) { componentsInChildren = val2.GetComponentsInChildren<Component>(true); foreach (Component val6 in componentsInChildren) { if (!((Object)(object)val6 == (Object)null) && !(val6 is Transform) && !(val6 is MeshFilter) && !(val6 is MeshRenderer) && !(val6 is SkinnedMeshRenderer) && !(val6 is Animator) && (!keepLights || (!(val6 is Light) && !((object)val6).GetType().Name.Contains("Light") && !((object)val6).GetType().Name.Contains("Flare")))) { Object.DestroyImmediate((Object)(object)val6); } } } val2.transform.SetParent((Transform)null, true); Object.Destroy((Object)(object)val); val2.SetActive(false); return val2; } internal static Bounds RenderBounds(GameObject go) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true); if (componentsInChildren.Length == 0) { return new Bounds(go.transform.position, Vector3.one * 0.15f); } Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } return bounds; } } internal class CruiserTuning { internal struct WheelSetup { public float Mass; public float SuspensionDistance; public float ForceAppPointDistance; public float DampingRate; public JointSpring Spring; public static WheelSetup Default() { //IL_003c: 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_0067: Unknown result type (might be due to invalid IL or missing references) return new WheelSetup { Mass = 30f, SuspensionDistance = 0.3f, ForceAppPointDistance = 0.1f, DampingRate = 0.25f, Spring = new JointSpring { spring = 35000f, damper = 4500f, targetPosition = 0.5f } }; } public static WheelSetup From(WheelCollider w) { //IL_003f: 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) return new WheelSetup { Mass = w.mass, SuspensionDistance = w.suspensionDistance, ForceAppPointDistance = w.forceAppPointDistance, DampingRate = w.wheelDampingRate, Spring = w.suspensionSpring }; } } public float EngineTorque = 1000f; public float CarAcceleration = 350f; public float IdleSpeed = 30f; public float SteeringWheelTurnSpeed = 2f; public float Stability = 0.3f; public float StabilizerSpeed = 2f; public float TurboBoostForce = 10000f; public float TurboBoostUpwardForce = 6000f; public float JumpForce = 4000f; public float Mass = 2500f; public float Drag = 0.05f; public float AngularDrag = 0.5f; public Vector3 CenterOfMass = new Vector3(0f, 0.6f, 0f); public WheelSetup Front = WheelSetup.Default(); public WheelSetup Rear = WheelSetup.Default(); public bool FromGame; public VehicleController Vc; public InteractTrigger DriverSeat; public InteractTrigger PassengerSeat; public InteractTrigger StartKey; public InteractTrigger RemoveKey; public InteractTrigger DriverDoorTrigger; public AnimatedObjectTrigger DriverDoor; public string[] CarTooltips; public int ExitCarLayerMask = -1; public float StartChance = 20f; public float HitMultiplier = 1000f; public int RamTriggerLayer = -1; public bool HasSeatGeometry; public Vector3 WheelFromNode; public Vector3 KeyFromNode; public Vector3 KeyTurnedFromNode; public Vector3 GearFromNode; public Vector3 PassengerFromNode; public float WheelDiameter = 0.4f; public Quaternion GearRotFromNode = Quaternion.identity; public Quaternion KeyRotFromNode = Quaternion.identity; public Quaternion KeyTurnedRotFromNode = Quaternion.identity; public GameObject GearStickPrefab; public GameObject KeyPrefab; public Vector3 KeyHandPositionOffset; public Vector3 KeyHandRotationOffset; public AudioClip DoorOpenClip; public AudioClip DoorCloseClip; private static CruiserTuning _cached; private static Quaternion RelRot(Transform node, Quaternion world) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Inverse(node.rotation) * world; } private void ReadDoorAudio(VehicleController vc) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; List<(AudioClip clip, string where)> doorClips = new List<(AudioClip, string)>(); List<string> list = new List<string>(); MonoBehaviour[] componentsInChildren = ((Component)vc).GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } string text = ((Object)((Component)val).transform).name.ToLowerInvariant(); Transform parent = ((Component)val).transform.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)vc).transform) { text = ((Object)parent).name.ToLowerInvariant() + "/" + text; parent = parent.parent; } FieldInfo[] fields = ((object)val).GetType().GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { List<AudioClip> list2 = new List<AudioClip>(); if (fieldInfo.FieldType == typeof(AudioClip)) { object? value = fieldInfo.GetValue(val); list2.Add((AudioClip)((value is AudioClip) ? value : null)); } else if (fieldInfo.FieldType == typeof(AudioClip[]) && fieldInfo.GetValue(val) is AudioClip[] collection) { list2.AddRange(collection); } foreach (AudioClip item in list2) { if (!((Object)(object)item == (Object)null)) { string text2 = text + ":" + ((object)val).GetType().Name + "." + fieldInfo.Name; list.Add(text2 + "=" + ((Object)item).name); string text3 = fieldInfo.Name.ToLowerInvariant(); string text4 = ((Object)item).name.ToLowerInvariant(); if (text.Contains("door") || text3.Contains("door") || text4.Contains("door")) { doorClips.Add((item, text2.ToLowerInvariant() + "|" + text4)); } } } } } Animator[] componentsInChildren2 = ((Component)vc).GetComponentsInChildren<Animator>(true); foreach (Animator val2 in componentsInChildren2) { if (!((Object)(object)val2.runtimeAnimatorController != (Object)null) || !((Object)((Component)val2).transform).name.ToLowerInvariant().Contains("door")) { continue; } AnimationClip[] animationClips = val2.runtimeAnimatorController.animationClips; foreach (AnimationClip val3 in animationClips) { AnimationEvent[] events = val3.events; for (int k = 0; k < events.Length; k++) { Object objectReferenceParameter = events[k].objectReferenceParameter; AudioClip val4 = (AudioClip)(object)((objectReferenceParameter is AudioClip) ? objectReferenceParameter : null); if (val4 != null) { doorClips.Add((val4, "anim:" + ((Object)val3).name.ToLowerInvariant() + "|" + ((Object)val4).name.ToLowerInvariant())); } } } } AudioSource[] componentsInChildren3 = ((Component)vc).GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val5 in componentsInChildren3) { if ((Object)(object)val5.clip != (Object)null && ((Object)((Component)val5).transform).name.ToLowerInvariant().Contains("door")) { doorClips.Add((val5.clip, "src:" + ((Object)((Component)val5).transform).name.ToLowerInvariant() + "|" + ((Object)val5.clip).name.ToLowerInvariant())); } } Plugin.Log.LogInfo((object)("Cruiser audio clips: " + string.Join(" ; ", list))); Plugin.Log.LogInfo((object)("Cruiser door clips: " + string.Join(" ; ", doorClips.ConvertAll(((AudioClip clip, string where) d) => d.where ?? "")))); DoorOpenClip = Pick(new string[2] { "open", "true" }); DoorCloseClip = Pick(new string[4] { "close", "shut", "slam", "false" }); if ((Object)(object)DoorOpenClip == (Object)null && doorClips.Count > 0) { DoorOpenClip = doorClips[0].clip; } if ((Object)(object)DoorCloseClip == (Object)null && doorClips.Count > 1) { DoorCloseClip = doorClips[1].clip; } Traverse val6 = Traverse.Create((object)vc); if ((Object)(object)DoorOpenClip == (Object)null) { DoorOpenClip = val6.Field("carHoodOpenSFX").GetValue<AudioClip>(); } if ((Object)(object)DoorCloseClip == (Object)null) { DoorCloseClip = val6.Field("carHoodCloseSFX").GetValue<AudioClip>(); } ManualLogSource log = Plugin.Log; AudioClip doorOpenClip = DoorOpenClip; string obj = ((doorOpenClip != null) ? ((Object)doorOpenClip).name : null) ?? "none"; AudioClip doorCloseClip = DoorCloseClip; log.LogInfo((object)("Door sounds: open=" + obj + " close=" + (((doorCloseClip != null) ? ((Object)doorCloseClip).name : null) ?? "none"))); AudioClip Pick(params string[] keys) { foreach (string value2 in keys) { foreach (var item2 in doorClips) { if (item2.where.Contains(value2)) { return item2.clip; } } } return null; } } private static Vector3 Rel(Transform node, Vector3 world) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Inverse(node.rotation) * (world - node.position); } private void ReadSeatGeometry(VehicleController vc) { //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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: 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_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: 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_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: 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) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)vc.driverSeatTrigger != (Object)null) ? vc.driverSeatTrigger.playerPositionNode : null); if ((Object)(object)val == (Object)null || (Object)(object)vc.steeringWheelAnimator == (Object)null) { return; } MeshFilter val2 = null; float num = 0f; MeshFilter[] componentsInChildren = ((Component)vc.steeringWheelAnimator).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val3 in componentsInChildren) { if (!((Object)(object)val3.sharedMesh == (Object)null)) { Bounds bounds = val3.sharedMesh.bounds; Vector3 lossyScale = ((Component)val3).transform.lossyScale; float num2 = Mathf.Max(new float[3] { ((Bounds)(ref bounds)).size.x * Mathf.Abs(lossyScale.x), ((Bounds)(ref bounds)).size.y * Mathf.Abs(lossyScale.y), ((Bounds)(ref bounds)).size.z * Mathf.Abs(lossyScale.z) }); if (num2 > num) { num = num2; val2 = val3; } } } Vector3 val4; if (!((Object)(object)val2 != (Object)null)) { val4 = ((Component)vc.steeringWheelAnimator).transform.position; } else { Transform transform = ((Component)val2).transform; Bounds bounds2 = val2.sharedMesh.bounds; val4 = transform.TransformPoint(((Bounds)(ref bounds2)).center); } Vector3 world = val4; if ((Object)(object)val2 != (Object)null) { WheelDiameter = num; } WheelFromNode = Rel(val, world); Traverse val5 = Traverse.Create((object)vc); Transform value = val5.Field("ignitionNotTurnedPosition").GetValue<Transform>(); Transform value2 = val5.Field("ignitionTurnedPosition").GetValue<Transform>(); KeyFromNode = (((Object)(object)value != (Object)null) ? Rel(val, value.position) : (WheelFromNode + new Vector3(0.3f, -0.15f, 0f))); KeyTurnedFromNode = (((Object)(object)value2 != (Object)null) ? Rel(val, value2.position) : KeyFromNode); if ((Object)(object)value != (Object)null) { KeyRotFromNode = RelRot(val, value.rotation); } KeyTurnedRotFromNode = (((Object)(object)value2 != (Object)null) ? RelRot(val, value2.rotation) : KeyRotFromNode); GearFromNode = (((Object)(object)vc.gearStickAnimator != (Object)null) ? Rel(val, ((Component)vc.gearStickAnimator).transform.position) : (WheelFromNode + new Vector3(0.45f, -0.3f, -0.1f))); if ((Object)(object)vc.gearStickAnimator != (Object)null) { GearRotFromNode = RelRot(val, ((Component)vc.gearStickAnimator).transform.rotation); GearStickPrefab = ((Component)vc.gearStickAnimator).gameObject; } MeshRenderer value3 = val5.Field("keyObject").GetValue<MeshRenderer>(); if ((Object)(object)value3 != (Object)null) { KeyPrefab = ((Component)value3).gameObject; } KeyHandPositionOffset = val5.Field("positionOffset").GetValue<Vector3>(); KeyHandRotationOffset = val5.Field("rotationOffset").GetValue<Vector3>(); Transform val6 = (((Object)(object)vc.passengerSeatTrigger != (Object)null) ? vc.passengerSeatTrigger.playerPositionNode : null); PassengerFromNode = (Vector3)(((Object)(object)val6 != (Object)null) ? Rel(val, val6.position) : new Vector3(0.9f, 0f, 0f)); HasSeatGeometry = true; Plugin.Log.LogInfo((object)$"Cruiser driver geometry (from seat node): wheel={WheelFromNode} d={WheelDiameter:0.000} key={KeyFromNode} keyTurned={KeyTurnedFromNode} gear={GearFromNode} passenger={PassengerFromNode}"); } internal static CruiserTuning Get() { //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) if (_cached != null && _cached.FromGame) { return _cached; } CruiserTuning cruiserTuning = new CruiserTuning(); try { Terminal val = Object.FindObjectOfType<Terminal>(); VehicleController val2 = null; if ((Object)(object)val != (Object)null && val.buyableVehicles != null) { BuyableVehicle[] buyableVehicles = val.buyableVehicles; foreach (BuyableVehicle val3 in buyableVehicles) { if (val3 != null && (Object)(object)val3.vehiclePrefab != (Object)null && (Object)(object)(val2 = val3.vehiclePrefab.GetComponent<VehicleController>()) != (Object)null) { break; } } } if ((Object)(object)val2 == (Object)null) { val2 = Object.FindObjectOfType<VehicleController>(); } if ((Object)(object)val2 != (Object)null) { cruiserTuning.EngineTorque = val2.EngineTorque; cruiserTuning.CarAcceleration = val2.carAcceleration; cruiserTuning.IdleSpeed = val2.idleSpeed; cruiserTuning.SteeringWheelTurnSpeed = val2.steeringWheelTurnSpeed; cruiserTuning.Stability = val2.stability; cruiserTuning.StabilizerSpeed = val2.speed; cruiserTuning.TurboBoostForce = val2.turboBoostForce; cruiserTuning.TurboBoostUpwardForce = val2.turboBoostUpwardForce; cruiserTuning.JumpForce = val2.jumpForce; Rigidbody val4 = (((Object)(object)val2.mainRigidbody != (Object)null) ? val2.mainRigidbody : ((Component)val2).GetComponent<Rigidbody>()); if ((Object)(object)val4 != (Object)null) { cruiserTuning.Mass = val4.mass; cruiserTuning.Drag = val4.drag; cruiserTuning.AngularDrag = val4.angularDrag; cruiserTuning.CenterOfMass = val4.centerOfMass; } if ((Object)(object)val2.FrontLeftWheel != (Object)null) { cruiserTuning.Front = WheelSetup.From(val2.FrontLeftWheel); } if ((Object)(object)val2.BackLeftWheel != (Object)null) { cruiserTuning.Rear = WheelSetup.From(val2.BackLeftWheel); } cruiserTuning.FromGame = true; cruiserTuning.Vc = val2; cruiserTuning.DriverSeat = val2.driverSeatTrigger; cruiserTuning.PassengerSeat = val2.passengerSeatTrigger; cruiserTuning.StartKey = (((Object)(object)val2.startKeyIgnitionTrigger != (Object)null) ? val2.startKeyIgnitionTrigger.GetComponentInChildren<InteractTrigger>(true) : null); cruiserTuning.RemoveKey = (((Object)(object)val2.removeKeyIgnitionTrigger != (Object)null) ? val2.removeKeyIgnitionTrigger.GetComponentInChildren<InteractTrigger>(true) : null); cruiserTuning.DriverDoorTrigger = val2.driverSideDoorTrigger; cruiserTuning.DriverDoor = val2.driverSideDoor; Traverse val5 = Traverse.Create((object)val2); cruiserTuning.CarTooltips = val5.Field("carTooltips").GetValue<string[]>(); cruiserTuning.ExitCarLayerMask = val5.Field("exitCarLayerMask").GetValue<int>(); if (cruiserTuning.ExitCarLayerMask == 0) { cruiserTuning.ExitCarLayerMask = -1; } float value = val5.Field("chanceToStartIgnition").GetValue<float>(); if (value > 0f) { cruiserTuning.StartChance = value; } cruiserTuning.HitMultiplier = val2.carReactToPlayerHitMultiplier; try { cruiserTuning.ReadDoorAudio(val2); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read door sounds: " + ex.Message)); } try { cruiserTuning.ReadSeatGeometry(val2); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Could not read cruiser seat geometry: " + ex2.Message)); } VehicleCollisionTrigger componentInChildren = ((Component)val2).GetComponentInChildren<VehicleCollisionTrigger>(true); if ((Object)(object)componentInChildren != (Object)null) { cruiserTuning.RamTriggerLayer = ((Component)componentInChildren).gameObject.layer; } Plugin.Log.LogInfo((object)("Cruiser seat driver: " + Desc(cruiserTuning.DriverSeat))); Plugin.Log.LogInfo((object)("Cruiser seat passenger: " + Desc(cruiserTuning.PassengerSeat))); Plugin.Log.LogInfo((object)("Cruiser key start: " + Desc(cruiserTuning.StartKey) + " | remove: " + Desc(cruiserTuning.RemoveKey) + " | door: " + Desc(cruiserTuning.DriverDoorTrigger))); Plugin.Log.LogInfo((object)string.Format("Cruiser tooltips: {0} startChance={1} hitMult={2} ramLayer={3} exitMask={4}", (cruiserTuning.CarTooltips == null) ? "null" : string.Join(" / ", cruiserTuning.CarTooltips), cruiserTuning.StartChance, cruiserTuning.HitMultiplier, cruiserTuning.RamTriggerLayer, cruiserTuning.ExitCarLayerMask)); Plugin.Log.LogInfo((object)($"Cruiser tuning: torque={cruiserTuning.EngineTorque} accel={cruiserTuning.CarAcceleration} idle={cruiserTuning.IdleSpeed} steerSpeed={cruiserTuning.SteeringWheelTurnSpeed} " + $"stability={cruiserTuning.Stability}/{cruiserTuning.StabilizerSpeed} turbo={cruiserTuning.TurboBoostForce}/{cruiserTuning.TurboBoostUpwardForce} jump={cruiserTuning.JumpForce} mass={cruiserTuning.Mass} drag={cruiserTuning.Drag}/{cruiserTuning.AngularDrag} com={cruiserTuning.CenterOfMass} " + $"frontSpring={cruiserTuning.Front.Spring.spring}/{cruiserTuning.Front.Spring.damper}/{cruiserTuning.Front.Spring.targetPosition} susp={cruiserTuning.Front.SuspensionDistance} " + $"rearSpring={cruiserTuning.Rear.Spring.spring}/{cruiserTuning.Rear.Spring.damper} wheelMass={cruiserTuning.Front.Mass}")); } else { Plugin.Log.LogWarning((object)"Cruiser prefab not found; using fallback handling values."); } } catch (Exception ex3) { Plugin.Log.LogWarning((object)("Could not read cruiser tuning: " + ex3.Message)); } _cached = cruiserTuning; return cruiserTuning; static string Desc(InteractTrigger it) { if (!((Object)(object)it == (Object)null)) { return $"'{it.hoverTip}' anim='{it.animationString}' stop={it.stopAnimationManually}/'{it.stopAnimationString}' clamp={it.clampLooking}({it.minVerticalClamp},{it.maxVerticalClamp},{it.horizontalClamp}) veh={it.setVehicleAnimation} hide={it.hidePlayerItem} hold={it.holdInteraction}/{it.timeToHold}"; } return "null"; } } internal static WheelFrictionCurve Forward(bool front) { //IL_0002: 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) WheelFrictionCurve result = default(WheelFrictionCurve); ((WheelFrictionCurve)(ref result)).extremumSlip = 0.2f; ((WheelFrictionCurve)(ref result)).extremumValue = 1f; ((WheelFrictionCurve)(ref result)).asymptoteSlip = 0.8f; ((WheelFrictionCurve)(ref result)).asymptoteValue = 1f; ((WheelFrictionCurve)(ref result)).stiffness = (front ? 2f : 0.75f); return result; } internal static WheelFrictionCurve Sideways() { //IL_0002: 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) WheelFrictionCurve result = default(WheelFrictionCurve); ((WheelFrictionCurve)(ref result)).extremumSlip = 0.7f; ((WheelFrictionCurve)(ref result)).extremumValue = 1f; ((WheelFrictionCurve)(ref result)).asymptoteSlip = 0.8f; ((WheelFrictionCurve)(ref result)).asymptoteValue = 1f; ((WheelFrictionCurve)(ref result)).stiffness = 2f; return result; } } [HarmonyPatch(typeof(ForestGiantAI), "OnCollideWithPlayer")] internal static class GiantGrabPatch { private static void Prefix(out List<KeyValuePair<GameObject, int>> __state) { __state = null; TruckController current = TruckController.Current; PlayerControllerB localPlayer = TruckDebugSpawner.LocalPlayer; if (!((Object)(object)current == (Object)null) && !((Object)(object)localPlayer == (Object)null) && current.HasInside(localPlayer)) { __state = current.HideWallsFromRays(); } } private static void Postfix(List<KeyValuePair<GameObject, int>> __state) { if (__state == null) { return; } foreach (KeyValuePair<GameObject, int> item in __state) { if ((Object)(object)item.Key != (Object)null) { item.Key.layer = item.Value; } } } } internal static class GlbModel { internal class Part { public string Name; public Vector3 LocalPosition; public Mesh Mesh; public Material[] Materials; } private static List<Part> _parts; private static bool _tried; internal static List<Part> Get() { if (_tried) { return _parts; } _tried = true; try { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location), "GJ_MilitaryTruck_ROK.glb"); if (!File.Exists(text)) { Plugin.Log.LogWarning((object)("Model not found: " + text + " (using placeholder boxes).")); return null; } _parts = Load(File.ReadAllBytes(text)); Plugin.Log.LogInfo((object)$"Loaded truck model: {_parts.Count} parts."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to load truck model: {arg}"); _parts = null; } return _parts; } internal static List<Part> LoadFile(string file) { try { string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location), file); if (!File.Exists(path)) { Plugin.Log.LogWarning((object)(file + " not found")); return null; } return Load(File.ReadAllBytes(path)); } catch (Exception ex) { Plugin.Log.LogWarning((object)(file + ": " + ex.Message)); return null; } } private static Vector3 G2U(Vector3 g) { //IL_0000: 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_000c: 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) return new Vector3(g.x, g.y, 0f - g.z); } private static List<Part> Load(byte[] glb) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //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_0139: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Expected O, but got Unknown //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Expected O, but got Unknown //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) int num = BitConverter.ToInt32(glb, 12); JObject val = JObject.Parse(Encoding.UTF8.GetString(glb, 20, num)); int binStart = 20 + num + 8; JArray views = (JArray)val["bufferViews"]; JArray accessors = (JArray)val["accessors"]; ? val2 = (JArray)val["images"]; if ((int)val2 == 0) { val2 = new JArray(); } List<Texture2D> list = new List<Texture2D>(); foreach (JToken item2 in (JArray)val2) { Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, true) { name = (((string)item2[(object)"name"]) ?? "tex"), wrapMode = (TextureWrapMode)0, anisoLevel = 4 }; if (item2[(object)"bufferView"] != null) { ImageConversion.LoadImage(val3, ViewBytes((int)item2[(object)"bufferView"]), true); } list.Add(val3); } ? val4 = (JArray)val["textures"]; if ((int)val4 == 0) { val4 = new JArray(); } JArray val5 = (JArray)val4; List<Material> mats = new List<Material>(); Shader val6 = Shader.Find("HDRP/Lit"); ? val7 = (JArray)val["materials"]; if ((int)val7 == 0) { val7 = new JArray(); } foreach (JToken item3 in (JArray)val7) { JToken val8 = item3[(object)"pbrMetallicRoughness"]; Color white = Color.white; JToken obj = ((val8 != null) ? val8[(object)"baseColorFactor"] : null); JArray val9 = (JArray)(object)((obj is JArray) ? obj : null); if (val9 != null) { ((Color)(ref white))..ctor((float)val9[0], (float)val9[1], (float)val9[2], 1f); } Material val10 = (((Object)(object)val6 != (Object)null) ? new Material(val6) : new Material(Shader.Find("Standard"))); ((Object)val10).name = (string)item3[(object)"name"]; val10.SetColor("_BaseColor", white); val10.color = white; if (((val8 != null) ? val8[(object)"baseColorTexture"] : null) != null) { int num2 = (int)val8[(object)"baseColorTexture"][(object)"index"]; int num3 = ((int?)val5[num2][(object)"source"]) ?? (-1); if (num3 >= 0 && num3 < list.Count) { val10.SetTexture("_BaseColorMap", (Texture)(object)list[num3]); val10.mainTexture = (Texture)(object)list[num3]; } } float valueOrDefault = ((float?)((val8 != null) ? val8[(object)"metallicFactor"] : null)).GetValueOrDefault(); float num4 = ((float?)((val8 != null) ? val8[(object)"roughnessFactor"] : null)) ?? 0.8f; if (val10.HasProperty("_Metallic")) { val10.SetFloat("_Metallic", valueOrDefault); } if (val10.HasProperty("_Smoothness")) { val10.SetFloat("_Smoothness", Mathf.Clamp01(1f - num4)); } if (((Object)val10).name == "Glass") { HdMat.Transparent(val10, Plugin.GlassOpacity.Value); } else { HdMat.Opaque(val10); } mats.Add(val10); } Material fallbackMat = (((Object)(object)val6 != (Object)null) ? new Material(val6) : new Material(Shader.Find("Standard"))); HdMat.Opaque(fallbackMat); JArray nodes = (JArray)val["nodes"]; JArray meshes = (JArray)val["meshes"]; List<Part> parts = new List<Part>(); JToken obj2 = val["scenes"]; object obj3; if (obj2 == null) { obj3 = null; } else { JToken obj4 = obj2[(object)((int?)val["scene"]).GetValueOrDefault()]; obj3 = ((obj4 != null) ? obj4[(object)"nodes"] : null); } JArray val11 = (JArray)((obj3 is JArray) ? obj3 : null); if (val11 != null) { foreach (JToken item4 in val11) { Walk((int)item4, Matrix4x4.identity); } } else { for (int i = 0; i < ((JContainer)nodes).Count; i++) { Walk(i, Matrix4x4.identity); } } return parts; Part BuildPart(string name, JToken mesh, Matrix4x4 world) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Expected O, but got Unknown //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0137: 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_017c: Unknown result type (might be due to invalid IL or missing references) Vector3 val12 = ((Matrix4x4)(ref world)).MultiplyPoint3x4(Vector3.zero); bool flag = ((Matrix4x4)(ref world)).determinant > 0f; List<Vector3> list2 = new List<Vector3>(); List<Vector3> list3 = new List<Vector3>(); List<Vector2> list4 = new List<Vector2>(); List<int[]> list5 = new List<int[]>(); List<Material> list6 = new List<Material>(); foreach (JToken item5 in (JArray)mesh[(object)"primitives"]) { JToken val13 = item5[(object)"attributes"]; float[] array = Floats((int)val13[(object)"POSITION"], 3); float[] array2 = ((val13[(object)"NORMAL"] != null) ? Floats((int)val13[(object)"NORMAL"], 3) : null); float[] array3 = ((val13[(object)"TEXCOORD_0"] != null) ? Floats((int)val13[(object)"TEXCOORD_0"], 2) : null); int count = list2.Count; int num5 = array.Length / 3; for (int j = 0; j < num5; j++) { Vector3 g = ((Matrix4x4)(ref world)).MultiplyPoint3x4(new Vector3(array[j * 3], array[j * 3 + 1], array[j * 3 + 2])) - val12; list2.Add(G2U(g)); Vector3 item; if (array2 == null) { item = Vector3.up; } else { Vector3 val14 = ((Matrix4x4)(ref world)).MultiplyVector(new Vector3(array2[j * 3], array2[j * 3 + 1], array2[j * 3 + 2])); item = G2U(((Vector3)(ref val14)).normalized); } list3.Add(item); list4.Add((Vector2)((array3 != null) ? new Vector2(array3[j * 2], 1f - array3[j * 2 + 1]) : Vector2.zero)); } int[] array4; if (item5[(object)"indices"] != null) { array4 = Ints((int)item5[(object)"indices"]); } else { array4 = new int[num5]; for (int k = 0; k < num5; k++) { array4[k] = k; } } int[] array5 = new int[array4.Length]; for (int l = 0; l + 2 < array4.Length; l += 3) { array5[l] = count + array4[l]; array5[l + 1] = count + (flag ? array4[l + 2] : array4[l + 1]); array5[l + 2] = count + (flag ? array4[l + 1] : array4[l + 2]); } list5.Add(array5); int num6 = ((int?)item5[(object)"material"]) ?? (-1); list6.Add((num6 >= 0 && num6 < mats.Count) ? mats[num6] : fallbackMat); } Mesh val15 = new Mesh { name = name, indexFormat = (IndexFormat)(list2.Count > 65000) }; val15.SetVertices(list2); val15.SetNormals(list3); val15.SetUVs(0, list4); val15.subMeshCount = list5.Count; for (int m = 0; m < list5.Count; m++) { val15.SetTriangles(list5[m], m); } val15.RecalculateBounds(); val15.UploadMeshData(true); return new Part { Name = name, LocalPosition = G2U(val12), Mesh = val15, Materials = list6.ToArray() }; } float[] Floats(int ai, int comps) { JToken val12 = accessors[ai]; JToken val13 = views[(int)val12[(object)"bufferView"]]; int num5 = binStart + ((int?)val13[(object)"byteOffset"]).GetValueOrDefault() + ((int?)val12[(object)"byteOffset"]).GetValueOrDefault(); int num6 = (int)val12[(object)"count"]; int num7 = ((int?)val13[(object)"byteStride"]) ?? (comps * 4); float[] array = new float[num6 * comps]; if (num7 == comps * 4 && BitConverter.IsLittleEndian) { Buffer.BlockCopy(glb, num5, array, 0, array.Length * 4); } else { for (int j = 0; j < num6; j++) { for (int k = 0; k < comps; k++) { array[j * comps + k] = BitConverter.ToSingle(glb, num5 + j * num7 + k * 4); } } } return array; } int[] Ints(int ai) { JToken val12 = accessors[ai]; JToken val13 = views[(int)val12[(object)"bufferView"]]; int num5 = binStart + ((int?)val13[(object)"byteOffset"]).GetValueOrDefault() + ((int?)val12[(object)"byteOffset"]).GetValueOrDefault(); int num6 = (int)val12[(object)"count"]; int num7 = (int)val12[(object)"componentType"]; int[] array = new int[num6]; if (num7 == 5125 && BitConverter.IsLittleEndian) { Buffer.BlockCopy(glb, num5, array, 0, num6 * 4); return array; } for (int j = 0; j < num6; j++) { array[j] = num7 switch { 5123 => BitConverter.ToUInt16(glb, num5 + j * 2), 5125 => (int)BitConverter.ToUInt32(glb, num5 + j * 4), _ => glb[num5 + j], }; } return array; } static Matrix4x4 LocalOf(JToken n) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) JToken obj5 = n[(object)"matrix"]; JArray val12 = (JArray)(object)((obj5 is JArray) ? obj5 : null); if (val12 != null) { Matrix4x4 result = default(Matrix4x4); for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { ((Matrix4x4)(ref result))[k, j] = (float)val12[j * 4 + k]; } } return result; } JToken obj6 = n[(object)"translation"]; JArray val13 = (JArray)(object)((obj6 is JArray) ? obj6 : null); ? val14 = ((val13 != null) ? new Vector3((float)val13[0], (float)val13[1], (float)val13[2]) : Vector3.zero); JToken obj7 = n[(object)"rotation"]; JArray val15 = (JArray)(object)((obj7 is JArray) ? obj7 : null); Quaternion val16 = (Quaternion)((val15 != null) ? new Quaternion((float)val15[0], (float)val15[1], (float)val15[2], (float)val15[3]) : Quaternion.identity); JToken obj8 = n[(object)"scale"]; JArray val17 = (JArray)(object)((obj8 is JArray) ? obj8 : null); Vector3 val18 = (Vector3)((val17 != null) ? new Vector3((float)val17[0], (float)val17[1], (float)val17[2]) : Vector3.one); return Matrix4x4.TRS((Vector3)val14, val16, val18); } byte[] ViewBytes(int vi) { JToken obj5 = views[vi]; int valueOrDefault2 = ((int?)obj5[(object)"byteOffset"]).GetValueOrDefault(); int num5 = (int)obj5[(object)"byteLength"]; byte[] array = new byte[num5]; Buffer.BlockCopy(glb, binStart + valueOrDefault2, array, 0, num5); return array; } void Walk(int ni, Matrix4x4 parent) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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) JToken val12 = nodes[ni]; Matrix4x4 val13 = parent * LocalOf(val12); if (val12[(object)"mesh"] != null) { parts.Add(BuildPart(((string)val12[(object)"name"]) ?? ("Node" + ni), meshes[(int)val12[(object)"mesh"]], val13)); } JToken obj5 = val12[(object)"children"]; JArray val14 = (JArray)(object)((obj5 is JArray) ? obj5 : null); if (val14 != null) { foreach (JToken item6 in val14) { Walk((int)item6, val13); } } } } internal static GameObject Spawn(Part part, Transform parent) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown GameObject val = new GameObject(part.Name); val.transform.SetParent(parent, false); val.transform.localPosition = part.LocalPosition; val.AddComponent<MeshFilter>().sharedMesh = part.Mesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterials = part.Materials; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; return val; } } internal static class HandTuner { internal class Pose { public string Name; public string Label; public bool Left; public Vector3 Offset; public Vector3 Rot; public float Hold = 0.7f; public float Grip; public float DefHold; public float DefGrip; public bool Body; public Vector3 DefOffset; } internal static readonly List<Pose> Poses; private static readonly Dictionary<string, Pose> ByName; internal static bool Editing; private static int _sel; private static readonly string[] Baked; private static PlayerControllerB _player; private static bool _fine; private static Vector2 _scroll; private static float _nextAutoSave; private const bool EditorEnabled = false; private static Vector3 _hold; private static GUIStyle _title; private static GUIStyle _btn; private static GUIStyle _sel2; private static GUIStyle _lbl; private static GUIStyle _rich; private static bool _third; internal static Pose Current { get { if (!Editing || Poses.Count <= 0) { return null; } return Poses[_sel]; } } private static string FilePath => Path.Combine(Paths.ConfigPath, "GJ_MilitaryTruck.hands.cfg"); private static void AddBody(string name, string label, Vector3 def) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Pose pose = new Pose { Name = name, Label = label, Body = true, Hold = 0f, DefHold = 0f, Offset = def, DefOffset = def }; Poses.Add(pose); ByName[name] = pose; } private static void Add(string name, string label, bool left, float grip, float hold = 0.7f) { Pose pose = new Pose { Name = name, Label = label, Left = left, Grip = grip, Hold = hold, DefGrip = grip, DefHold = hold }; Poses.Add(pose); ByName[name] = pose; } static HandTuner() { //IL_02bc: 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) Poses = new List<Pose>(); ByName = new Dictionary<string, Pose>(); Baked = new string[26] { "WheelL = 0, 0.024, -0.093, 0, 0.047, -4, 0, 46", "WheelR = -0.028, 0.015, -0.07, 0, 0.313, 0, 0, -51", "Gear = 0.018, 0.059, -0.1, 0.8, 0.9, 0, 0, 0", "Transfer = 0, 0.002, 0, 0.7, 0.8, 0, 0, 0", "Ignition = 0.065, 0.029, 0.167, 0.7, 0.464, 25, -15, 71", "Lights = 0.06, -0.002, 0, 0.7, 0.5, 17, -26, 46", "ParkBrake = 0.167, -0.085, 0.274, 0.7, 0.204, 0, 0, 0", "Wipers = -0.001, 0.19, 0, 0.7, 0.387, 10, -14, 11", "Horn = 0, 0, 0, 0, 0.2, 0, 0, 0", "Hatch = -0.039, 0.074, 0, 0.6, 0.18, -28, 61, 0", "GunL = -0.026, -0.001, -0.105, 0, 0, -25, 0, 4", "GunR = 0.033, 0.064, -0.127, 0, 0, 0, 0, 2", "3P_WheelL = -0.082, 0.078, -0.096, 0, 0.8, 0, 0, 0", "3P_WheelR = 0, 0, 0, 0, 0.85, 0, 0, 0", "3P_Gear = 0, 0, 0, 0.85, 0.9, 0, 0, 0", "3P_Transfer = 0, 0, 0, 0.7, 0.8, 0, 0, 0", "3P_Ignition = 0, 0, 0, 0.7, 0.55, 0, 0, 0", "3P_Lights = 0, 0, 0, 0.7, 0.5, 0, 0, 0", "3P_ParkBrake = 0, 0, 0, 0.7, 0.9, 0, 0, 0", "3P_Wipers = 0, 0, 0, 0.7, 0.45, 0, 0, 0", "3P_Horn = 0, 0, 0, 0, 0.2, 0, 0, 0", "3P_Hatch = 0, 0, 0, 0.6, 0.9, 0, 0, 0", "3P_GunL = 0, -0.055, -0.117, 0, 0.96, 0, 0, -2", "3P_GunR = 0, 0, 0, 0, 0.9, 0, 0, 0", "3P_SeatBody = 0, -0.341, 0, 0, 0, 0, 0, 0", "3P_GunnerBody = 0.021, -0.024, 0, 0, 0, 0, 0, 0" }; Add("WheelL", "핸들 (왼손)", left: true, 0.85f, 0f); Add("WheelR", "핸들 (오른손)", left: false, 0.85f, 0f); Add("Gear", "기어 레버 (오른손)", left: false, 0.9f, 0.85f); Add("Transfer", "보조변속기 (오른손)", left: false, 0.8f); Add("Ignition", "시동 스위치 (왼손)", left: true, 0.55f); Add("Lights", "라이트 스위치 (왼손)", left: true, 0.5f); Add("ParkBrake", "주차 브레이크 (왼손)", left: true, 0.9f); Add("Wipers", "와이퍼 (왼손)", left: true, 0.45f); Add("Horn", "경적 (오른손)", left: false, 0.2f, 0f); Add("Hatch", "해치 손잡이 (오른손)", left: false, 0.9f, 0.6f); Add("GunL", "기관총 손잡이 (왼손)", left: true, 0.9f, 0f); Add("GunR", "기관총 손잡이 (오른손)", left: false, 0.9f, 0f); foreach (Pose item in new List<Pose>(Poses)) { Add("3P_" + item.Name, "[3인칭] " + item.Label, item.Left, item.DefGrip, item.DefHold); } AddBody("3P_SeatBody", "[3인칭] 좌석에 앉은 몸", new Vector3(0f, -0.34f, 0f)); AddBody("3P_GunnerBody", "[3인칭] 해치에 선 몸", Vector3.zero); Load(); } internal static Pose Get(string name) { if (name == null || !ByName.TryGetValue(name, out var value)) { return null; } return value; } internal static Vector3 Offset(string name) { //IL_0010: 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) return Get(name)?.Offset ?? Vector3.zero; } internal static float Hold(string name) { Pose pose = Get(name); if (pose == null || !(pose.Hold > 0f)) { return 0.7f; } return pose.Hold; } internal static float Grip(string name) { return Get(name)?.Grip ?? 0.7f; } internal static Vector3 Rot(string name) { //IL_0010: 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) return Get(name)?.Rot ?? Vector3.zero; } private static void Load() { //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_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) try { string[] baked = Baked; for (int i = 0; i < baked.Length; i++) { string text = baked[i].Trim(); if (text.Length == 0 || text.StartsWith("#")) { continue; } int num = text.IndexOf('='); if (num < 0) { continue; } Pose pose = Get(text.Substring(0, num).Trim()); if (pose != null) { string[] array = text.Substring(num + 1).Split(','); if (array.Length >= 3) { pose.Offset = new Vector3(F(array[0]), F(array[1]), F(array[2])); } if (array.Length >= 4) { pose.Hold = F(array[3]); } if (array.Length >= 5) { pose.Grip = F(array[4]); } if (array.Length >= 8) { pose.Rot = new Vector3(F(array[5]), F(array[6]), F(array[7])); } } } Plugin.Log.LogInfo((object)"Hand poses: built-in."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Hand poses: " + ex.Message)); } } private static float F(string s) { return float.Parse(s.Trim(), CultureInfo.InvariantCulture); } private static string S(float f) { return f.ToString("0.###", CultureInfo.InvariantCulture); } private static void Save(bool quiet = false) { try { List<string> list = new List<string> { "# GJ_MilitaryTruck hand poses: name = offsetX(right), offsetY(up), offsetZ(forward) [m], hold [s], grip [0..1], wrist pitch, yaw, twist [deg]. Edit in game with F6." }; foreach (Pose pose in Poses) { list.Add(pose.Name + " = " + S(pose.Offset.x) + ", " + S(pose.Offset.y) + ", " + S(pose.Offset.z) + ", " + S(pose.Hold) + ", " + S(pose.Grip) + ", " + S(pose.Rot.x) + ", " + S(pose.Rot.y) + ", " + S(pose.Rot.z)); } File.WriteAllLines(FilePath, list); if (!quiet) { Plugin.Log.LogInfo((object)("Hand poses saved to " + FilePath + ".")); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Hand poses not saved: " + ex.Message)); } } private static void Open(PlayerControllerB p) { Editing = true; _player = p; if ((Object)(object)p != (Object)null) { p.disableLookInput = true; } } private static void Close() { Editing = false; if ((Object)(object)_player != (Object)null) { _player.disableLookInput = false; } Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } internal static void Update(PlayerControllerB player) { if (Editing) { Close(); } } internal static void OnGUI() { //IL_0125: 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_0145: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_003f: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Invalid comparison between Unknown and I4 //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) if (!Editing) { return; } if (_title == null) { _title = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1 }; _title.normal.textColor = Color.white; _lbl = new GUIStyle(GUI.skin.label) { fontSize = 15 }; _lbl.normal.textColor = Color.white; _btn = new GUIStyle(GUI.skin.button) { fontSize = 15 }; _sel2 = new GUIStyle(GUI.skin.button) { fontSize = 15, fontStyle = (FontStyle)1 }; GUIStyleState normal = _sel2.normal; GUIStyleState hover = _sel2.hover; Color textColor = default(Color); ((Color)(ref textColor))..ctor(1f, 0.75f, 0.2f); hover.textColor = textColor; normal.textColor = textColor; } Pose pose = Poses[_sel]; float num = Mathf.Min(760f, (float)Screen.height - 110f); GUILayout.BeginArea(new Rect(20f, 90f, 490f, num), GUI.skin.box); _scroll = GUILayout.BeginScrollView(_scroll, false, true, Array.Empty<GUILayoutOption>()); GUILayout.Label("손 위치 편집", _title, Array.Empty<GUILayoutOption>()); GUILayout.Label("기능을 고르면 그 손이 거기 가 있어요. 화살표 버튼을 누르고 있으면 움직여요.", _lbl, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("1인칭 (내 손)", (!_third) ? _sel2 : _btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _third = false; SelectFirst(); } if (GUILayout.Button("3인칭 (다른 사람 몸)", _third ? _sel2 : _btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _third = true; SelectFirst(); } GUILayout.EndHorizontal(); if (_third) { GUILayout.Label("3인칭: 차에 탄 다른 플레이어를 보면서 맞추세요. 고른 동작으로 그 사람 손이 가 있어요.", _lbl, Array.Empty<GUILayoutOption>()); } GUILayout.Space(4f); GUILayout.Label("왼손", _lbl, Array.Empty<GUILayoutOption>()); Row(left: true); GUILayout.Label("오른손", _lbl, Array.Empty<GUILayoutOption>()); Row(left: false); if (_third) { GUILayout.Label("몸 위치 (다른 사람 몸이 뜨거나 천장에 닿으면)", _lbl, Array.Empty<GUILayoutOption>()); BodyRow(); } GUILayout.Space(8f); GUILayout.Label($"<b>{pose.Label}</b> 좌우 {pose.Offset.x * 100f:0.0} · 위아래 {pose.Offset.y * 100f:0.0} · 앞뒤 {pose.Offset.z * 100f:0.0} cm", RichLbl(), Array.Empty<GUILayoutOption>()); Vector3 zero = Vector3.zero; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.RepeatButton("▲ 위", _btn, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(34f) })) { zero.y += 1f; } GUILayout.Space(12f); if (GUILayout.RepeatButton("앞으로 ↗", _btn, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(34f) })) { zero.z += 1f; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.RepeatButton("◀ 왼쪽", _btn, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(34f) })) { zero.x -= 1f; } if (GUILayout.RepeatButton("오른쪽 ▶", _btn, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(34f) })) { zero.x += 1f; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.RepeatButton("▼ 아래", _btn, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(34f) })) { zero.y -= 1f; } GUILayout.Space(12f); if (GUILayout.RepeatButton("뒤로 ↙", _btn, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(34f) })) { zero.z -= 1f; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); _fine = GUILayout.Toggle(_fine, " 천천히 움직이기", _lbl, Array.Empty<GUILayoutOption>()); if ((int)Event.current.type == 7 && zero != Vector3.zero) { pose.Offset += zero * (_fine ? 0.03f : 0.15f) * Time.deltaTime; } GUILayout.Space(6f); if (!pose.Body) { GUILayout.Label($"손목 위아래 {pose.Rot.x:0}°", _lbl, Array.Empty<GUILayoutOption>()); pose.Rot.x = Mathf.Round(GUILayout.HorizontalSlider(pose.Rot.x, -90f, 90f, Array.Empty<GUILayoutOption>())); GUILayout.Label($"손목 좌우 {pose.Rot.y:0}°", _lbl, Array.Empty<GUILayoutOption>()); pose.Rot.y = Mathf.Round(GUILayout.HorizontalSlider(pose.Rot.y, -90f, 90f, Array.Empty<GUILayoutOption>())); GUILayout.Label($"손 비틀기 {pose.Rot.z:0}°", _lbl, Array.Empty<GUILayoutOption>()); pose.Rot.z = Mathf.Round(GUILayout.HorizontalSlider(pose.Rot.z, -180f, 180f, Array.Empty<GUILayoutOption>())); GUILayout.Label($"손가락 쥐기 {pose.Grip * 100f:0}%", _lbl, Array.Empty<GUILayoutOption>()); pose.Grip = GUILayout.HorizontalSlider(pose.Grip, 0f, 1f, Array.Empty<GUILayoutOption>()); if (pose.Hold > 0f) { GUILayout.Label($"손을 대고 있는 시간 {pose.Hold:0.0}초", _lbl, Array.Empty<GUILayoutOption>()); pose.Hold = Mathf.Round(GUILayout.HorizontalSlider(pose.Hold, 0.2f, 3f, Array.Empty<GUILayoutOption>()) * 10f) / 10f; } } GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("이 기능 초기화", _btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { pose.Offset = pose.DefOffset; pose.Rot = Vector3.zero; pose.Hold = pose.DefHold; pose.Grip = pose.DefGrip; } if (GUILayout.Button("저장하고 닫기 (F6)", _btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { Close(); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.EndArea(); } private static GUIStyle RichLbl() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (_rich == null) { _rich = new GUIStyle(_lbl) { richText = true }; } return _rich; } private static bool InSet(Pose p) { return p.Name.StartsWith("3P_") == _third; } private static void SelectFirst() { for (int i = 0; i < Poses.Count; i++) { if (InSet(Poses[i])) { _sel = i; break; } } } private static void BodyRow() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i < Poses.Count; i++) { if (Poses[i].Body && GUILayout.Button(Poses[i].Label.Replace("[3인칭] ", ""), (i == _sel) ? _sel2 : _btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _sel = i; } } GUILayout.EndHorizontal(); } private static void Row(bool left) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int num = 0; for (int i = 0; i < Poses.Count; i++) { if (!Poses[i].Body && Poses[i].Left == left && InSet(Poses[i])) { if (GUILayout.Button(Poses[i].Label.Replace(left ? " (왼손)" : " (오른손)", "").Replace("[3인칭] ", ""), (i == _sel) ? _sel2 : _btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _sel = i; } if (++num % 3 == 0) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); } } } GUILayout.EndHorizontal(); } } internal static class FingerCurl { private static PlayerControllerB _for; private static Transform[] _l; private static Transform[] _r; private static bool[] _lThumb; private static bool[] _rThumb; private static Quaternion[] _lRest; private static Quaternion[] _rRest; private static bool _lOn; private static bool _rOn; internal static bool[] Thumbs(Transform[] bones) { if (bones == null) { return null; } bool[] array = new bool[bones.Length]; for (int i = 0; i < bones.Length; i++) { array[i] = (Object)(object)bones[i] != (Object)null && ((Object)bones[i]).name.StartsWith("finger1"); } return array; } private static Transform[] Find(PlayerControllerB p, string side, out Quaternion[] rest) { //IL_00ea: 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) rest = null; SkinnedMeshRenderer thisPlayerModelArms = p.thisPlayerModelArms; if ((Object)(object)thisPlayerModelArms == (Object)null || thisPlayerModelArms.bones == null) { return null; } List<Transform> list = new List<Transform>(); for (int i = 1; i <= 5; i++) { string[] array = new string[2] { $"finger{i}.{side}", $"finger{i}.{side}.001" }; foreach (string text in array) { Transform[] bones = thisPlayerModelArms.bones; foreach (Transform val in bones) { if ((Object)(object)val != (Object)null && ((Object)val).name == text) { list.Add(val); break; } } } } if (list.Count == 0) { return null; } rest = (Quaternion[])(object)new Quaternion[list.Count]; for (int l = 0; l < list.Count; l++) { rest[l] = list[l].localRotation; } return list.ToArray(); } internal static void Apply(PlayerControllerB p, float left, float right) { if (!((Object)(object)p == (Object)null)) { if ((Object)(object)_for != (Object)(object)p) { _for = p; _l = Find(p, "L", out _lRest); _r = Find(p, "R", out _rRest); _lThumb = Thumbs(_l); _rThumb = Thumbs(_r); _lOn = (_rOn = false); ManualLogSource log = Plugin.Log; Transform[] l = _l; object arg = ((l != null) ? l.Length : 0); Transform[] r = _r; log.LogInfo((object)$"Finger bones: L={arg} R={((r != null) ? r.Length : 0)}"); } Curl(_l, _lThumb, _lRest, left, ref _lOn); Curl(_r, _rThumb, _rRest, right, ref _rOn); } } private static void Curl(Transform[] bones, bool[] thumbs, Quaternion[] rest, float grip, ref bool on) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (bones == null) { return; } if (grip <= 0.001f) { if (on) { for (int i = 0; i < bones.Length; i++) { bones[i].localRotation = rest[i]; } on = false; } return; } on = true; float num = Plugin.FingerCurlDegrees.Value * grip; string value = Plugin.FingerCurlAxis.Value; Vector3 val = ((value == "Y") ? Vector3.up : ((value == "Z") ? Vector3.forward : Vector3.right)); for (int j = 0; j < bones.Length; j++) { bones[j].localRotation = rest[j] * Quaternion.AngleAxis(thumbs[j] ? (num * 0.45f) : num, val); } } } internal static class ArmBoneIK { private class Arm { public Transform Upper; public Transform Lower; public Transform Hand; public bool HasCanon; public Quaternion Canon; } private static PlayerControllerB _for; private static Arm _l; private static Arm _r; private static float _w; private static bool _logged; private static bool _init; private static bool _lock; private static bool _lockReady; private static Transform _body; private static Vector3 _sl; private static Vector3 _sr; private static Vector3 _rl; private static Vector3 _rr; private static Quaternion _tl = Quaternion.identity; private static Quaternion _tr = Quaternion.identity; private static Arm Find(PlayerControllerB p, string side) { SkinnedMeshRenderer smr = p.thisPlayerModelArms; if ((Object)(object)smr == (Object)null || smr.bones == null) { return null; } Arm arm = new Arm { Upper = B("arm." + side + "_upper"), Lower = B("arm." + side + "_lower"), Hand = B("hand." + side) }; if (!((Object)(object)arm.Upper != (Object)null) || !((Object)(object)arm.Lower != (Object)null) || !((Object)(object)arm.Hand != (Object)null)) { return null; } return arm; Transform B(string n) { Transform[] bones = smr.bones; foreach (Transform val in bones) { if ((Object)(object)val != (Object)null && ((Object)val).name == n) { return val; } } return null; } } internal static void Apply(PlayerControllerB p, bool on, Vector3 left, Vector3 right, Vector3 rotL, Vector3 rotR, Quaternion twL, Quaternion twR, Transform truck, bool useLeft = true, bool noSmooth = false, bool lockWrists = false, bool lockReady = false) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_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_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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0160: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: 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_01be: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: 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_020c: 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_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_021e: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null) { return; } if ((Object)(object)_for != (Object)(object)p) { _for = p; _l = Find(p, "L"); _r = Find(p, "R"); _logged = false; } if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)$"Arm bones: L={_l != null} R={_r != null}"); } _w = Mathf.MoveTowards(_w, on ? 1f : 0f, Time.deltaTime * 4f); if (_w <= 0f || (Object)(object)truck == (Object)null) { _init = false; return; } Vector3 val = -truck.up; Vector3 right2 = truck.right; Vector3 val2 = -truck.forward; float num = (noSmooth ? 1f : (1f - Mathf.Exp((0f - Time.deltaTime) * 9f))); Vector3 val3 = truck.InverseTransformPoint(left); Vector3 val4 = truck.InverseTransformPoint(right); if (!_init) { _sl = val3; _sr = val4; _rl = rotL; _rr = rotR; _init = true; } _sl = Vector3.Lerp(_sl, val3, num); _sr = Vector3.Lerp(_sr, val4, num); _rl = Vector3.Lerp(_rl, rotL, num); _rr = Vector3.Lerp(_rr, rotR, num); _tl = Quaternion.Slerp(_tl, twL, num); _tr = Quaternion.Slerp(_tr, twR, num); twL = _tl; twR = _tr; left = truck.TransformPoint(_sl); right = truck.TransformPoint(_sr); rotL = _rl; rotR = _rr; _lock = lockWrists; _lockReady = lockReady; _body = ((Component)p).transform; if (useLeft) { Solve(_l, left, val * 1f - right2 * 0.7f + val2 * 0.2f, rotL, twL, truck); } Solve(_r, right, val * 1f + right2 * 0.7f + val2 * 0.2f, rotR, twR, truck); } private static void Solve(Arm a, Vector3 target, Vector3 poleDir, Vector3 rot, Quaternion twist, Transform truck) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0183: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if (a == null) { return; } Vector3 position = a.Upper.position; Vector3 position2 = a.Lower.position; Vector3 position3 = a.Hand.position; target = Vector3.Lerp(position3, target, _w); float num = Vector3.Distance(position, position2); float num2 = Vector3.Distance(position2, position3); Vector3 val = target - position; float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, 0.001f, (num + num2) * 0.999f); Vector3 normalized = ((Vector3)(ref val)).normalized; float num4 = (num * num - num2 * num2 + num3 * num3) / (2f * num3); float num5 = Mathf.Sqrt(Mathf.Max(0f, num * num - num4 * num4)); Vector3 val2 = Vector3.ProjectOnPlane(poleDir, normalized); if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { val2 = Vector3.ProjectOnPlane(Vector3.down, normalized); } Vector3 val3 = position + normalized * num4 + ((Vector3)(ref val2)).normalized * num5; Quaternion val4 = a.Hand.rotation; if (_lock) { if (!a.HasCanon && _lockReady && (Object)(object)_body != (Object)null) { a.HasCanon = true; a.Canon = Quaternion.Inverse(_body.rotation) * val4; } if (a.HasCanon) { val4 = truck.rotation * a.Canon; } } a.Upper.rotation = Quaternion.FromToRotation(position2 - position, val3 - position) * a.Upper.rotation; position2 = a.Lower.position; position3 = a.Hand.position; a.Lower.rotation = Quaternion.FromToRotation(position3 - position2, position + normalized * num3 - position2) * a.Lower.rotation; Quaternion val5 = Quaternion.AngleAxis(rot.y, truck.up) * Quaternion.AngleAxis(rot.x, truck.right) * Quaternion.AngleAxis(rot.z, truck.forward); a.Hand.rotation = Quaternion.Slerp(Quaternion.identity, twist * val5, _w) * val4; } } internal static class HdMat { private static MethodInfo _validate; private static bool _looked; private static void Validate(Material m) { if (!_looked) { _looked = true; _validate = Type.GetType("UnityEngine.Rendering.HighDefinition.HDMaterial, Unity.RenderPipelines.HighDefinition.Runtime")?.GetMethod("ValidateMaterial", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Material) }, null); Plugin.Log.LogInfo((object)((_validate != null) ? "HDRP material validation available." : "HDRP HDMaterial.ValidateMaterial not found; materials set up by hand.")); } try { _validate?.Invoke(null, new object[1] { m }); } catch (Exception ex) { Plugin.Log.LogWarning((object)("ValidateMaterial(" + ((Object)m).name + "): " + (ex.InnerException?.Message ?? ex.Message))); } } internal static void Opaque(Material m, bool doubleSided = true) { if (!((Object)(object)m == (Object)null)) { if (doubleSided) { m.SetFloat("_DoubleSidedEnable", 1f); m.SetFloat("_CullMode", 0f); m.SetFloat("_CullModeForward", 0f); m.SetFloat("_DoubleSidedNormalMode", 1f); m.EnableKeyword("_DOUBLESIDED_ON"); } m.SetFloat("_SurfaceType", 0f); m.SetFloat("_ZWrite", 1f); Validate(m); } } internal static void Transparent(Material m, float alpha) { //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_0024: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m == (Object)null)) { Color color = m.GetColor("_BaseColor"); color.a = alpha; m.SetColor("_BaseColor", color); m.SetFloat("_SurfaceType", 1f); m.SetFloat("_BlendMode", 0f); m.SetFloat("_EnableFogOnTransparent", 0f); m.SetFloat("_DoubleSidedEnable", 1f); m.SetFloat("_CullMode", 0f); m.SetFloat("_CullModeForward", 0f); m.SetFloat("_RefractionModel", 0f); m.SetFloat("_TransparentZWrite", 0f); m.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); m.EnableKeyword("_BLENDMODE_ALPHA"); m.EnableKeyword("_DOUBLESIDED_ON"); m.renderQueue = 3000; Validate(m); } } } internal static class HumveeShop { private static TerminalNode _confirm; private static TerminalNode _bought; private static TerminalNode _cancelled; private static TerminalNode _fail; internal static bool Pending; private static TerminalNode _noCruiser; private const string ListTag = "[gjHumveeLine]"; private static Terminal _term; private static string _lastScreen; private static bool _viaDropship; private static float _landedAt = -1f; private const string SaveKey = "GJ_HMMWV"; private static Type _es3; internal static bool SessionGone; private static bool _loadEngine; private static (Vector3, Quaternion)? _loadPose; private static int _loadTries; private static float _nextLoadTry; internal static int Price => Mathf.Max(0, Plugin.HumveePrice.Value); internal static bool Enabled { get { if (Plugin.EnableHumvee != null) { return Plugin.EnableHumvee.Value; } return true; } } internal static bool HumveeOwned { get { if ((!Enabled || !((Object)(object)TruckController.Current != (Object)null) || TruckController.Current.Destroyed) && !Pending) { return _loadPose.HasValue; } return true; } } private static string SavePath { get { GameNetworkManager instance = GameNetworkManager.Instance; string text = (((Object)(object)instance != (Object)null && !string.IsNullOrEmpty(instance.currentSaveFileName)) ? instance.currentSaveFileName : "LCSaveFile1"); return Path.Combine(Application.persistentDataPath, "GJ_MilitaryTruck_" + text + ".txt"); } } private static Type Es3 { get { if (_es3 != null) { return _es3; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("ES3", throwOnError: false); if (type != null) { _es3 = type; break; } } return _es3; } } private static string Slot { get { GameNetworkManager instance = GameNetworkManager.Instance; if (!((Object)(object)instance != (Object)nu