Aetheria/Assets/Scripts/ServerShared/ExponentialCurve.cs

39 lines
912 B
C#
Raw Normal View History

2026-06-13 04:56:50 +01:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Serializable]
public class ExponentialCurve
{
[Inspectable]
public float Exponent;
2026-06-13 04:56:50 +01:00
[Inspectable]
public float Multiplier;
2026-06-13 04:56:50 +01:00
[Inspectable]
public float Constant;
2026-06-13 04:56:50 +01:00
public float Evaluate(float value) => Multiplier * pow(value, Exponent) + Constant;
}
[Serializable]
public class ExponentialLerp
{
[Inspectable]
public float Exponent;
2026-06-13 04:56:50 +01:00
[Inspectable]
public float Minimum;
2026-06-13 04:56:50 +01:00
[Inspectable]
public float Maximum;
2026-06-13 04:56:50 +01:00
public float Evaluate(float value) => Minimum + pow(saturate(value), Exponent) * (Maximum - Minimum);
}