Decompiled source of KinetosNPC v1.0.0
Mods/KinetosNPC.dll
Decompiled 6 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BoneLib; using BoneLib.BoneMenu; using BoneLib.Notifications; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppRootMotion; using Il2CppRootMotion.FinalIK; using Il2CppSLZ.Data; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.Utilities; using Il2CppSLZ.Marrow.Warehouse; using KinetosNPC; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Kinetos NPC")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: MelonInfo(typeof(KinetosNpcMod), "Kinetos NPC", "1.0.0", "Gabri", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace KinetosNPC { public static class KinetosAssets { public const string PcBundleResource = "KinetosNPC.Resources.kinetos_npc_pc.bundle"; public const string QuestBundleResource = "KinetosNPC.Resources.kinetos_npc_quest.bundle"; private static AssetBundle _bundle; private static Material _templateOpaqueMat; private static readonly Dictionary<uint, Material> _sharedMatCache = new Dictionary<uint, Material>(); public static bool IsLoaded { get { if ((Object)(object)_bundle != (Object)null && ((Il2CppObjectBase)_bundle).Pointer != IntPtr.Zero && (Object)(object)RigPrefab != (Object)null) { return ((Il2CppObjectBase)RigPrefab).Pointer != IntPtr.Zero; } return false; } } public static GameObject RigPrefab { get; private set; } public static AudioClip BoneCrackClip { get; private set; } public static AudioClip VitalHitClip { get; private set; } public static AudioClip[] FootstepClips { get; private set; } = Array.Empty<AudioClip>(); public static bool EnsureLoaded() { if (IsLoaded) { return true; } string text = (KinetosPreferences.IsQuestDevice ? "KinetosNPC.Resources.kinetos_npc_quest.bundle" : "KinetosNPC.Resources.kinetos_npc_pc.bundle"); try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text); if (stream == null) { MelonLogger.Error("[KinetosNPC] Missing embedded bundle resource '" + text + "'!"); return false; } byte[] array; using (MemoryStream memoryStream = new MemoryStream((int)Math.Max(65536L, stream.Length))) { stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Il2CppStructArray<byte> val = new Il2CppStructArray<byte>((long)array.Length); for (int i = 0; i < array.Length; i++) { ((Il2CppArrayBase<byte>)(object)val)[i] = array[i]; } _bundle = AssetBundle.LoadFromMemory(val); if ((Object)(object)_bundle == (Object)null || ((Il2CppObjectBase)_bundle).Pointer == IntPtr.Zero) { MelonLogger.Error("[KinetosNPC] AssetBundle.LoadFromMemory failed for '" + text + "'!"); return false; } ((Object)_bundle).hideFlags = (HideFlags)32; Il2CppReferenceArray<Object> val2 = _bundle.LoadAllAssets(); Dictionary<string, AudioClip> dictionary = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase); if (val2 != null) { foreach (Object item in (Il2CppArrayBase<Object>)(object)val2) { if (item == (Object)null || ((Il2CppObjectBase)item).Pointer == IntPtr.Zero) { continue; } GameObject val3 = ((Il2CppObjectBase)item).TryCast<GameObject>(); if ((Object)(object)val3 != (Object)null && (Object)(object)val3.transform.Find("Pilot PuppetMaster") != (Object)null) { RigPrefab = val3; continue; } AudioClip val4 = ((Il2CppObjectBase)item).TryCast<AudioClip>(); if ((Object)(object)val4 != (Object)null) { string text2 = ((Object)val4).name ?? ""; if (text2.Contains("bone-crack", StringComparison.OrdinalIgnoreCase)) { BoneCrackClip = val4; } else if (text2.Contains("FootstepVinyl-07", StringComparison.OrdinalIgnoreCase)) { VitalHitClip = val4; } else if (text2.StartsWith("FootstepVinyl-", StringComparison.OrdinalIgnoreCase)) { dictionary[text2] = val4; } } } } List<AudioClip> list = new List<AudioClip>(4); string[] array2 = new string[4] { "01", "02", "03", "04" }; foreach (string text3 in array2) { if (dictionary.TryGetValue("FootstepVinyl-" + text3, out var value) && (Object)(object)value != (Object)null && ((Il2CppObjectBase)value).Pointer != IntPtr.Zero) { ((Object)value).hideFlags = (HideFlags)32; list.Add(value); } } FootstepClips = list.ToArray(); if ((Object)(object)RigPrefab != (Object)null) { ((Object)RigPrefab).hideFlags = (HideFlags)32; } if ((Object)(object)BoneCrackClip != (Object)null) { ((Object)BoneCrackClip).hideFlags = (HideFlags)32; } if ((Object)(object)VitalHitClip != (Object)null) { ((Object)VitalHitClip).hideFlags = (HideFlags)32; } if ((Object)(object)RigPrefab == (Object)null || ((Il2CppObjectBase)RigPrefab).Pointer == IntPtr.Zero) { MelonLogger.Error("[KinetosNPC] KinetosNPCRig prefab missing inside bundle!"); return false; } MelonLogger.Msg($"[KinetosNPC] Loaded '{text}'! RigPrefab='KinetosNPCRig', BoneCrack={(Object)(object)BoneCrackClip != (Object)null}, Footsteps={FootstepClips.Length}"); return true; } catch (Exception value2) { MelonLogger.Error($"[KinetosNPC] Failed loading bundle '{text}': {value2}"); return false; } } private static T LoadAsset<T>(string name) where T : Object { if ((Object)(object)_bundle == (Object)null || ((Il2CppObjectBase)_bundle).Pointer == IntPtr.Zero) { return default(T); } try { Object obj = _bundle.LoadAsset(name, Il2CppType.Of<T>()); return (obj != null) ? ((Il2CppObjectBase)obj).TryCast<T>() : default(T); } catch { return default(T); } } public static AudioClip GetRandomFootstepClip() { if (FootstepClips == null || FootstepClips.Length == 0) { return VitalHitClip; } return FootstepClips[Random.Range(0, FootstepClips.Length)]; } public static Color ResolveStyleColor(KinetosColorStyle style) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) return (Color)(style switch { KinetosColorStyle.OriginalKinetosGrey => new Color(0.5849f, 0.5849f, 0.5849f, 1f), KinetosColorStyle.CrashTestYellow => new Color(0.95f, 0.76f, 0.14f, 1f), KinetosColorStyle.TacticalRed => new Color(0.84f, 0.16f, 0.16f, 1f), KinetosColorStyle.CyberBlue => new Color(0.14f, 0.56f, 0.92f, 1f), KinetosColorStyle.NeonGreen => new Color(0.2f, 0.85f, 0.36f, 1f), KinetosColorStyle.PureWhite => new Color(0.92f, 0.93f, 0.95f, 1f), KinetosColorStyle.RandomColor => Color.HSVToRGB(Random.value, 0.72f, 0.9f), _ => new Color(0.5849f, 0.5849f, 0.5849f, 1f), }); } public static Material CreateUniqueSurfaceMaterial(Color baseColor, float smoothness = 0.08f, float metallic = 0f) { //IL_0018: 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) Material obj = CloneBaseURPMaterial(); ((Object)obj).name = "Kinetos_NPC_InstanceMat"; obj.enableInstancing = true; ApplySurfaceProps(obj, baseColor, smoothness, metallic, Color.black); return obj; } public static void ApplySurfaceProps(Material mat, Color color, float smoothness, float metallic, Color emission) { //IL_001d: 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_004f: 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) if ((Object)(object)mat == (Object)null || ((Il2CppObjectBase)mat).Pointer == IntPtr.Zero) { return; } mat.color = color; if (mat.HasProperty("_BaseColor")) { mat.SetColor("_BaseColor", color); } if (mat.HasProperty("_Color")) { mat.SetColor("_Color", color); } if (mat.HasProperty("_Smoothness")) { mat.SetFloat("_Smoothness", smoothness); } if (mat.HasProperty("_Glossiness")) { mat.SetFloat("_Glossiness", smoothness); } if (mat.HasProperty("_Metallic")) { mat.SetFloat("_Metallic", metallic); } if (mat.HasProperty("_BumpScale")) { mat.SetFloat("_BumpScale", 0f); } if (mat.HasProperty("_OcclusionStrength")) { mat.SetFloat("_OcclusionStrength", 0f); } if (mat.HasProperty("_EmissionColor")) { mat.SetColor("_EmissionColor", emission); if (((Color)(ref emission)).maxColorComponent > 0.01f) { mat.EnableKeyword("_EMISSION"); } } } private static Material CloneBaseURPMaterial() { //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown if ((Object)(object)_templateOpaqueMat == (Object)null || ((Il2CppObjectBase)_templateOpaqueMat).Pointer == IntPtr.Zero) { Shader val = Shader.Find("Universal Render Pipeline/Lit (PBR Workflow)"); if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero) { val = Shader.Find("Universal Render Pipeline/Lit"); } if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero) { val = Shader.Find("Universal Render Pipeline/Simple Lit"); } if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero) { val = Shader.Find("SLZ/Lit"); } if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero) { _templateOpaqueMat = new Material(val); } else { Il2CppArrayBase<Material> val2 = Resources.FindObjectsOfTypeAll<Material>(); if (val2 != null) { foreach (Material item in val2) { if (!((Object)(object)item == (Object)null) && !(((Il2CppObjectBase)item).Pointer == IntPtr.Zero) && !((Object)(object)item.shader == (Object)null)) { string text = ((Object)item.shader).name ?? ""; if (item.renderQueue <= 2500 && (text.Contains("Lit") || text.Contains("Universal Render Pipeline"))) { _templateOpaqueMat = new Material(item); break; } } } } if ((Object)(object)_templateOpaqueMat == (Object)null || ((Il2CppObjectBase)_templateOpaqueMat).Pointer == IntPtr.Zero) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); _templateOpaqueMat = new Material(((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial); Object.Destroy((Object)(object)obj); } } string[] array = new string[10] { "_BaseMap", "_MainTex", "_BumpMap", "_MetallicGlossMap", "_MetallicMap", "_SpecGlossMap", "_OcclusionMap", "_EmissionMap", "_DetailAlbedoMap", "_DetailNormalMap" }; foreach (string text2 in array) { if (_templateOpaqueMat.HasProperty(text2)) { _templateOpaqueMat.SetTexture(text2, (Texture)null); } } ((Object)_templateOpaqueMat).hideFlags = (HideFlags)32; } return new Material(_templateOpaqueMat); } } public static class KinetosGrips { private sealed class HandCollisionPass { public IntPtr HeldGripPtr; public Rigidbody HeldLimbBody; public KinetosNpcBrain HeldNpc; public float ReleaseEndTime = -1f; public readonly List<Collider> HandSolids = new List<Collider>(12); public readonly List<Collider> NpcSolids = new List<Collider>(24); } public const string GripObjectName = "KinetosBoxGrip"; private const int DefaultInteractableLayer = 15; private const float ReleasePassLingerSeconds = 0.25f; public const int SolidRayMask = -2081194553; private static readonly Dictionary<string, HandPose> _poseCache = new Dictionary<string, HandPose>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> _missingPoses = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<IntPtr, KinetosNpcBrain> _limbRbToNpc = new Dictionary<IntPtr, KinetosNpcBrain>(); private static bool _anyActiveHold; private static readonly HandCollisionPass[] _passes = new HandCollisionPass[2] { new HandCollisionPass(), new HandCollisionPass() }; public static void RegisterLimb(Rigidbody limbRb, KinetosNpcBrain npc) { if ((Object)(object)limbRb != (Object)null && ((Il2CppObjectBase)limbRb).Pointer != IntPtr.Zero && (Object)(object)npc != (Object)null) { _limbRbToNpc[((Il2CppObjectBase)limbRb).Pointer] = npc; } } public static void UnregisterLimbs(IReadOnlyList<Rigidbody> rigidbodies) { if (rigidbodies == null) { return; } for (int i = 0; i < rigidbodies.Count; i++) { Rigidbody val = rigidbodies[i]; if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero) { _limbRbToNpc.Remove(((Il2CppObjectBase)val).Pointer); } } } public static bool IsLimbHeldByPlayer(KinetosNpcBrain npc, Rigidbody limbRb, out int totalHandsOnNpc) { totalHandsOnNpc = 0; if (!_anyActiveHold || (Object)(object)npc == (Object)null || ((Il2CppObjectBase)npc).Pointer == IntPtr.Zero) { return false; } bool result = false; IntPtr intPtr = (((Object)(object)limbRb != (Object)null) ? ((Il2CppObjectBase)limbRb).Pointer : IntPtr.Zero); for (int i = 0; i < _passes.Length; i++) { HandCollisionPass handCollisionPass = _passes[i]; if (handCollisionPass.ReleaseEndTime < 0f && (Object)(object)handCollisionPass.HeldNpc != (Object)null && ((Il2CppObjectBase)handCollisionPass.HeldNpc).Pointer == ((Il2CppObjectBase)npc).Pointer) { totalHandsOnNpc++; if (intPtr != IntPtr.Zero && (Object)(object)handCollisionPass.HeldLimbBody != (Object)null && ((Il2CppObjectBase)handCollisionPass.HeldLimbBody).Pointer == intPtr) { result = true; } } } return result; } public static BoxGrip AttachLimbGrip(Rigidbody limbRb, MarrowEntity entity, MarrowBody marrowBody, InteractableHost host, Collider solidCollider, bool highPriority, out Transform gripTransform) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00c7: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown gripTransform = null; if ((Object)(object)limbRb == (Object)null || (Object)(object)entity == (Object)null || (Object)(object)marrowBody == (Object)null || (Object)(object)host == (Object)null || (Object)(object)solidCollider == (Object)null) { return null; } ((MarrowBehaviour)host).marrowEntity = entity; host._marrowBody = marrowBody; host.ignoreBodyOnGrab = false; ComputeColliderRelativeBox(((Component)limbRb).transform, solidCollider, out var center, out var size); Vector3 val = Vector3.Max(size * 1.28f, new Vector3(0.13f, 0.13f, 0.13f)); int num = LayerMask.NameToLayer("Interactable"); if (num < 0) { num = 15; } GameObject val2 = new GameObject("KinetosBoxGrip"); val2.SetActive(false); val2.layer = num; val2.transform.SetParent(((Component)limbRb).transform, false); val2.transform.localPosition = center; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; BoxCollider val3 = val2.AddComponent<BoxCollider>(); ((Collider)val3).isTrigger = true; val3.center = Vector3.zero; val3.size = val; BoxGrip val4 = val2.AddComponent<BoxGrip>(); ((Grip)val4)._marrowEntity = entity; ((Grip)val4).targetTransform = val2.transform; ((Grip)val4).isThrowable = true; ((Grip)val4).ignoreGripTargetOnAttach = false; ((Grip)val4).primaryMovementAxis = Vector3.forward; ((Grip)val4).secondaryMovementAxis = Vector3.up; ((Grip)val4).gripOptions = (InteractionOptions)9; ((Grip)val4).priority = (highPriority ? 1.35f : 1f); ((Grip)val4).minBreakForce = float.PositiveInfinity; ((Grip)val4).maxBreakForce = float.PositiveInfinity; ((Grip)val4).defaultGripDistance = float.PositiveInfinity; ((TargetGrip)val4).rotationLimit = 180f; ((TargetGrip)val4).rotationPriorityBuffer = 20f; ((TargetGrip)val4).targetFlipOnPrimaryAxis = true; ((TargetGrip)val4).targetFlipOnTertiaryAxis = false; val4.sandwichSize = 0.12f; float num2 = Mathf.Min(val.x, Mathf.Min(val.y, val.z)); val4.edgePadding = Mathf.Clamp(num2 * 0.25f, 0.01f, 0.03f); HandPose val5 = ResolveHandPose("BoxFaceGrip"); HandPose val6 = ResolveHandPose("BoxEdgeGrip") ?? val5; HandPose val7 = ResolveHandPose("BoxCornerGrip") ?? val5; HandPose sandwichHandPose = ResolveHandPose("BoxSandwichGrip") ?? val5; val4.sandwichHandPose = sandwichHandPose; val4.canBeSandwichedGrabbed = false; val4.edgeHandPose = val6; val4.edgeHandPoseRadius = 0.05f; val4.canBeEdgeGrabbed = (Object)(object)val6 != (Object)null; val4.cornerHandPose = val7; val4.cornerHandPoseRadius = 0.05f; val4.canBeCornerGrabbed = (Object)(object)val7 != (Object)null; val4.faceHandPose = val5; val4.faceHandPoseRadius = 1f; val4.canBeFaceGrabbed = true; if ((Object)(object)val5 != (Object)null) { ((Grip)val4).handPose = val5; } val4.enabledFaces = (Faces)(-1); val4.enabledEdges = (Edges)(-1); val4.enabledCorners = (Corners)(-1); val4.forceGrabFace = (Faces)2; val4.forceGrabTop = (Faces)4; val4._boxCollider = val3; val4._boxCenter = Vector3.zero; val4._boxSize = val; val4._boxExtents = val * 0.5f; val4._bounds = new Bounds(Vector3.zero, val); ((Grip)val4).gripColliders = new Il2CppReferenceArray<Collider>(0L); Il2CppReferenceArray<Collider> val8 = new Il2CppReferenceArray<Collider>(1L); ((Il2CppArrayBase<Collider>)(object)val8)[0] = solidCollider; ((Grip)val4).additionalGripColliders = val8; AnimationCurve val9 = new AnimationCurve(); val9.AddKey(-180f, 0f); val9.AddKey(0f, 0f); val9.AddKey(180f, 0f); ((Grip)val4).handleAmplifyCurve = val9; ForcePullGrip obj = val2.AddComponent<ForcePullGrip>(); obj._grip = (Grip)(object)val4; obj.maxSpeed = float.PositiveInfinity; val2.SetActive(true); gripTransform = val2.transform; return val4; } public static void FinalizeHostGrips(List<(InteractableHost Host, Transform GripTransform)> hostEntries) { if (hostEntries == null) { return; } for (int i = 0; i < hostEntries.Count; i++) { var (val, val2) = hostEntries[i]; if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero || (Object)(object)val2 == (Object)null || ((Il2CppObjectBase)val2).Pointer == IntPtr.Zero) { continue; } try { if (val._grips == null || val._grips.Count == 0) { val.DecorateHostOnChildGrips(val2); } } catch { } } } public static void ForceDetachNpcGrips(IReadOnlyList<InteractableHost> hosts) { if (hosts == null) { return; } for (int i = 0; i < hosts.Count; i++) { InteractableHost val = hosts[i]; if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero || val._grips == null) { continue; } try { for (int j = 0; j < val._grips.Count; j++) { Grip val2 = val._grips[j]; if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero && val2.attachedHands != null && val2.attachedHands.Count > 0) { val2.ForceDetach(); } } } catch { } } } private static void ComputeColliderRelativeBox(Transform rbTf, Collider solidCollider, out Vector3 center, out Vector3 size) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; size = new Vector3(0.14f, 0.14f, 0.14f); CapsuleCollider val2 = ((Il2CppObjectBase)solidCollider).TryCast<CapsuleCollider>(); if ((Object)(object)val2 != (Object)null) { val = val2.center; float radius = val2.radius; float num = Mathf.Max(val2.height * 0.5f, radius); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(radius, radius, radius); if (val2.direction == 0) { val3.x = num; } else if (val2.direction == 1) { val3.y = num; } else { val3.z = num; } size = val3 * 2f; } else { BoxCollider val4 = ((Il2CppObjectBase)solidCollider).TryCast<BoxCollider>(); if ((Object)(object)val4 != (Object)null) { val = val4.center; size = val4.size; } } if ((Object)(object)((Component)solidCollider).transform != (Object)(object)rbTf) { center = rbTf.InverseTransformPoint(((Component)solidCollider).transform.TransformPoint(val)); } else { center = val; } } private static HandPose ResolveHandPose(string poseName) { if (_poseCache.TryGetValue(poseName, out var value) && (Object)(object)value != (Object)null && ((Il2CppObjectBase)value).Pointer != IntPtr.Zero) { return value; } if (_missingPoses.Contains(poseName)) { return null; } HandPose val = null; try { Il2CppArrayBase<HandPose> val2 = Resources.FindObjectsOfTypeAll<HandPose>(); if (val2 != null) { foreach (HandPose item in val2) { if ((Object)(object)item != (Object)null && ((Il2CppObjectBase)item).Pointer != IntPtr.Zero && string.Equals(((Object)item).name, poseName, StringComparison.OrdinalIgnoreCase)) { val = item; break; } } } if ((Object)(object)val == (Object)null) { val = LoadHandPoseFromDedupedBundle(poseName); } if ((Object)(object)val == (Object)null) { Il2CppArrayBase<BoxGrip> val3 = Resources.FindObjectsOfTypeAll<BoxGrip>(); if (val3 != null) { foreach (BoxGrip item2 in val3) { if (!((Object)(object)item2 == (Object)null) && !(((Il2CppObjectBase)item2).Pointer == IntPtr.Zero)) { if (poseName.Contains("Face", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.faceHandPose != (Object)null) { val = item2.faceHandPose; break; } if (poseName.Contains("Edge", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.edgeHandPose != (Object)null) { val = item2.edgeHandPose; break; } if (poseName.Contains("Corner", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.cornerHandPose != (Object)null) { val = item2.cornerHandPose; break; } if (poseName.Contains("Sandwich", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.sandwichHandPose != (Object)null) { val = item2.sandwichHandPose; break; } } } } } if ((Object)(object)val == (Object)null && (Object)(object)Player.RigManager != (Object)null && (Object)(object)Player.RigManager.worldGrip != (Object)null && (Object)(object)((Grip)Player.RigManager.worldGrip).handPose != (Object)null) { val = ((Grip)Player.RigManager.worldGrip).handPose; } } catch { } if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero) { _missingPoses.Add(poseName); return null; } ((Object)val).hideFlags = (HideFlags)32; _poseCache[poseName] = val; return val; } private static HandPose LoadHandPoseFromDedupedBundle(string poseName) { string streamingAssetsPath = Application.streamingAssetsPath; if (string.IsNullOrEmpty(streamingAssetsPath)) { return null; } string[] array = new string[2] { "StandaloneWindows64", "Android" }; foreach (string path in array) { string path2 = Path.Combine(streamingAssetsPath, "aa", path, "deduped_assets_handpose"); if (!Directory.Exists(path2)) { continue; } string[] files = Directory.GetFiles(path2, poseName.ToLowerInvariant() + "_*.bundle"); if (files.Length == 0) { continue; } AssetBundle val = AssetBundle.LoadFromFile(files[0]); if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero) { Il2CppReferenceArray<AssetBundle> allLoadedAssetBundles_Native = AssetBundle.GetAllLoadedAssetBundles_Native(); if (allLoadedAssetBundles_Native == null) { continue; } foreach (AssetBundle item in (Il2CppArrayBase<AssetBundle>)(object)allLoadedAssetBundles_Native) { if ((Object)(object)item == (Object)null || ((Il2CppObjectBase)item).Pointer == IntPtr.Zero || string.IsNullOrEmpty(((Object)item).name) || !((Object)item).name.Contains(poseName, StringComparison.OrdinalIgnoreCase)) { continue; } foreach (Object item2 in (Il2CppArrayBase<Object>)(object)item.LoadAllAssets()) { HandPose val2 = ((item2 != null) ? ((Il2CppObjectBase)item2).TryCast<HandPose>() : null); if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero) { return val2; } } } continue; } try { foreach (Object item3 in (Il2CppArrayBase<Object>)(object)val.LoadAllAssets()) { HandPose val3 = ((item3 != null) ? ((Il2CppObjectBase)item3).TryCast<HandPose>() : null); if ((Object)(object)val3 != (Object)null && ((Il2CppObjectBase)val3).Pointer != IntPtr.Zero) { return val3; } } } finally { val.Unload(false); } } return null; } public static void OnUpdate() { try { TrackHand(Player.LeftHand, _passes[0], _passes[1]); TrackHand(Player.RightHand, _passes[1], _passes[0]); _anyActiveHold = (_passes[0].ReleaseEndTime < 0f && (Object)(object)_passes[0].HeldNpc != (Object)null) || (_passes[1].ReleaseEndTime < 0f && (Object)(object)_passes[1].HeldNpc != (Object)null); } catch { } } private static void TrackHand(Hand hand, HandCollisionPass pass, HandCollisionPass otherPass) { //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)hand != (Object)null && ((Il2CppObjectBase)hand).Pointer != IntPtr.Zero) ? hand.m_CurrentAttachedGO : null); IntPtr intPtr = (((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero) ? ((Il2CppObjectBase)val).Pointer : IntPtr.Zero); if (intPtr != pass.HeldGripPtr) { pass.HeldGripPtr = intPtr; Rigidbody val2 = (((Object)(object)val != (Object)null && string.Equals(((Object)val).name, "KinetosBoxGrip", StringComparison.Ordinal)) ? val.GetComponentInParent<Rigidbody>() : null); if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero && _limbRbToNpc.TryGetValue(((Il2CppObjectBase)val2).Pointer, out var value) && (Object)(object)value != (Object)null && ((Il2CppObjectBase)value).Pointer != IntPtr.Zero) { EndPass(pass); pass.HeldLimbBody = val2; pass.HeldNpc = value; pass.ReleaseEndTime = -1f; if ((Object)(object)hand.rb != (Object)null && ((Il2CppObjectBase)hand.rb).Pointer != IntPtr.Zero) { foreach (Collider componentsInChild in ((Component)hand.rb).GetComponentsInChildren<Collider>()) { if ((Object)(object)componentsInChild != (Object)null && ((Il2CppObjectBase)componentsInChild).Pointer != IntPtr.Zero && !componentsInChild.isTrigger) { pass.HandSolids.Add(componentsInChild); } } } IReadOnlyList<Collider> solidColliders = value.SolidColliders; for (int i = 0; i < solidColliders.Count; i++) { Collider val3 = solidColliders[i]; if ((Object)(object)val3 != (Object)null && ((Il2CppObjectBase)val3).Pointer != IntPtr.Zero && !val3.isTrigger) { pass.NpcSolids.Add(val3); } } SetCollisionIgnore(pass, ignore: true); value.OnGrabbedByPlayerHand(val2); } else if ((Object)(object)pass.HeldLimbBody != (Object)null) { if (pass.ReleaseEndTime < 0f && (Object)(object)pass.HeldNpc != (Object)null && ((Il2CppObjectBase)pass.HeldNpc).Pointer != IntPtr.Zero) { Vector3 releaseVel = (((Object)(object)hand != (Object)null && ((Il2CppObjectBase)hand).Pointer != IntPtr.Zero && (Object)(object)hand.rb != (Object)null && ((Il2CppObjectBase)hand.rb).Pointer != IntPtr.Zero) ? hand.rb.velocity : Vector3.zero); pass.HeldNpc.OnReleasedByPlayerHand(pass.HeldLimbBody, releaseVel); } pass.ReleaseEndTime = Time.time + 0.25f; } } if (pass.ReleaseEndTime > 0f && Time.time >= pass.ReleaseEndTime) { EndPass(pass); } } private static void SetCollisionIgnore(HandCollisionPass pass, bool ignore) { for (int i = 0; i < pass.HandSolids.Count; i++) { Collider val = pass.HandSolids[i]; if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero) { continue; } for (int j = 0; j < pass.NpcSolids.Count; j++) { Collider val2 = pass.NpcSolids[j]; if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero) { Physics.IgnoreCollision(val, val2, ignore); } } } } private static void EndPass(HandCollisionPass pass) { if ((Object)(object)pass.HeldLimbBody != (Object)null) { SetCollisionIgnore(pass, ignore: false); } pass.HeldLimbBody = null; pass.HeldNpc = null; pass.ReleaseEndTime = -1f; pass.HandSolids.Clear(); pass.NpcSolids.Clear(); } public static void OnLevelUnloaded() { _anyActiveHold = false; _limbRbToNpc.Clear(); for (int i = 0; i < _passes.Length; i++) { HandCollisionPass obj = _passes[i]; obj.HeldGripPtr = IntPtr.Zero; obj.HeldLimbBody = null; obj.HeldNpc = null; obj.ReleaseEndTime = -1f; obj.HandSolids.Clear(); obj.NpcSolids.Clear(); } } } public class KinetosMuscleSensor : MonoBehaviour { private KinetosNpcBrain _brain; private int _muscleIndex; private bool _isFoot; private float _lastStayCheckTime; public KinetosMuscleSensor(IntPtr ptr) : base(ptr) { } [HideFromIl2Cpp] public void Setup(KinetosNpcBrain brain, int muscleIndex, bool isFoot) { _brain = brain; _muscleIndex = muscleIndex; _isFoot = isFoot; } private void OnCollisionEnter(Collision collision) { if (!((Object)(object)_brain == (Object)null) && collision != null) { _brain.HandleMuscleCollision(_muscleIndex, collision, isStay: false); } } private void OnCollisionStay(Collision collision) { if (!((Object)(object)_brain == (Object)null) && _isFoot && _brain.IsAlive && collision != null) { float time = Time.time; if (!(time - _lastStayCheckTime < 0.045f)) { _lastStayCheckTime = time; _brain.HandleMuscleCollision(_muscleIndex, collision, isStay: true); } } } } public class KinetosNpcBrain : MonoBehaviour { private static readonly List<KinetosNpcBrain> _activeNpcs = new List<KinetosNpcBrain>(24); private static readonly Dictionary<IntPtr, (KinetosNpcBrain Brain, int MuscleIdx)> _impactLookup = new Dictionary<IntPtr, (KinetosNpcBrain, int)>(); private static readonly int HashForward = Animator.StringToHash("Forward"); private static readonly int HashTurn = Animator.StringToHash("Turn"); private static readonly int HashOnGround = Animator.StringToHash("OnGround"); private static readonly int HashIsStrafing = Animator.StringToHash("IsStrafing"); private static readonly int HashActionIndex = Animator.StringToHash("ActionIndex"); private KinetosPuppetEngine _engine; private Transform _targetRoot; private Animator _animator; private SkinnedMeshRenderer _humanSmr; private Material _instanceMat; private Color _baseColor; private AudioSource _audioSource; private KinetosAiMode _aiMode; private float _hitFlashTimer; private float _bodyHealth = 100f; private float _nextWanderPickTime; private float _wanderYaw; private float _nextFootstepAudioTime; private float _nextBrawlerAttackTime; private float _punchActiveUntil; private readonly List<Rigidbody> _rigidbodies = new List<Rigidbody>(14); private readonly List<Collider> _solidColliders = new List<Collider>(16); private readonly List<InteractableHost> _hosts = new List<InteractableHost>(14); private readonly List<IntPtr> _registeredImpactPtrs = new List<IntPtr>(16); [HideFromIl2Cpp] public static IReadOnlyList<KinetosNpcBrain> ActiveNpcs { [HideFromIl2Cpp] get { return _activeNpcs; } } [HideFromIl2Cpp] public IReadOnlyList<Collider> SolidColliders { [HideFromIl2Cpp] get { return _solidColliders; } } [HideFromIl2Cpp] public bool IsAlive { [HideFromIl2Cpp] get { if (_engine != null) { return _engine.IsAlive; } return false; } } [HideFromIl2Cpp] public KinetosPuppetEngine Engine { [HideFromIl2Cpp] get { return _engine; } } public KinetosNpcBrain(IntPtr ptr) : base(ptr) { } [HideFromIl2Cpp] public static bool TryGetByImpact(ImpactProperties prop, out KinetosNpcBrain brain, out int muscleIdx) { brain = null; muscleIdx = -1; if ((Object)(object)prop == (Object)null || ((Il2CppObjectBase)prop).Pointer == IntPtr.Zero) { return false; } if (_impactLookup.TryGetValue(((Il2CppObjectBase)prop).Pointer, out (KinetosNpcBrain, int) value) && (Object)(object)value.Item1 != (Object)null && ((Il2CppObjectBase)value.Item1).Pointer != IntPtr.Zero) { (brain, muscleIdx) = value; return true; } return false; } [HideFromIl2Cpp] public void InitializeNpc(KinetosPuppetEngine engine, Transform targetRoot, Animator animator, SkinnedMeshRenderer humanSmr, Material instanceMat, Color baseColor, AudioSource audioSource, KinetosAiMode aiMode, List<Rigidbody> rbs, List<Collider> cols, List<InteractableHost> hosts, List<(ImpactProperties Prop, int MuscleIdx)> impacts) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) _engine = engine; _targetRoot = targetRoot; _animator = animator; _humanSmr = humanSmr; _instanceMat = instanceMat; _baseColor = baseColor; _audioSource = audioSource; _aiMode = aiMode; _rigidbodies.AddRange(rbs); _solidColliders.AddRange(cols); _hosts.AddRange(hosts); for (int i = 0; i < rbs.Count; i++) { KinetosGrips.RegisterLimb(rbs[i], this); } for (int j = 0; j < impacts.Count; j++) { var (val, item) = impacts[j]; if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero) { _impactLookup[((Il2CppObjectBase)val).Pointer] = (this, item); _registeredImpactPtrs.Add(((Il2CppObjectBase)val).Pointer); } } _engine.OnBoneFractured = OnBoneFracturedCallback; _engine.OnFootstepStepped = PlayFootstepSound; _engine.Initiate(); _wanderYaw = _targetRoot.eulerAngles.y; _activeNpcs.Add(this); } private void Update() { //IL_0058: 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) if (_hitFlashTimer > 0f) { _hitFlashTimer -= Time.deltaTime; if (_hitFlashTimer <= 0f && (Object)(object)_instanceMat != (Object)null && ((Il2CppObjectBase)_instanceMat).Pointer != IntPtr.Zero) { KinetosAssets.ApplySurfaceProps(_instanceMat, _baseColor, 0.08f, 0f, Color.black); } } } private void FixedUpdate() { //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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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) if (_engine == null) { return; } float fixedDeltaTime = Time.fixedDeltaTime; if (_engine.IsAlive && _engine.ActiveBehaviour == KinetosBehaviourMode.Puppet && _engine.SubState == KinetosSubState.Puppet) { UpdateAiLocomotion(fixedDeltaTime); } else if ((Object)(object)_animator != (Object)null && ((Il2CppObjectBase)_animator).Pointer != IntPtr.Zero) { _animator.SetFloat(HashForward, 0f); _animator.SetFloat(HashTurn, 0f); _animator.SetInteger(HashActionIndex, -1); } Vector3 val = _targetRoot.position + _targetRoot.forward * 2.5f + Vector3.up * 1.55f; bool allowLookAt = KinetosPreferences.LookAtPlayer.Value; if ((Object)(object)Player.Head != (Object)null && ((Il2CppObjectBase)Player.Head).Pointer != IntPtr.Zero) { val = Player.Head.position; Vector3 val2 = val - (_targetRoot.position + Vector3.up * 1.5f); if (((Vector3)(ref val2)).sqrMagnitude > 144f || Vector3.Dot(_targetRoot.forward, ((Vector3)(ref val2)).normalized) < -0.35f) { allowLookAt = false; } } _engine.StepFixedUpdate(fixedDeltaTime, allowLookAt, val); } private void LateUpdate() { if (_engine != null) { _engine.StepLateUpdate(Time.deltaTime); } } [HideFromIl2Cpp] private void UpdateAiLocomotion(float fdt) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00da: 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_0183: 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_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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_064c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_animator == (Object)null || ((Il2CppObjectBase)_animator).Pointer == IntPtr.Zero) { return; } _animator.SetBool(HashOnGround, true); _animator.SetBool(HashIsStrafing, false); RaycastHit val = default(RaycastHit); if (!Physics.Raycast(_targetRoot.position + Vector3.up * 0.55f, Vector3.down, ref val, 1.4f, -2081194553, (QueryTriggerInteraction)1)) { _engine.ActivateFallBehaviour(); return; } _targetRoot.position = new Vector3(_targetRoot.position.x, Mathf.Lerp(_targetRoot.position.y, ((RaycastHit)(ref val)).point.y, fdt * 16f), _targetRoot.position.z); KinetosGrips.IsLimbHeldByPlayer(this, null, out var totalHandsOnNpc); if (totalHandsOnNpc > 0 || _aiMode == KinetosAiMode.OriginalKinetosDummy) { _animator.SetFloat(HashForward, Mathf.MoveTowards(_animator.GetFloat(HashForward), 0f, fdt * 5f)); _animator.SetFloat(HashTurn, Mathf.MoveTowards(_animator.GetFloat(HashTurn), 0f, fdt * 5f)); _animator.SetInteger(HashActionIndex, -1); return; } Transform head = Player.Head; Vector3 val2 = (((Object)(object)head != (Object)null) ? head.position : (_targetRoot.position + _targetRoot.forward * 4f)); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val2.x - _targetRoot.position.x, 0f, val2.z - _targetRoot.position.z); float magnitude = ((Vector3)(ref val3)).magnitude; Vector3 val4 = ((magnitude > 0.01f) ? (val3 / magnitude) : _targetRoot.forward); float num = 0f; Vector3 val5 = _targetRoot.forward; int num2 = -1; switch (_aiMode) { case KinetosAiMode.WanderExplorer: if (Time.time >= _nextWanderPickTime) { _nextWanderPickTime = Time.time + Random.Range(2.4f, 5.2f); _wanderYaw += Random.Range(-85f, 85f); } val5 = Quaternion.Euler(0f, _wanderYaw, 0f) * Vector3.forward; if (Physics.Raycast(_targetRoot.position + Vector3.up * 1f, val5, 1.35f, -2081194553, (QueryTriggerInteraction)1)) { _wanderYaw += 115f; val5 = Quaternion.Euler(0f, _wanderYaw, 0f) * Vector3.forward; } num = 0.52f; break; case KinetosAiMode.FriendlyFollower: val5 = val4; num = ((!(magnitude > 4.5f)) ? ((!(magnitude > 2.15f)) ? 0f : 0.52f) : 0.95f); break; case KinetosAiMode.HostileBrawler: val5 = val4; if (magnitude > 1.35f) { num = ((magnitude > 2.6f) ? 1f : 0.65f); break; } num = 0.1f; if (Time.time >= _nextBrawlerAttackTime) { _nextBrawlerAttackTime = Time.time + 1.35f; _punchActiveUntil = Time.time + 0.35f; num2 = 1; Rigidbody rigidbody = _engine.Muscles[12].Rigidbody; if (!_engine.Muscles[12].IsBroken && (Object)(object)rigidbody != (Object)null) { Vector3 val6 = _targetRoot.forward + Vector3.up * 0.15f; rigidbody.AddForce(((Vector3)(ref val6)).normalized * 7.5f, (ForceMode)2); } } break; case KinetosAiMode.PanicFlee: if (magnitude < 10.5f) { val5 = -val4; if (Physics.Raycast(_targetRoot.position + Vector3.up * 1f, val5, 1.4f, -2081194553, (QueryTriggerInteraction)1)) { val5 = Quaternion.Euler(0f, 75f, 0f) * val5; } num = 1f; } break; } float num3 = Vector3.SignedAngle(_targetRoot.forward, val5, Vector3.up); float num4 = Mathf.Clamp(num3 / 75f, -1f, 1f); float num5 = Mathf.Clamp(KinetosPreferences.MoveSpeedMult.Value, 0.2f, 2.5f); float num6 = Mathf.MoveTowards(_animator.GetFloat(HashForward), num, fdt * 4f); float num7 = Mathf.MoveTowards(_animator.GetFloat(HashTurn), num4, fdt * 5f); _animator.SetFloat(HashForward, num6); _animator.SetFloat(HashTurn, num7); _animator.SetInteger(HashActionIndex, (Time.time < _punchActiveUntil) ? 1 : num2); if (Mathf.Abs(num3) > 2f) { float num8 = ((num6 > 0.1f) ? 210f : 150f) * fdt; _targetRoot.Rotate(0f, Mathf.Clamp(num3, 0f - num8, num8), 0f, (Space)0); } if (num6 > 0.05f) { float num9 = Mathf.Lerp(0f, 3.6f, num6) * num5; Vector3 position = _targetRoot.position + _targetRoot.forward * (num9 * fdt); if (!Physics.Raycast(_targetRoot.position + Vector3.up * 0.9f, _targetRoot.forward, num9 * fdt + 0.38f, -2081194553, (QueryTriggerInteraction)1)) { _targetRoot.position = position; } float num10 = Mathf.Lerp(0.52f, 0.28f, num6) / Mathf.Max(0.5f, num5); if (Time.time >= _nextFootstepAudioTime) { _nextFootstepAudioTime = Time.time + num10; PlayFootstepSound(); } } } [HideFromIl2Cpp] public void HandleMuscleCollision(int muscleIdx, Collision collision, bool isStay) { if (_engine != null) { _engine.OnMuscleCollision(muscleIdx, collision, isStay); } } [HideFromIl2Cpp] public void ReceiveMarrowAttack(int muscleIdx, Attack attack) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (_engine == null || muscleIdx < 0 || muscleIdx >= _engine.Muscles.Length) { return; } KinetosMuscleRuntime kinetosMuscleRuntime = _engine.Muscles[muscleIdx]; Vector3 direction = attack.direction; Vector3 val; if (!(((Vector3)(ref direction)).sqrMagnitude > 0.001f)) { val = -attack.normal; } else { direction = attack.direction; val = ((Vector3)(ref direction)).normalized; } Vector3 val2 = val; float num = Mathf.Max(0.5f, attack.damage); float num2 = Mathf.Clamp(num * 14f, 18f, 135f); kinetosMuscleRuntime.Rigidbody.AddForceAtPosition(val2 * num2, attack.origin, (ForceMode)1); TriggerHitFlash(); PlaySound(KinetosAssets.VitalHitClip, 0.85f, Random.Range(0.92f, 1.08f)); bool flag = (attack.attackType & 0x39) != 0 || num >= 8f; if (!_engine.IsAlive) { return; } if (KinetosPreferences.VitalHeadChestKill.Value && kinetosMuscleRuntime.Spec.IsVitalKillZone && (flag || num >= 4f)) { if (kinetosMuscleRuntime.Spec.IsNeckBone && KinetosPreferences.EnableBoneFractures.Value) { _engine.BreakMuscle(muscleIdx, num2 * 500f); return; } _engine.MuscleDamper = 0f; _engine.Kill(); } else if (KinetosPreferences.EnableBoneFractures.Value && flag && (kinetosMuscleRuntime.Spec.Group == KinetosMuscleGroup.Leg || kinetosMuscleRuntime.Spec.Group == KinetosMuscleGroup.Foot || kinetosMuscleRuntime.Spec.Group == KinetosMuscleGroup.Arm)) { _engine.BreakMuscle(muscleIdx, num2 * 450f); _engine.UnPin(muscleIdx, 3.2f); } else { _bodyHealth -= num * (kinetosMuscleRuntime.Spec.IsVitalKillZone ? 2.2f : 1f); if (_bodyHealth <= 0f) { _engine.Kill(); } else { _engine.UnPin(muscleIdx, Mathf.Clamp(num * 0.45f, 1.1f, 6.5f)); } } } [HideFromIl2Cpp] public void OnGrabbedByPlayerHand(Rigidbody limbRb) { if (_engine == null || (Object)(object)limbRb == (Object)null) { return; } IntPtr pointer = ((Il2CppObjectBase)limbRb).Pointer; for (int i = 0; i < _engine.Muscles.Length; i++) { if (((Il2CppObjectBase)_engine.Muscles[i].Rigidbody).Pointer == pointer) { _engine.UnPin(i, 1.35f); break; } } } [HideFromIl2Cpp] public void OnReleasedByPlayerHand(Rigidbody limbRb, Vector3 releaseVel) { //IL_0023: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (_engine != null && !((Object)(object)limbRb == (Object)null)) { float magnitude = ((Vector3)(ref releaseVel)).magnitude; if (magnitude > 3.2f) { limbRb.velocity = Vector3.ClampMagnitude(releaseVel * 1.15f, 18f); _engine.UnPin(0, magnitude * 0.65f); } } } [HideFromIl2Cpp] public void SetAiMode(KinetosAiMode mode) { _aiMode = mode; } [HideFromIl2Cpp] public void HealAllBonesAndRevive() { _bodyHealth = 100f; _engine?.HealAndResurrect(); } [HideFromIl2Cpp] public void ForceKill() { _bodyHealth = 0f; _engine?.Kill(); } [HideFromIl2Cpp] private void OnBoneFracturedCallback(KinetosMuscleRuntime brokenMuscle, float impact, bool fatalNeckBreak) { TriggerHitFlash(); PlaySound(KinetosAssets.BoneCrackClip, 1f, fatalNeckBreak ? 0.92f : Random.Range(0.95f, 1.08f)); } [HideFromIl2Cpp] private void TriggerHitFlash() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_instanceMat == (Object)null) && !(((Il2CppObjectBase)_instanceMat).Pointer == IntPtr.Zero)) { _hitFlashTimer = 0.22f; KinetosAssets.ApplySurfaceProps(_instanceMat, new Color(0.92f, 0.16f, 0.16f, 1f), 0.12f, 0f, new Color(0.25f, 0.02f, 0.02f, 1f)); } } [HideFromIl2Cpp] private void PlayFootstepSound() { PlaySound(KinetosAssets.GetRandomFootstepClip(), 0.42f, Random.Range(0.92f, 1.08f)); } [HideFromIl2Cpp] private void PlaySound(AudioClip clip, float baseVol, float pitch) { if (!((Object)(object)clip == (Object)null) && !(((Il2CppObjectBase)clip).Pointer == IntPtr.Zero) && !((Object)(object)_audioSource == (Object)null) && !(((Il2CppObjectBase)_audioSource).Pointer == IntPtr.Zero)) { float num = Mathf.Clamp(baseVol * KinetosPreferences.SoundVolume.Value, 0f, 1.5f); if (!(num <= 0.005f)) { _audioSource.pitch = pitch; _audioSource.PlayOneShot(clip, num); } } } private void OnDestroy() { _activeNpcs.Remove(this); KinetosGrips.UnregisterLimbs(_rigidbodies); for (int i = 0; i < _registeredImpactPtrs.Count; i++) { _impactLookup.Remove(_registeredImpactPtrs[i]); } _registeredImpactPtrs.Clear(); if ((Object)(object)_instanceMat != (Object)null && ((Il2CppObjectBase)_instanceMat).Pointer != IntPtr.Zero) { try { Object.Destroy((Object)(object)_instanceMat); } catch { } _instanceMat = null; } } [HideFromIl2Cpp] public static void ClearAllNpcs() { KinetosNpcBrain[] array = _activeNpcs.ToArray(); _activeNpcs.Clear(); foreach (KinetosNpcBrain kinetosNpcBrain in array) { if (!((Object)(object)kinetosNpcBrain == (Object)null) && !(((Il2CppObjectBase)kinetosNpcBrain).Pointer == IntPtr.Zero)) { KinetosGrips.ForceDetachNpcGrips(kinetosNpcBrain._hosts); if ((Object)(object)((Component)kinetosNpcBrain).gameObject != (Object)null && ((Il2CppObjectBase)((Component)kinetosNpcBrain).gameObject).Pointer != IntPtr.Zero) { Object.Destroy((Object)(object)((Component)kinetosNpcBrain).gameObject); } } } } [HideFromIl2Cpp] public static void HealAllActiveNpcs() { for (int i = 0; i < _activeNpcs.Count; i++) { _activeNpcs[i]?.HealAllBonesAndRevive(); } } [HideFromIl2Cpp] public static void KillAllActiveNpcs() { for (int i = 0; i < _activeNpcs.Count; i++) { _activeNpcs[i]?.ForceKill(); } } [HideFromIl2Cpp] public static void SetAiModeOnAll(KinetosAiMode mode) { for (int i = 0; i < _activeNpcs.Count; i++) { _activeNpcs[i]?.SetAiMode(mode); } } } public static class KinetosNpcBuilder { private static int _spawnCounter; private static PhysicMaterial _ragdollPhysMat; public static KinetosNpcBrain SpawnInFrontOfPlayer(KinetosAiMode? aiOverride = null, KinetosColorStyle? colorOverride = null, float distanceAhead = 2.2f, float angleOffsetDeg = 0f) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) PhysicsRig physicsRig = Player.PhysicsRig; Transform val = (((Object)(object)Player.Head != (Object)null) ? Player.Head : (((Object)(object)physicsRig != (Object)null) ? ((Rig)physicsRig).m_head : null)); if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero) { MelonLogger.Warning("[KinetosNPC] Cannot spawn Kinetos NPC: Player Rig not ready yet!"); return null; } Vector3 val2 = Vector3.ProjectOnPlane(val.forward, Vector3.up); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } ((Vector3)(ref val2)).Normalize(); Vector3 preferredDir = Quaternion.Euler(0f, angleOffsetDeg, 0f) * val2; ResolveSafeSpawnPosition(((Object)(object)physicsRig != (Object)null && (Object)(object)physicsRig.torso != (Object)null && (Object)(object)physicsRig.torso.rbPelvis != (Object)null) ? (physicsRig.torso.rbPelvis.position - Vector3.up * 0.45f) : (val.position - Vector3.up * 1.5f), preferredDir, distanceAhead, out var spawnPos, out var usedDir); Quaternion worldRotation = Quaternion.LookRotation(-usedDir, Vector3.up); return SpawnNpc(spawnPos, worldRotation, aiOverride, colorOverride); } private static void ResolveSafeSpawnPosition(Vector3 feetOrigin, Vector3 preferredDir, float distanceAhead, out Vector3 spawnPos, out Vector3 usedDir) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_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_01be: 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_01c5: 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_01d2: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_00b2: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_0194: 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_01a7: 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) Vector3 val = feetOrigin + Vector3.up * 1.05f; Transform val2 = (((Object)(object)Player.RigManager != (Object)null) ? ((Component)Player.RigManager).transform : null); float[] array = new float[4] { 0f, 90f, -90f, 180f }; RaycastHit val4 = default(RaycastHit); RaycastHit val6 = default(RaycastHit); for (int i = 0; i < array.Length; i++) { Vector3 val3 = ((i == 0) ? preferredDir : (Quaternion.Euler(0f, array[i], 0f) * preferredDir)); float num = distanceAhead; if (Physics.Raycast(val, val3, ref val4, distanceAhead + 0.4f, -2081194553, (QueryTriggerInteraction)1) && (!((Object)(object)val2 != (Object)null) || !((Object)(object)((RaycastHit)(ref val4)).transform != (Object)null) || !((RaycastHit)(ref val4)).transform.IsChildOf(val2)) && ((RaycastHit)(ref val4)).normal.y < 0.55f) { num = ((RaycastHit)(ref val4)).distance - 0.55f; if (num < 1.1f) { continue; } } Vector3 val5 = feetOrigin + val3 * num; if (Physics.Raycast(val5 + Vector3.up * 2.1f, Vector3.down, ref val6, 6.5f, -2081194553, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val6)).transform != (Object)null && ((RaycastHit)(ref val6)).normal.y >= 0.5f && ((Object)(object)val2 == (Object)null || !((RaycastHit)(ref val6)).transform.IsChildOf(val2)) && Mathf.Abs(((RaycastHit)(ref val6)).point.y - feetOrigin.y) <= 3.6f) { spawnPos = new Vector3(val5.x, ((RaycastHit)(ref val6)).point.y + 0.02f, val5.z); usedDir = val3; return; } } usedDir = preferredDir; spawnPos = feetOrigin + preferredDir * Mathf.Min(distanceAhead, 2f) + Vector3.up * 0.25f; } public static KinetosNpcBrain SpawnNpc(Vector3 worldPosition, Quaternion worldRotation, KinetosAiMode? aiOverride = null, KinetosColorStyle? colorOverride = null) { //IL_096d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_0747: 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_0763: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Expected O, but got Unknown //IL_07d0: Unknown result type (might be due to invalid IL or missing references) //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_080e: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_082d: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_0857: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) if (!KinetosAssets.EnsureLoaded()) { return null; } _spawnCounter++; EnsurePhysicMaterial(); KinetosAiMode aiMode = aiOverride ?? KinetosPreferences.AiMode.Value; Color baseColor = KinetosAssets.ResolveStyleColor(colorOverride ?? KinetosPreferences.ColorStyle.Value); KinetosAssets.RigPrefab.SetActive(false); GameObject val = Object.Instantiate<GameObject>(KinetosAssets.RigPrefab); ((Object)val).name = $"Kinetos_NPC_{_spawnCounter}"; val.SetActive(false); val.transform.SetPositionAndRotation(worldPosition, worldRotation); val.transform.localScale = Vector3.one; Transform val2 = val.transform.Find("Pilot PuppetMaster"); Transform val3 = val.transform.Find("Animation Controller"); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { MelonLogger.Error("[KinetosNPC] Missing Pilot PuppetMaster or Animation Controller on KinetosNPCRig!"); Object.Destroy((Object)(object)val); return null; } Material val4 = KinetosAssets.CreateUniqueSurfaceMaterial(baseColor); Transform val5 = val.transform.Find("Pilot PuppetMaster/Human/HumanMesh"); SkinnedMeshRenderer val6 = (((Object)(object)val5 != (Object)null) ? ((Component)val5).GetComponent<SkinnedMeshRenderer>() : val.GetComponentInChildren<SkinnedMeshRenderer>(true)); if ((Object)(object)val6 != (Object)null) { ((Renderer)val6).sharedMaterial = val4; val6.updateWhenOffscreen = true; val6.skinnedMotionVectors = false; if (KinetosPreferences.IsQuestDevice) { val6.quality = (SkinQuality)2; } } Animator component = ((Component)val3).GetComponent<Animator>(); FullBodyBipedIK val7 = SetupFullBodyBipedIK(val.transform, val3); LookAtIK val8 = SetupLookAtIK(val.transform, val3); Poolee poolee = ((Component)val2).gameObject.AddComponent<Poolee>(); MarrowEntity val9 = ((Component)val2).gameObject.AddComponent<MarrowEntity>(); val9._tags = new TagList(); val9._poolee = poolee; val9._originalScale = Vector3.one; val9._joints = new Il2CppReferenceArray<MarrowJoint>(0L); SurfaceData val10 = (((Object)(object)Player.PhysicsRig != (Object)null && ((Il2CppObjectBase)Player.PhysicsRig).Pointer != IntPtr.Zero) ? Player.PhysicsRig._surfaceDataDefault : null); KinetosNpcBrain kinetosNpcBrain = val.AddComponent<KinetosNpcBrain>(); int num = KinetosRigData.Muscles.Length; KinetosMuscleRuntime[] array = new KinetosMuscleRuntime[num]; Dictionary<string, Rigidbody> dictionary = new Dictionary<string, Rigidbody>(StringComparer.Ordinal); List<Rigidbody> list = new List<Rigidbody>(num); List<Collider> list2 = new List<Collider>(16); List<MarrowBody> list3 = new List<MarrowBody>(num); List<InteractableHost> list4 = new List<InteractableHost>(num); List<(InteractableHost, Transform)> list5 = new List<(InteractableHost, Transform)>(num); List<(ImpactProperties, int)> list6 = new List<(ImpactProperties, int)>(16); MarrowBody val11 = null; bool flag = !KinetosPreferences.IsQuestDevice; for (int i = 0; i < num; i++) { KinetosMuscleSpec spec = KinetosRigData.Muscles[i]; Transform val12 = val.transform.Find(spec.JointRelPath); Transform val13 = val.transform.Find(spec.TargetRelPath); if ((Object)(object)val12 == (Object)null || (Object)(object)val13 == (Object)null) { MelonLogger.Error($"[KinetosNPC] Missing muscle transform '{spec.JointRelPath}' or target '{spec.TargetRelPath}'!"); Object.Destroy((Object)(object)val); return null; } List<Collider> list7 = new List<Collider>(spec.Colliders.Length); for (int j = 0; j < spec.Colliders.Length; j++) { KinetosColliderSpec kinetosColliderSpec = spec.Colliders[j]; Transform val14 = val.transform.Find(kinetosColliderSpec.RelPath) ?? val12; Collider val15; if (kinetosColliderSpec.IsBox) { BoxCollider obj = ((Component)val14).gameObject.AddComponent<BoxCollider>(); obj.center = kinetosColliderSpec.Center; obj.size = kinetosColliderSpec.BoxSize; val15 = (Collider)(object)obj; } else { CapsuleCollider obj2 = ((Component)val14).gameObject.AddComponent<CapsuleCollider>(); obj2.center = kinetosColliderSpec.Center; obj2.radius = kinetosColliderSpec.Radius; obj2.height = kinetosColliderSpec.Height; obj2.direction = kinetosColliderSpec.Direction; val15 = (Collider)(object)obj2; } val15.isTrigger = false; val15.sharedMaterial = _ragdollPhysMat; list7.Add(val15); list2.Add(val15); } Rigidbody val16 = ((Component)val12).gameObject.AddComponent<Rigidbody>(); val16.mass = spec.Mass; val16.drag = spec.Drag; val16.angularDrag = spec.AngularDrag; val16.useGravity = true; val16.isKinematic = false; val16.interpolation = (RigidbodyInterpolation)0; val16.collisionDetectionMode = (CollisionDetectionMode)(flag ? 2 : 0); dictionary[spec.JointRelPath] = val16; list.Add(val16); ImpactProperties val17 = ((Component)val12).gameObject.AddComponent<ImpactProperties>(); val17.decalType = (DecalType)0; val17.megaPascalModifier = 1f; if ((Object)(object)val10 != (Object)null) { val17.surfaceData = val10; } list6.Add((val17, i)); for (int k = 0; k < list7.Count; k++) { if ((Object)(object)((Component)list7[k]).gameObject != (Object)(object)((Component)val12).gameObject) { ImpactProperties val18 = ((Component)list7[k]).gameObject.AddComponent<ImpactProperties>(); val18.decalType = (DecalType)0; val18.megaPascalModifier = 1f; if ((Object)(object)val10 != (Object)null) { val18.surfaceData = val10; } list6.Add((val18, i)); } } MarrowBody val19 = ((Component)val12).gameObject.AddComponent<MarrowBody>(); val19._tags = new TagList(); val19.Validate(val16, val9); list3.Add(val19); if (i == 0) { val11 = val19; } InteractableHost val20 = ((Component)val12).gameObject.AddComponent<InteractableHost>(); list4.Add(val20); bool highPriority = spec.IsNeckBone || spec.Group == KinetosMuscleGroup.Arm || spec.Group == KinetosMuscleGroup.Foot; KinetosGrips.AttachLimbGrip(val16, val9, val19, val20, list7[0], highPriority, out var gripTransform); if ((Object)(object)gripTransform != (Object)null) { list5.Add((val20, gripTransform)); } ((Component)val12).gameObject.AddComponent<KinetosMuscleSensor>().Setup(kinetosNpcBrain, i, spec.Group == KinetosMuscleGroup.Foot); array[i] = new KinetosMuscleRuntime { Index = i, Spec = spec, Transform = val12, Rigidbody = val16, Target = val13, Colliders = list7.ToArray() }; } Il2CppReferenceArray<MarrowBody> val21 = new Il2CppReferenceArray<MarrowBody>((long)list3.Count); for (int l = 0; l < list3.Count; l++) { ((Il2CppArrayBase<MarrowBody>)(object)val21)[l] = list3[l]; } val9._bodies = val21; if ((Object)(object)val11 != (Object)null) { val9._anchorBody = val11; } Il2CppReferenceArray<MarrowBehaviour> val22 = new Il2CppReferenceArray<MarrowBehaviour>((long)list4.Count); for (int m = 0; m < list4.Count; m++) { ((MarrowBehaviour)list4[m]).marrowEntity = val9; ((Il2CppArrayBase<MarrowBehaviour>)(object)val22)[m] = (MarrowBehaviour)(object)list4[m]; } val9._behaviours = val22; for (int n = 0; n < num; n++) { KinetosMuscleRuntime obj3 = array[n]; KinetosMuscleSpec spec2 = obj3.Spec; ConfigurableJoint val23 = ((Component)obj3.Transform).gameObject.AddComponent<ConfigurableJoint>(); ((Joint)val23).anchor = Vector3.zero; ((Joint)val23).axis = spec2.Axis; val23.secondaryAxis = spec2.SecondaryAxis; ((Joint)val23).enablePreprocessing = false; ((Joint)val23).enableCollision = false; if (!string.IsNullOrEmpty(spec2.ConnectedBodyRelPath) && dictionary.TryGetValue(spec2.ConnectedBodyRelPath, out var value)) { ((Joint)val23).connectedBody = value; ((Joint)val23).autoConfigureConnectedAnchor = true; val23.xMotion = (ConfigurableJointMotion)0; val23.yMotion = (ConfigurableJointMotion)0; val23.zMotion = (ConfigurableJointMotion)0; val23.angularXMotion = spec2.AngularXMotion; val23.angularYMotion = spec2.AngularYMotion; val23.angularZMotion = spec2.AngularZMotion; SoftJointLimit val24 = default(SoftJointLimit); ((SoftJointLimit)(ref val24)).limit = spec2.LowAngularX; val23.lowAngularXLimit = val24; val24 = default(SoftJointLimit); ((SoftJointLimit)(ref val24)).limit = spec2.HighAngularX; val23.highAngularXLimit = val24; val24 = default(SoftJointLimit); ((SoftJointLimit)(ref val24)).limit = spec2.AngularY; val23.angularYLimit = val24; val24 = default(SoftJointLimit); ((SoftJointLimit)(ref val24)).limit = spec2.AngularZ; val23.angularZLimit = val24; } else { ((Joint)val23).connectedBody = null; val23.xMotion = (ConfigurableJointMotion)2; val23.yMotion = (ConfigurableJointMotion)2; val23.zMotion = (ConfigurableJointMotion)2; val23.angularXMotion = (ConfigurableJointMotion)2; val23.angularYMotion = (ConfigurableJointMotion)2; val23.angularZMotion = (ConfigurableJointMotion)2; } obj3.Joint = val23; } AudioSource val25 = ((Component)array[7].Transform).gameObject.AddComponent<AudioSource>(); val25.spatialBlend = 1f; val25.minDistance = 1.2f; val25.maxDistance = 20f; val25.rolloffMode = (AudioRolloffMode)1; val25.playOnAwake = false; val.SetActive(true); KinetosGrips.FinalizeHostGrips(list5); try { if (val7 != null) { IKSolverFullBodyBiped solver = val7.solver; if (solver != null) { ((IKSolver)solver).Initiate(val3); } } if (val8 != null) { IKSolverLookAt solver2 = val8.solver; if (solver2 != null) { ((IKSolver)solver2).Initiate(val3); } } } catch { } KinetosPuppetEngine engine = new KinetosPuppetEngine(kinetosNpcBrain, val3, component, val7, val8, array); kinetosNpcBrain.InitializeNpc(engine, val3, component, val6, val4, baseColor, val25, aiMode, list, list2, list4, list6); return kinetosNpcBrain; } private static FullBodyBipedIK SetupFullBodyBipedIK(Transform rootTf, Transform animCtrlTf) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0063: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00c9: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown try { FullBodyBipedIK val = ((Component)animCtrlTf).gameObject.AddComponent<FullBodyBipedIK>(); ((Behaviour)val).enabled = false; BipedReferences val2 = new BipedReferences { root = animCtrlTf, pelvis = rootTf.Find("Animation Controller/Pilot/Pelvis"), leftThigh = rootTf.Find("Animation Controller/Pilot/Pelvis/LLegUpper"), leftCalf = rootTf.Find("Animation Controller/Pilot/Pelvis/LLegUpper/LLegCalf"), leftFoot = rootTf.Find("Animation Controller/Pilot/Pelvis/LLegUpper/LLegCalf/LLegAnkle"), rightThigh = rootTf.Find("Animation Controller/Pilot/Pelvis/RLegUpper"), rightCalf = rootTf.Find("Animation Controller/Pilot/Pelvis/RLegUpper/RLegCalf"), rightFoot = rootTf.Find("Animation Controller/Pilot/Pelvis/RLegUpper/RLegCalf/RLegAnkle"), leftUpperArm = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/LArmCollarbone/LArmUpper1"), leftForearm = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/LArmCollarbone/LArmUpper1/LArmUpper2/LArmForearm1"), leftHand = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/LArmCollarbone/LArmUpper1/LArmUpper2/LArmForearm1/LArmForearm2/LArmHand"), rightUpperArm = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/RArmCollarbone/RArmUpper1"), rightForearm = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/RArmCollarbone/RArmUpper1/RArmUpper2/RArmForearm1"), rightHand = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/RArmCollarbone/RArmUpper1/RArmUpper2/RArmForearm1/RArmForearm2/RArmHand"), head = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/Neck1/NeckHead"), eyes = new Il2CppReferenceArray<Transform>(0L) }; Il2CppReferenceArray<Transform> val3 = new Il2CppReferenceArray<Transform>((long)KinetosRigData.FbbSpineRelPaths.Length); for (int i = 0; i < KinetosRigData.FbbSpineRelPaths.Length; i++) { ((Il2CppArrayBase<Transform>)(object)val3)[i] = rootTf.Find(KinetosRigData.FbbSpineRelPaths[i]); } val2.spine = val3; val.SetReferences(val2, val2.pelvis); return val; } catch (Exception ex) { MelonLogger.Warning("[KinetosNPC] FullBodyBipedIK setup note: " + ex.Message); return null; } } private static LookAtIK SetupLookAtIK(Transform rootTf, Transform animCtrlTf) { try { LookAtIK val = ((Component)animCtrlTf).gameObject.AddComponent<LookAtIK>(); ((Behaviour)val).enabled = false; Transform val2 = rootTf.Find("Animation Controller/Pilot/Pelvis/Spine1/Spine2/Spine3/Neck1/NeckHead"); Il2CppReferenceArray<Transform> val3 = new Il2CppReferenceArray<Transform>((long)KinetosRigData.LookAtSpineRelPaths.Length); for (int i = 0; i < KinetosRigData.LookAtSpineRelPaths.Length; i++) { ((Il2CppArrayBase<Transform>)(object)val3)[i] = rootTf.Find(KinetosRigData.LookAtSpineRelPaths[i]); } Il2CppReferenceArray<Transform> val4 = new Il2CppReferenceArray<Transform>(0L); val.solver.SetChain(val3, val2, val4, animCtrlTf); val.solver.bodyWeight = 0.25f; val.solver.headWeight = 0.85f; val.solver.clampWeight = 0.55f; val.solver.clampWeightHead = 0.6f; ((IKSolver)val.solver).IKPositionWeight = 0f; return val; } catch (Exception ex) { MelonLogger.Warning("[KinetosNPC] LookAtIK setup note: " + ex.Message); return null; } } private static void EnsurePhysicMaterial() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown if (!((Object)(object)_ragdollPhysMat != (Object)null) || !(((Il2CppObjectBase)_ragdollPhysMat).Pointer != IntPtr.Zero)) { _ragdollPhysMat = new PhysicMaterial("Kinetos_RagdollPhysMat") { dynamicFriction = 0.45f, staticFriction = 0.45f, bounciness = 0f, frictionCombine = (PhysicMaterialCombine)0, bounceCombine = (PhysicMaterialCombine)2, hideFlags = (HideFlags)32 }; } } } public class KinetosNpcMod : MelonMod { public const string ModName = "Kinetos NPC"; public const string ModVersion = "1.0.0"; public const string ModAuthor = "Gabri"; private static Page _mainPage; private static Page _tuningPage; public override void OnInitializeMelon() { try { ClassInjector.RegisterTypeInIl2Cpp<KinetosNpcBrain>(); ClassInjector.RegisterTypeInIl2Cpp<KinetosMuscleSensor>(); } catch (Exception value) { MelonLogger.Error($"[KinetosNPC] Failed registering Il2Cpp types: {value}"); } KinetosPreferences.Initialize(); SetupBoneMenu(); Hooking.OnLevelLoaded += OnLevelLoaded; Hooking.OnLevelUnloaded += OnLevelUnloaded; MelonLogger.Msg("[KinetosNPC] v1.0.0 initialized! Platform=" + (KinetosPreferences.IsQuestDevice ? "Meta Quest (Android)" : "PCVR (Windows)")); } private static void OnLevelLoaded(LevelInfo info) { KinetosAssets.EnsureLoaded(); } private static void OnLevelUnloaded() { KinetosNpcBrain.ClearAllNpcs(); KinetosGrips.OnLevelUnloaded(); } public override void OnUpdate() { KinetosGrips.OnUpdate(); } public static void SendToast(string title, string message, NotificationType type = (NotificationType)0, float length = 2f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown try { Notifier.Send(new Notification { Title = NotificationText.op_Implicit(title), Message = NotificationText.op_Implicit(message), Type = type, PopupLength = length, ShowTitleOnPopup = true }); } catch { } } private static void SetupBoneMenu() { //IL_008e: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0389: 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_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); ((Color)(ref val))..ctor(0.24f, 0.86f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.28f, 0.9f, 0.45f); Color val3 = default(Color); ((Color)(ref val3))..ctor(1f, 0.82f, 0.2f); Color val4 = default(Color); ((Color)(ref val4))..ctor(1f, 0.54f, 0.18f); Color val5 = default(Color); ((Color)(ref val5))..ctor(0.96f, 0.28f, 0.28f); Color val6 = default(Color); ((Color)(ref val6))..ctor(0.76f, 0.42f, 1f); _mainPage = Page.Root.CreatePage("Kinetos NPC", val, 0, true); _mainPage.CreateFunction("Spawn Kinetos NPC", val2, (Action)delegate { KinetosNpcBuilder.SpawnInFrontOfPlayer(); }); _mainPage.CreateFunction("Spawn Squad (4x)", val3, (Action)delegate { for (int i = 0; i < 4; i++) { float angleOffsetDeg = ((float)i - 1.5f) * 32f; KinetosNpcBuilder.SpawnInFrontOfPlayer(null, null, 2.7f, angleOffsetDeg); } }); _mainPage.CreateFunction("Spawn Hostile Brawler", val5, (Action)delegate { KinetosNpcBuilder.SpawnInFrontOfPlayer(KinetosAiMode.HostileBrawler, KinetosColorStyle.TacticalRed); }); _mainPage.CreateFunction("Spawn Friendly Follower", val, (Action)delegate { KinetosNpcBuilder.SpawnInFrontOfPlayer(KinetosAiMode.FriendlyFollower, KinetosColorStyle.CyberBlue); }); _mainPage.CreateEnum("Behavior Mode", val3, (Enum)KinetosPreferences.AiMode.Value, (Action<Enum>)delegate(Enum obj) { KinetosAiMode kinetosAiMode = (KinetosAiMode)(object)obj; KinetosPreferences.AiMode.Value = kinetosAiMode; KinetosPreferences.Save(); KinetosNpcBrain.SetAiModeOnAll(kinetosAiMode); }); _mainPage.CreateEnum("Color Style", val6, (Enum)KinetosPreferences.ColorStyle.Value, (Action<Enum>)delegate(Enum obj) { KinetosPreferences.ColorStyle.Value = (KinetosColorStyle)(object)obj; KinetosPreferences.Save(); }); _mainPage.CreateFunction("Heal & Revive All NPCs", val2, (Action)delegate { KinetosNpcBrain.HealAllActiveNpcs(); SendToast("Kinetos NPCs Healed!", "Healed all fractured bones and revived all Kinetos NPCs.", (NotificationType)3); }); _mainPage.CreateFunction("Kill / Ragdoll All NPCs", val4, (Action)delegate { KinetosNpcBrain.KillAllActiveNpcs(); }); _mainPage.CreateFunction("Clear All Kinetos NPCs", Color.white, (Action)delegate { KinetosNpcBrain.ClearAllNpcs(); }); _tuningPage = _mainPage.CreatePage("Fracture & Physics Tuning", val4, 0, true); _tuningPage.CreateBool("Bone Fractures (Crack!)", val5, KinetosPreferences.EnableBoneFractures.Value, (Action<bool>)delegate(bool value) { KinetosPreferences.EnableBoneFractures.Value = value; KinetosPreferences.Save(); }); _tuningPage.CreateFloat("Fracture Sensitivity", val3, KinetosPreferences.FractureSensitivity.Value, 0.25f, 0.25f, 3f, (Action<float>)delegate(float num) { KinetosPreferences.FractureSensitivity.Value = Mathf.Round(num * 100f) * 0.01f; KinetosPreferences.Save(); }); _tuningPage.CreateBool("Head/Chest Vital Kill", val5, KinetosPreferences.VitalHeadChestKill.Value, (Action<bool>)delegate(bool value) { KinetosPreferences.VitalHeadChestKill.Value = value; KinetosPreferences.Save(); }); _tuningPage.CreateBool("Euphoria Stagger Steps", val, KinetosPreferences.EnableStaggerStepping.Value, (Action<bool>)delegate(bool value) { KinetosPreferences.EnableStaggerStepping.Value = value; KinetosPreferences.Save(); }); _tuningPage.CreateBool("Auto Get Up From Floor", val2, KinetosPreferences.CanGetUp.Value, (Action<bool>)delegate(bool value) { KinetosPreferences.CanGetUp.Value = value; KinetosPreferences.Save(); }); _tuningPage.CreateBool("Look At Player (Head IK)", val6, KinetosPreferences.LookAtPlayer.Value, (Action<bool>)delegate(bool value) { KinetosPreferences.LookAtPlayer.Value = value; KinetosPreferences.Save(); }); _tuningPage.CreateFloat("Muscle Strength Mult", val, KinetosPreferences.MuscleStrengthMult.Value, 0.1f, 0.3f, 2.5f, (Action<float>)delegate(float num) { KinetosPreferences.MuscleStrengthMult.Value = Mathf.Round(num * 100f) * 0.01f; KinetosPreferences.Save(); }); _tuningPage.CreateFloat("Walk / Run Speed Mult", val2, KinetosPreferences.MoveSpeedMult.Value, 0.1f, 0.3f, 2.5f, (Action<float>)delegate(float num) { KinetosPreferences.MoveSpeedMult.Value = Mathf.Round(num * 100f) * 0.01f; KinetosPreferences.Save(); }); _tuningPage.CreateFloat("Sound Volume", Color.white, KinetosPreferences.SoundVolume.Value, 0.1f, 0f, 1.5f, (Action<float>)delegate(float num) { KinetosPreferences.SoundVolume.Value = Mathf.Round(num * 100f) * 0.01f; KinetosPreferences.Save(); }); } } [HarmonyPatch(typeof(ImpactProperties), "ReceiveAttack")] internal static class KinetosImpactReceiveAttackPatch { private static void Postfix(ImpactProperties __instance, Attack attack) { try { if (KinetosNpcBrain.TryGetByImpact(__instance, out var brain, out var muscleIdx)) { brain.ReceiveMarrowAttack(muscleIdx, attack); } } catch { } } } public enum KinetosAiMode { OriginalKinetosDummy, WanderExplorer, FriendlyFollower, HostileBrawler, PanicFlee } public enum KinetosColorStyle { OriginalKinetosGrey, CrashTestY