change: fixing of many issues in handler, deprecation/deletion of variables, cleanup of UnitMovementHandler, cleaning up of inspector

This commit is contained in:
Chris
2025-09-23 14:14:47 -04:00
parent b21adf93e2
commit bd2903a0b2
10 changed files with 445 additions and 838 deletions

View File

@@ -33,7 +33,7 @@ namespace Reset.Units {
// ValueGroup.ChangeSmoothingEasing(jumpPower, ref agent.data.jumpPower.currentSmoothing,
// ref agent.data.jumpPower.easing, ref agent.defaultData.jumpPower.smoothing, ref agent.defaultData.jumpPower.easing);
FloatValueGroup.UpdateValue(jumpPowerDecay, agent.data.jumpPowerDecay);
// FloatValueGroup.UpdateValue(jumpPowerDecay, agent.data.jumpPowerDecay);
// Deprecated by SetNewGravity
// FloatValueGroup.UpdateValue(gravityPower, ref agent.data.gravityPower.value, ref agent.defaultData.gravityPower.value);

View File

@@ -13,10 +13,45 @@ public static class MathExtensions{
return (to - origin).normalized;
}
public static Vector3 ToVector3(this Vector2 vector2){
return new Vector3(vector2.x, 0f, vector2.y);
}
public static Vector2 ToVector2(this Vector3 vector3){
return new Vector2(vector3.x, vector3.z);
}
public static Color Alpha(this Color input, float newAlpha){
return new Color(input.r, input.g, input.b, newAlpha);
}
public static Quaternion SmoothDamp(Quaternion rot, Quaternion target, ref Quaternion deriv, float time) {
if (Time.deltaTime < Mathf.Epsilon) return rot;
// account for double-cover
var Dot = Quaternion.Dot(rot, target);
var Multi = Dot > 0f ? 1f : -1f;
target.x *= Multi;
target.y *= Multi;
target.z *= Multi;
target.w *= Multi;
// smooth damp (nlerp approx)
var Result = new Vector4(
Mathf.SmoothDamp(rot.x, target.x, ref deriv.x, time),
Mathf.SmoothDamp(rot.y, target.y, ref deriv.y, time),
Mathf.SmoothDamp(rot.z, target.z, ref deriv.z, time),
Mathf.SmoothDamp(rot.w, target.w, ref deriv.w, time)
).normalized;
// ensure deriv is tangent
var derivError = Vector4.Project(new Vector4(deriv.x, deriv.y, deriv.z, deriv.w), Result);
deriv.x -= derivError.x;
deriv.y -= derivError.y;
deriv.z -= derivError.z;
deriv.w -= derivError.w;
return new Quaternion(Result.x, Result.y, Result.z, Result.w);
}
public static Vector2 Rotate(this Vector2 v, float delta) {
return new Vector2(
v.x * Mathf.Cos(delta) - v.y * Mathf.Sin(delta),