Decompiled source of Emotes2 And Knuckles v1.4.1
plugins/LcEmotes2AndKnucklesFeaturingDante/LcEmotes2AndKnucklesFeaturingDante.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using Emotes2JigglePhysics; using EmotesAPI; using GameNetcodeStuff; using LcEmotes2AndKnucklesFeaturingDante.Common; using LcEmotes2AndKnucklesFeaturingDante.Common.Rand; using LcEmotes2AndKnucklesFeaturingDante.Emotes; using LcEmotes2AndKnucklesFeaturingDante.Emotes.GoblinPain; using LcEmotes2AndKnucklesFeaturingDante.Emotes.GoblinPain.Chat; using LcEmotes2AndKnucklesFeaturingDante.Emotes.GoblinPain.Data; using LcEmotes2AndKnucklesFeaturingDante.Emotes.JermaWindow; using LcEmotes2AndKnucklesFeaturingDante.Emotes.LightsCameraAction; using LcEmotes2AndKnucklesFeaturingDante.Emotes.Megaman; using LcEmotes2AndKnucklesFeaturingDante.Emotes.MottekeSailorFukku; using LcEmotes2AndKnucklesFeaturingDante.Emotes.xQcClap; using LcEmotes2AndKnucklesFeaturingDante.JoinSpots; using LcEmotes2AndKnucklesFeaturingDante.JoinSpots.JermaWindow; using LcEmotes2AndKnucklesFeaturingDante.JoinSpots.MottekeSailorFukku; using LcEmotes2AndKnucklesFeaturingDante.NetcodePatcher; using LcEmotes2AndKnucklesFeaturingDante.Utils; using LethalEmotesAPI; using LethalEmotesAPI.Core; using LethalEmotesAPI.ImportV2; using LethalVRM; using Microsoft.CodeAnalysis; using ModelReplacement; using MonoMod.RuntimeDetour; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.Serialization; using UnityEngine.TextCore; using UnityEngine.Timeline; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("LethalVRM")] [assembly: IgnoresAccessChecksTo("MToon")] [assembly: IgnoresAccessChecksTo("UniGLTF")] [assembly: IgnoresAccessChecksTo("UniGLTF.Utils")] [assembly: IgnoresAccessChecksTo("UniHumanoid")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("VRM10")] [assembly: IgnoresAccessChecksTo("VrmLib")] [assembly: IgnoresAccessChecksTo("VRMShaders.GLTF.IO.Runtime")] [assembly: IgnoresAccessChecksTo("VRMShaders.VRM.IO.Runtime")] [assembly: IgnoresAccessChecksTo("VRMShaders.VRM10.Format.Runtime")] [assembly: IgnoresAccessChecksTo("VRMShaders.VRM10.MToon10.Runtime")] [assembly: AssemblyCompany("LcEmotes2AndKnucklesFeaturingDante")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ce576b093db91c32b1d57fd75e12af9f4fe87405")] [assembly: AssemblyProduct("LcEmotes2AndKnucklesFeaturingDante")] [assembly: AssemblyTitle("LcEmotes2AndKnucklesFeaturingDante")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 Emotes2JigglePhysics { public static class CachedSphereCollider { private class DestroyListener : MonoBehaviour { private void OnDestroy() { _hasSphere = false; } } private static bool _hasSphere; private static SphereCollider _sphereCollider; [RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)] private static void Init() { if ((Object)(object)_sphereCollider != (Object)null) { if (Application.isPlaying) { Object.Destroy((Object)(object)_sphereCollider); } else { Object.DestroyImmediate((Object)(object)_sphereCollider); } } _hasSphere = false; _sphereCollider = null; } public static void EnableSphereCollider() { if (TryGet(out SphereCollider collider)) { ((Collider)collider).enabled = true; } } public static void DisableSphereCollider() { if (TryGet(out SphereCollider collider)) { ((Collider)collider).enabled = false; } } public static bool TryGet(out SphereCollider collider) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (_hasSphere) { collider = _sphereCollider; return true; } GameObject val = null; try { val = new GameObject("JiggleBoneSphereCollider", new Type[2] { typeof(SphereCollider), typeof(DestroyListener) }) { hideFlags = (HideFlags)52 }; Object.DontDestroyOnLoad((Object)(object)val); if (!val.TryGetComponent<SphereCollider>(ref _sphereCollider)) { throw new UnityException("This should never happen..."); } collider = _sphereCollider; ((Collider)collider).enabled = false; _hasSphere = true; return true; } catch { if (Object.op_Implicit((Object)(object)val)) { if (Application.isPlaying) { Object.Destroy((Object)(object)val); } else { Object.DestroyImmediate((Object)(object)val); } } _hasSphere = false; collider = null; throw; } } } [Serializable] public enum JiggleUpdateMode { LateUpdate, FixedUpdate } public interface IJiggleAdvancable { void Advance(float dt, Vector3 gravity, double timeAsDouble, double timeAsDoubleOneStepBack, SphereCollider sphereCollider); } public interface IJiggleBlendable { bool enabled { get; set; } float blend { get; set; } } public class JiggleBone { public readonly bool hasTransform; public readonly PositionSignal targetAnimatedBoneSignal; public Vector3 currentFixedAnimatedBonePosition; public bool hasParent; public int parentID; public bool hasChild; public int childID; public Quaternion boneRotationChangeCheck; public Vector3 bonePositionChangeCheck; public Quaternion lastValidPoseBoneRotation; public float projectionAmount; public Vector3 lastValidPoseBoneLocalPosition; public float normalizedIndex; public readonly Transform transform; public readonly PositionSignal particleSignal; public Vector3 workingPosition; public Vector3? preTeleportPosition; public Vector3 extrapolatedPosition; public readonly bool shouldConfineAngle; public Vector3 cachedPositionForPosing; private Quaternion cachedRotationForPosing; public Vector3 parentPosition; public Vector3 parentPose; private Vector3 cachedLerpedPositionForPosing; public float cachedLengthToParent; public void SetParentID(int? id) { hasParent = id.HasValue; parentID = id ?? (-1); } public void SetChildID(int? id) { hasChild = id.HasValue; childID = id ?? (-1); } public JiggleBone(List<JiggleBone> bones, Transform transform, JiggleBone parent, int? parentID, float projectionAmount = 1f) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0124: Unknown result type (might be due to invalid IL or missing references) this.transform = transform; this.projectionAmount = projectionAmount; Vector3 startPosition; if ((Object)(object)transform != (Object)null) { transform.GetLocalPositionAndRotation(ref lastValidPoseBoneLocalPosition, ref lastValidPoseBoneRotation); startPosition = transform.position; } else { Vector3 position = parent.transform.position; Vector3 val = parent.GetParentTransform(bones.ToArray()).InverseTransformPoint(position) * projectionAmount; startPosition = parent.transform.TransformPoint(val); lastValidPoseBoneLocalPosition = val; lastValidPoseBoneRotation = Quaternion.identity; } targetAnimatedBoneSignal = new PositionSignal(startPosition, Time.timeAsDouble); particleSignal = new PositionSignal(startPosition, Time.timeAsDouble); hasTransform = (Object)(object)transform != (Object)null; shouldConfineAngle = hasTransform || this.projectionAmount != 0f; currentFixedAnimatedBonePosition = default(Vector3); boneRotationChangeCheck = default(Quaternion); bonePositionChangeCheck = default(Vector3); normalizedIndex = 0f; workingPosition = default(Vector3); preTeleportPosition = null; extrapolatedPosition = default(Vector3); SetParentID(parentID); SetChildID(null); } public void CalculateNormalizedIndex(List<JiggleBone> bones) { int num = 0; bool flag = hasParent; int index = parentID; while (flag) { flag = bones[index].hasParent; index = bones[index].parentID; num++; } int num2 = 0; flag = hasChild; index = childID; while (flag) { flag = bones[index].hasChild; index = bones[index].childID; num2++; } int num3 = num + num2; float num4 = (float)num / (float)num3; normalizedIndex = num4; } private Vector3 GetRealTransformPosition(JiggleBone[] bones) { //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_0026: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (!hasTransform) { JiggleBone jiggleBone = bones[parentID]; Transform parentTransform = jiggleBone.GetParentTransform(bones); Vector3 position = jiggleBone.transform.position; Vector3 val = position - ((Component)parentTransform).transform.position; return position + val * projectionAmount; } return transform.position; } private Transform GetParentTransform(JiggleBone[] bones) { if (hasParent) { return bones[parentID].transform; } return transform.parent; } [Obsolete("Please use SetTargetAndResetToLastValidPose() instead.")] public void SampleAndReset(JiggleBone[] bones) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) double timeAsDouble = Time.timeAsDouble; Vector3 realTransformPosition = GetRealTransformPosition(bones); particleSignal.FlattenSignal(timeAsDouble, realTransformPosition); if (hasTransform) { transform.SetLocalPositionAndRotation(bonePositionChangeCheck, boneRotationChangeCheck); } } public void SetTargetAndResetToLastValidPose(JiggleBone[] bones) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) double timeAsDouble = Time.timeAsDouble; Vector3 realTransformPosition = GetRealTransformPosition(bones); particleSignal.FlattenSignal(timeAsDouble, realTransformPosition); if (hasTransform) { transform.SetLocalPositionAndRotation(bonePositionChangeCheck, boneRotationChangeCheck); } } public void MatchAnimationInstantly(JiggleBone[] bones) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) double timeAsDouble = Time.timeAsDouble; Vector3 realTransformPosition = GetRealTransformPosition(bones); targetAnimatedBoneSignal.FlattenSignal(timeAsDouble, realTransformPosition); particleSignal.FlattenSignal(timeAsDouble, realTransformPosition); } public void PrepareTeleport(JiggleBone[] bones) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) preTeleportPosition = GetRealTransformPosition(bones); } public void FinishTeleport(JiggleBone[] bones) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) if (!preTeleportPosition.HasValue) { MatchAnimationInstantly(bones); return; } Vector3 realTransformPosition = GetRealTransformPosition(bones); Vector3 val = realTransformPosition - preTeleportPosition.Value; targetAnimatedBoneSignal.FlattenSignal(Time.timeAsDouble, realTransformPosition); particleSignal.OffsetSignal(val); workingPosition += val; } public void DebugDraw(JiggleBone[] bones, Color simulateColor, Color targetColor, bool interpolated) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (hasParent) { if (interpolated) { Debug.DrawLine(extrapolatedPosition, bones[parentID].extrapolatedPosition, simulateColor, 0f, false); } else { Debug.DrawLine(workingPosition, bones[parentID].workingPosition, simulateColor, 0f, false); } Debug.DrawLine(currentFixedAnimatedBonePosition, bones[parentID].currentFixedAnimatedBonePosition, targetColor, 0f, false); } } public Vector3 DeriveFinalSolvePosition(Vector3 offset, double timeAsDoubleOneStepBack) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) extrapolatedPosition = particleSignal.SamplePosition(timeAsDoubleOneStepBack) + offset; return extrapolatedPosition; } public Vector3 GetCachedSolvePosition() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return extrapolatedPosition; } public void ApplyValidPoseThenSampleTargetPose(JiggleBone[] bones, double timeAsDouble, bool animated) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (!hasTransform) { cachedPositionForPosing = GetRealTransformPosition(bones); targetAnimatedBoneSignal.SetPosition(cachedPositionForPosing, timeAsDouble); cachedLengthToParent = Vector3.Distance(cachedPositionForPosing, bones[parentID].cachedPositionForPosing); return; } if (animated) { Vector3 val = default(Vector3); Quaternion val2 = default(Quaternion); transform.GetLocalPositionAndRotation(ref val, ref val2); bool flag = boneRotationChangeCheck != val2; bool flag2 = bonePositionChangeCheck != val; if (!flag && !flag2) { transform.SetLocalPositionAndRotation(lastValidPoseBoneLocalPosition, lastValidPoseBoneRotation); } else if (flag && flag2) { transform.GetLocalPositionAndRotation(ref lastValidPoseBoneLocalPosition, ref lastValidPoseBoneRotation); } else if (flag) { lastValidPoseBoneRotation = transform.localRotation; transform.localPosition = lastValidPoseBoneLocalPosition; } else { lastValidPoseBoneLocalPosition = transform.localPosition; transform.localRotation = lastValidPoseBoneRotation; } } else { transform.SetLocalPositionAndRotation(lastValidPoseBoneLocalPosition, lastValidPoseBoneRotation); } cachedPositionForPosing = transform.position; targetAnimatedBoneSignal.SetPosition(cachedPositionForPosing, timeAsDouble); if (!hasParent) { cachedLengthToParent = 0.1f; } else { cachedLengthToParent = Vector3.Distance(cachedPositionForPosing, bones[parentID].cachedPositionForPosing); } } public void OnDrawGizmos(JiggleBone[] bones, JiggleSettingsBase jiggleSettings, bool isRoot = false) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) double timeAsDouble = Time.timeAsDouble; Vector3 val = ((!isRoot && Application.isPlaying) ? particleSignal.SamplePosition(timeAsDouble - 0.019999999552965164) : (hasTransform ? transform.position : GetRealTransformPosition(bones))); if (hasChild) { Gizmos.DrawLine(val, Application.isPlaying ? bones[childID].particleSignal.SamplePosition(timeAsDouble - 0.019999999552965164) : (bones[childID].hasTransform ? bones[childID].transform.position : bones[childID].GetRealTransformPosition(bones))); } if ((Object)(object)jiggleSettings != (Object)null) { Gizmos.DrawWireSphere(val, jiggleSettings.GetRadius(normalizedIndex)); } } public void PoseBonePreCache(JiggleBone[] bones, float blend) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (hasTransform) { transform.GetPositionAndRotation(ref cachedPositionForPosing, ref cachedRotationForPosing); } else { JiggleBone jiggleBone = bones[parentID]; if (jiggleBone.hasParent) { JiggleBone jiggleBone2 = bones[jiggleBone.parentID]; Vector3 val = jiggleBone.cachedPositionForPosing; Vector3 val2 = val - jiggleBone2.cachedPositionForPosing; cachedPositionForPosing = val + val2 * projectionAmount; } else { Vector3 val3 = jiggleBone.cachedPositionForPosing; Vector3 val4 = val3 - ((Component)jiggleBone.transform.parent).transform.position; cachedPositionForPosing = val3 + val4 * projectionAmount; } } cachedLerpedPositionForPosing = Vector3.LerpUnclamped(cachedPositionForPosing, extrapolatedPosition, blend); } public void PoseBone(JiggleBone[] bones, bool animated) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (hasChild) { Vector3 val = cachedLerpedPositionForPosing; JiggleBone jiggleBone = bones[childID]; Vector3 val2 = jiggleBone.cachedPositionForPosing; Vector3 val3 = jiggleBone.cachedLerpedPositionForPosing; Vector3 val4 = val2 - cachedPositionForPosing; Vector3 val5 = val3 - val; Quaternion val6 = Quaternion.FromToRotation(val4, val5); if (hasParent) { transform.SetPositionAndRotation(val, val6 * cachedRotationForPosing); } else { transform.rotation = val6 * cachedRotationForPosing; } } if (hasTransform && animated) { transform.GetLocalPositionAndRotation(ref bonePositionChangeCheck, ref boneRotationChangeCheck); } } } public class JiggleRigBuilder : MonoBehaviour, IJiggleAdvancable, IJiggleBlendable { [Serializable] public class JiggleRig { [SerializeField] [Tooltip("The root bone from which an individual JiggleRig will be constructed. The JiggleRig encompasses all children of the specified root.")] [FormerlySerializedAs("target")] private Transform rootTransform; [Tooltip("The settings that the rig should update with, create them using the Create->JigglePhysics->Settings menu option.")] public JiggleSettingsBase jiggleSettings; [SerializeField] [Tooltip("The list of transforms to ignore during the jiggle. Each bone listed will also ignore all the children of the specified bone.")] private List<Transform> ignoredTransforms; [SerializeField] private Collider[] colliders; [Tooltip("Turn this on if you animate the jiggle bones via Animator (or through script). ")] public bool animated = false; private int boneCount; private bool needsCollisions; private int colliderCount; [HideInInspector] protected JiggleBone[] simulatedPoints; private bool initialized => simulatedPoints != null; public void SetColliders(ICollection<Collider> newColliders) { colliders = newColliders.ToArray(); colliderCount = colliders.Length; needsCollisions = colliders.Length != 0; } public Collider[] GetColliders() { return colliders; } public Transform GetRootTransform() { return rootTransform; } public JiggleRig(Transform rootTransform, JiggleSettingsBase jiggleSettings, ICollection<Transform> ignoredTransforms, ICollection<Collider> colliders) { this.rootTransform = rootTransform; this.jiggleSettings = jiggleSettings; this.ignoredTransforms = new List<Transform>(ignoredTransforms); SetColliders(colliders); Initialize(); } [Obsolete("Please use SetTargetAndResetToLastValidPose() instead.")] public void SampleAndReset() { for (int num = boneCount - 1; num >= 0; num--) { simulatedPoints[num].SetTargetAndResetToLastValidPose(simulatedPoints); } } public void SetTargetAndResetToLastValidPose() { for (int num = boneCount - 1; num >= 0; num--) { simulatedPoints[num].SetTargetAndResetToLastValidPose(simulatedPoints); } } public void ApplyValidPoseThenSampleTargetPose(double timeAsDouble) { for (int i = 0; i < boneCount; i++) { simulatedPoints[i].ApplyValidPoseThenSampleTargetPose(simulatedPoints, timeAsDouble, animated); } } public void StepSimulation(JiggleSettingsData data, double time, Vector3 acceleration, SphereCollider sphereCollider) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040e: 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_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: 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_0329: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0308: 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_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: 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_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: 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) for (int i = 0; i < boneCount; i++) { JiggleBone jiggleBone = simulatedPoints[i]; jiggleBone.currentFixedAnimatedBonePosition = jiggleBone.targetAnimatedBoneSignal.SamplePosition(time); if (!jiggleBone.hasParent) { jiggleBone.workingPosition = jiggleBone.currentFixedAnimatedBonePosition; jiggleBone.parentPose = 2f * jiggleBone.currentFixedAnimatedBonePosition - simulatedPoints[jiggleBone.childID].currentFixedAnimatedBonePosition; jiggleBone.parentPosition = jiggleBone.parentPose; continue; } JiggleBone jiggleBone2 = simulatedPoints[jiggleBone.parentID]; jiggleBone.parentPose = jiggleBone2.currentFixedAnimatedBonePosition; jiggleBone.parentPosition = jiggleBone2.workingPosition; Vector3 current = jiggleBone.particleSignal.GetCurrent(); Vector3 val = current - jiggleBone.particleSignal.GetPrevious(); Vector3 val2 = val - (jiggleBone2.particleSignal.GetCurrent() - jiggleBone2.particleSignal.GetPrevious()); Vector3 val3 = val - val2; jiggleBone.workingPosition = current + val3 * data.airDragOneMinus + val2 * data.frictionOneMinus + acceleration; } Vector3 val14 = default(Vector3); Quaternion val15 = default(Quaternion); Vector3 val16 = default(Vector3); float num2 = default(float); for (int j = 0; j < boneCount; j++) { JiggleBone jiggleBone3 = simulatedPoints[j]; if (!jiggleBone3.hasParent) { continue; } JiggleBone jiggleBone4 = simulatedPoints[jiggleBone3.parentID]; float cachedLengthToParent = jiggleBone3.cachedLengthToParent; if (jiggleBone3.shouldConfineAngle) { Vector3 val4 = jiggleBone4.currentFixedAnimatedBonePosition - jiggleBone4.parentPose; Vector3 val5 = jiggleBone4.workingPosition - jiggleBone4.parentPosition; Quaternion val6 = Quaternion.FromToRotation(val4, val5); Vector3 val7 = jiggleBone3.currentFixedAnimatedBonePosition - jiggleBone4.parentPose; Vector3 val8 = val6 * val7; float num = Vector3.Distance(jiggleBone3.workingPosition, jiggleBone4.parentPosition + val8); num /= cachedLengthToParent; num = Mathf.Min(num, 1f); num = Mathf.Pow(num, data.doubleElasticitySoften); jiggleBone3.workingPosition = Vector3.LerpUnclamped(jiggleBone3.workingPosition, jiggleBone4.parentPosition + val8, data.squaredAngleElasticity * num); } if (needsCollisions) { Vector3 val9 = jiggleBone3.workingPosition - jiggleBone4.workingPosition; Vector3 normalized = ((Vector3)(ref val9)).normalized; Vector3 val10 = Vector3.LerpUnclamped(jiggleBone3.workingPosition, jiggleBone4.workingPosition + normalized * cachedLengthToParent, data.squaredLengthElasticity); if (jiggleBone3.hasChild) { JiggleBone jiggleBone5 = simulatedPoints[jiggleBone3.childID]; Vector3 val11 = jiggleBone3.workingPosition - jiggleBone5.workingPosition; Vector3 normalized2 = ((Vector3)(ref val11)).normalized; Vector3 val12 = Vector3.LerpUnclamped(jiggleBone3.workingPosition, jiggleBone5.workingPosition + normalized2 * jiggleBone5.cachedLengthToParent, data.squaredLengthElasticity); val10 = (val10 + val12) / 2f; } jiggleBone3.workingPosition = val10; for (int k = 0; k < colliderCount; k++) { Collider val13 = colliders[k]; sphereCollider.radius = jiggleSettings.GetRadius(jiggleBone3.normalizedIndex); if (!(sphereCollider.radius <= 0f)) { ((Component)val13).transform.GetPositionAndRotation(ref val14, ref val15); if (Physics.ComputePenetration((Collider)(object)sphereCollider, jiggleBone3.workingPosition, Quaternion.identity, val13, val14, val15, ref val16, ref num2)) { jiggleBone3.workingPosition += val16 * num2; } } } } else { Vector3 val17 = jiggleBone3.workingPosition - jiggleBone4.workingPosition; Vector3 normalized3 = ((Vector3)(ref val17)).normalized; jiggleBone3.workingPosition = Vector3.LerpUnclamped(jiggleBone3.workingPosition, jiggleBone4.workingPosition + normalized3 * cachedLengthToParent, data.squaredLengthElasticity); } } } public void WriteSimulatedStep(double timeAsDouble) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < boneCount; i++) { JiggleBone jiggleBone = simulatedPoints[i]; jiggleBone.particleSignal.SetPosition(jiggleBone.workingPosition, timeAsDouble); } } public void Initialize() { List<JiggleBone> list = new List<JiggleBone>(); if (!((Object)(object)rootTransform == (Object)null)) { CreateSimulatedPoints(list, ignoredTransforms, rootTransform, null, null); for (int i = 0; i < list.Count; i++) { list[i].CalculateNormalizedIndex(list); } simulatedPoints = list.ToArray(); boneCount = simulatedPoints.Length; colliderCount = colliders.Length; needsCollisions = colliderCount != 0; } } internal void DeriveFinalSolve(double timeAsDoubleOneStepBack) { //IL_0009: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Vector3 offset = simulatedPoints[0].cachedPositionForPosing - simulatedPoints[0].DeriveFinalSolvePosition(Vector3.zero, timeAsDoubleOneStepBack); for (int i = 0; i < boneCount; i++) { simulatedPoints[i].DeriveFinalSolvePosition(offset, timeAsDoubleOneStepBack); } } public void Pose(bool debugDraw, double timeAsDoubleOneStepBack, float blend) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) DeriveFinalSolve(timeAsDoubleOneStepBack); for (int i = 0; i < boneCount; i++) { simulatedPoints[i].PoseBonePreCache(simulatedPoints, blend); } for (int j = 0; j < boneCount; j++) { JiggleBone jiggleBone = simulatedPoints[j]; jiggleBone.PoseBone(simulatedPoints, animated); if (debugDraw) { jiggleBone.DebugDraw(simulatedPoints, Color.red, Color.blue, interpolated: true); } } } public void PrepareTeleport() { for (int i = 0; i < boneCount; i++) { simulatedPoints[i].PrepareTeleport(simulatedPoints); } } public void FinishTeleport() { for (int i = 0; i < boneCount; i++) { simulatedPoints[i].FinishTeleport(simulatedPoints); } } public void OnDrawGizmos() { if (!initialized) { Initialize(); } simulatedPoints[0].OnDrawGizmos(simulatedPoints, jiggleSettings, isRoot: true); for (int i = 1; i < boneCount; i++) { simulatedPoints[i].OnDrawGizmos(simulatedPoints, jiggleSettings); } } protected virtual void CreateSimulatedPoints(List<JiggleBone> outputPoints, ICollection<Transform> ignoredTransforms, Transform currentTransform, JiggleBone? parentJiggleBone, int? parentJiggleBoneID) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) JiggleBone jiggleBone = new JiggleBone(outputPoints, currentTransform, parentJiggleBone, parentJiggleBoneID); outputPoints.Add(jiggleBone); int num = outputPoints.Count - 1; if (parentJiggleBoneID.HasValue) { outputPoints[parentJiggleBoneID.Value].SetChildID(outputPoints.Count - 1); } bool flag = false; for (int i = 0; i < currentTransform.childCount; i++) { if (!ignoredTransforms.Contains(currentTransform.GetChild(i))) { flag = true; CreateSimulatedPoints(outputPoints, ignoredTransforms, currentTransform.GetChild(i), jiggleBone, num); } } if (flag) { return; } if (!jiggleBone.hasParent) { if ((Object)(object)jiggleBone.transform.parent == (Object)null) { throw new UnityException("Can't have a singular jiggle bone with no parents. That doesn't even make sense!"); } outputPoints.Add(new JiggleBone(outputPoints, null, jiggleBone, num)); outputPoints[num].SetChildID(outputPoints.Count - 1); } else { outputPoints.Add(new JiggleBone(outputPoints, null, jiggleBone, num)); outputPoints[num].SetChildID(outputPoints.Count - 1); } } } public const float VERLET_TIME_STEP = 0.02f; public const float MAX_CATCHUP_TIME = 0.08f; internal const float SETTLE_TIME = 0.2f; internal const float SQUARED_VERLET_TIME_STEP = 0.0004f; [Tooltip("Enables interpolation for the simulation, this should be set to LateUpdate unless you *really* need the simulation to only update on FixedUpdate.")] [SerializeField] private JiggleUpdateMode jiggleUpdateMode = JiggleUpdateMode.LateUpdate; private JiggleRigLOD jiggleRigLOD; public List<JiggleRig> jiggleRigs; [Tooltip("An air force that is applied to the entire rig, this is useful to plug in some wind volumes from external sources.")] public Vector3 wind; [Tooltip("Draws some simple lines to show what the simulation is doing. Generally this should be disabled.")] [SerializeField] private bool debugDraw; private double accumulation; private float settleTimer; private bool wasLODActive = true; [field: SerializeField] [field: Range(0f, 1f)] public float blend { get; set; } = 1f; public void SetJiggleRigLOD(JiggleRigLOD lod) { if ((Object)(object)jiggleRigLOD != (Object)null) { jiggleRigLOD.RemoveTrackedJiggleRig(this); } jiggleRigLOD = lod; if ((Object)(object)jiggleRigLOD != (Object)null) { jiggleRigLOD.AddTrackedJiggleRig(this); } } public JiggleRigLOD GetJiggleRigLOD() { return jiggleRigLOD; } private void Start() { JiggleRigLOD jiggleRigLOD = default(JiggleRigLOD); if (((Component)this).TryGetComponent<JiggleRigLOD>(ref jiggleRigLOD)) { SetJiggleRigLOD(jiggleRigLOD); } } public void SetJiggleUpdateMode(JiggleUpdateMode mode) { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.RemoveJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.RemoveJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } jiggleUpdateMode = mode; switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.AddJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.AddJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } } private void Awake() { Initialize(); accumulation = Random.Range(0f, 0.02f); } private void OnEnable() { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.AddJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.AddJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } if (settleTimer > 0.2f) { FinishTeleport(); } } private void OnDisable() { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.RemoveJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.RemoveJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } PrepareTeleport(); } public void Initialize() { accumulation = 0.0; if (jiggleRigs == null) { jiggleRigs = new List<JiggleRig>(); } foreach (JiggleRig jiggleRig in jiggleRigs) { jiggleRig.Initialize(); } settleTimer = 0f; } public JiggleUpdateMode GetJiggleUpdateMode() { return jiggleUpdateMode; } public virtual void Advance(float deltaTime, Vector3 gravity, double timeAsDouble, double timeAsDoubleOneStepBack, SphereCollider sphereCollider) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if (settleTimer < 0.2f) { settleTimer += deltaTime; if (settleTimer >= 0.2f) { FinishTeleport(); } return; } foreach (JiggleRig jiggleRig in jiggleRigs) { jiggleRig.ApplyValidPoseThenSampleTargetPose(timeAsDouble); } accumulation = Math.Min(accumulation + (double)deltaTime, 0.07999999821186066); while (accumulation > 0.019999999552965164) { accumulation -= 0.019999999552965164; double num = timeAsDouble - accumulation; foreach (JiggleRig jiggleRig2 in jiggleRigs) { JiggleSettingsData data = jiggleRig2.jiggleSettings.GetData(); data.blend *= blend; Vector3 acceleration = gravity * (data.gravityMultiplier * 0.0004f) + wind * (0.02f * data.airDrag); jiggleRig2.StepSimulation(data, num, acceleration, sphereCollider); } foreach (JiggleRig jiggleRig3 in jiggleRigs) { jiggleRig3.WriteSimulatedStep(num); } } foreach (JiggleRig jiggleRig4 in jiggleRigs) { JiggleSettingsData data2 = jiggleRig4.jiggleSettings.GetData(); jiggleRig4.Pose(debugDraw, timeAsDoubleOneStepBack, data2.blend * blend); } } public JiggleRig GetJiggleRig(Transform rootTransform) { foreach (JiggleRig jiggleRig in jiggleRigs) { if ((Object)(object)jiggleRig.GetRootTransform() == (Object)(object)rootTransform) { return jiggleRig; } } return null; } public void PrepareTeleport() { foreach (JiggleRig jiggleRig in jiggleRigs) { jiggleRig.PrepareTeleport(); } } public void FinishTeleport() { foreach (JiggleRig jiggleRig in jiggleRigs) { jiggleRig.FinishTeleport(); } } private void OnDrawGizmos() { if (jiggleRigs == null || !((Behaviour)this).enabled) { return; } foreach (JiggleRig jiggleRig in jiggleRigs) { jiggleRig.OnDrawGizmos(); } } private void OnDestroy() { if ((Object)(object)jiggleRigLOD != (Object)null) { jiggleRigLOD.RemoveTrackedJiggleRig(this); } } private void OnValidate() { if (Application.isPlaying) { JiggleRigHandler<JiggleRigLateUpdateHandler>.RemoveJiggleRigAdvancable(this); JiggleRigHandler<JiggleRigFixedUpdateHandler>.RemoveJiggleRigAdvancable(this); if (((Behaviour)this).isActiveAndEnabled) { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.AddJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.AddJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } } } else { if (jiggleRigs == null) { return; } foreach (JiggleRig jiggleRig in jiggleRigs) { jiggleRig.Initialize(); } } } bool IJiggleBlendable.get_enabled() { return ((Behaviour)this).enabled; } void IJiggleBlendable.set_enabled(bool value) { ((Behaviour)this).enabled = value; } } internal class JiggleRigFixedUpdateHandler : JiggleRigHandler<JiggleRigFixedUpdateHandler> { private void FixedUpdate() { //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_003b: 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) CachedSphereCollider.EnableSphereCollider(); Vector3 gravity = Physics.gravity; float deltaTime = Time.deltaTime; double timeAsDouble = Time.timeAsDouble; double timeAsDoubleOneStepBack = timeAsDouble - 0.019999999552965164; if (!CachedSphereCollider.TryGet(out SphereCollider collider)) { throw new UnityException("Failed to create a sphere collider, this should never happen! Is a scene not loaded but a jiggle rig is?"); } foreach (IJiggleAdvancable jiggleRig in JiggleRigHandler<JiggleRigFixedUpdateHandler>.jiggleRigs) { jiggleRig.Advance(deltaTime, gravity, timeAsDouble, timeAsDoubleOneStepBack, collider); } CachedSphereCollider.DisableSphereCollider(); } } internal class JiggleRigHandler<T> : MonoBehaviour where T : MonoBehaviour { private static T instance; protected static List<IJiggleAdvancable> jiggleRigs = new List<IJiggleAdvancable>(); private static void CreateInstanceIfNeeded() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)instance)) { GameObject val = new GameObject("JiggleRigHandler", new Type[1] { typeof(T) }) { hideFlags = (HideFlags)52 }; if (!val.TryGetComponent<T>(ref instance)) { throw new UnityException("Should never happen!"); } Object.DontDestroyOnLoad((Object)(object)val); } } private static void RemoveInstanceIfNeeded() { if (jiggleRigs.Count == 0 && Object.op_Implicit((Object)(object)instance)) { if (Application.isPlaying) { Object.Destroy((Object)(object)((Component)(object)instance).gameObject); } else { Object.DestroyImmediate((Object)(object)((Component)(object)instance).gameObject); } instance = default(T); } } [RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)] private static void Initialize() { jiggleRigs.Clear(); } internal static void AddJiggleRigAdvancable(IJiggleAdvancable advancable) { CreateInstanceIfNeeded(); if (!jiggleRigs.Contains(advancable)) { jiggleRigs.Add(advancable); } } internal static void RemoveJiggleRigAdvancable(IJiggleAdvancable advancable) { if (!jiggleRigs.Contains(advancable)) { RemoveInstanceIfNeeded(); return; } jiggleRigs.Remove(advancable); RemoveInstanceIfNeeded(); } private void OnDestroy() { if ((Object)(object)instance == (Object)(object)this) { instance = default(T); } } } internal class JiggleRigLateUpdateHandler : JiggleRigHandler<JiggleRigLateUpdateHandler> { private void LateUpdate() { //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_003b: 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) CachedSphereCollider.EnableSphereCollider(); Vector3 gravity = Physics.gravity; float deltaTime = Time.deltaTime; double timeAsDouble = Time.timeAsDouble; double timeAsDoubleOneStepBack = timeAsDouble - 0.019999999552965164; if (!CachedSphereCollider.TryGet(out SphereCollider collider)) { throw new UnityException("Failed to create a sphere collider, this should never happen! Is a scene not loaded but a jiggle rig is?"); } foreach (IJiggleAdvancable jiggleRig in JiggleRigHandler<JiggleRigLateUpdateHandler>.jiggleRigs) { jiggleRig.Advance(deltaTime, gravity, timeAsDouble, timeAsDoubleOneStepBack, collider); } CachedSphereCollider.DisableSphereCollider(); } } [DisallowMultipleComponent] public abstract class JiggleRigLOD : MonoBehaviour { protected List<IJiggleBlendable> jiggles; protected bool wasActive; protected virtual void Awake() { jiggles = new List<IJiggleBlendable>(); } public virtual void AddTrackedJiggleRig(IJiggleBlendable blendable) { if (!jiggles.Contains(blendable)) { jiggles.Add(blendable); } } public virtual void RemoveTrackedJiggleRig(IJiggleBlendable blendable) { if (jiggles.Contains(blendable)) { jiggles.Remove(blendable); } } private void Update() { if (!CheckActive()) { if (wasActive) { foreach (IJiggleBlendable jiggle in jiggles) { jiggle.enabled = false; } } wasActive = false; return; } if (!wasActive) { foreach (IJiggleBlendable jiggle2 in jiggles) { jiggle2.enabled = true; } } wasActive = true; } protected abstract bool CheckActive(); private void OnDisable() { foreach (IJiggleBlendable jiggle in jiggles) { jiggle.enabled = false; } } } public class MonoBehaviorHider { public class JiggleRigLODRenderComponent : MonoBehaviour { public Action<bool> VisibilityChange; public void OnBecameInvisible() { VisibilityChange?.Invoke(obj: false); } public void OnBecameVisible() { VisibilityChange?.Invoke(obj: true); } } } public class JiggleRigRendererLOD : JiggleRigSimpleLOD { private class RendererSubscription { public bool visible; public Action<bool> action; public MonoBehaviorHider.JiggleRigLODRenderComponent rendererSubscription; } private RendererSubscription[] subscriptions; private int subscriptionCount; private bool lastVisibility; public void ClearRenderers() { for (int i = 0; i < subscriptionCount; i++) { MonoBehaviorHider.JiggleRigLODRenderComponent rendererSubscription = subscriptions[i].rendererSubscription; rendererSubscription.VisibilityChange = (Action<bool>)Delegate.Remove(rendererSubscription.VisibilityChange, subscriptions[i].action); } subscriptions = null; subscriptionCount = 0; } public void SetRenderers(Renderer[] renderers) { ClearRenderers(); MonoBehaviorHider.JiggleRigLODRenderComponent jiggleRigLODRenderComponent = null; subscriptionCount = renderers.Length; subscriptions = new RendererSubscription[subscriptionCount]; for (int i = 0; i < subscriptionCount; i++) { Renderer val = renderers[i]; if (!Object.op_Implicit((Object)(object)val)) { continue; } if (!((Component)val).TryGetComponent<MonoBehaviorHider.JiggleRigLODRenderComponent>(ref jiggleRigLODRenderComponent)) { jiggleRigLODRenderComponent = ((Component)val).gameObject.AddComponent<MonoBehaviorHider.JiggleRigLODRenderComponent>(); } int index = i; Action<bool> action = delegate(bool visible) { if (index < 0 || index >= subscriptionCount) { Debug.LogError((object)("Index out of bounds: " + index + ". Valid range is 0 to " + (subscriptionCount - 1))); } else { subscriptions[index].visible = visible; RevalulateVisiblity(); } }; subscriptions[i] = new RendererSubscription { visible = val.isVisible, action = action, rendererSubscription = jiggleRigLODRenderComponent }; MonoBehaviorHider.JiggleRigLODRenderComponent jiggleRigLODRenderComponent2 = jiggleRigLODRenderComponent; jiggleRigLODRenderComponent2.VisibilityChange = (Action<bool>)Delegate.Combine(jiggleRigLODRenderComponent2.VisibilityChange, action); } RevalulateVisiblity(); } protected override void Awake() { base.Awake(); SetRenderers(((Component)this).GetComponentsInChildren<Renderer>()); } private void RevalulateVisiblity() { for (int i = 0; i < subscriptionCount; i++) { if (subscriptions[i].visible) { lastVisibility = true; return; } } lastVisibility = false; } protected override bool CheckActive() { if (!lastVisibility) { return false; } return base.CheckActive(); } } public class JiggleRigSimpleLOD : JiggleRigLOD { [Tooltip("Distance to disable the jiggle rig.")] [SerializeField] private float distance = 20f; [Tooltip("Distance past distance from which it blends out rather than instantly disabling.")] [SerializeField] private float blend = 5f; private static Camera currentCamera; protected virtual bool TryGetCamera(out Camera camera) { if (!Object.op_Implicit((Object)(object)currentCamera) || !((Component)currentCamera).CompareTag("MainCamera")) { currentCamera = Camera.main; } camera = currentCamera; return Object.op_Implicit((Object)(object)currentCamera); } protected override bool CheckActive() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!TryGetCamera(out Camera camera)) { return false; } Vector3 position = ((Component)this).transform.position; float num = Vector3.Distance(((Component)camera).transform.position, position); float num2 = (num - distance + blend) / blend; num2 = Mathf.Clamp01(1f - num2); foreach (IJiggleBlendable jiggle in jiggles) { jiggle.blend = num2; } return num < distance; } } public struct JiggleSettingsData { private float _friction; private float _airDrag; private float _angleElasticity; private float _lengthElasticity; private float _elasticitySoften; public float gravityMultiplier; public float blend; public float radiusMultiplier; public float squaredAngleElasticity; public float squaredLengthElasticity; public float airDragOneMinus; public float frictionOneMinus; public float doubleElasticitySoften; public float friction { get { return _friction; } set { _friction = value; frictionOneMinus = 1f - _friction; } } public float airDrag { get { return _airDrag; } set { _airDrag = value; airDragOneMinus = 1f - _airDrag; } } public float angleElasticity { get { return _angleElasticity; } set { _angleElasticity = value; squaredAngleElasticity = _angleElasticity * _angleElasticity; } } public float lengthElasticity { get { return _lengthElasticity; } set { _lengthElasticity = value; squaredLengthElasticity = _lengthElasticity * _lengthElasticity; } } public float elasticitySoften { get { return _elasticitySoften; } set { _elasticitySoften = value; doubleElasticitySoften = _elasticitySoften * 2f; } } public static JiggleSettingsData Lerp(JiggleSettingsData a, JiggleSettingsData b, float t) { JiggleSettingsData result = default(JiggleSettingsData); result.gravityMultiplier = Mathf.Lerp(a.gravityMultiplier, b.gravityMultiplier, t); result.friction = Mathf.Lerp(a.friction, b.friction, t); result.angleElasticity = Mathf.Lerp(a.angleElasticity, b.angleElasticity, t); result.blend = Mathf.Lerp(a.blend, b.blend, t); result.airDrag = Mathf.Lerp(a.airDrag, b.airDrag, t); result.lengthElasticity = Mathf.Lerp(a.lengthElasticity, b.lengthElasticity, t); result.elasticitySoften = Mathf.Lerp(a.elasticitySoften, b.elasticitySoften, t); result.radiusMultiplier = Mathf.Lerp(a.radiusMultiplier, b.radiusMultiplier, t); return result; } } [CreateAssetMenu(fileName = "JiggleSettings", menuName = "JigglePhysics/Settings", order = 1)] public class JiggleSettings : JiggleSettingsBase { [SerializeField] [Range(0f, 2f)] [Tooltip("How much gravity to apply to the simulation, it is a multiplier of the Physics.gravity setting.")] private float gravityMultiplier = 1f; [SerializeField] [Range(0f, 1f)] [Tooltip("How much mechanical friction to apply, this is specifically how quickly oscillations come to rest.")] private float friction = 0.4f; [SerializeField] [Range(0f, 1f)] [Tooltip("How much angular force is applied to bring it to the target shape.")] private float angleElasticity = 0.4f; [SerializeField] [Range(0f, 1f)] [Tooltip("How much of the simulation should be expressed. A value of 0 would make the jiggle have zero effect. A value of 1 gives the full movement as intended. 0.5 would ")] private float blend = 1f; [FormerlySerializedAs("airFriction")] [HideInInspector] [SerializeField] [Range(0f, 1f)] [Tooltip("How much jiggled objects should get dragged behind by moving through the air. Or how \"thick\" the air is.")] private float airDrag = 0.1f; [HideInInspector] [SerializeField] [Range(0f, 1f)] [Tooltip("How rigidly the rig holds its length. Low values cause lots of squash and stretch!")] private float lengthElasticity = 0.8f; [HideInInspector] [SerializeField] [Range(0f, 1f)] [Tooltip("How much to allow free bone motion before engaging elasticity.")] private float elasticitySoften = 0f; [HideInInspector] [SerializeField] [Tooltip("How much radius points have, only used for collisions. Set to 0 to disable collisions")] private float radiusMultiplier = 0f; [HideInInspector] [SerializeField] [Tooltip("How the radius is expressed as a curve along the bone chain from root to child.")] private AnimationCurve radiusCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1f), new Keyframe(1f, 0f) }); public override JiggleSettingsData GetData() { JiggleSettingsData result = default(JiggleSettingsData); result.gravityMultiplier = gravityMultiplier; result.friction = friction; result.airDrag = airDrag; result.blend = blend; result.angleElasticity = angleElasticity; result.elasticitySoften = elasticitySoften; result.lengthElasticity = lengthElasticity; result.radiusMultiplier = radiusMultiplier; return result; } public void SetData(JiggleSettingsData data) { gravityMultiplier = data.gravityMultiplier; friction = data.friction; angleElasticity = data.angleElasticity; blend = data.blend; airDrag = data.airDrag; lengthElasticity = data.lengthElasticity; elasticitySoften = data.elasticitySoften; radiusMultiplier = data.radiusMultiplier; } public override float GetRadius(float normalizedIndex) { return radiusMultiplier * radiusCurve.Evaluate(normalizedIndex); } public void SetRadiusCurve(AnimationCurve curve) { radiusCurve = curve; } } public class JiggleSettingsBase : ScriptableObject { public virtual JiggleSettingsData GetData() { return default(JiggleSettingsData); } public virtual float GetRadius(float normalizedIndex) { return 0f; } } [CreateAssetMenu(fileName = "JiggleSettingsBlend", menuName = "JigglePhysics/Blend Settings", order = 1)] public class JiggleSettingsBlend : JiggleSettingsBase { [Tooltip("The list of jiggle settings to blend between.")] public List<JiggleSettings> blendSettings; [Range(0f, 1f)] [Tooltip("A value from 0 to 1 that linearly blends between all of the blendSettings.")] private float normalizedBlend; private JiggleSettingsData cachedData; public void SetNormalizedBlend(float blend) { if (!Mathf.Approximately(blend, normalizedBlend)) { normalizedBlend = blend; Cache(); } } public float GetNormalizedBlend() { return normalizedBlend; } private void Cache() { int num = blendSettings.Count - 1; float num2 = Mathf.Clamp01(normalizedBlend); int num3 = Mathf.Clamp(Mathf.FloorToInt(num2 * (float)num), 0, num); int index = Mathf.Clamp(Mathf.FloorToInt(num2 * (float)num) + 1, 0, num); cachedData = JiggleSettingsData.Lerp(blendSettings[num3].GetData(), blendSettings[index].GetData(), Mathf.Clamp01(num2 * (float)num - (float)num3)); } public override JiggleSettingsData GetData() { return cachedData; } public override float GetRadius(float normalizedIndex) { float num = Mathf.Clamp01(normalizedBlend); int num2 = Mathf.FloorToInt(num * (float)blendSettings.Count); int num3 = Mathf.FloorToInt(num * (float)blendSettings.Count) + 1; return Mathf.Lerp(blendSettings[Mathf.Clamp(num2, 0, blendSettings.Count - 1)].GetRadius(normalizedIndex), blendSettings[Mathf.Clamp(num3, 0, blendSettings.Count - 1)].GetRadius(normalizedIndex), Mathf.Clamp01(num * (float)blendSettings.Count - (float)num2)); } private void Awake() { Cache(); } private void OnValidate() { Cache(); } } public class JiggleSkin : MonoBehaviour, IJiggleAdvancable, IJiggleBlendable { [Serializable] public class JiggleZone : JiggleRigBuilder.JiggleRig { [Tooltip("How large of a radius the zone should effect, in target-space meters. (Scaling the target will effect the radius.)")] public float radius; public JiggleZone(Transform rootTransform, JiggleSettingsBase jiggleSettings, ICollection<Transform> ignoredTransforms, ICollection<Collider> colliders) : base(rootTransform, jiggleSettings, ignoredTransforms, colliders) { } protected override void CreateSimulatedPoints(List<JiggleBone> outputPoints, ICollection<Transform> ignoredTransforms, Transform currentTransform, JiggleBone? parentJiggleBone, int? parentID) { JiggleBone jiggleBone = new JiggleBone(outputPoints, currentTransform, null, null); jiggleBone.SetChildID(1); outputPoints.Add(jiggleBone); outputPoints.Add(new JiggleBone(outputPoints, null, jiggleBone, 0, 0f)); } public void JiggleZonePrecache() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < simulatedPoints.Length; i++) { JiggleBone jiggleBone = simulatedPoints[i]; if (jiggleBone.hasTransform) { jiggleBone.cachedPositionForPosing = jiggleBone.transform.position; } else { jiggleBone.cachedPositionForPosing = simulatedPoints[jiggleBone.parentID].cachedPositionForPosing; } } } public void DebugDraw() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Debug.DrawLine(GetPointSolve(), GetRootTransform().position, Color.cyan, 0f, false); } public Vector3 GetPointSolve() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return simulatedPoints[1].GetCachedSolvePosition(); } public void OnDrawGizmosSelected() { //IL_0028: 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_004a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)GetRootTransform() == (Object)null)) { Gizmos.color = new Color(0.1f, 0.1f, 0.8f, 0.5f); Gizmos.DrawWireSphere(GetRootTransform().position, radius * GetRootTransform().lossyScale.x); } } } [SerializeField] [Tooltip("Enables interpolation for the simulation, this should be LateUpdate unless you *really* need the simulation to only update on FixedUpdate.")] private JiggleUpdateMode jiggleUpdateMode = JiggleUpdateMode.LateUpdate; public List<JiggleZone> jiggleZones; [SerializeField] [Tooltip("The list of skins to send the deformation data too, they should have JiggleSkin-compatible materials!")] public List<SkinnedMeshRenderer> targetSkins; [Tooltip("An air force that is applied to the entire rig, this is useful to plug in some wind volumes from external sources.")] public Vector3 wind; [SerializeField] [Tooltip("Draws some simple lines to show what the simulation is doing. Generally this should be disabled.")] private bool debugDraw = false; private float settleTimer; private bool wasLODActive = true; private double accumulation; private MaterialPropertyBlock materialPropertyBlock; private List<Vector4> packedVectors; private int jiggleInfoNameID; private JiggleRigLOD jiggleRigLOD; [field: SerializeField] [field: Range(0f, 1f)] public float blend { get; set; } = 1f; public void SetJiggleRigLOD(JiggleRigLOD lod) { if ((Object)(object)jiggleRigLOD != (Object)null) { jiggleRigLOD.RemoveTrackedJiggleRig(this); } jiggleRigLOD = lod; if ((Object)(object)jiggleRigLOD != (Object)null) { jiggleRigLOD.AddTrackedJiggleRig(this); } } public JiggleRigLOD GetJiggleRigLOD() { return jiggleRigLOD; } public void PrepareTeleport() { foreach (JiggleZone jiggleZone in jiggleZones) { jiggleZone.PrepareTeleport(); } } public void FinishTeleport() { foreach (JiggleZone jiggleZone in jiggleZones) { jiggleZone.FinishTeleport(); } } private void Awake() { Initialize(); } private void Start() { JiggleRigLOD jiggleRigLOD = default(JiggleRigLOD); if (((Component)this).TryGetComponent<JiggleRigLOD>(ref jiggleRigLOD)) { SetJiggleRigLOD(jiggleRigLOD); } } private void OnEnable() { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.AddJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.AddJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } if (settleTimer >= 0.2f) { FinishTeleport(); } } private void OnDisable() { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.RemoveJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.RemoveJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } PrepareTeleport(); } public void SetJiggleUpdateMode(JiggleUpdateMode mode) { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.RemoveJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.RemoveJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } jiggleUpdateMode = mode; switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.AddJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.AddJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } } public void Initialize() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown accumulation = Random.Range(0f, 0.02f); if (jiggleZones == null) { jiggleZones = new List<JiggleZone>(); } foreach (JiggleZone jiggleZone in jiggleZones) { jiggleZone.Initialize(); } jiggleInfoNameID = Shader.PropertyToID("_JiggleInfos"); packedVectors = new List<Vector4>(); settleTimer = 0f; materialPropertyBlock = new MaterialPropertyBlock(); } public JiggleZone GetJiggleZone(Transform target) { foreach (JiggleZone jiggleZone in jiggleZones) { if ((Object)(object)jiggleZone.GetRootTransform() == (Object)(object)target) { return jiggleZone; } } return null; } public JiggleUpdateMode GetJiggleUpdateMode() { return jiggleUpdateMode; } public void Advance(float deltaTime, Vector3 gravity, double timeAsDouble, double timeAsDoubleOneStepBack, SphereCollider sphereCollider) { //IL_00e9: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0121: Unknown result type (might be due to invalid IL or missing references) if (settleTimer < 0.2f) { settleTimer += deltaTime; if (settleTimer >= 0.2f) { FinishTeleport(); } return; } foreach (JiggleZone jiggleZone in jiggleZones) { jiggleZone.ApplyValidPoseThenSampleTargetPose(timeAsDouble); } accumulation = Math.Min(accumulation + (double)deltaTime, 0.07999999821186066); while (accumulation > 0.019999999552965164) { accumulation -= 0.019999999552965164; double num = timeAsDouble - accumulation; foreach (JiggleZone jiggleZone2 in jiggleZones) { JiggleSettingsData data = jiggleZone2.jiggleSettings.GetData(); Vector3 acceleration = gravity * (data.gravityMultiplier * 0.0004f) + wind * (0.02f * data.airDrag); jiggleZone2.StepSimulation(data, num, acceleration, sphereCollider); } foreach (JiggleZone jiggleZone3 in jiggleZones) { jiggleZone3.WriteSimulatedStep(num); } } foreach (JiggleZone jiggleZone4 in jiggleZones) { jiggleZone4.JiggleZonePrecache(); } foreach (JiggleZone jiggleZone5 in jiggleZones) { jiggleZone5.DeriveFinalSolve(timeAsDouble); } UpdateMesh(); if (!debugDraw) { return; } foreach (JiggleZone jiggleZone6 in jiggleZones) { jiggleZone6.DebugDraw(); } } private void UpdateMesh() { //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b8: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) packedVectors.Clear(); foreach (SkinnedMeshRenderer targetSkin in targetSkins) { foreach (JiggleZone jiggleZone in jiggleZones) { Vector3 val = targetSkin.rootBone.InverseTransformPoint(jiggleZone.GetRootTransform().position); Vector3 val2 = targetSkin.rootBone.InverseTransformPoint(jiggleZone.GetPointSolve()); packedVectors.Add(new Vector4(val.x, val.y, val.z, jiggleZone.radius * jiggleZone.GetRootTransform().lossyScale.x)); packedVectors.Add(new Vector4(val2.x, val2.y, val2.z, jiggleZone.jiggleSettings.GetData().blend * blend)); } } for (int i = packedVectors.Count; i < 16; i++) { packedVectors.Add(Vector4.zero); } foreach (SkinnedMeshRenderer targetSkin2 in targetSkins) { ((Renderer)targetSkin2).GetPropertyBlock(materialPropertyBlock); materialPropertyBlock.SetVectorArray(jiggleInfoNameID, packedVectors); ((Renderer)targetSkin2).SetPropertyBlock(materialPropertyBlock); } } private void OnValidate() { if (Application.isPlaying) { JiggleRigHandler<JiggleRigLateUpdateHandler>.RemoveJiggleRigAdvancable(this); JiggleRigHandler<JiggleRigFixedUpdateHandler>.RemoveJiggleRigAdvancable(this); if (((Behaviour)this).isActiveAndEnabled) { switch (jiggleUpdateMode) { case JiggleUpdateMode.LateUpdate: JiggleRigHandler<JiggleRigLateUpdateHandler>.AddJiggleRigAdvancable(this); break; case JiggleUpdateMode.FixedUpdate: JiggleRigHandler<JiggleRigFixedUpdateHandler>.AddJiggleRigAdvancable(this); break; default: throw new ArgumentOutOfRangeException(); } } } if (jiggleZones != null) { for (int num = jiggleZones.Count - 1; num > 8; num--) { jiggleZones.RemoveAt(num); } } } private void OnDestroy() { if ((Object)(object)jiggleRigLOD != (Object)null) { jiggleRigLOD.RemoveTrackedJiggleRig(this); } } private void OnDrawGizmosSelected() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (jiggleZones == null) { return; } Gizmos.color = new Color(0.1f, 0.1f, 0.8f, 0.5f); foreach (JiggleZone jiggleZone in jiggleZones) { jiggleZone.OnDrawGizmosSelected(); } } public Vector3 ApplyJiggle(Vector3 toPoint, float blend, double timeAsDouble) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0066: 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_0069: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = toPoint; foreach (JiggleZone jiggleZone in jiggleZones) { jiggleZone.DeriveFinalSolve(timeAsDouble); Vector3 val2 = targetSkins[0].rootBone.InverseTransformPoint(jiggleZone.GetRootTransform().position); Vector3 val3 = targetSkins[0].rootBone.InverseTransformPoint(jiggleZone.GetPointSolve()); Vector3 val4 = val3 - val2; float num = Vector3.Distance(val2, targetSkins[0].rootBone.InverseTransformPoint(toPoint)); float num2 = 1f - Mathf.SmoothStep(0f, jiggleZone.radius * jiggleZone.GetRootTransform().lossyScale.x, num); val += targetSkins[0].rootBone.TransformVector(val4) * jiggleZone.jiggleSettings.GetData().blend * blend * num2; } return val; } bool IJiggleBlendable.get_enabled() { return ((Behaviour)this).enabled; } void IJiggleBlendable.set_enabled(bool value) { ((Behaviour)this).enabled = value; } } public class PositionSignal { private struct Frame { public Vector3 position; public double time; } private Frame previousFrame; private Frame currentFrame; public PositionSignal(Vector3 startPosition, double time) { //IL_0014: 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) currentFrame = (previousFrame = new Frame { position = startPosition, time = time }); } public void SetPosition(Vector3 position, double time) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) previousFrame = currentFrame; currentFrame = new Frame { position = position, time = time }; } public void OffsetSignal(Vector3 offset) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) previousFrame = new Frame { position = previousFrame.position + offset, time = previousFrame.time }; currentFrame = new Frame { position = currentFrame.position + offset, time = previousFrame.time }; } public void FlattenSignal(double time, Vector3 position) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) previousFrame = new Frame { position = position, time = time - 0.1599999964237213 }; currentFrame = new Frame { position = position, time = time - 0.07999999821186066 }; } public Vector3 GetCurrent() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return currentFrame.position; } public Vector3 GetPrevious() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return previousFrame.position; } public Vector3 SamplePosition(double time) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) double num = currentFrame.time - previousFrame.time; if (num == 0.0) { return previousFrame.position; } double num2 = (time - previousFrame.time) / num; return Vector3.LerpUnclamped(previousFrame.position, currentFrame.position, (float)num2); } } } namespace LcEmotes2AndKnucklesFeaturingDante { internal static class Assets { private static readonly List<AssetBundle> AssetBundles = new List<AssetBundle>(); private static readonly Dictionary<string, int> AssetIndices = new Dictionary<string, int>(); public static void LoadAllAssetBundles() { foreach (string item in Directory.EnumerateFiles(FsUtils.AssetBundlesDir, "*", SearchOption.AllDirectories)) { string text = item; if (text.StartsWith(FsUtils.AssetBundlesDir)) { string text2 = text; int length = FsUtils.AssetBundlesDir.Length; text = text2.Substring(length, text2.Length - length); } while (text.StartsWith("/") || text.StartsWith("\\")) { string text2 = text; text = text2.Substring(1, text2.Length - 1); } AddBundle(text); } } public static void AddBundle(string bundleName) { string text = Path.Combine(FsUtils.AssetBundlesDir, bundleName); AssetBundle val = AssetBundle.LoadFromFile(text); int count = AssetBundles.Count; AssetBundles.Add(val); string[] allAssetNames = val.GetAllAssetNames(); foreach (string text2 in allAssetNames) { string text3 = text2.ToLowerInvariant(); if (text3.StartsWith("assets/")) { string text4 = text3; int length = "assets/".Length; text3 = text4.Substring(length, text4.Length - length); } AssetIndices[text3] = count; } } public static T? Load<T>(string assetName) where T : Object { try { assetName = assetName.ToLowerInvariant(); if (assetName.StartsWith("assets/")) { string text = assetName; int length = "assets/".Length; assetName = text.Substring(length, text.Length - length); } int index = AssetIndices[assetName]; return AssetBundles[index].LoadAsset<T>("assets/" + assetName); } catch (Exception arg) { ManualLogSource? logger = LcEmotes2AndKnucklesFeaturingDantePlugin.Logger; if (logger != null) { logger.LogError((object)$"Couldn't load asset [{assetName}] exception: {arg}"); } return default(T); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.gemumoddo.lc_emotes2_and_knuckles_featuring_dante", "Emotes 2 And Knuckles Featuring Dante", "1.4.0")] public class LcEmotes2AndKnucklesFeaturingDantePlugin : BaseUnityPlugin { public const string ModGuid = "com.gemumoddo.lc_emotes2_and_knuckles_featuring_dante"; public const string ModName = "Emotes 2 And Knuckles Featuring Dante"; public const string ModVersion = "1.4.0"; public static bool watermarkRemoverPresent; public static PluginInfo? PluginInfo { get; private set; } public static ManualLogSource? Log