From 134f1deb971b0514a26e04e23926f91983a5497f Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Wed, 13 Mar 2024 11:38:18 +0800 Subject: * move --- AnimationHandler.cs | 14 -- ArmLeft.cs | 12 -- ArmRight.cs | 12 -- Balance.cs | 101 ----------- Damagable.cs | 54 ------ DamageEffects.cs | 84 --------- DragHandler.cs | 25 --- FootHandler.cs | 75 -------- FootLeft.cs | 12 -- FootRight.cs | 12 -- Gravity.cs | 47 ----- HandLeft.cs | 12 -- HandRight.cs | 12 -- HasControl.cs | 28 --- Head.cs | 12 -- HeadCollisionHandler.cs | 31 ---- Hip.cs | 12 -- Holding.cs | 288 ------------------------------- InputHandler.cs | 120 ------------- KneeLeft.cs | 12 -- KneeRight.cs | 12 -- LeftHandPos.cs | 12 -- LegLeft.cs | 12 -- LegRight.cs | 12 -- MovementDataHandler.cs | 92 ---------- MovementHandler.cs | 85 --------- Neck.cs | 12 -- PickupHandler.cs | 63 ------- Player.cs | 18 -- PlayerDeath.cs | 125 -------------- PlayerKnockback.cs | 52 ------ RagdollHandler.cs | 21 --- RemoveMouse.cs | 17 -- RigidbodyHolder.cs | 44 ----- RotationHandler.cs | 73 -------- SetAnimationByInput.cs | 40 ----- SetAnimationByVelocity.cs | 12 -- SetRigidbodySettings.cs | 20 --- Standing.cs | 55 ------ StandingDataHandler.cs | 69 -------- StartRotation.cs | 18 -- StayInPlace.cs | 50 ------ StepHandler.cs | 53 ------ Strength.cs | 21 --- Torso.cs | 12 -- WeaponHandler.cs | 75 -------- _ActiveRagdoll/AnimationHandler.cs | 14 ++ _ActiveRagdoll/Balance.cs | 101 +++++++++++ _ActiveRagdoll/BodyParts/ArmLeft.cs | 12 ++ _ActiveRagdoll/BodyParts/ArmRight.cs | 12 ++ _ActiveRagdoll/BodyParts/FootLeft.cs | 12 ++ _ActiveRagdoll/BodyParts/FootRight.cs | 12 ++ _ActiveRagdoll/BodyParts/KneeLeft.cs | 12 ++ _ActiveRagdoll/BodyParts/KneeRight.cs | 12 ++ _ActiveRagdoll/BodyParts/LegLeft.cs | 12 ++ _ActiveRagdoll/BodyParts/LegRight.cs | 12 ++ _ActiveRagdoll/BodyParts/Neck.cs | 12 ++ _ActiveRagdoll/BodyParts/Torso.cs | 12 ++ _ActiveRagdoll/Damagable.cs | 54 ++++++ _ActiveRagdoll/DamageEffects.cs | 84 +++++++++ _ActiveRagdoll/DragHandler.cs | 25 +++ _ActiveRagdoll/FootHandler.cs | 75 ++++++++ _ActiveRagdoll/Gravity.cs | 47 +++++ _ActiveRagdoll/HandLeft.cs | 12 ++ _ActiveRagdoll/HandRight.cs | 12 ++ _ActiveRagdoll/HasControl.cs | 28 +++ _ActiveRagdoll/Head.cs | 12 ++ _ActiveRagdoll/HeadCollisionHandler.cs | 31 ++++ _ActiveRagdoll/Hip.cs | 12 ++ _ActiveRagdoll/Holding.cs | 288 +++++++++++++++++++++++++++++++ _ActiveRagdoll/InputHandler.cs | 120 +++++++++++++ _ActiveRagdoll/LeftHandPos.cs | 12 ++ _ActiveRagdoll/MovementDataHandler.cs | 92 ++++++++++ _ActiveRagdoll/MovementHandler.cs | 85 +++++++++ _ActiveRagdoll/PickupHandler.cs | 63 +++++++ _ActiveRagdoll/Player.cs | 18 ++ _ActiveRagdoll/PlayerDeath.cs | 125 ++++++++++++++ _ActiveRagdoll/PlayerKnockback.cs | 52 ++++++ _ActiveRagdoll/RagdollHandler.cs | 21 +++ _ActiveRagdoll/RemoveMouse.cs | 17 ++ _ActiveRagdoll/RigidbodyHolder.cs | 44 +++++ _ActiveRagdoll/RotationHandler.cs | 73 ++++++++ _ActiveRagdoll/SetAnimationByInput.cs | 40 +++++ _ActiveRagdoll/SetAnimationByVelocity.cs | 12 ++ _ActiveRagdoll/SetRigidbodySettings.cs | 20 +++ _ActiveRagdoll/Standing.cs | 55 ++++++ _ActiveRagdoll/StandingDataHandler.cs | 69 ++++++++ _ActiveRagdoll/StartRotation.cs | 18 ++ _ActiveRagdoll/StayInPlace.cs | 50 ++++++ _ActiveRagdoll/StepHandler.cs | 53 ++++++ _ActiveRagdoll/Strength.cs | 21 +++ _ActiveRagdoll/WeaponHandler.cs | 75 ++++++++ 92 files changed, 2050 insertions(+), 2050 deletions(-) delete mode 100644 AnimationHandler.cs delete mode 100644 ArmLeft.cs delete mode 100644 ArmRight.cs delete mode 100644 Balance.cs delete mode 100644 Damagable.cs delete mode 100644 DamageEffects.cs delete mode 100644 DragHandler.cs delete mode 100644 FootHandler.cs delete mode 100644 FootLeft.cs delete mode 100644 FootRight.cs delete mode 100644 Gravity.cs delete mode 100644 HandLeft.cs delete mode 100644 HandRight.cs delete mode 100644 HasControl.cs delete mode 100644 Head.cs delete mode 100644 HeadCollisionHandler.cs delete mode 100644 Hip.cs delete mode 100644 Holding.cs delete mode 100644 InputHandler.cs delete mode 100644 KneeLeft.cs delete mode 100644 KneeRight.cs delete mode 100644 LeftHandPos.cs delete mode 100644 LegLeft.cs delete mode 100644 LegRight.cs delete mode 100644 MovementDataHandler.cs delete mode 100644 MovementHandler.cs delete mode 100644 Neck.cs delete mode 100644 PickupHandler.cs delete mode 100644 Player.cs delete mode 100644 PlayerDeath.cs delete mode 100644 PlayerKnockback.cs delete mode 100644 RagdollHandler.cs delete mode 100644 RemoveMouse.cs delete mode 100644 RigidbodyHolder.cs delete mode 100644 RotationHandler.cs delete mode 100644 SetAnimationByInput.cs delete mode 100644 SetAnimationByVelocity.cs delete mode 100644 SetRigidbodySettings.cs delete mode 100644 Standing.cs delete mode 100644 StandingDataHandler.cs delete mode 100644 StartRotation.cs delete mode 100644 StayInPlace.cs delete mode 100644 StepHandler.cs delete mode 100644 Strength.cs delete mode 100644 Torso.cs delete mode 100644 WeaponHandler.cs create mode 100644 _ActiveRagdoll/AnimationHandler.cs create mode 100644 _ActiveRagdoll/Balance.cs create mode 100644 _ActiveRagdoll/BodyParts/ArmLeft.cs create mode 100644 _ActiveRagdoll/BodyParts/ArmRight.cs create mode 100644 _ActiveRagdoll/BodyParts/FootLeft.cs create mode 100644 _ActiveRagdoll/BodyParts/FootRight.cs create mode 100644 _ActiveRagdoll/BodyParts/KneeLeft.cs create mode 100644 _ActiveRagdoll/BodyParts/KneeRight.cs create mode 100644 _ActiveRagdoll/BodyParts/LegLeft.cs create mode 100644 _ActiveRagdoll/BodyParts/LegRight.cs create mode 100644 _ActiveRagdoll/BodyParts/Neck.cs create mode 100644 _ActiveRagdoll/BodyParts/Torso.cs create mode 100644 _ActiveRagdoll/Damagable.cs create mode 100644 _ActiveRagdoll/DamageEffects.cs create mode 100644 _ActiveRagdoll/DragHandler.cs create mode 100644 _ActiveRagdoll/FootHandler.cs create mode 100644 _ActiveRagdoll/Gravity.cs create mode 100644 _ActiveRagdoll/HandLeft.cs create mode 100644 _ActiveRagdoll/HandRight.cs create mode 100644 _ActiveRagdoll/HasControl.cs create mode 100644 _ActiveRagdoll/Head.cs create mode 100644 _ActiveRagdoll/HeadCollisionHandler.cs create mode 100644 _ActiveRagdoll/Hip.cs create mode 100644 _ActiveRagdoll/Holding.cs create mode 100644 _ActiveRagdoll/InputHandler.cs create mode 100644 _ActiveRagdoll/LeftHandPos.cs create mode 100644 _ActiveRagdoll/MovementDataHandler.cs create mode 100644 _ActiveRagdoll/MovementHandler.cs create mode 100644 _ActiveRagdoll/PickupHandler.cs create mode 100644 _ActiveRagdoll/Player.cs create mode 100644 _ActiveRagdoll/PlayerDeath.cs create mode 100644 _ActiveRagdoll/PlayerKnockback.cs create mode 100644 _ActiveRagdoll/RagdollHandler.cs create mode 100644 _ActiveRagdoll/RemoveMouse.cs create mode 100644 _ActiveRagdoll/RigidbodyHolder.cs create mode 100644 _ActiveRagdoll/RotationHandler.cs create mode 100644 _ActiveRagdoll/SetAnimationByInput.cs create mode 100644 _ActiveRagdoll/SetAnimationByVelocity.cs create mode 100644 _ActiveRagdoll/SetRigidbodySettings.cs create mode 100644 _ActiveRagdoll/Standing.cs create mode 100644 _ActiveRagdoll/StandingDataHandler.cs create mode 100644 _ActiveRagdoll/StartRotation.cs create mode 100644 _ActiveRagdoll/StayInPlace.cs create mode 100644 _ActiveRagdoll/StepHandler.cs create mode 100644 _ActiveRagdoll/Strength.cs create mode 100644 _ActiveRagdoll/WeaponHandler.cs diff --git a/AnimationHandler.cs b/AnimationHandler.cs deleted file mode 100644 index 6011e47..0000000 --- a/AnimationHandler.cs +++ /dev/null @@ -1,14 +0,0 @@ -using UnityEngine; - -public class AnimationHandler : MonoBehaviour -{ - public int animationState; - - private void Start() - { - } - - private void Update() - { - } -} diff --git a/ArmLeft.cs b/ArmLeft.cs deleted file mode 100644 index b7ee14c..0000000 --- a/ArmLeft.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class ArmLeft : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/ArmRight.cs b/ArmRight.cs deleted file mode 100644 index 735d646..0000000 --- a/ArmRight.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class ArmRight : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/Balance.cs b/Balance.cs deleted file mode 100644 index dc9ae60..0000000 --- a/Balance.cs +++ /dev/null @@ -1,101 +0,0 @@ -using UnityEngine; - -public class Balance : MonoBehaviour -{ - private Rigidbody handLeft; - - private Rigidbody handRight; - - private Rigidbody footLeft; - - private Rigidbody footRight; - - private Rigidbody hip; - - private Vector3 centerOfMass; - - private Rigidbody[] allRigs; - - public float[] balanceForce; - - public float[] footCenterForces; - - private AnimationHandler animationHandler; - - private PlayerDeath death; - - private Strength str; - - private float muscleMultiplier; - - private void Start() - { - death = GetComponent(); - str = GetComponent(); - allRigs = GetComponentsInChildren(); - HandLeft componentInChildren = GetComponentInChildren(); - if ((bool)componentInChildren) - { - handLeft = componentInChildren.GetComponent(); - } - HandRight componentInChildren2 = GetComponentInChildren(); - if ((bool)componentInChildren2) - { - handRight = componentInChildren2.GetComponent(); - } - footLeft = GetComponentInChildren().GetComponent(); - footRight = GetComponentInChildren().GetComponent(); - hip = GetComponentInChildren().GetComponent(); - animationHandler = GetComponent(); - } - - private void FixedUpdate() - { - if (!death.dead) - { - muscleMultiplier = str.strength; - centerOfMass = Vector3.zero; - Rigidbody[] array = allRigs; - foreach (Rigidbody rigidbody in array) - { - centerOfMass += rigidbody.worldCenterOfMass; - } - centerOfMass /= (float)allRigs.Length; - centerOfMass.y = 0f; - BalanceLegs(); - CenterLegs(); - } - } - - private void CenterLegs() - { - Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f; - Vector3 vector2 = footRight.transform.position + footRight.transform.forward * 0.5f; - Vector3 vector3 = vector; - if (vector.y + 0.3f < hip.worldCenterOfMass.y) - { - vector3.y = 0f; - footLeft.AddForceAtPosition((centerOfMass - vector3) * muscleMultiplier * footCenterForces[animationHandler.animationState], vector, ForceMode.Acceleration); - } - Vector3 vector4 = vector2; - if (vector4.y + 0.3f < hip.worldCenterOfMass.y) - { - vector4.y = 0f; - footRight.AddForceAtPosition((centerOfMass - vector4) * muscleMultiplier * footCenterForces[animationHandler.animationState], vector2, ForceMode.Acceleration); - } - } - - private void BalanceLegs() - { - Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f; - Vector3 vector2 = footRight.transform.position + footRight.transform.forward * 0.5f; - Vector3 vector3 = (vector + vector2) / 2f; - if (!(vector3.y + 0.3f > hip.worldCenterOfMass.y)) - { - vector3.y = 0f; - Vector3 vector4 = centerOfMass - vector3; - footLeft.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector, ForceMode.Acceleration); - footRight.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector2, ForceMode.Acceleration); - } - } -} diff --git a/Damagable.cs b/Damagable.cs deleted file mode 100644 index 667cd5e..0000000 --- a/Damagable.cs +++ /dev/null @@ -1,54 +0,0 @@ -using UnityEngine; -using UnityEngine.Events; - -public class Damagable : MonoBehaviour -{ - public float multiplier = 1f; - - private PlayerDeath playerDeath; - - public UnityEvent outOfLiveEvent; - - public UnityEvent damageEvent; - - public float health = 100f; - - private float currentHealth; - - private bool dead; - - private Rigidbody rig; - - private void Start() - { - rig = GetComponent(); - currentHealth = health; - playerDeath = base.transform.root.GetComponent(); - } - - private void Update() - { - } - - public void TakeDamage(Vector3 damage, Vector3 hitPoint) - { - damage *= multiplier; - if ((bool)playerDeath) - { - playerDeath.TakeDamage(damage, hitPoint, rig); - return; - } - damageEvent.Invoke(); - currentHealth -= damage.magnitude; - if (currentHealth < 0f && !dead) - { - dead = true; - outOfLiveEvent.Invoke(); - } - } - - public void RefillHP() - { - currentHealth = health; - } -} diff --git a/DamageEffects.cs b/DamageEffects.cs deleted file mode 100644 index 305c1d7..0000000 --- a/DamageEffects.cs +++ /dev/null @@ -1,84 +0,0 @@ -using UnityEngine; -using UnityEngine.PostProcessing; - -public class DamageEffects : MonoBehaviour -{ - private WobbleShake screenShake; - - private ParticleParent[] particleParents; - - private float counter; - - public AnimationCurve curve; - - public AnimationCurve curve2; - - public PostProcessingProfile post; - - private Camera mainCam; - - public float damageValue; - - private Transform hip; - - private void Start() - { - screenShake = base.transform.root.GetComponentInChildren(); - particleParents = GetComponentsInChildren(); - mainCam = base.transform.root.GetComponentInChildren(); - hip = base.transform.root.GetComponentInChildren().transform; - } - - private void Update() - { - VignetteModel.Settings settings = post.vignette.settings; - ChromaticAberrationModel.Settings settings2 = post.chromaticAberration.settings; - counter += Time.deltaTime; - if (damageValue > 0f) - { - damageValue -= Time.deltaTime * 0.3f; - } - if (counter < curve.keys[curve.length - 1].time) - { - float intensity = curve.Evaluate(counter); - settings.intensity = intensity; - } - settings.intensity = Mathf.Lerp(settings.intensity, 0f, Time.deltaTime * 0.5f); - settings.intensity = Mathf.Clamp(settings.intensity, 0f, 9f); - post.vignette.settings = settings; - if (counter < curve2.keys[curve2.length - 1].time) - { - float intensity2 = curve2.Evaluate(counter); - settings2.intensity = intensity2; - } - settings2.intensity = Mathf.Lerp(settings2.intensity, 0f, Time.deltaTime * 0.5f); - settings2.intensity = Mathf.Clamp(settings2.intensity, 0f, 9f); - post.chromaticAberration.settings = settings2; - } - - public void TakeDamage(Vector3 damage, Vector3 hitPoint) - { - counter = 0f; - damageValue += damage.magnitude * 0.02f; - damageValue = Mathf.Clamp(damageValue, 0f, 0.5f); - GetComponentInChildren().GetComponent().AddForce(damage.normalized * (damage.magnitude * 0.3f + 3f), ForceMode.VelocityChange); - screenShake.AddShakeWorld(damage * 0.4f, 0.8f); - DirectionalParticles(mainCam.transform.InverseTransformDirection(-damage)); - } - - private void DirectionalParticles(Vector3 damage) - { - for (int i = 0; i < particleParents.Length; i++) - { - Vector3 from = particleParents[i].transform.position - particleParents[i].transform.parent.position; - Vector3 to = damage; - from.y = 0f; - to.y = 0f; - if (Vector3.Angle(from, to) < 15f + damage.magnitude * 0.5f) - { - float multi = 1f - Vector3.Angle(from, to) / damage.magnitude * 0.5f; - particleParents[i].Play(damage.magnitude, multi); - } - } - } -} diff --git a/DragHandler.cs b/DragHandler.cs deleted file mode 100644 index adb8df4..0000000 --- a/DragHandler.cs +++ /dev/null @@ -1,25 +0,0 @@ -using UnityEngine; - -public class DragHandler : MonoBehaviour -{ - private float drag; - - private float angularDrag; - - private Rigidbody rig; - - public float dragAmount = 1f; - - private void Start() - { - rig = GetComponent(); - drag = rig.drag; - angularDrag = rig.angularDrag; - } - - private void Update() - { - rig.drag = drag * dragAmount; - rig.angularDrag = angularDrag * dragAmount; - } -} diff --git a/FootHandler.cs b/FootHandler.cs deleted file mode 100644 index 7343e21..0000000 --- a/FootHandler.cs +++ /dev/null @@ -1,75 +0,0 @@ -using UnityEngine; - -public class FootHandler : MonoBehaviour -{ - private AnimationHandler animHandler; - - private Collider collider; - - public PhysicMaterial slippery; - - private PhysicMaterial footMaterial; - - private Transform torso; - - private MovementDataHandler moveData; - - private Rigidbody rig; - - private RotationHandler rot; - - private Vector3 rotationDif; - - private AnimationObject anim; - - private StepHandler handler; - - private void Start() - { - animHandler = base.transform.root.GetComponent(); - moveData = base.transform.root.GetComponent(); - collider = GetComponentInChildren(); - rig = GetComponent(); - footMaterial = collider.material; - torso = base.transform.root.GetComponentInChildren().transform; - rot = base.transform.root.GetComponent(); - handler = base.transform.root.GetComponent(); - anim = GetComponentInChildren(); - } - - private void Update() - { - float num = Mathf.Abs(torso.position.x - base.transform.position.x) + Mathf.Abs(torso.position.z - base.transform.position.z); - if (rot.hipCorrectionAmount > 30f || ((bool)anim && anim.isLeft != handler.isLeft)) - { - SetFoot(active: false); - } - else if (animHandler.animationState == 0) - { - if (num > 0.1f || rotationDif.magnitude > 15f) - { - SetFoot(active: false); - } - else - { - SetFoot(active: true); - } - } - else - { - SetFoot(active: true); - } - } - - private void FixedUpdate() - { - } - - private void SetFoot(bool active) - { - if (active) - { - collider.material = footMaterial; - } - } -} diff --git a/FootLeft.cs b/FootLeft.cs deleted file mode 100644 index da0d11f..0000000 --- a/FootLeft.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class FootLeft : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/FootRight.cs b/FootRight.cs deleted file mode 100644 index c5014db..0000000 --- a/FootRight.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class FootRight : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/Gravity.cs b/Gravity.cs deleted file mode 100644 index f646f0c..0000000 --- a/Gravity.cs +++ /dev/null @@ -1,47 +0,0 @@ -using UnityEngine; - -public class Gravity : MonoBehaviour -{ - public float baseGravity; - - public float scalingGravity; - - private RigidbodyHolder allRigs; - - private StandingDataHandler standingData; - - private Holding holding; - - private PlayerDeath death; - - private void Start() - { - death = GetComponent(); - allRigs = GetComponent(); - standingData = GetComponent(); - holding = GetComponent(); - } - - private void FixedUpdate() - { - if (death.dead) - { - return; - } - for (int i = 0; i < allRigs.GetAllRigs().Length; i++) - { - allRigs.GetAllRigs()[i].AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration); - } - if ((bool)holding) - { - if ((bool)holding.heldObject) - { - holding.heldObject.rig.AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration); - } - if ((bool)holding.heldObjectOffHand) - { - holding.heldObjectOffHand.rig.AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration); - } - } - } -} diff --git a/HandLeft.cs b/HandLeft.cs deleted file mode 100644 index 5f92108..0000000 --- a/HandLeft.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class HandLeft : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/HandRight.cs b/HandRight.cs deleted file mode 100644 index cb78d06..0000000 --- a/HandRight.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class HandRight : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/HasControl.cs b/HasControl.cs deleted file mode 100644 index dde8ad6..0000000 --- a/HasControl.cs +++ /dev/null @@ -1,28 +0,0 @@ -using UnityEngine; - -public class HasControl : MonoBehaviour -{ - public bool hasControl = true; - - public GameObject[] objectsToRemove; - - private void Awake() - { - UpdateControl(); - } - - private void UpdateControl() - { - GameObject[] array = objectsToRemove; - foreach (GameObject gameObject in array) - { - gameObject.SetActive(hasControl); - } - } - - public void ChangeControl(bool control) - { - hasControl = control; - UpdateControl(); - } -} diff --git a/Head.cs b/Head.cs deleted file mode 100644 index ce81442..0000000 --- a/Head.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class Head : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/HeadCollisionHandler.cs b/HeadCollisionHandler.cs deleted file mode 100644 index c929f0e..0000000 --- a/HeadCollisionHandler.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; - -public class HeadCollisionHandler : MonoBehaviour -{ - public float collisionValue; - - private void Start() - { - } - - private void Update() - { - collisionValue = Mathf.Lerp(collisionValue, 0f, Time.deltaTime * 6f); - } - - private void OnCollisionEnter(Collision collision) - { - if (!(collision.transform.root == base.transform.root)) - { - collisionValue += collision.relativeVelocity.magnitude * 0.5f; - } - } - - private void OnCollisionStay(Collision collision) - { - if (!(collision.transform.root == base.transform.root)) - { - collisionValue += collision.relativeVelocity.magnitude * 0.1f; - } - } -} diff --git a/Hip.cs b/Hip.cs deleted file mode 100644 index 379fb1d..0000000 --- a/Hip.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class Hip : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/Holding.cs b/Holding.cs deleted file mode 100644 index dafc08b..0000000 --- a/Holding.cs +++ /dev/null @@ -1,288 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Holding : MonoBehaviour -{ - [HideInInspector] - public HoldableObject heldObject; - - [HideInInspector] - public HoldableObject heldObjectOffHand; - - [HideInInspector] - public Transform baseTransform; - - private Rigidbody rightHand; - - private Rigidbody leftHand; - - [HideInInspector] - public ConfigurableJoint leftHandJoint; - - [HideInInspector] - public ConfigurableJoint rightHandJoint; - - public float grabForce; - - [HideInInspector] - public bool isGrabbing; - - private Transform rotaionTarget; - - private bool hasMainHandWeapon; - - private PlayerDeath death; - - public LayerMask mask = default(LayerMask); - - private Strength str; - - private float strength = 1f; - - private PID leftHandPID; - - private PID rightHandPID; - - private StandingDataHandler standingData; - - private void Awake() - { - death = GetComponent(); - standingData = GetComponent(); - str = GetComponent(); - if (!baseTransform) - { - baseTransform = GetComponentInChildren().transform; - } - rightHand = GetComponentInChildren().GetComponent(); - leftHand = GetComponentInChildren().GetComponent(); - rotaionTarget = base.transform.GetComponentInChildren().transform; - mask = LayerMask.GetMask("Map"); - leftHandPID = leftHand.GetComponent(); - rightHandPID = rightHand.GetComponent(); - } - - private void Update() - { - if (!death.dead && (bool)heldObject) - { - strength = str.strength; - if (((bool)rightHandJoint || !heldObject.rightHandPos) && ((bool)leftHandJoint || !heldObject.leftHandPos) && (!heldObjectOffHand || (((bool)rightHandJoint || !heldObjectOffHand.rightHandPos) && ((bool)leftHandJoint || !heldObjectOffHand.leftHandPos)))) - { - isGrabbing = false; - } - } - } - - private void FixedUpdate() - { - if (death.dead || isGrabbing) - { - return; - } - if ((bool)heldObject) - { - HoldObjectInPlace(heldObject.rig, heldObject, offHand: false, rightHand); - if (!heldObjectOffHand && (bool)leftHandJoint) - { - HoldObjectInPlace(heldObject.rig, heldObject, offHand: false, leftHand, justHand: true); - } - } - if ((bool)heldObjectOffHand) - { - HoldObjectInPlace(heldObjectOffHand.rig, heldObjectOffHand, offHand: true, leftHand); - } - } - - private void HoldObjectInPlace(Rigidbody rigi, HoldableObject held, bool offHand, Rigidbody hand, bool justHand = false) - { - Vector3 holdingPosition = held.holdingPosition; - if (offHand) - { - holdingPosition.x *= -1f; - } - holdingPosition = baseTransform.TransformPoint(holdingPosition); - Vector3 holdingRotation = held.holdingRotation; - Vector3 targetRotation = baseTransform.TransformDirection(holdingRotation); - Vector3 targetRotationUp = baseTransform.TransformDirection(held.holdingUpRotation); - if (!justHand) - { - held.pid.DoPID(holdingPosition, targetRotation, targetRotationUp, strength); - } - PID pID = rightHandPID; - Vector3 localPosition = held.rightHandPos.localPosition; - if (hand == leftHand) - { - localPosition = held.leftHandPos.localPosition; - pID = leftHandPID; - } - Vector3 position = held.holdingPosition + localPosition; - if (offHand) - { - position.x *= -1f; - } - position = baseTransform.TransformPoint(position); - Debug.DrawLine(position, position + Vector3.up); - Debug.DrawLine(holdingPosition, holdingPosition + Vector3.up); - pID.DoPID(position, Vector3.zero, Vector3.zero, strength); - } - - public void StartHolding(HoldableObject holdableObject, bool hasOffHand) - { - holdableObject.isHeld = true; - isGrabbing = true; - bool offHand = false; - if (!hasMainHandWeapon) - { - hasMainHandWeapon = true; - heldObject = holdableObject; - if ((bool)heldObject.rightHandPos) - { - StartCoroutine(Grab(mainHand: true, rightHand, heldObject, offHand: false)); - } - if ((bool)heldObject.leftHandPos && !hasOffHand) - { - StartCoroutine(Grab(mainHand: false, leftHand, heldObject, offHand: false)); - } - } - else - { - offHand = true; - heldObjectOffHand = holdableObject; - heldObjectOffHand.leftHandPos = heldObjectOffHand.rightHandPos; - if ((bool)heldObjectOffHand.rightHandPos) - { - StartCoroutine(Grab(mainHand: false, leftHand, heldObjectOffHand, offHand: true)); - } - } - StartCoroutine(HoldweaponStill(holdableObject.rig, offHand, holdableObject)); - } - - private IEnumerator Grab(bool mainHand, Rigidbody hand, HoldableObject held, bool offHand) - { - while (isGrabbing) - { - if (mainHand) - { - if (!rightHandJoint) - { - ReachForPoint(rightHand, rightHand.transform.GetChild(0).position, held.rightHandPos, isLeft: false, held.rig, held, offHand); - rightHand.GetComponentInChildren().enabled = false; - } - } - else if (!leftHandJoint) - { - ReachForPoint(leftHand, leftHand.transform.GetChild(0).position, held.leftHandPos, isLeft: true, held.rig, held, offHand); - leftHand.GetComponentInChildren().enabled = false; - } - yield return null; - } - leftHand.GetComponentInChildren().enabled = true; - rightHand.GetComponentInChildren().enabled = true; - } - - private IEnumerator HoldweaponStill(Rigidbody rigToGrab, bool offHand, HoldableObject held) - { - while (isGrabbing) - { - Vector3 pos = held.holdingPosition; - if (offHand) - { - pos.x *= -1f; - } - rigToGrab.transform.position = baseTransform.TransformPoint(pos); - rigToGrab.transform.rotation = Quaternion.LookRotation(baseTransform.TransformDirection(heldObject.holdingRotation)); - yield return null; - } - } - - public void Drop() - { - List list = new List(); - if ((bool)heldObject) - { - list.Add(heldObject); - } - if ((bool)heldObjectOffHand) - { - list.Add(heldObjectOffHand); - } - for (int i = 0; i < list.Count; i++) - { - list[i].holder = null; - list[i].isHeld = false; - list[i].rig.useGravity = true; - list[i].rig.drag = 0f; - list[i].rig.angularDrag = 0f; - Collider[] componentsInChildren = list[i].GetComponentsInChildren(); - foreach (Collider collider in componentsInChildren) - { - collider.material = null; - } - } - heldObject = null; - heldObjectOffHand = null; - if ((bool)rightHandJoint) - { - Object.Destroy(rightHandJoint); - } - if ((bool)leftHandJoint) - { - Object.Destroy(leftHandJoint); - } - hasMainHandWeapon = false; - } - - private void ReachForPoint(Rigidbody rigToReach, Vector3 forcePosition, Transform targetPositionTransform, bool isLeft, Rigidbody rigToGrab, HoldableObject held, bool offHand) - { - Vector3 normalized = (targetPositionTransform.position - forcePosition).normalized; - rigToReach.AddForceAtPosition(normalized * grabForce * Mathf.Clamp(Time.deltaTime, 0f, 0.1f), forcePosition, ForceMode.Acceleration); - if (Vector3.Distance(targetPositionTransform.position, forcePosition) < 0.5f) - { - ConnectRig(rigToReach, rigToGrab, targetPositionTransform, isLeft, held, offHand); - } - } - - private void ConnectRig(Rigidbody startRig, Rigidbody targetRig, Transform targetPositionTransform, bool isLeft, HoldableObject held, bool offHand) - { - ConfigurableJoint configurableJoint = startRig.gameObject.AddComponent(); - if (offHand) - { - targetPositionTransform.localRotation = Quaternion.Euler(targetPositionTransform.localEulerAngles.x, 0f - targetPositionTransform.localEulerAngles.y, targetPositionTransform.localEulerAngles.z); - } - startRig.transform.rotation = targetPositionTransform.rotation; - startRig.transform.position += targetPositionTransform.position - startRig.transform.GetChild(0).position; - configurableJoint.connectedBody = targetRig; - configurableJoint.projectionMode = JointProjectionMode.PositionAndRotation; - configurableJoint.xMotion = ConfigurableJointMotion.Locked; - configurableJoint.yMotion = ConfigurableJointMotion.Locked; - configurableJoint.zMotion = ConfigurableJointMotion.Locked; - configurableJoint.angularXMotion = ConfigurableJointMotion.Limited; - configurableJoint.angularYMotion = ConfigurableJointMotion.Limited; - configurableJoint.angularZMotion = ConfigurableJointMotion.Limited; - SoftJointLimit highAngularXLimit = configurableJoint.highAngularXLimit; - highAngularXLimit.limit = held.swingAngles.y; - configurableJoint.highAngularXLimit = highAngularXLimit; - highAngularXLimit.limit = held.swingAngles.x; - configurableJoint.lowAngularXLimit = highAngularXLimit; - highAngularXLimit.limit = held.twistAngles.x; - configurableJoint.angularYLimit = highAngularXLimit; - highAngularXLimit.limit = held.twistAngles.y; - configurableJoint.angularZLimit = highAngularXLimit; - SoftJointLimitSpring angularXLimitSpring = configurableJoint.angularXLimitSpring; - angularXLimitSpring.spring = held.swingSpring; - configurableJoint.angularXLimitSpring = angularXLimitSpring; - angularXLimitSpring.spring = held.twistSpring; - configurableJoint.angularYZLimitSpring = angularXLimitSpring; - configurableJoint.anchor = startRig.transform.InverseTransformPoint(startRig.transform.GetChild(0).position); - if (isLeft) - { - leftHandJoint = configurableJoint; - } - else - { - rightHandJoint = configurableJoint; - } - } -} diff --git a/InputHandler.cs b/InputHandler.cs deleted file mode 100644 index 27adc82..0000000 --- a/InputHandler.cs +++ /dev/null @@ -1,120 +0,0 @@ -using UnityEngine; - -public class InputHandler : MonoBehaviour -{ - public Vector3 inputMovementDirection; - - public Vector3 lastInputDirection; - - public bool isSpringting; - - private WeaponHandler wepaonHandler; - - private MovementDataHandler movementData; - - private WeaponHandler weaponHandler; - - private CameraMovement cameraMovement; - - private PlayerDeath death; - - private HasControl hasControl; - - private MovementHandler movement; - - public bool allowStrafe = true; - - private void Start() - { - death = GetComponent(); - movement = GetComponent(); - wepaonHandler = GetComponent(); - hasControl = GetComponent(); - movementData = GetComponent(); - weaponHandler = GetComponent(); - cameraMovement = GetComponentInChildren(); - } - - private void Update() - { - if ((bool)death && death.dead) - { - return; - } - if (!hasControl || hasControl.hasControl) - { - isSpringting = false; - inputMovementDirection = Vector3.zero; - if (Input.GetKey(KeyCode.W)) - { - inputMovementDirection += movementData.groundedForward; - } - if (Input.GetKey(KeyCode.S)) - { - inputMovementDirection += movementData.groundedBack; - } - if (Input.GetKey(KeyCode.D) && allowStrafe) - { - inputMovementDirection += movementData.right; - } - if (Input.GetKey(KeyCode.A) && allowStrafe) - { - inputMovementDirection += movementData.left; - } - if (Input.GetKey(KeyCode.LeftShift) && (!cameraMovement || !cameraMovement.ADS)) - { - isSpringting = true; - } - inputMovementDirection = inputMovementDirection.normalized; - if ((bool)movement && Input.GetKeyDown(KeyCode.Space)) - { - movement.Jump(); - } - if ((bool)weaponHandler) - { - if (weaponHandler.isDualWeilding) - { - if (Input.GetKey(KeyCode.Mouse1)) - { - weaponHandler.HoldAttack(shootWithRightGun: true, ADS: false); - } - if (Input.GetKeyDown(KeyCode.Mouse1)) - { - weaponHandler.PressAttack(shootWithRightGun: true, ADS: false); - } - if (Input.GetKey(KeyCode.Mouse0)) - { - weaponHandler.HoldAttack(shootWithRightGun: false, ADS: false); - } - if (Input.GetKeyDown(KeyCode.Mouse0)) - { - weaponHandler.PressAttack(shootWithRightGun: false, ADS: false); - } - } - else - { - if (Input.GetKey(KeyCode.Mouse1)) - { - cameraMovement.ADS = true; - } - else - { - cameraMovement.ADS = false; - } - if (Input.GetKey(KeyCode.Mouse0)) - { - weaponHandler.HoldAttack(shootWithRightGun: true, cameraMovement.ADS); - } - if (Input.GetKeyDown(KeyCode.Mouse0)) - { - weaponHandler.PressAttack(shootWithRightGun: true, cameraMovement.ADS); - } - } - } - } - if (inputMovementDirection != Vector3.zero) - { - lastInputDirection = inputMovementDirection; - } - } -} diff --git a/KneeLeft.cs b/KneeLeft.cs deleted file mode 100644 index da00140..0000000 --- a/KneeLeft.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class KneeLeft : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/KneeRight.cs b/KneeRight.cs deleted file mode 100644 index 302a4ed..0000000 --- a/KneeRight.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class KneeRight : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/LeftHandPos.cs b/LeftHandPos.cs deleted file mode 100644 index 955cf44..0000000 --- a/LeftHandPos.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class LeftHandPos : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/LegLeft.cs b/LegLeft.cs deleted file mode 100644 index 23446b9..0000000 --- a/LegLeft.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class LegLeft : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/LegRight.cs b/LegRight.cs deleted file mode 100644 index a050339..0000000 --- a/LegRight.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class LegRight : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/MovementDataHandler.cs b/MovementDataHandler.cs deleted file mode 100644 index 18d43f5..0000000 --- a/MovementDataHandler.cs +++ /dev/null @@ -1,92 +0,0 @@ -using UnityEngine; - -public class MovementDataHandler : MonoBehaviour -{ - [HideInInspector] - public Vector3 groundedForward; - - [HideInInspector] - public Vector3 right; - - [HideInInspector] - public Vector3 left; - - [HideInInspector] - public Vector3 groundedBack; - - private Transform hip; - - private Transform torso; - - public Transform rotationTarget; - - [HideInInspector] - public float slopeStrenght; - - public float slopeVelocityStrenght; - - [HideInInspector] - public float sinceJump = 1f; - - [HideInInspector] - public Vector3 groundNormal; - - private InputHandler inputHandler; - - private Transform leftKnee; - - private Transform rightKnee; - - private void Start() - { - inputHandler = GetComponent(); - hip = GetComponentInChildren().transform; - torso = GetComponentInChildren().transform; - if (!rotationTarget) - { - rotationTarget = GetComponentInChildren().transform; - } - KneeLeft componentInChildren = GetComponentInChildren(); - if ((bool)componentInChildren) - { - leftKnee = componentInChildren.transform; - } - KneeRight componentInChildren2 = GetComponentInChildren(); - if ((bool)componentInChildren2) - { - rightKnee = componentInChildren2.transform; - } - } - - private void Update() - { - sinceJump += Time.deltaTime; - groundedForward = rotationTarget.forward; - groundedForward.y = slopeStrenght * 1f; - groundedForward = groundedForward.normalized; - groundedBack = -groundedForward; - right = rotationTarget.right; - left = -rotationTarget.right; - slopeStrenght = Mathf.Lerp(slopeStrenght, 0f, Time.deltaTime * 1f); - Debug.DrawLine(hip.position, hip.position + groundedForward * 10f); - } - - public void SetSlope(Vector3 normal) - { - groundNormal = normal; - slopeStrenght = Vector3.Cross(rotationTarget.right, normal).y; - Vector3 lhs = Vector3.Cross(Vector3.up, inputHandler.inputMovementDirection); - slopeVelocityStrenght = Vector3.Cross(lhs, normal).y; - } - - public float GetSmallestLegAngle() - { - float num = Vector3.Angle(leftKnee.forward, Vector3.down); - float num2 = Vector3.Angle(rightKnee.forward, Vector3.down); - if (num < num2) - { - return num; - } - return num2; - } -} diff --git a/MovementHandler.cs b/MovementHandler.cs deleted file mode 100644 index 22795f7..0000000 --- a/MovementHandler.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Collections; -using UnityEngine; - -public class MovementHandler : MonoBehaviour -{ - private InputHandler inputHandler; - - public float friction = 0.9f; - - public Vector3 movementVector; - - public float[] animationForceAmounts; - - private AnimationHandler animationHandler; - - private RigidbodyHolder allRigs; - - public AnimationCurve jumpCurve; - - public float jumpForce; - - private StandingDataHandler standingData; - - private MovementDataHandler data; - - private PlayerDeath death; - - [HideInInspector] - public float multiplier = 1f; - - private WobbleShake wobbleShake; - - private void Start() - { - wobbleShake = GetComponentInChildren(); - death = GetComponent(); - standingData = GetComponent(); - inputHandler = GetComponent(); - animationHandler = GetComponent(); - allRigs = GetComponent(); - data = GetComponent(); - } - - private void FixedUpdate() - { - if (!death.dead) - { - data.sinceJump += Time.fixedDeltaTime; - movementVector += inputHandler.inputMovementDirection * animationForceAmounts[animationHandler.animationState]; - movementVector *= friction; - for (int i = 0; i < allRigs.GetAllRigs().Length; i++) - { - allRigs.GetAllRigs()[i].AddForce(movementVector * multiplier, ForceMode.Acceleration); - } - } - } - - public void Jump() - { - if (!(data.sinceJump < 0.5f) && !(standingData.sinceGrounded > 0.3f)) - { - data.sinceJump = 0f; - StartCoroutine(AddJumpForce()); - wobbleShake.AddShake(Vector3.up * 2f, 0.8f); - } - } - - private IEnumerator AddJumpForce() - { - float counter = 0f; - for (int i = 0; i < allRigs.GetAllRigs().Length; i++) - { - allRigs.GetAllRigs()[i].velocity = new Vector3(allRigs.GetAllRigs()[i].velocity.x, 0f, allRigs.GetAllRigs()[i].velocity.z); - } - while (counter < jumpCurve.keys[jumpCurve.length - 1].time && !death.dead) - { - counter += Time.deltaTime; - for (int j = 0; j < allRigs.GetAllRigs().Length; j++) - { - allRigs.GetAllRigs()[j].AddForce(Vector3.up * multiplier * jumpForce * jumpCurve.Evaluate(counter) * Time.deltaTime, ForceMode.Acceleration); - } - yield return null; - } - } -} diff --git a/Neck.cs b/Neck.cs deleted file mode 100644 index 31cd544..0000000 --- a/Neck.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class Neck : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/PickupHandler.cs b/PickupHandler.cs deleted file mode 100644 index 8bf1615..0000000 --- a/PickupHandler.cs +++ /dev/null @@ -1,63 +0,0 @@ -using UnityEngine; - -public class PickupHandler : MonoBehaviour -{ - public Pickup setWeapon; - - public Pickup setWeapon2; - - private WeaponHandler weaponHandler; - - private Holding holding; - - private float counter; - - private void Start() - { - weaponHandler = GetComponent(); - holding = GetComponent(); - if ((bool)setWeapon) - { - PickUp(setWeapon); - } - if ((bool)setWeapon2) - { - PickUp2(setWeapon2); - } - } - - private void Update() - { - counter += Time.deltaTime; - } - - public void PickUp(Pickup objectToPickUp) - { - if (!(counter < 1f)) - { - counter = 0f; - holding.Drop(); - Weapon component = objectToPickUp.GetComponent(); - Gun component2 = component.GetComponent(); - weaponHandler.SetGun(component2, mainHand: true); - bool hasOffHand = false; - if ((bool)setWeapon2) - { - hasOffHand = true; - } - HoldableObject component3 = component.GetComponent(); - component3.holder = base.transform; - holding.StartHolding(component3, hasOffHand); - } - } - - public void PickUp2(Pickup objectToPickUp) - { - Weapon component = objectToPickUp.GetComponent(); - Gun component2 = component.GetComponent(); - weaponHandler.SetGun(component2, mainHand: false); - HoldableObject component3 = component.GetComponent(); - component3.holder = base.transform; - holding.StartHolding(component3, hasOffHand: true); - } -} diff --git a/Player.cs b/Player.cs deleted file mode 100644 index 55ff387..0000000 --- a/Player.cs +++ /dev/null @@ -1,18 +0,0 @@ -using UnityEngine; - -public class Player : MonoBehaviour -{ - public static Player localPlayer; - - public bool isLocalPlayer; - - public Transform torso; - - private void Start() - { - if (isLocalPlayer) - { - localPlayer = this; - } - } -} diff --git a/PlayerDeath.cs b/PlayerDeath.cs deleted file mode 100644 index ec0813a..0000000 --- a/PlayerDeath.cs +++ /dev/null @@ -1,125 +0,0 @@ -using UnityEngine; - -public class PlayerDeath : MonoBehaviour -{ - public bool dead; - - private bool isFrozen; - - public float muscleFunction = 1f; - - public bool terminalState; - - private DamageEffects damageEffects; - - private RagdollHandler ragdoll; - - private Transform hip; - - public float health = 100f; - - public ParticleSystem[] damageParticles; - - private HasControl hasControll; - - private Holding holding; - - private void Start() - { - damageEffects = GetComponent(); - ragdoll = GetComponent(); - hip = GetComponentInChildren().transform; - hasControll = GetComponent(); - holding = GetComponent(); - } - - private void Update() - { - if (health < 100f) - { - health += Time.deltaTime * 10f; - health = Mathf.Clamp(health, -10f, 100f); - } - if (hip.transform.position.y < -10f) - { - Die(); - } - if (terminalState && muscleFunction > 0f) - { - muscleFunction -= Time.deltaTime * 1f; - } - if (muscleFunction < 0f && !isFrozen) - { - FreezeBody(); - } - } - - public void TakeDamage(Vector3 damage, Vector3 hitPoint, Rigidbody hitRig = null) - { - if (hasControll.hasControl) - { - damageEffects.TakeDamage(damage, hitPoint); - } - if (hitPoint != Vector3.zero) - { - for (int i = 0; i < damageParticles.Length; i++) - { - damageParticles[i].transform.rotation = Quaternion.LookRotation(damage); - damageParticles[i].transform.position = hitPoint; - damageParticles[i].Play(); - } - } - health -= damage.magnitude; - if (!(health <= 0f)) - { - return; - } - if ((bool)hitRig) - { - ConfigurableJoint component = hitRig.GetComponent(); - if ((bool)component) - { - Object.Destroy(component); - } - } - Kill(); - } - - public void FreezeBody() - { - isFrozen = true; - Joint[] componentsInChildren = GetComponentsInChildren(); - for (int i = 0; i < componentsInChildren.Length; i++) - { - ConfigurableJoint configurableJoint = (ConfigurableJoint)componentsInChildren[i]; - Rigidbody component = configurableJoint.GetComponent(); - JointDrive angularXDrive = configurableJoint.angularXDrive; - angularXDrive.positionSpring = 5f * component.mass; - angularXDrive.positionDamper = 1f * component.mass; - configurableJoint.angularXDrive = angularXDrive; - configurableJoint.angularYZDrive = angularXDrive; - configurableJoint.SetTargetRotationLocal(configurableJoint.transform.localRotation, configurableJoint.gameObject.GetComponent().startRotationLocal); - } - } - - public void Die() - { - if (!dead) - { - holding.Drop(); - dead = true; - ragdoll.ragdollValue = 0f; - Collider[] componentsInChildren = GetComponentsInChildren(); - foreach (Collider collider in componentsInChildren) - { - collider.material = null; - } - } - } - - public void Kill() - { - terminalState = true; - Die(); - } -} diff --git a/PlayerKnockback.cs b/PlayerKnockback.cs deleted file mode 100644 index 89fffb8..0000000 --- a/PlayerKnockback.cs +++ /dev/null @@ -1,52 +0,0 @@ -using UnityEngine; - -public class PlayerKnockback : MonoBehaviour -{ - private RigidbodyHolder allRigs; - - private StandingDataHandler standing; - - private WeaponHandler weapons; - - private void Start() - { - allRigs = GetComponent(); - standing = GetComponent(); - weapons = GetComponent(); - } - - private void Update() - { - if (Input.GetKeyDown(KeyCode.K)) - { - AddSeriousKnockback(); - } - } - - public void AddForce(Vector3 force, Rigidbody rig) - { - if (force.magnitude > 200f) - { - AddSeriousKnockback(); - force *= 0.1f; - } - for (int i = 0; i < allRigs.GetAllRigs().Length; i++) - { - float num = 1f; - if (rig == allRigs.GetAllRigs()[i]) - { - num *= 1f; - } - allRigs.GetAllRigs()[i].AddForce(force * num * 20f, ForceMode.Acceleration); - } - } - - private void AddSeriousKnockback() - { - GetComponent().Kill(); - } - - private void AddNormalKnockback() - { - } -} diff --git a/RagdollHandler.cs b/RagdollHandler.cs deleted file mode 100644 index ca52b8d..0000000 --- a/RagdollHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using UnityEngine; - -public class RagdollHandler : MonoBehaviour -{ - public float ragdollValue = 1f; - - private RigidbodyHolder rigs; - - private void Start() - { - rigs = GetComponent(); - } - - private void Update() - { - for (int i = 0; i < rigs.GetAllRigs().Length; i++) - { - rigs.GetAllRigs()[i].GetComponent().dragAmount = ragdollValue; - } - } -} diff --git a/RemoveMouse.cs b/RemoveMouse.cs deleted file mode 100644 index 85d89db..0000000 --- a/RemoveMouse.cs +++ /dev/null @@ -1,17 +0,0 @@ -using UnityEngine; - -public class RemoveMouse : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - if (Input.GetKey(KeyCode.Mouse1)) - { - Cursor.lockState = CursorLockMode.Locked; - Cursor.visible = false; - } - } -} diff --git a/RigidbodyHolder.cs b/RigidbodyHolder.cs deleted file mode 100644 index 796f77a..0000000 --- a/RigidbodyHolder.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -public class RigidbodyHolder : MonoBehaviour -{ - private Rigidbody[] allRigs; - - private WeaponHandler weapons; - - private void Start() - { - allRigs = GetComponentsInChildren(); - weapons = GetComponent(); - } - - private void Update() - { - } - - public Rigidbody[] GetAllRigs() - { - if (!weapons.leftGun && !weapons.rightGun) - { - return allRigs; - } - List list = new List(); - for (int i = 0; i < allRigs.Length; i++) - { - list.Add(allRigs[i]); - } - if ((bool)weapons) - { - if ((bool)weapons.leftGun) - { - list.Add(weapons.leftGun.rig); - } - if ((bool)weapons.rightGun) - { - list.Add(weapons.rightGun.rig); - } - } - return list.ToArray(); - } -} diff --git a/RotationHandler.cs b/RotationHandler.cs deleted file mode 100644 index ee33545..0000000 --- a/RotationHandler.cs +++ /dev/null @@ -1,73 +0,0 @@ -using UnityEngine; - -public class RotationHandler : MonoBehaviour -{ - private Transform rotationTarget; - - private Rigidbody hip; - - private Rigidbody torso; - - private Rigidbody head; - - public float rotationTorque; - - public float clamp; - - private InputHandler input; - - private PlayerDeath death; - - [HideInInspector] - public float hipCorrectionAmount; - - public bool useHip = true; - - public bool useTorso = true; - - public bool useHead = true; - - private void Start() - { - death = GetComponent(); - rotationTarget = GetComponentInChildren().transform; - hip = GetComponentInChildren().GetComponent(); - torso = GetComponentInChildren().GetComponent(); - head = GetComponentInChildren().GetComponent(); - input = GetComponent(); - } - - private void FixedUpdate() - { - if (!death.dead) - { - float num = head.transform.InverseTransformPoint(rotationTarget.position).x; - float num2 = torso.transform.InverseTransformPoint(rotationTarget.position).x; - hipCorrectionAmount = hip.transform.InverseTransformPoint(hip.transform.position + input.lastInputDirection * 10f).x; - float muscleFunction = death.muscleFunction; - float num3 = 0.3f; - if (input.inputMovementDirection.magnitude > 0.1f) - { - num3 = 1f; - } - if (clamp != 0f) - { - hipCorrectionAmount = Mathf.Clamp(hipCorrectionAmount, 0f - clamp, clamp); - num = Mathf.Clamp(num, 0f - clamp, clamp); - num2 = Mathf.Clamp(num2, 0f - clamp, clamp); - } - if (useHip) - { - hip.AddTorque(Vector3.up * muscleFunction * rotationTorque * num3 * hipCorrectionAmount, ForceMode.Acceleration); - } - if (useTorso) - { - torso.AddTorque(Vector3.up * muscleFunction * rotationTorque * num2, ForceMode.Acceleration); - } - if (useHead) - { - head.AddTorque(Vector3.up * muscleFunction * rotationTorque * num, ForceMode.Acceleration); - } - } - } -} diff --git a/SetAnimationByInput.cs b/SetAnimationByInput.cs deleted file mode 100644 index cc50e5a..0000000 --- a/SetAnimationByInput.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; - -public class SetAnimationByInput : MonoBehaviour -{ - private InputHandler input; - - private AnimationHandler anim; - - private StandingDataHandler standingData; - - private void Start() - { - anim = GetComponent(); - input = GetComponent(); - standingData = GetComponent(); - } - - private void Update() - { - if ((double)standingData.sinceGrounded > 0.2) - { - anim.animationState = 3; - } - else if (input.inputMovementDirection.magnitude > 0.1f) - { - if (input.isSpringting) - { - anim.animationState = 1; - } - else - { - anim.animationState = 2; - } - } - else - { - anim.animationState = 0; - } - } -} diff --git a/SetAnimationByVelocity.cs b/SetAnimationByVelocity.cs deleted file mode 100644 index c737363..0000000 --- a/SetAnimationByVelocity.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class SetAnimationByVelocity : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/SetRigidbodySettings.cs b/SetRigidbodySettings.cs deleted file mode 100644 index 2521b75..0000000 --- a/SetRigidbodySettings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using UnityEngine; - -public class SetRigidbodySettings : MonoBehaviour -{ - public float maxAngular; - - private void Start() - { - Rigidbody[] componentsInChildren = GetComponentsInChildren(); - foreach (Rigidbody rigidbody in componentsInChildren) - { - rigidbody.maxAngularVelocity = maxAngular; - rigidbody.maxDepenetrationVelocity = 10000f; - } - } - - private void Update() - { - } -} diff --git a/Standing.cs b/Standing.cs deleted file mode 100644 index 6162215..0000000 --- a/Standing.cs +++ /dev/null @@ -1,55 +0,0 @@ -using UnityEngine; - -public class Standing : MonoBehaviour -{ - public RigidbodyMovment[] rigsToLift; - - public AnimationCurve[] animationLiftCurves; - - private StandingDataHandler standingData; - - private AnimationHandler animationHandler; - - public float offset; - - private PlayerDeath death; - - private Strength str; - - private float muscleMultiplier = 1f; - - private float legAngleMultiplier; - - private MovementDataHandler moveData; - - private void Start() - { - death = GetComponent(); - str = GetComponent(); - standingData = GetComponent(); - moveData = GetComponent(); - animationHandler = GetComponent(); - } - - private void FixedUpdate() - { - if (!death.dead) - { - muscleMultiplier = str.strength; - if (standingData.isGrounded) - { - Stand(animationLiftCurves[animationHandler.animationState]); - } - } - } - - private void Stand(AnimationCurve curve) - { - legAngleMultiplier = 1f; - RigidbodyMovment[] array = rigsToLift; - foreach (RigidbodyMovment rigidbodyMovment in array) - { - rigidbodyMovment.rig.AddForce(Vector3.up * muscleMultiplier * rigidbodyMovment.force * legAngleMultiplier * curve.Evaluate(standingData.distanceToGround + offset + moveData.slopeVelocityStrenght * -0.2f), ForceMode.Acceleration); - } - } -} diff --git a/StandingDataHandler.cs b/StandingDataHandler.cs deleted file mode 100644 index 10a1473..0000000 --- a/StandingDataHandler.cs +++ /dev/null @@ -1,69 +0,0 @@ -using UnityEngine; - -public class StandingDataHandler : MonoBehaviour -{ - public Rigidbody mainRig; - - public float sinceGrounded; - - public float sinceLanded; - - public bool isGrounded; - - public float distanceToGround = 1f; - - private bool hasRecievedTouchedGround; - - private MovementDataHandler moveMentData; - - private PlayerKnockback knockback; - - private WobbleShake wobbleShake; - - private void Start() - { - wobbleShake = GetComponentInChildren(); - knockback = GetComponent(); - } - - private void FixedUpdate() - { - sinceGrounded += Time.fixedDeltaTime; - sinceLanded += Time.fixedDeltaTime; - moveMentData = GetComponent(); - if ((double)sinceGrounded > 0.1) - { - isGrounded = false; - } - } - - private void LateUpdate() - { - hasRecievedTouchedGround = false; - } - - public void TouchGround(float distance, Vector3 normal) - { - if (sinceGrounded > 0.5f && (bool)wobbleShake) - { - wobbleShake.AddShake(-Vector3.up * 5f * Mathf.Pow(sinceGrounded, 1.5f), 0.8f); - } - if (sinceGrounded > 0.5f) - { - Land(sinceGrounded); - } - sinceGrounded = 0f; - isGrounded = true; - if (distance > distanceToGround || !hasRecievedTouchedGround) - { - distanceToGround = distance; - } - hasRecievedTouchedGround = true; - moveMentData.SetSlope(normal); - } - - private void Land(float landForce) - { - sinceLanded = 0f; - } -} diff --git a/StartRotation.cs b/StartRotation.cs deleted file mode 100644 index 4ae91b2..0000000 --- a/StartRotation.cs +++ /dev/null @@ -1,18 +0,0 @@ -using UnityEngine; - -public class StartRotation : MonoBehaviour -{ - public Quaternion startRotation; - - public Quaternion startRotationLocal; - - private void Start() - { - startRotation = base.transform.rotation; - startRotationLocal = base.transform.localRotation; - } - - private void Update() - { - } -} diff --git a/StayInPlace.cs b/StayInPlace.cs deleted file mode 100644 index d10ebba..0000000 --- a/StayInPlace.cs +++ /dev/null @@ -1,50 +0,0 @@ -using UnityEngine; - -public class StayInPlace : MonoBehaviour -{ - private InputHandler input; - - public Rigidbody rig; - - public float force; - - private Vector3 stopPosition; - - private bool isBroken; - - private PlayerDeath death; - - private Strength str; - - private float strength = 1f; - - private void Start() - { - str = GetComponent(); - input = GetComponent(); - death = GetComponent(); - stopPosition = rig.position; - } - - private void FixedUpdate() - { - if (death.dead) - { - return; - } - strength = str.strength; - if (input.inputMovementDirection.magnitude > 0.1f) - { - stopPosition = rig.position + rig.velocity * 0.25f; - isBroken = false; - } - else if (!isBroken) - { - if (Vector3.Distance(stopPosition, rig.position) > 1f) - { - isBroken = true; - } - rig.AddForce((stopPosition - rig.position) * force * strength, ForceMode.Acceleration); - } - } -} diff --git a/StepHandler.cs b/StepHandler.cs deleted file mode 100644 index fd8110b..0000000 --- a/StepHandler.cs +++ /dev/null @@ -1,53 +0,0 @@ -using UnityEngine; - -public class StepHandler : MonoBehaviour -{ - public float staticCounter; - - public Step[] steps; - - public bool isLeft; - - private float counter; - - private Transform leftLeg; - - private Transform rightLeg; - - private AnimationHandler animationHandler; - - private Transform hip; - - private void Start() - { - if (staticCounter == 0f) - { - leftLeg = GetComponentInChildren().transform; - rightLeg = GetComponentInChildren().transform; - animationHandler = GetComponent(); - hip = GetComponentInChildren().transform; - } - } - - private void Update() - { - counter += Time.deltaTime; - if (staticCounter != 0f) - { - if (counter > staticCounter) - { - Switch(); - } - } - else if (counter > steps[animationHandler.animationState].minTime && (steps[animationHandler.animationState].minAngle == 0f || steps[animationHandler.animationState].minAngle < Vector3.Angle(leftLeg.forward, rightLeg.forward)) && isLeft == hip.InverseTransformPoint(leftLeg.position + leftLeg.forward).z > hip.InverseTransformPoint(rightLeg.position + rightLeg.forward).z) - { - Switch(); - } - } - - private void Switch() - { - isLeft = !isLeft; - counter = 0f; - } -} diff --git a/Strength.cs b/Strength.cs deleted file mode 100644 index f458b21..0000000 --- a/Strength.cs +++ /dev/null @@ -1,21 +0,0 @@ -using UnityEngine; - -public class Strength : MonoBehaviour -{ - public float strength = 1f; - - private PlayerDeath death; - - private RagdollHandler ragdoll; - - private void Start() - { - ragdoll = GetComponent(); - death = GetComponent(); - } - - private void Update() - { - strength = ragdoll.ragdollValue * death.muscleFunction; - } -} diff --git a/Torso.cs b/Torso.cs deleted file mode 100644 index 3cf28df..0000000 --- a/Torso.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -public class Torso : MonoBehaviour -{ - private void Start() - { - } - - private void Update() - { - } -} diff --git a/WeaponHandler.cs b/WeaponHandler.cs deleted file mode 100644 index 7b3d80f..0000000 --- a/WeaponHandler.cs +++ /dev/null @@ -1,75 +0,0 @@ -using UnityEngine; - -public class WeaponHandler : MonoBehaviour -{ - [HideInInspector] - public Gun leftGun; - - [HideInInspector] - public Gun rightGun; - - [HideInInspector] - public Transform gunADS; - - [HideInInspector] - public float ADSFOV; - - public bool isDualWeilding; - - private void Start() - { - } - - private void Update() - { - } - - public void SetWeapon(Weapon w, bool mainHand) - { - } - - public void SetGun(Gun g, bool mainHand) - { - if (mainHand) - { - rightGun = g; - gunADS = g.GetComponentInChildren().transform; - ADSFOV = g.ADSFOV; - } - else - { - leftGun = g; - } - if ((bool)leftGun && (bool)rightGun) - { - isDualWeilding = true; - } - } - - public void HoldAttack(bool shootWithRightGun, bool ADS) - { - if (shootWithRightGun) - { - if (rightGun.auto) - { - rightGun.Shoot(base.transform.root, ADS); - } - } - else if (leftGun.auto) - { - leftGun.Shoot(base.transform.root, ADS); - } - } - - public void PressAttack(bool shootWithRightGun, bool ADS) - { - if (shootWithRightGun) - { - rightGun.Shoot(base.transform.root, ADS); - } - else - { - leftGun.Shoot(base.transform.root, ADS); - } - } -} diff --git a/_ActiveRagdoll/AnimationHandler.cs b/_ActiveRagdoll/AnimationHandler.cs new file mode 100644 index 0000000..6011e47 --- /dev/null +++ b/_ActiveRagdoll/AnimationHandler.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +public class AnimationHandler : MonoBehaviour +{ + public int animationState; + + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/Balance.cs b/_ActiveRagdoll/Balance.cs new file mode 100644 index 0000000..dc9ae60 --- /dev/null +++ b/_ActiveRagdoll/Balance.cs @@ -0,0 +1,101 @@ +using UnityEngine; + +public class Balance : MonoBehaviour +{ + private Rigidbody handLeft; + + private Rigidbody handRight; + + private Rigidbody footLeft; + + private Rigidbody footRight; + + private Rigidbody hip; + + private Vector3 centerOfMass; + + private Rigidbody[] allRigs; + + public float[] balanceForce; + + public float[] footCenterForces; + + private AnimationHandler animationHandler; + + private PlayerDeath death; + + private Strength str; + + private float muscleMultiplier; + + private void Start() + { + death = GetComponent(); + str = GetComponent(); + allRigs = GetComponentsInChildren(); + HandLeft componentInChildren = GetComponentInChildren(); + if ((bool)componentInChildren) + { + handLeft = componentInChildren.GetComponent(); + } + HandRight componentInChildren2 = GetComponentInChildren(); + if ((bool)componentInChildren2) + { + handRight = componentInChildren2.GetComponent(); + } + footLeft = GetComponentInChildren().GetComponent(); + footRight = GetComponentInChildren().GetComponent(); + hip = GetComponentInChildren().GetComponent(); + animationHandler = GetComponent(); + } + + private void FixedUpdate() + { + if (!death.dead) + { + muscleMultiplier = str.strength; + centerOfMass = Vector3.zero; + Rigidbody[] array = allRigs; + foreach (Rigidbody rigidbody in array) + { + centerOfMass += rigidbody.worldCenterOfMass; + } + centerOfMass /= (float)allRigs.Length; + centerOfMass.y = 0f; + BalanceLegs(); + CenterLegs(); + } + } + + private void CenterLegs() + { + Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f; + Vector3 vector2 = footRight.transform.position + footRight.transform.forward * 0.5f; + Vector3 vector3 = vector; + if (vector.y + 0.3f < hip.worldCenterOfMass.y) + { + vector3.y = 0f; + footLeft.AddForceAtPosition((centerOfMass - vector3) * muscleMultiplier * footCenterForces[animationHandler.animationState], vector, ForceMode.Acceleration); + } + Vector3 vector4 = vector2; + if (vector4.y + 0.3f < hip.worldCenterOfMass.y) + { + vector4.y = 0f; + footRight.AddForceAtPosition((centerOfMass - vector4) * muscleMultiplier * footCenterForces[animationHandler.animationState], vector2, ForceMode.Acceleration); + } + } + + private void BalanceLegs() + { + Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f; + Vector3 vector2 = footRight.transform.position + footRight.transform.forward * 0.5f; + Vector3 vector3 = (vector + vector2) / 2f; + if (!(vector3.y + 0.3f > hip.worldCenterOfMass.y)) + { + vector3.y = 0f; + Vector3 vector4 = centerOfMass - vector3; + footLeft.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector, ForceMode.Acceleration); + footRight.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector2, ForceMode.Acceleration); + } + } +} diff --git a/_ActiveRagdoll/BodyParts/ArmLeft.cs b/_ActiveRagdoll/BodyParts/ArmLeft.cs new file mode 100644 index 0000000..b7ee14c --- /dev/null +++ b/_ActiveRagdoll/BodyParts/ArmLeft.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class ArmLeft : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/ArmRight.cs b/_ActiveRagdoll/BodyParts/ArmRight.cs new file mode 100644 index 0000000..735d646 --- /dev/null +++ b/_ActiveRagdoll/BodyParts/ArmRight.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class ArmRight : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/FootLeft.cs b/_ActiveRagdoll/BodyParts/FootLeft.cs new file mode 100644 index 0000000..da0d11f --- /dev/null +++ b/_ActiveRagdoll/BodyParts/FootLeft.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class FootLeft : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/FootRight.cs b/_ActiveRagdoll/BodyParts/FootRight.cs new file mode 100644 index 0000000..c5014db --- /dev/null +++ b/_ActiveRagdoll/BodyParts/FootRight.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class FootRight : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/KneeLeft.cs b/_ActiveRagdoll/BodyParts/KneeLeft.cs new file mode 100644 index 0000000..da00140 --- /dev/null +++ b/_ActiveRagdoll/BodyParts/KneeLeft.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class KneeLeft : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/KneeRight.cs b/_ActiveRagdoll/BodyParts/KneeRight.cs new file mode 100644 index 0000000..302a4ed --- /dev/null +++ b/_ActiveRagdoll/BodyParts/KneeRight.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class KneeRight : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/LegLeft.cs b/_ActiveRagdoll/BodyParts/LegLeft.cs new file mode 100644 index 0000000..23446b9 --- /dev/null +++ b/_ActiveRagdoll/BodyParts/LegLeft.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class LegLeft : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/LegRight.cs b/_ActiveRagdoll/BodyParts/LegRight.cs new file mode 100644 index 0000000..a050339 --- /dev/null +++ b/_ActiveRagdoll/BodyParts/LegRight.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class LegRight : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/Neck.cs b/_ActiveRagdoll/BodyParts/Neck.cs new file mode 100644 index 0000000..31cd544 --- /dev/null +++ b/_ActiveRagdoll/BodyParts/Neck.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class Neck : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/BodyParts/Torso.cs b/_ActiveRagdoll/BodyParts/Torso.cs new file mode 100644 index 0000000..3cf28df --- /dev/null +++ b/_ActiveRagdoll/BodyParts/Torso.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class Torso : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/Damagable.cs b/_ActiveRagdoll/Damagable.cs new file mode 100644 index 0000000..667cd5e --- /dev/null +++ b/_ActiveRagdoll/Damagable.cs @@ -0,0 +1,54 @@ +using UnityEngine; +using UnityEngine.Events; + +public class Damagable : MonoBehaviour +{ + public float multiplier = 1f; + + private PlayerDeath playerDeath; + + public UnityEvent outOfLiveEvent; + + public UnityEvent damageEvent; + + public float health = 100f; + + private float currentHealth; + + private bool dead; + + private Rigidbody rig; + + private void Start() + { + rig = GetComponent(); + currentHealth = health; + playerDeath = base.transform.root.GetComponent(); + } + + private void Update() + { + } + + public void TakeDamage(Vector3 damage, Vector3 hitPoint) + { + damage *= multiplier; + if ((bool)playerDeath) + { + playerDeath.TakeDamage(damage, hitPoint, rig); + return; + } + damageEvent.Invoke(); + currentHealth -= damage.magnitude; + if (currentHealth < 0f && !dead) + { + dead = true; + outOfLiveEvent.Invoke(); + } + } + + public void RefillHP() + { + currentHealth = health; + } +} diff --git a/_ActiveRagdoll/DamageEffects.cs b/_ActiveRagdoll/DamageEffects.cs new file mode 100644 index 0000000..305c1d7 --- /dev/null +++ b/_ActiveRagdoll/DamageEffects.cs @@ -0,0 +1,84 @@ +using UnityEngine; +using UnityEngine.PostProcessing; + +public class DamageEffects : MonoBehaviour +{ + private WobbleShake screenShake; + + private ParticleParent[] particleParents; + + private float counter; + + public AnimationCurve curve; + + public AnimationCurve curve2; + + public PostProcessingProfile post; + + private Camera mainCam; + + public float damageValue; + + private Transform hip; + + private void Start() + { + screenShake = base.transform.root.GetComponentInChildren(); + particleParents = GetComponentsInChildren(); + mainCam = base.transform.root.GetComponentInChildren(); + hip = base.transform.root.GetComponentInChildren().transform; + } + + private void Update() + { + VignetteModel.Settings settings = post.vignette.settings; + ChromaticAberrationModel.Settings settings2 = post.chromaticAberration.settings; + counter += Time.deltaTime; + if (damageValue > 0f) + { + damageValue -= Time.deltaTime * 0.3f; + } + if (counter < curve.keys[curve.length - 1].time) + { + float intensity = curve.Evaluate(counter); + settings.intensity = intensity; + } + settings.intensity = Mathf.Lerp(settings.intensity, 0f, Time.deltaTime * 0.5f); + settings.intensity = Mathf.Clamp(settings.intensity, 0f, 9f); + post.vignette.settings = settings; + if (counter < curve2.keys[curve2.length - 1].time) + { + float intensity2 = curve2.Evaluate(counter); + settings2.intensity = intensity2; + } + settings2.intensity = Mathf.Lerp(settings2.intensity, 0f, Time.deltaTime * 0.5f); + settings2.intensity = Mathf.Clamp(settings2.intensity, 0f, 9f); + post.chromaticAberration.settings = settings2; + } + + public void TakeDamage(Vector3 damage, Vector3 hitPoint) + { + counter = 0f; + damageValue += damage.magnitude * 0.02f; + damageValue = Mathf.Clamp(damageValue, 0f, 0.5f); + GetComponentInChildren().GetComponent().AddForce(damage.normalized * (damage.magnitude * 0.3f + 3f), ForceMode.VelocityChange); + screenShake.AddShakeWorld(damage * 0.4f, 0.8f); + DirectionalParticles(mainCam.transform.InverseTransformDirection(-damage)); + } + + private void DirectionalParticles(Vector3 damage) + { + for (int i = 0; i < particleParents.Length; i++) + { + Vector3 from = particleParents[i].transform.position - particleParents[i].transform.parent.position; + Vector3 to = damage; + from.y = 0f; + to.y = 0f; + if (Vector3.Angle(from, to) < 15f + damage.magnitude * 0.5f) + { + float multi = 1f - Vector3.Angle(from, to) / damage.magnitude * 0.5f; + particleParents[i].Play(damage.magnitude, multi); + } + } + } +} diff --git a/_ActiveRagdoll/DragHandler.cs b/_ActiveRagdoll/DragHandler.cs new file mode 100644 index 0000000..adb8df4 --- /dev/null +++ b/_ActiveRagdoll/DragHandler.cs @@ -0,0 +1,25 @@ +using UnityEngine; + +public class DragHandler : MonoBehaviour +{ + private float drag; + + private float angularDrag; + + private Rigidbody rig; + + public float dragAmount = 1f; + + private void Start() + { + rig = GetComponent(); + drag = rig.drag; + angularDrag = rig.angularDrag; + } + + private void Update() + { + rig.drag = drag * dragAmount; + rig.angularDrag = angularDrag * dragAmount; + } +} diff --git a/_ActiveRagdoll/FootHandler.cs b/_ActiveRagdoll/FootHandler.cs new file mode 100644 index 0000000..7343e21 --- /dev/null +++ b/_ActiveRagdoll/FootHandler.cs @@ -0,0 +1,75 @@ +using UnityEngine; + +public class FootHandler : MonoBehaviour +{ + private AnimationHandler animHandler; + + private Collider collider; + + public PhysicMaterial slippery; + + private PhysicMaterial footMaterial; + + private Transform torso; + + private MovementDataHandler moveData; + + private Rigidbody rig; + + private RotationHandler rot; + + private Vector3 rotationDif; + + private AnimationObject anim; + + private StepHandler handler; + + private void Start() + { + animHandler = base.transform.root.GetComponent(); + moveData = base.transform.root.GetComponent(); + collider = GetComponentInChildren(); + rig = GetComponent(); + footMaterial = collider.material; + torso = base.transform.root.GetComponentInChildren().transform; + rot = base.transform.root.GetComponent(); + handler = base.transform.root.GetComponent(); + anim = GetComponentInChildren(); + } + + private void Update() + { + float num = Mathf.Abs(torso.position.x - base.transform.position.x) + Mathf.Abs(torso.position.z - base.transform.position.z); + if (rot.hipCorrectionAmount > 30f || ((bool)anim && anim.isLeft != handler.isLeft)) + { + SetFoot(active: false); + } + else if (animHandler.animationState == 0) + { + if (num > 0.1f || rotationDif.magnitude > 15f) + { + SetFoot(active: false); + } + else + { + SetFoot(active: true); + } + } + else + { + SetFoot(active: true); + } + } + + private void FixedUpdate() + { + } + + private void SetFoot(bool active) + { + if (active) + { + collider.material = footMaterial; + } + } +} diff --git a/_ActiveRagdoll/Gravity.cs b/_ActiveRagdoll/Gravity.cs new file mode 100644 index 0000000..f646f0c --- /dev/null +++ b/_ActiveRagdoll/Gravity.cs @@ -0,0 +1,47 @@ +using UnityEngine; + +public class Gravity : MonoBehaviour +{ + public float baseGravity; + + public float scalingGravity; + + private RigidbodyHolder allRigs; + + private StandingDataHandler standingData; + + private Holding holding; + + private PlayerDeath death; + + private void Start() + { + death = GetComponent(); + allRigs = GetComponent(); + standingData = GetComponent(); + holding = GetComponent(); + } + + private void FixedUpdate() + { + if (death.dead) + { + return; + } + for (int i = 0; i < allRigs.GetAllRigs().Length; i++) + { + allRigs.GetAllRigs()[i].AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration); + } + if ((bool)holding) + { + if ((bool)holding.heldObject) + { + holding.heldObject.rig.AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration); + } + if ((bool)holding.heldObjectOffHand) + { + holding.heldObjectOffHand.rig.AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration); + } + } + } +} diff --git a/_ActiveRagdoll/HandLeft.cs b/_ActiveRagdoll/HandLeft.cs new file mode 100644 index 0000000..5f92108 --- /dev/null +++ b/_ActiveRagdoll/HandLeft.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class HandLeft : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/HandRight.cs b/_ActiveRagdoll/HandRight.cs new file mode 100644 index 0000000..cb78d06 --- /dev/null +++ b/_ActiveRagdoll/HandRight.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class HandRight : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/HasControl.cs b/_ActiveRagdoll/HasControl.cs new file mode 100644 index 0000000..dde8ad6 --- /dev/null +++ b/_ActiveRagdoll/HasControl.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +public class HasControl : MonoBehaviour +{ + public bool hasControl = true; + + public GameObject[] objectsToRemove; + + private void Awake() + { + UpdateControl(); + } + + private void UpdateControl() + { + GameObject[] array = objectsToRemove; + foreach (GameObject gameObject in array) + { + gameObject.SetActive(hasControl); + } + } + + public void ChangeControl(bool control) + { + hasControl = control; + UpdateControl(); + } +} diff --git a/_ActiveRagdoll/Head.cs b/_ActiveRagdoll/Head.cs new file mode 100644 index 0000000..ce81442 --- /dev/null +++ b/_ActiveRagdoll/Head.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class Head : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/HeadCollisionHandler.cs b/_ActiveRagdoll/HeadCollisionHandler.cs new file mode 100644 index 0000000..c929f0e --- /dev/null +++ b/_ActiveRagdoll/HeadCollisionHandler.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +public class HeadCollisionHandler : MonoBehaviour +{ + public float collisionValue; + + private void Start() + { + } + + private void Update() + { + collisionValue = Mathf.Lerp(collisionValue, 0f, Time.deltaTime * 6f); + } + + private void OnCollisionEnter(Collision collision) + { + if (!(collision.transform.root == base.transform.root)) + { + collisionValue += collision.relativeVelocity.magnitude * 0.5f; + } + } + + private void OnCollisionStay(Collision collision) + { + if (!(collision.transform.root == base.transform.root)) + { + collisionValue += collision.relativeVelocity.magnitude * 0.1f; + } + } +} diff --git a/_ActiveRagdoll/Hip.cs b/_ActiveRagdoll/Hip.cs new file mode 100644 index 0000000..379fb1d --- /dev/null +++ b/_ActiveRagdoll/Hip.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class Hip : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/Holding.cs b/_ActiveRagdoll/Holding.cs new file mode 100644 index 0000000..dafc08b --- /dev/null +++ b/_ActiveRagdoll/Holding.cs @@ -0,0 +1,288 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Holding : MonoBehaviour +{ + [HideInInspector] + public HoldableObject heldObject; + + [HideInInspector] + public HoldableObject heldObjectOffHand; + + [HideInInspector] + public Transform baseTransform; + + private Rigidbody rightHand; + + private Rigidbody leftHand; + + [HideInInspector] + public ConfigurableJoint leftHandJoint; + + [HideInInspector] + public ConfigurableJoint rightHandJoint; + + public float grabForce; + + [HideInInspector] + public bool isGrabbing; + + private Transform rotaionTarget; + + private bool hasMainHandWeapon; + + private PlayerDeath death; + + public LayerMask mask = default(LayerMask); + + private Strength str; + + private float strength = 1f; + + private PID leftHandPID; + + private PID rightHandPID; + + private StandingDataHandler standingData; + + private void Awake() + { + death = GetComponent(); + standingData = GetComponent(); + str = GetComponent(); + if (!baseTransform) + { + baseTransform = GetComponentInChildren().transform; + } + rightHand = GetComponentInChildren().GetComponent(); + leftHand = GetComponentInChildren().GetComponent(); + rotaionTarget = base.transform.GetComponentInChildren().transform; + mask = LayerMask.GetMask("Map"); + leftHandPID = leftHand.GetComponent(); + rightHandPID = rightHand.GetComponent(); + } + + private void Update() + { + if (!death.dead && (bool)heldObject) + { + strength = str.strength; + if (((bool)rightHandJoint || !heldObject.rightHandPos) && ((bool)leftHandJoint || !heldObject.leftHandPos) && (!heldObjectOffHand || (((bool)rightHandJoint || !heldObjectOffHand.rightHandPos) && ((bool)leftHandJoint || !heldObjectOffHand.leftHandPos)))) + { + isGrabbing = false; + } + } + } + + private void FixedUpdate() + { + if (death.dead || isGrabbing) + { + return; + } + if ((bool)heldObject) + { + HoldObjectInPlace(heldObject.rig, heldObject, offHand: false, rightHand); + if (!heldObjectOffHand && (bool)leftHandJoint) + { + HoldObjectInPlace(heldObject.rig, heldObject, offHand: false, leftHand, justHand: true); + } + } + if ((bool)heldObjectOffHand) + { + HoldObjectInPlace(heldObjectOffHand.rig, heldObjectOffHand, offHand: true, leftHand); + } + } + + private void HoldObjectInPlace(Rigidbody rigi, HoldableObject held, bool offHand, Rigidbody hand, bool justHand = false) + { + Vector3 holdingPosition = held.holdingPosition; + if (offHand) + { + holdingPosition.x *= -1f; + } + holdingPosition = baseTransform.TransformPoint(holdingPosition); + Vector3 holdingRotation = held.holdingRotation; + Vector3 targetRotation = baseTransform.TransformDirection(holdingRotation); + Vector3 targetRotationUp = baseTransform.TransformDirection(held.holdingUpRotation); + if (!justHand) + { + held.pid.DoPID(holdingPosition, targetRotation, targetRotationUp, strength); + } + PID pID = rightHandPID; + Vector3 localPosition = held.rightHandPos.localPosition; + if (hand == leftHand) + { + localPosition = held.leftHandPos.localPosition; + pID = leftHandPID; + } + Vector3 position = held.holdingPosition + localPosition; + if (offHand) + { + position.x *= -1f; + } + position = baseTransform.TransformPoint(position); + Debug.DrawLine(position, position + Vector3.up); + Debug.DrawLine(holdingPosition, holdingPosition + Vector3.up); + pID.DoPID(position, Vector3.zero, Vector3.zero, strength); + } + + public void StartHolding(HoldableObject holdableObject, bool hasOffHand) + { + holdableObject.isHeld = true; + isGrabbing = true; + bool offHand = false; + if (!hasMainHandWeapon) + { + hasMainHandWeapon = true; + heldObject = holdableObject; + if ((bool)heldObject.rightHandPos) + { + StartCoroutine(Grab(mainHand: true, rightHand, heldObject, offHand: false)); + } + if ((bool)heldObject.leftHandPos && !hasOffHand) + { + StartCoroutine(Grab(mainHand: false, leftHand, heldObject, offHand: false)); + } + } + else + { + offHand = true; + heldObjectOffHand = holdableObject; + heldObjectOffHand.leftHandPos = heldObjectOffHand.rightHandPos; + if ((bool)heldObjectOffHand.rightHandPos) + { + StartCoroutine(Grab(mainHand: false, leftHand, heldObjectOffHand, offHand: true)); + } + } + StartCoroutine(HoldweaponStill(holdableObject.rig, offHand, holdableObject)); + } + + private IEnumerator Grab(bool mainHand, Rigidbody hand, HoldableObject held, bool offHand) + { + while (isGrabbing) + { + if (mainHand) + { + if (!rightHandJoint) + { + ReachForPoint(rightHand, rightHand.transform.GetChild(0).position, held.rightHandPos, isLeft: false, held.rig, held, offHand); + rightHand.GetComponentInChildren().enabled = false; + } + } + else if (!leftHandJoint) + { + ReachForPoint(leftHand, leftHand.transform.GetChild(0).position, held.leftHandPos, isLeft: true, held.rig, held, offHand); + leftHand.GetComponentInChildren().enabled = false; + } + yield return null; + } + leftHand.GetComponentInChildren().enabled = true; + rightHand.GetComponentInChildren().enabled = true; + } + + private IEnumerator HoldweaponStill(Rigidbody rigToGrab, bool offHand, HoldableObject held) + { + while (isGrabbing) + { + Vector3 pos = held.holdingPosition; + if (offHand) + { + pos.x *= -1f; + } + rigToGrab.transform.position = baseTransform.TransformPoint(pos); + rigToGrab.transform.rotation = Quaternion.LookRotation(baseTransform.TransformDirection(heldObject.holdingRotation)); + yield return null; + } + } + + public void Drop() + { + List list = new List(); + if ((bool)heldObject) + { + list.Add(heldObject); + } + if ((bool)heldObjectOffHand) + { + list.Add(heldObjectOffHand); + } + for (int i = 0; i < list.Count; i++) + { + list[i].holder = null; + list[i].isHeld = false; + list[i].rig.useGravity = true; + list[i].rig.drag = 0f; + list[i].rig.angularDrag = 0f; + Collider[] componentsInChildren = list[i].GetComponentsInChildren(); + foreach (Collider collider in componentsInChildren) + { + collider.material = null; + } + } + heldObject = null; + heldObjectOffHand = null; + if ((bool)rightHandJoint) + { + Object.Destroy(rightHandJoint); + } + if ((bool)leftHandJoint) + { + Object.Destroy(leftHandJoint); + } + hasMainHandWeapon = false; + } + + private void ReachForPoint(Rigidbody rigToReach, Vector3 forcePosition, Transform targetPositionTransform, bool isLeft, Rigidbody rigToGrab, HoldableObject held, bool offHand) + { + Vector3 normalized = (targetPositionTransform.position - forcePosition).normalized; + rigToReach.AddForceAtPosition(normalized * grabForce * Mathf.Clamp(Time.deltaTime, 0f, 0.1f), forcePosition, ForceMode.Acceleration); + if (Vector3.Distance(targetPositionTransform.position, forcePosition) < 0.5f) + { + ConnectRig(rigToReach, rigToGrab, targetPositionTransform, isLeft, held, offHand); + } + } + + private void ConnectRig(Rigidbody startRig, Rigidbody targetRig, Transform targetPositionTransform, bool isLeft, HoldableObject held, bool offHand) + { + ConfigurableJoint configurableJoint = startRig.gameObject.AddComponent(); + if (offHand) + { + targetPositionTransform.localRotation = Quaternion.Euler(targetPositionTransform.localEulerAngles.x, 0f - targetPositionTransform.localEulerAngles.y, targetPositionTransform.localEulerAngles.z); + } + startRig.transform.rotation = targetPositionTransform.rotation; + startRig.transform.position += targetPositionTransform.position - startRig.transform.GetChild(0).position; + configurableJoint.connectedBody = targetRig; + configurableJoint.projectionMode = JointProjectionMode.PositionAndRotation; + configurableJoint.xMotion = ConfigurableJointMotion.Locked; + configurableJoint.yMotion = ConfigurableJointMotion.Locked; + configurableJoint.zMotion = ConfigurableJointMotion.Locked; + configurableJoint.angularXMotion = ConfigurableJointMotion.Limited; + configurableJoint.angularYMotion = ConfigurableJointMotion.Limited; + configurableJoint.angularZMotion = ConfigurableJointMotion.Limited; + SoftJointLimit highAngularXLimit = configurableJoint.highAngularXLimit; + highAngularXLimit.limit = held.swingAngles.y; + configurableJoint.highAngularXLimit = highAngularXLimit; + highAngularXLimit.limit = held.swingAngles.x; + configurableJoint.lowAngularXLimit = highAngularXLimit; + highAngularXLimit.limit = held.twistAngles.x; + configurableJoint.angularYLimit = highAngularXLimit; + highAngularXLimit.limit = held.twistAngles.y; + configurableJoint.angularZLimit = highAngularXLimit; + SoftJointLimitSpring angularXLimitSpring = configurableJoint.angularXLimitSpring; + angularXLimitSpring.spring = held.swingSpring; + configurableJoint.angularXLimitSpring = angularXLimitSpring; + angularXLimitSpring.spring = held.twistSpring; + configurableJoint.angularYZLimitSpring = angularXLimitSpring; + configurableJoint.anchor = startRig.transform.InverseTransformPoint(startRig.transform.GetChild(0).position); + if (isLeft) + { + leftHandJoint = configurableJoint; + } + else + { + rightHandJoint = configurableJoint; + } + } +} diff --git a/_ActiveRagdoll/InputHandler.cs b/_ActiveRagdoll/InputHandler.cs new file mode 100644 index 0000000..27adc82 --- /dev/null +++ b/_ActiveRagdoll/InputHandler.cs @@ -0,0 +1,120 @@ +using UnityEngine; + +public class InputHandler : MonoBehaviour +{ + public Vector3 inputMovementDirection; + + public Vector3 lastInputDirection; + + public bool isSpringting; + + private WeaponHandler wepaonHandler; + + private MovementDataHandler movementData; + + private WeaponHandler weaponHandler; + + private CameraMovement cameraMovement; + + private PlayerDeath death; + + private HasControl hasControl; + + private MovementHandler movement; + + public bool allowStrafe = true; + + private void Start() + { + death = GetComponent(); + movement = GetComponent(); + wepaonHandler = GetComponent(); + hasControl = GetComponent(); + movementData = GetComponent(); + weaponHandler = GetComponent(); + cameraMovement = GetComponentInChildren(); + } + + private void Update() + { + if ((bool)death && death.dead) + { + return; + } + if (!hasControl || hasControl.hasControl) + { + isSpringting = false; + inputMovementDirection = Vector3.zero; + if (Input.GetKey(KeyCode.W)) + { + inputMovementDirection += movementData.groundedForward; + } + if (Input.GetKey(KeyCode.S)) + { + inputMovementDirection += movementData.groundedBack; + } + if (Input.GetKey(KeyCode.D) && allowStrafe) + { + inputMovementDirection += movementData.right; + } + if (Input.GetKey(KeyCode.A) && allowStrafe) + { + inputMovementDirection += movementData.left; + } + if (Input.GetKey(KeyCode.LeftShift) && (!cameraMovement || !cameraMovement.ADS)) + { + isSpringting = true; + } + inputMovementDirection = inputMovementDirection.normalized; + if ((bool)movement && Input.GetKeyDown(KeyCode.Space)) + { + movement.Jump(); + } + if ((bool)weaponHandler) + { + if (weaponHandler.isDualWeilding) + { + if (Input.GetKey(KeyCode.Mouse1)) + { + weaponHandler.HoldAttack(shootWithRightGun: true, ADS: false); + } + if (Input.GetKeyDown(KeyCode.Mouse1)) + { + weaponHandler.PressAttack(shootWithRightGun: true, ADS: false); + } + if (Input.GetKey(KeyCode.Mouse0)) + { + weaponHandler.HoldAttack(shootWithRightGun: false, ADS: false); + } + if (Input.GetKeyDown(KeyCode.Mouse0)) + { + weaponHandler.PressAttack(shootWithRightGun: false, ADS: false); + } + } + else + { + if (Input.GetKey(KeyCode.Mouse1)) + { + cameraMovement.ADS = true; + } + else + { + cameraMovement.ADS = false; + } + if (Input.GetKey(KeyCode.Mouse0)) + { + weaponHandler.HoldAttack(shootWithRightGun: true, cameraMovement.ADS); + } + if (Input.GetKeyDown(KeyCode.Mouse0)) + { + weaponHandler.PressAttack(shootWithRightGun: true, cameraMovement.ADS); + } + } + } + } + if (inputMovementDirection != Vector3.zero) + { + lastInputDirection = inputMovementDirection; + } + } +} diff --git a/_ActiveRagdoll/LeftHandPos.cs b/_ActiveRagdoll/LeftHandPos.cs new file mode 100644 index 0000000..955cf44 --- /dev/null +++ b/_ActiveRagdoll/LeftHandPos.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class LeftHandPos : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/MovementDataHandler.cs b/_ActiveRagdoll/MovementDataHandler.cs new file mode 100644 index 0000000..18d43f5 --- /dev/null +++ b/_ActiveRagdoll/MovementDataHandler.cs @@ -0,0 +1,92 @@ +using UnityEngine; + +public class MovementDataHandler : MonoBehaviour +{ + [HideInInspector] + public Vector3 groundedForward; + + [HideInInspector] + public Vector3 right; + + [HideInInspector] + public Vector3 left; + + [HideInInspector] + public Vector3 groundedBack; + + private Transform hip; + + private Transform torso; + + public Transform rotationTarget; + + [HideInInspector] + public float slopeStrenght; + + public float slopeVelocityStrenght; + + [HideInInspector] + public float sinceJump = 1f; + + [HideInInspector] + public Vector3 groundNormal; + + private InputHandler inputHandler; + + private Transform leftKnee; + + private Transform rightKnee; + + private void Start() + { + inputHandler = GetComponent(); + hip = GetComponentInChildren().transform; + torso = GetComponentInChildren().transform; + if (!rotationTarget) + { + rotationTarget = GetComponentInChildren().transform; + } + KneeLeft componentInChildren = GetComponentInChildren(); + if ((bool)componentInChildren) + { + leftKnee = componentInChildren.transform; + } + KneeRight componentInChildren2 = GetComponentInChildren(); + if ((bool)componentInChildren2) + { + rightKnee = componentInChildren2.transform; + } + } + + private void Update() + { + sinceJump += Time.deltaTime; + groundedForward = rotationTarget.forward; + groundedForward.y = slopeStrenght * 1f; + groundedForward = groundedForward.normalized; + groundedBack = -groundedForward; + right = rotationTarget.right; + left = -rotationTarget.right; + slopeStrenght = Mathf.Lerp(slopeStrenght, 0f, Time.deltaTime * 1f); + Debug.DrawLine(hip.position, hip.position + groundedForward * 10f); + } + + public void SetSlope(Vector3 normal) + { + groundNormal = normal; + slopeStrenght = Vector3.Cross(rotationTarget.right, normal).y; + Vector3 lhs = Vector3.Cross(Vector3.up, inputHandler.inputMovementDirection); + slopeVelocityStrenght = Vector3.Cross(lhs, normal).y; + } + + public float GetSmallestLegAngle() + { + float num = Vector3.Angle(leftKnee.forward, Vector3.down); + float num2 = Vector3.Angle(rightKnee.forward, Vector3.down); + if (num < num2) + { + return num; + } + return num2; + } +} diff --git a/_ActiveRagdoll/MovementHandler.cs b/_ActiveRagdoll/MovementHandler.cs new file mode 100644 index 0000000..22795f7 --- /dev/null +++ b/_ActiveRagdoll/MovementHandler.cs @@ -0,0 +1,85 @@ +using System.Collections; +using UnityEngine; + +public class MovementHandler : MonoBehaviour +{ + private InputHandler inputHandler; + + public float friction = 0.9f; + + public Vector3 movementVector; + + public float[] animationForceAmounts; + + private AnimationHandler animationHandler; + + private RigidbodyHolder allRigs; + + public AnimationCurve jumpCurve; + + public float jumpForce; + + private StandingDataHandler standingData; + + private MovementDataHandler data; + + private PlayerDeath death; + + [HideInInspector] + public float multiplier = 1f; + + private WobbleShake wobbleShake; + + private void Start() + { + wobbleShake = GetComponentInChildren(); + death = GetComponent(); + standingData = GetComponent(); + inputHandler = GetComponent(); + animationHandler = GetComponent(); + allRigs = GetComponent(); + data = GetComponent(); + } + + private void FixedUpdate() + { + if (!death.dead) + { + data.sinceJump += Time.fixedDeltaTime; + movementVector += inputHandler.inputMovementDirection * animationForceAmounts[animationHandler.animationState]; + movementVector *= friction; + for (int i = 0; i < allRigs.GetAllRigs().Length; i++) + { + allRigs.GetAllRigs()[i].AddForce(movementVector * multiplier, ForceMode.Acceleration); + } + } + } + + public void Jump() + { + if (!(data.sinceJump < 0.5f) && !(standingData.sinceGrounded > 0.3f)) + { + data.sinceJump = 0f; + StartCoroutine(AddJumpForce()); + wobbleShake.AddShake(Vector3.up * 2f, 0.8f); + } + } + + private IEnumerator AddJumpForce() + { + float counter = 0f; + for (int i = 0; i < allRigs.GetAllRigs().Length; i++) + { + allRigs.GetAllRigs()[i].velocity = new Vector3(allRigs.GetAllRigs()[i].velocity.x, 0f, allRigs.GetAllRigs()[i].velocity.z); + } + while (counter < jumpCurve.keys[jumpCurve.length - 1].time && !death.dead) + { + counter += Time.deltaTime; + for (int j = 0; j < allRigs.GetAllRigs().Length; j++) + { + allRigs.GetAllRigs()[j].AddForce(Vector3.up * multiplier * jumpForce * jumpCurve.Evaluate(counter) * Time.deltaTime, ForceMode.Acceleration); + } + yield return null; + } + } +} diff --git a/_ActiveRagdoll/PickupHandler.cs b/_ActiveRagdoll/PickupHandler.cs new file mode 100644 index 0000000..8bf1615 --- /dev/null +++ b/_ActiveRagdoll/PickupHandler.cs @@ -0,0 +1,63 @@ +using UnityEngine; + +public class PickupHandler : MonoBehaviour +{ + public Pickup setWeapon; + + public Pickup setWeapon2; + + private WeaponHandler weaponHandler; + + private Holding holding; + + private float counter; + + private void Start() + { + weaponHandler = GetComponent(); + holding = GetComponent(); + if ((bool)setWeapon) + { + PickUp(setWeapon); + } + if ((bool)setWeapon2) + { + PickUp2(setWeapon2); + } + } + + private void Update() + { + counter += Time.deltaTime; + } + + public void PickUp(Pickup objectToPickUp) + { + if (!(counter < 1f)) + { + counter = 0f; + holding.Drop(); + Weapon component = objectToPickUp.GetComponent(); + Gun component2 = component.GetComponent(); + weaponHandler.SetGun(component2, mainHand: true); + bool hasOffHand = false; + if ((bool)setWeapon2) + { + hasOffHand = true; + } + HoldableObject component3 = component.GetComponent(); + component3.holder = base.transform; + holding.StartHolding(component3, hasOffHand); + } + } + + public void PickUp2(Pickup objectToPickUp) + { + Weapon component = objectToPickUp.GetComponent(); + Gun component2 = component.GetComponent(); + weaponHandler.SetGun(component2, mainHand: false); + HoldableObject component3 = component.GetComponent(); + component3.holder = base.transform; + holding.StartHolding(component3, hasOffHand: true); + } +} diff --git a/_ActiveRagdoll/Player.cs b/_ActiveRagdoll/Player.cs new file mode 100644 index 0000000..55ff387 --- /dev/null +++ b/_ActiveRagdoll/Player.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +public class Player : MonoBehaviour +{ + public static Player localPlayer; + + public bool isLocalPlayer; + + public Transform torso; + + private void Start() + { + if (isLocalPlayer) + { + localPlayer = this; + } + } +} diff --git a/_ActiveRagdoll/PlayerDeath.cs b/_ActiveRagdoll/PlayerDeath.cs new file mode 100644 index 0000000..ec0813a --- /dev/null +++ b/_ActiveRagdoll/PlayerDeath.cs @@ -0,0 +1,125 @@ +using UnityEngine; + +public class PlayerDeath : MonoBehaviour +{ + public bool dead; + + private bool isFrozen; + + public float muscleFunction = 1f; + + public bool terminalState; + + private DamageEffects damageEffects; + + private RagdollHandler ragdoll; + + private Transform hip; + + public float health = 100f; + + public ParticleSystem[] damageParticles; + + private HasControl hasControll; + + private Holding holding; + + private void Start() + { + damageEffects = GetComponent(); + ragdoll = GetComponent(); + hip = GetComponentInChildren().transform; + hasControll = GetComponent(); + holding = GetComponent(); + } + + private void Update() + { + if (health < 100f) + { + health += Time.deltaTime * 10f; + health = Mathf.Clamp(health, -10f, 100f); + } + if (hip.transform.position.y < -10f) + { + Die(); + } + if (terminalState && muscleFunction > 0f) + { + muscleFunction -= Time.deltaTime * 1f; + } + if (muscleFunction < 0f && !isFrozen) + { + FreezeBody(); + } + } + + public void TakeDamage(Vector3 damage, Vector3 hitPoint, Rigidbody hitRig = null) + { + if (hasControll.hasControl) + { + damageEffects.TakeDamage(damage, hitPoint); + } + if (hitPoint != Vector3.zero) + { + for (int i = 0; i < damageParticles.Length; i++) + { + damageParticles[i].transform.rotation = Quaternion.LookRotation(damage); + damageParticles[i].transform.position = hitPoint; + damageParticles[i].Play(); + } + } + health -= damage.magnitude; + if (!(health <= 0f)) + { + return; + } + if ((bool)hitRig) + { + ConfigurableJoint component = hitRig.GetComponent(); + if ((bool)component) + { + Object.Destroy(component); + } + } + Kill(); + } + + public void FreezeBody() + { + isFrozen = true; + Joint[] componentsInChildren = GetComponentsInChildren(); + for (int i = 0; i < componentsInChildren.Length; i++) + { + ConfigurableJoint configurableJoint = (ConfigurableJoint)componentsInChildren[i]; + Rigidbody component = configurableJoint.GetComponent(); + JointDrive angularXDrive = configurableJoint.angularXDrive; + angularXDrive.positionSpring = 5f * component.mass; + angularXDrive.positionDamper = 1f * component.mass; + configurableJoint.angularXDrive = angularXDrive; + configurableJoint.angularYZDrive = angularXDrive; + configurableJoint.SetTargetRotationLocal(configurableJoint.transform.localRotation, configurableJoint.gameObject.GetComponent().startRotationLocal); + } + } + + public void Die() + { + if (!dead) + { + holding.Drop(); + dead = true; + ragdoll.ragdollValue = 0f; + Collider[] componentsInChildren = GetComponentsInChildren(); + foreach (Collider collider in componentsInChildren) + { + collider.material = null; + } + } + } + + public void Kill() + { + terminalState = true; + Die(); + } +} diff --git a/_ActiveRagdoll/PlayerKnockback.cs b/_ActiveRagdoll/PlayerKnockback.cs new file mode 100644 index 0000000..89fffb8 --- /dev/null +++ b/_ActiveRagdoll/PlayerKnockback.cs @@ -0,0 +1,52 @@ +using UnityEngine; + +public class PlayerKnockback : MonoBehaviour +{ + private RigidbodyHolder allRigs; + + private StandingDataHandler standing; + + private WeaponHandler weapons; + + private void Start() + { + allRigs = GetComponent(); + standing = GetComponent(); + weapons = GetComponent(); + } + + private void Update() + { + if (Input.GetKeyDown(KeyCode.K)) + { + AddSeriousKnockback(); + } + } + + public void AddForce(Vector3 force, Rigidbody rig) + { + if (force.magnitude > 200f) + { + AddSeriousKnockback(); + force *= 0.1f; + } + for (int i = 0; i < allRigs.GetAllRigs().Length; i++) + { + float num = 1f; + if (rig == allRigs.GetAllRigs()[i]) + { + num *= 1f; + } + allRigs.GetAllRigs()[i].AddForce(force * num * 20f, ForceMode.Acceleration); + } + } + + private void AddSeriousKnockback() + { + GetComponent().Kill(); + } + + private void AddNormalKnockback() + { + } +} diff --git a/_ActiveRagdoll/RagdollHandler.cs b/_ActiveRagdoll/RagdollHandler.cs new file mode 100644 index 0000000..ca52b8d --- /dev/null +++ b/_ActiveRagdoll/RagdollHandler.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +public class RagdollHandler : MonoBehaviour +{ + public float ragdollValue = 1f; + + private RigidbodyHolder rigs; + + private void Start() + { + rigs = GetComponent(); + } + + private void Update() + { + for (int i = 0; i < rigs.GetAllRigs().Length; i++) + { + rigs.GetAllRigs()[i].GetComponent().dragAmount = ragdollValue; + } + } +} diff --git a/_ActiveRagdoll/RemoveMouse.cs b/_ActiveRagdoll/RemoveMouse.cs new file mode 100644 index 0000000..85d89db --- /dev/null +++ b/_ActiveRagdoll/RemoveMouse.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +public class RemoveMouse : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + if (Input.GetKey(KeyCode.Mouse1)) + { + Cursor.lockState = CursorLockMode.Locked; + Cursor.visible = false; + } + } +} diff --git a/_ActiveRagdoll/RigidbodyHolder.cs b/_ActiveRagdoll/RigidbodyHolder.cs new file mode 100644 index 0000000..796f77a --- /dev/null +++ b/_ActiveRagdoll/RigidbodyHolder.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using UnityEngine; + +public class RigidbodyHolder : MonoBehaviour +{ + private Rigidbody[] allRigs; + + private WeaponHandler weapons; + + private void Start() + { + allRigs = GetComponentsInChildren(); + weapons = GetComponent(); + } + + private void Update() + { + } + + public Rigidbody[] GetAllRigs() + { + if (!weapons.leftGun && !weapons.rightGun) + { + return allRigs; + } + List list = new List(); + for (int i = 0; i < allRigs.Length; i++) + { + list.Add(allRigs[i]); + } + if ((bool)weapons) + { + if ((bool)weapons.leftGun) + { + list.Add(weapons.leftGun.rig); + } + if ((bool)weapons.rightGun) + { + list.Add(weapons.rightGun.rig); + } + } + return list.ToArray(); + } +} diff --git a/_ActiveRagdoll/RotationHandler.cs b/_ActiveRagdoll/RotationHandler.cs new file mode 100644 index 0000000..ee33545 --- /dev/null +++ b/_ActiveRagdoll/RotationHandler.cs @@ -0,0 +1,73 @@ +using UnityEngine; + +public class RotationHandler : MonoBehaviour +{ + private Transform rotationTarget; + + private Rigidbody hip; + + private Rigidbody torso; + + private Rigidbody head; + + public float rotationTorque; + + public float clamp; + + private InputHandler input; + + private PlayerDeath death; + + [HideInInspector] + public float hipCorrectionAmount; + + public bool useHip = true; + + public bool useTorso = true; + + public bool useHead = true; + + private void Start() + { + death = GetComponent(); + rotationTarget = GetComponentInChildren().transform; + hip = GetComponentInChildren().GetComponent(); + torso = GetComponentInChildren().GetComponent(); + head = GetComponentInChildren().GetComponent(); + input = GetComponent(); + } + + private void FixedUpdate() + { + if (!death.dead) + { + float num = head.transform.InverseTransformPoint(rotationTarget.position).x; + float num2 = torso.transform.InverseTransformPoint(rotationTarget.position).x; + hipCorrectionAmount = hip.transform.InverseTransformPoint(hip.transform.position + input.lastInputDirection * 10f).x; + float muscleFunction = death.muscleFunction; + float num3 = 0.3f; + if (input.inputMovementDirection.magnitude > 0.1f) + { + num3 = 1f; + } + if (clamp != 0f) + { + hipCorrectionAmount = Mathf.Clamp(hipCorrectionAmount, 0f - clamp, clamp); + num = Mathf.Clamp(num, 0f - clamp, clamp); + num2 = Mathf.Clamp(num2, 0f - clamp, clamp); + } + if (useHip) + { + hip.AddTorque(Vector3.up * muscleFunction * rotationTorque * num3 * hipCorrectionAmount, ForceMode.Acceleration); + } + if (useTorso) + { + torso.AddTorque(Vector3.up * muscleFunction * rotationTorque * num2, ForceMode.Acceleration); + } + if (useHead) + { + head.AddTorque(Vector3.up * muscleFunction * rotationTorque * num, ForceMode.Acceleration); + } + } + } +} diff --git a/_ActiveRagdoll/SetAnimationByInput.cs b/_ActiveRagdoll/SetAnimationByInput.cs new file mode 100644 index 0000000..cc50e5a --- /dev/null +++ b/_ActiveRagdoll/SetAnimationByInput.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +public class SetAnimationByInput : MonoBehaviour +{ + private InputHandler input; + + private AnimationHandler anim; + + private StandingDataHandler standingData; + + private void Start() + { + anim = GetComponent(); + input = GetComponent(); + standingData = GetComponent(); + } + + private void Update() + { + if ((double)standingData.sinceGrounded > 0.2) + { + anim.animationState = 3; + } + else if (input.inputMovementDirection.magnitude > 0.1f) + { + if (input.isSpringting) + { + anim.animationState = 1; + } + else + { + anim.animationState = 2; + } + } + else + { + anim.animationState = 0; + } + } +} diff --git a/_ActiveRagdoll/SetAnimationByVelocity.cs b/_ActiveRagdoll/SetAnimationByVelocity.cs new file mode 100644 index 0000000..c737363 --- /dev/null +++ b/_ActiveRagdoll/SetAnimationByVelocity.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +public class SetAnimationByVelocity : MonoBehaviour +{ + private void Start() + { + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/SetRigidbodySettings.cs b/_ActiveRagdoll/SetRigidbodySettings.cs new file mode 100644 index 0000000..2521b75 --- /dev/null +++ b/_ActiveRagdoll/SetRigidbodySettings.cs @@ -0,0 +1,20 @@ +using UnityEngine; + +public class SetRigidbodySettings : MonoBehaviour +{ + public float maxAngular; + + private void Start() + { + Rigidbody[] componentsInChildren = GetComponentsInChildren(); + foreach (Rigidbody rigidbody in componentsInChildren) + { + rigidbody.maxAngularVelocity = maxAngular; + rigidbody.maxDepenetrationVelocity = 10000f; + } + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/Standing.cs b/_ActiveRagdoll/Standing.cs new file mode 100644 index 0000000..6162215 --- /dev/null +++ b/_ActiveRagdoll/Standing.cs @@ -0,0 +1,55 @@ +using UnityEngine; + +public class Standing : MonoBehaviour +{ + public RigidbodyMovment[] rigsToLift; + + public AnimationCurve[] animationLiftCurves; + + private StandingDataHandler standingData; + + private AnimationHandler animationHandler; + + public float offset; + + private PlayerDeath death; + + private Strength str; + + private float muscleMultiplier = 1f; + + private float legAngleMultiplier; + + private MovementDataHandler moveData; + + private void Start() + { + death = GetComponent(); + str = GetComponent(); + standingData = GetComponent(); + moveData = GetComponent(); + animationHandler = GetComponent(); + } + + private void FixedUpdate() + { + if (!death.dead) + { + muscleMultiplier = str.strength; + if (standingData.isGrounded) + { + Stand(animationLiftCurves[animationHandler.animationState]); + } + } + } + + private void Stand(AnimationCurve curve) + { + legAngleMultiplier = 1f; + RigidbodyMovment[] array = rigsToLift; + foreach (RigidbodyMovment rigidbodyMovment in array) + { + rigidbodyMovment.rig.AddForce(Vector3.up * muscleMultiplier * rigidbodyMovment.force * legAngleMultiplier * curve.Evaluate(standingData.distanceToGround + offset + moveData.slopeVelocityStrenght * -0.2f), ForceMode.Acceleration); + } + } +} diff --git a/_ActiveRagdoll/StandingDataHandler.cs b/_ActiveRagdoll/StandingDataHandler.cs new file mode 100644 index 0000000..10a1473 --- /dev/null +++ b/_ActiveRagdoll/StandingDataHandler.cs @@ -0,0 +1,69 @@ +using UnityEngine; + +public class StandingDataHandler : MonoBehaviour +{ + public Rigidbody mainRig; + + public float sinceGrounded; + + public float sinceLanded; + + public bool isGrounded; + + public float distanceToGround = 1f; + + private bool hasRecievedTouchedGround; + + private MovementDataHandler moveMentData; + + private PlayerKnockback knockback; + + private WobbleShake wobbleShake; + + private void Start() + { + wobbleShake = GetComponentInChildren(); + knockback = GetComponent(); + } + + private void FixedUpdate() + { + sinceGrounded += Time.fixedDeltaTime; + sinceLanded += Time.fixedDeltaTime; + moveMentData = GetComponent(); + if ((double)sinceGrounded > 0.1) + { + isGrounded = false; + } + } + + private void LateUpdate() + { + hasRecievedTouchedGround = false; + } + + public void TouchGround(float distance, Vector3 normal) + { + if (sinceGrounded > 0.5f && (bool)wobbleShake) + { + wobbleShake.AddShake(-Vector3.up * 5f * Mathf.Pow(sinceGrounded, 1.5f), 0.8f); + } + if (sinceGrounded > 0.5f) + { + Land(sinceGrounded); + } + sinceGrounded = 0f; + isGrounded = true; + if (distance > distanceToGround || !hasRecievedTouchedGround) + { + distanceToGround = distance; + } + hasRecievedTouchedGround = true; + moveMentData.SetSlope(normal); + } + + private void Land(float landForce) + { + sinceLanded = 0f; + } +} diff --git a/_ActiveRagdoll/StartRotation.cs b/_ActiveRagdoll/StartRotation.cs new file mode 100644 index 0000000..4ae91b2 --- /dev/null +++ b/_ActiveRagdoll/StartRotation.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +public class StartRotation : MonoBehaviour +{ + public Quaternion startRotation; + + public Quaternion startRotationLocal; + + private void Start() + { + startRotation = base.transform.rotation; + startRotationLocal = base.transform.localRotation; + } + + private void Update() + { + } +} diff --git a/_ActiveRagdoll/StayInPlace.cs b/_ActiveRagdoll/StayInPlace.cs new file mode 100644 index 0000000..d10ebba --- /dev/null +++ b/_ActiveRagdoll/StayInPlace.cs @@ -0,0 +1,50 @@ +using UnityEngine; + +public class StayInPlace : MonoBehaviour +{ + private InputHandler input; + + public Rigidbody rig; + + public float force; + + private Vector3 stopPosition; + + private bool isBroken; + + private PlayerDeath death; + + private Strength str; + + private float strength = 1f; + + private void Start() + { + str = GetComponent(); + input = GetComponent(); + death = GetComponent(); + stopPosition = rig.position; + } + + private void FixedUpdate() + { + if (death.dead) + { + return; + } + strength = str.strength; + if (input.inputMovementDirection.magnitude > 0.1f) + { + stopPosition = rig.position + rig.velocity * 0.25f; + isBroken = false; + } + else if (!isBroken) + { + if (Vector3.Distance(stopPosition, rig.position) > 1f) + { + isBroken = true; + } + rig.AddForce((stopPosition - rig.position) * force * strength, ForceMode.Acceleration); + } + } +} diff --git a/_ActiveRagdoll/StepHandler.cs b/_ActiveRagdoll/StepHandler.cs new file mode 100644 index 0000000..fd8110b --- /dev/null +++ b/_ActiveRagdoll/StepHandler.cs @@ -0,0 +1,53 @@ +using UnityEngine; + +public class StepHandler : MonoBehaviour +{ + public float staticCounter; + + public Step[] steps; + + public bool isLeft; + + private float counter; + + private Transform leftLeg; + + private Transform rightLeg; + + private AnimationHandler animationHandler; + + private Transform hip; + + private void Start() + { + if (staticCounter == 0f) + { + leftLeg = GetComponentInChildren().transform; + rightLeg = GetComponentInChildren().transform; + animationHandler = GetComponent(); + hip = GetComponentInChildren().transform; + } + } + + private void Update() + { + counter += Time.deltaTime; + if (staticCounter != 0f) + { + if (counter > staticCounter) + { + Switch(); + } + } + else if (counter > steps[animationHandler.animationState].minTime && (steps[animationHandler.animationState].minAngle == 0f || steps[animationHandler.animationState].minAngle < Vector3.Angle(leftLeg.forward, rightLeg.forward)) && isLeft == hip.InverseTransformPoint(leftLeg.position + leftLeg.forward).z > hip.InverseTransformPoint(rightLeg.position + rightLeg.forward).z) + { + Switch(); + } + } + + private void Switch() + { + isLeft = !isLeft; + counter = 0f; + } +} diff --git a/_ActiveRagdoll/Strength.cs b/_ActiveRagdoll/Strength.cs new file mode 100644 index 0000000..f458b21 --- /dev/null +++ b/_ActiveRagdoll/Strength.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +public class Strength : MonoBehaviour +{ + public float strength = 1f; + + private PlayerDeath death; + + private RagdollHandler ragdoll; + + private void Start() + { + ragdoll = GetComponent(); + death = GetComponent(); + } + + private void Update() + { + strength = ragdoll.ragdollValue * death.muscleFunction; + } +} diff --git a/_ActiveRagdoll/WeaponHandler.cs b/_ActiveRagdoll/WeaponHandler.cs new file mode 100644 index 0000000..7b3d80f --- /dev/null +++ b/_ActiveRagdoll/WeaponHandler.cs @@ -0,0 +1,75 @@ +using UnityEngine; + +public class WeaponHandler : MonoBehaviour +{ + [HideInInspector] + public Gun leftGun; + + [HideInInspector] + public Gun rightGun; + + [HideInInspector] + public Transform gunADS; + + [HideInInspector] + public float ADSFOV; + + public bool isDualWeilding; + + private void Start() + { + } + + private void Update() + { + } + + public void SetWeapon(Weapon w, bool mainHand) + { + } + + public void SetGun(Gun g, bool mainHand) + { + if (mainHand) + { + rightGun = g; + gunADS = g.GetComponentInChildren().transform; + ADSFOV = g.ADSFOV; + } + else + { + leftGun = g; + } + if ((bool)leftGun && (bool)rightGun) + { + isDualWeilding = true; + } + } + + public void HoldAttack(bool shootWithRightGun, bool ADS) + { + if (shootWithRightGun) + { + if (rightGun.auto) + { + rightGun.Shoot(base.transform.root, ADS); + } + } + else if (leftGun.auto) + { + leftGun.Shoot(base.transform.root, ADS); + } + } + + public void PressAttack(bool shootWithRightGun, bool ADS) + { + if (shootWithRightGun) + { + rightGun.Shoot(base.transform.root, ADS); + } + else + { + leftGun.Shoot(base.transform.root, ADS); + } + } +} -- cgit v1.1-26-g67d0