using System; using UnityEngine; namespace SLSFramework.General { public static class MathExtensions { public static float ClampAngle(float lfAngle, float lfMin, float lfMax) { if (lfAngle < -360f) lfAngle += 360f; if (lfAngle > 360f) lfAngle -= 360f; return Mathf.Clamp(lfAngle, lfMin, lfMax); } public static Vector3 Flatten(this Vector3 vector) { return new Vector3(vector.x, 0, vector.z); } } public class LerpFloat { public float currentValue; public float targetValue; public float lerpSpeed; public LerpFloat(float initialValue, float lerpSpeed) { this.currentValue = initialValue; this.targetValue = initialValue; this.lerpSpeed = lerpSpeed; } public void Update(float deltaTime) { currentValue = Mathf.Lerp(currentValue, targetValue, lerpSpeed * deltaTime); } public void Update(float customSpeed, float deltaTime) { currentValue = Mathf.Lerp(currentValue, targetValue, customSpeed * deltaTime); } } public class LerpVector3 { public Vector3 currentValue; public Vector3 targetValue; public float lerpSpeed; public LerpVector3(Vector3 initialValue, float lerpSpeed) { this.currentValue = initialValue; this.targetValue = initialValue; this.lerpSpeed = lerpSpeed; } public void Update(float deltaTime) { currentValue = Vector3.Lerp(currentValue, targetValue, lerpSpeed * deltaTime); } public void Update(float customSpeed, float deltaTime) { currentValue = Vector3.Lerp(currentValue, targetValue, customSpeed * deltaTime); } } public class LerpColor { public Color currentValue; public Color targetValue; public float lerpSpeed; public LerpColor(Color initialValue, float lerpSpeed) { this.currentValue = initialValue; this.targetValue = initialValue; this.lerpSpeed = lerpSpeed; } public void Update(float deltaTime) { currentValue = Color.Lerp(currentValue, targetValue, lerpSpeed * deltaTime); } public void Update(float customSpeed, float deltaTime) { currentValue = Color.Lerp(currentValue, targetValue, customSpeed * deltaTime); } } }