From 54c872fa42b1ba0fdbcfe812b80bb8eb0cfe108f Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Wed, 13 Mar 2024 17:37:47 +0800
Subject: *misc
---
AddForceByCollision.cs | 34 ---------
AddForceToTarget.cs | 26 -------
AnimationObject.cs | 140 ----------------------------------
_ActiveRagdoll/AddForceByCollision.cs | 34 +++++++++
_ActiveRagdoll/AddForceToTarget.cs | 26 +++++++
_ActiveRagdoll/AnimationObject.cs | 140 ++++++++++++++++++++++++++++++++++
_ActiveRagdoll/BodyParts/HandLeft.cs | 12 +++
_ActiveRagdoll/BodyParts/HandRight.cs | 12 +++
_ActiveRagdoll/BodyParts/Head.cs | 12 +++
_ActiveRagdoll/BodyParts/Hip.cs | 12 +++
_ActiveRagdoll/HandLeft.cs | 12 ---
_ActiveRagdoll/HandRight.cs | 12 ---
_ActiveRagdoll/Head.cs | 12 ---
_ActiveRagdoll/Hip.cs | 12 ---
14 files changed, 248 insertions(+), 248 deletions(-)
delete mode 100644 AddForceByCollision.cs
delete mode 100644 AddForceToTarget.cs
delete mode 100644 AnimationObject.cs
create mode 100644 _ActiveRagdoll/AddForceByCollision.cs
create mode 100644 _ActiveRagdoll/AddForceToTarget.cs
create mode 100644 _ActiveRagdoll/AnimationObject.cs
create mode 100644 _ActiveRagdoll/BodyParts/HandLeft.cs
create mode 100644 _ActiveRagdoll/BodyParts/HandRight.cs
create mode 100644 _ActiveRagdoll/BodyParts/Head.cs
create mode 100644 _ActiveRagdoll/BodyParts/Hip.cs
delete mode 100644 _ActiveRagdoll/HandLeft.cs
delete mode 100644 _ActiveRagdoll/HandRight.cs
delete mode 100644 _ActiveRagdoll/Head.cs
delete mode 100644 _ActiveRagdoll/Hip.cs
diff --git a/AddForceByCollision.cs b/AddForceByCollision.cs
deleted file mode 100644
index 8392efa..0000000
--- a/AddForceByCollision.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using UnityEngine;
-
-public class AddForceByCollision : MonoBehaviour
-{
- public Rigidbody rig;
-
- public float amout;
-
- private void Start()
- {
- }
-
- private void Update()
- {
- }
-
- private void OnCollisionEnter(Collision collision)
- {
- Collide(collision);
- }
-
- private void OnCollisionStay(Collision collision)
- {
- Collide(collision);
- }
-
- private void Collide(Collision collision)
- {
- if (collision.gameObject.layer == 9)
- {
- rig.AddForce(collision.contacts[0].normal * collision.impactForceSum.magnitude * amout, ForceMode.Acceleration);
- }
- }
-}
diff --git a/AddForceToTarget.cs b/AddForceToTarget.cs
deleted file mode 100644
index 9464c97..0000000
--- a/AddForceToTarget.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using UnityEngine;
-
-public class AddForceToTarget : MonoBehaviour
-{
- public AnimationCurve forceByRangeCurve;
-
- public Rigidbody target;
-
- public float force;
-
- private Transform head;
-
- private void Start()
- {
- head = GetComponentInChildren
().transform;
- }
-
- private void FixedUpdate()
- {
- float num = forceByRangeCurve.Evaluate(Vector3.Distance(head.position, target.position)) * force;
- if (num > 0f)
- {
- target.AddForce((head.position - target.position).normalized * num, ForceMode.Force);
- }
- }
-}
diff --git a/AnimationObject.cs b/AnimationObject.cs
deleted file mode 100644
index 0c2d636..0000000
--- a/AnimationObject.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using UnityEngine;
-using UnityEngine.Events;
-
-public class AnimationObject : MonoBehaviour
-{
- public PhysicsAnimation[] animations;
-
- private Rigidbody rig;
-
- private StepHandler stepHandler;
-
- private Transform hip;
-
- public float smoothing;
-
- public float multiplier = 1f;
-
- private bool isCurrentlyLeft;
-
- public bool isLeft;
-
- public UnityEvent switchToForwardEvent;
-
- public UnityEvent switchToBackwardsEvent;
-
- public bool dontAnimateIfHoldingSomething;
-
- private Holding holding;
-
- private AnimationHandler animationHandler;
-
- private PlayerDeath death;
-
- private float muscleMultiplier = 1f;
-
- private void Start()
- {
- animationHandler = base.transform.root.GetComponent();
- rig = GetComponent();
- stepHandler = base.transform.root.GetComponent();
- holding = base.transform.root.GetComponent();
- death = base.transform.root.GetComponent();
- Hip componentInChildren = base.transform.root.GetComponentInChildren();
- if ((bool)componentInChildren)
- {
- hip = componentInChildren.transform;
- }
- }
-
- private void FixedUpdate()
- {
- if ((bool)death)
- {
- if (death.muscleFunction < 0f)
- {
- return;
- }
- muscleMultiplier = death.muscleFunction;
- }
- if ((!holding || !dontAnimateIfHoldingSomething || !holding.heldObject) && animationHandler.animationState < animations.Length)
- {
- SetMultiplier();
- AddTorque();
- AddForce();
- }
- }
-
- private void AddForce()
- {
- Vector3 vector = Vector3.zero;
- if (isCurrentlyLeft == isLeft)
- {
- Vector3 forwardForce = animations[animationHandler.animationState].forwardForce;
- if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.World)
- {
- vector = forwardForce;
- }
- if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.Hip)
- {
- vector = hip.TransformDirection(forwardForce);
- }
- }
- else
- {
- Vector3 backwardsForce = animations[animationHandler.animationState].backwardsForce;
- if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.World)
- {
- vector = backwardsForce;
- }
- if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.Hip)
- {
- vector = hip.TransformDirection(backwardsForce);
- }
- }
- rig.AddForce(vector * muscleMultiplier * multiplier, ForceMode.Acceleration);
- }
-
- private void AddTorque()
- {
- Vector3 vector = ((isCurrentlyLeft != isLeft) ? hip.TransformDirection(animations[animationHandler.animationState].backwardsTorque) : hip.TransformDirection(animations[animationHandler.animationState].forwardTorque));
- rig.AddTorque(vector * muscleMultiplier * multiplier, ForceMode.Acceleration);
- }
-
- private void SetMultiplier()
- {
- if (smoothing != 0f)
- {
- float b = 1f;
- if (isCurrentlyLeft != stepHandler.isLeft)
- {
- b = 0f;
- }
- multiplier = Mathf.Lerp(multiplier, b, 1f / smoothing);
- if (multiplier < 0.1f)
- {
- ChangeStep();
- }
- }
- else
- {
- ChangeStep();
- }
- }
-
- private void ChangeStep()
- {
- if (isCurrentlyLeft != stepHandler.isLeft)
- {
- if (stepHandler.isLeft == isLeft)
- {
- switchToForwardEvent.Invoke();
- }
- else
- {
- switchToBackwardsEvent.Invoke();
- }
- isCurrentlyLeft = stepHandler.isLeft;
- }
- }
-}
diff --git a/_ActiveRagdoll/AddForceByCollision.cs b/_ActiveRagdoll/AddForceByCollision.cs
new file mode 100644
index 0000000..8392efa
--- /dev/null
+++ b/_ActiveRagdoll/AddForceByCollision.cs
@@ -0,0 +1,34 @@
+using UnityEngine;
+
+public class AddForceByCollision : MonoBehaviour
+{
+ public Rigidbody rig;
+
+ public float amout;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+
+ private void OnCollisionEnter(Collision collision)
+ {
+ Collide(collision);
+ }
+
+ private void OnCollisionStay(Collision collision)
+ {
+ Collide(collision);
+ }
+
+ private void Collide(Collision collision)
+ {
+ if (collision.gameObject.layer == 9)
+ {
+ rig.AddForce(collision.contacts[0].normal * collision.impactForceSum.magnitude * amout, ForceMode.Acceleration);
+ }
+ }
+}
diff --git a/_ActiveRagdoll/AddForceToTarget.cs b/_ActiveRagdoll/AddForceToTarget.cs
new file mode 100644
index 0000000..9464c97
--- /dev/null
+++ b/_ActiveRagdoll/AddForceToTarget.cs
@@ -0,0 +1,26 @@
+using UnityEngine;
+
+public class AddForceToTarget : MonoBehaviour
+{
+ public AnimationCurve forceByRangeCurve;
+
+ public Rigidbody target;
+
+ public float force;
+
+ private Transform head;
+
+ private void Start()
+ {
+ head = GetComponentInChildren().transform;
+ }
+
+ private void FixedUpdate()
+ {
+ float num = forceByRangeCurve.Evaluate(Vector3.Distance(head.position, target.position)) * force;
+ if (num > 0f)
+ {
+ target.AddForce((head.position - target.position).normalized * num, ForceMode.Force);
+ }
+ }
+}
diff --git a/_ActiveRagdoll/AnimationObject.cs b/_ActiveRagdoll/AnimationObject.cs
new file mode 100644
index 0000000..0c2d636
--- /dev/null
+++ b/_ActiveRagdoll/AnimationObject.cs
@@ -0,0 +1,140 @@
+using UnityEngine;
+using UnityEngine.Events;
+
+public class AnimationObject : MonoBehaviour
+{
+ public PhysicsAnimation[] animations;
+
+ private Rigidbody rig;
+
+ private StepHandler stepHandler;
+
+ private Transform hip;
+
+ public float smoothing;
+
+ public float multiplier = 1f;
+
+ private bool isCurrentlyLeft;
+
+ public bool isLeft;
+
+ public UnityEvent switchToForwardEvent;
+
+ public UnityEvent switchToBackwardsEvent;
+
+ public bool dontAnimateIfHoldingSomething;
+
+ private Holding holding;
+
+ private AnimationHandler animationHandler;
+
+ private PlayerDeath death;
+
+ private float muscleMultiplier = 1f;
+
+ private void Start()
+ {
+ animationHandler = base.transform.root.GetComponent();
+ rig = GetComponent();
+ stepHandler = base.transform.root.GetComponent();
+ holding = base.transform.root.GetComponent();
+ death = base.transform.root.GetComponent();
+ Hip componentInChildren = base.transform.root.GetComponentInChildren();
+ if ((bool)componentInChildren)
+ {
+ hip = componentInChildren.transform;
+ }
+ }
+
+ private void FixedUpdate()
+ {
+ if ((bool)death)
+ {
+ if (death.muscleFunction < 0f)
+ {
+ return;
+ }
+ muscleMultiplier = death.muscleFunction;
+ }
+ if ((!holding || !dontAnimateIfHoldingSomething || !holding.heldObject) && animationHandler.animationState < animations.Length)
+ {
+ SetMultiplier();
+ AddTorque();
+ AddForce();
+ }
+ }
+
+ private void AddForce()
+ {
+ Vector3 vector = Vector3.zero;
+ if (isCurrentlyLeft == isLeft)
+ {
+ Vector3 forwardForce = animations[animationHandler.animationState].forwardForce;
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.World)
+ {
+ vector = forwardForce;
+ }
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.Hip)
+ {
+ vector = hip.TransformDirection(forwardForce);
+ }
+ }
+ else
+ {
+ Vector3 backwardsForce = animations[animationHandler.animationState].backwardsForce;
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.World)
+ {
+ vector = backwardsForce;
+ }
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.Hip)
+ {
+ vector = hip.TransformDirection(backwardsForce);
+ }
+ }
+ rig.AddForce(vector * muscleMultiplier * multiplier, ForceMode.Acceleration);
+ }
+
+ private void AddTorque()
+ {
+ Vector3 vector = ((isCurrentlyLeft != isLeft) ? hip.TransformDirection(animations[animationHandler.animationState].backwardsTorque) : hip.TransformDirection(animations[animationHandler.animationState].forwardTorque));
+ rig.AddTorque(vector * muscleMultiplier * multiplier, ForceMode.Acceleration);
+ }
+
+ private void SetMultiplier()
+ {
+ if (smoothing != 0f)
+ {
+ float b = 1f;
+ if (isCurrentlyLeft != stepHandler.isLeft)
+ {
+ b = 0f;
+ }
+ multiplier = Mathf.Lerp(multiplier, b, 1f / smoothing);
+ if (multiplier < 0.1f)
+ {
+ ChangeStep();
+ }
+ }
+ else
+ {
+ ChangeStep();
+ }
+ }
+
+ private void ChangeStep()
+ {
+ if (isCurrentlyLeft != stepHandler.isLeft)
+ {
+ if (stepHandler.isLeft == isLeft)
+ {
+ switchToForwardEvent.Invoke();
+ }
+ else
+ {
+ switchToBackwardsEvent.Invoke();
+ }
+ isCurrentlyLeft = stepHandler.isLeft;
+ }
+ }
+}
diff --git a/_ActiveRagdoll/BodyParts/HandLeft.cs b/_ActiveRagdoll/BodyParts/HandLeft.cs
new file mode 100644
index 0000000..5f92108
--- /dev/null
+++ b/_ActiveRagdoll/BodyParts/HandLeft.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class HandLeft : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/_ActiveRagdoll/BodyParts/HandRight.cs b/_ActiveRagdoll/BodyParts/HandRight.cs
new file mode 100644
index 0000000..cb78d06
--- /dev/null
+++ b/_ActiveRagdoll/BodyParts/HandRight.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class HandRight : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/_ActiveRagdoll/BodyParts/Head.cs b/_ActiveRagdoll/BodyParts/Head.cs
new file mode 100644
index 0000000..ce81442
--- /dev/null
+++ b/_ActiveRagdoll/BodyParts/Head.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class Head : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/_ActiveRagdoll/BodyParts/Hip.cs b/_ActiveRagdoll/BodyParts/Hip.cs
new file mode 100644
index 0000000..379fb1d
--- /dev/null
+++ b/_ActiveRagdoll/BodyParts/Hip.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class Hip : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/_ActiveRagdoll/HandLeft.cs b/_ActiveRagdoll/HandLeft.cs
deleted file mode 100644
index 5f92108..0000000
--- a/_ActiveRagdoll/HandLeft.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using UnityEngine;
-
-public class HandLeft : MonoBehaviour
-{
- private void Start()
- {
- }
-
- private void Update()
- {
- }
-}
diff --git a/_ActiveRagdoll/HandRight.cs b/_ActiveRagdoll/HandRight.cs
deleted file mode 100644
index cb78d06..0000000
--- a/_ActiveRagdoll/HandRight.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using UnityEngine;
-
-public class HandRight : MonoBehaviour
-{
- private void Start()
- {
- }
-
- private void Update()
- {
- }
-}
diff --git a/_ActiveRagdoll/Head.cs b/_ActiveRagdoll/Head.cs
deleted file mode 100644
index ce81442..0000000
--- a/_ActiveRagdoll/Head.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using UnityEngine;
-
-public class Head : MonoBehaviour
-{
- private void Start()
- {
- }
-
- private void Update()
- {
- }
-}
diff --git a/_ActiveRagdoll/Hip.cs b/_ActiveRagdoll/Hip.cs
deleted file mode 100644
index 379fb1d..0000000
--- a/_ActiveRagdoll/Hip.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using UnityEngine;
-
-public class Hip : MonoBehaviour
-{
- private void Start()
- {
- }
-
- private void Update()
- {
- }
-}
--
cgit v1.1-26-g67d0