Added a bunch of utilities and modfief the character data structue

This commit is contained in:
Sebastian Bularca
2026-03-29 18:31:03 +02:00
parent 4a9c00212a
commit ee97b2fec3
110 changed files with 6752 additions and 169 deletions

View File

@@ -0,0 +1,45 @@
using System;
using UnityEngine;
namespace Jovian.Utilities {
public abstract class NumberRange<T> {
public T min;
public T max;
public abstract float Lerp(float t);
public abstract float LerpUnclamped(float t);
// returns 0 to 1
public abstract float InverseLerp(float t);
// returns values -1 to 1
public abstract float InverseLerpSigned(float t);
public abstract T Random();
}
[Serializable]
public class FloatRange : NumberRange<float> {
public FloatRange(float min, float max) {
this.min = min;
this.max = max;
}
public override float Lerp(float t) => Mathf.Lerp(min, max, t);
public override float LerpUnclamped(float t) => Mathf.LerpUnclamped(min, max, t);
public override float InverseLerp(float t) => Mathf.InverseLerp(min, max, t);
public override float InverseLerpSigned(float t) => Mathf.InverseLerp(min, max, t) * 2f - 1f;
public override float Random() => UnityEngine.Random.Range(min, max);
}
[Serializable]
public class IntRange : NumberRange<int> {
public IntRange(int min, int max) {
this.min = min;
this.max = max;
}
public override float Lerp(float t) => Mathf.Lerp(min, max, t);
public override float LerpUnclamped(float t) => Mathf.LerpUnclamped(min, max, t);
public override float InverseLerp(float t) => Mathf.InverseLerp(min, max, t);
public override float InverseLerpSigned(float t) => Mathf.InverseLerp(min, max, t) * 2f - 1f;
public override int Random() => UnityEngine.Random.Range(min, max);
}
}