Version 0.1 - 0.3.1

Added the World
Added Mobs, and spawning those mobs at runtime
Added simple camera movement
Added simple UI/HUD
This commit is contained in:
gdz
2025-07-29 23:21:53 +02:00
parent 9cef1ddce2
commit 802918e5b8
46 changed files with 1087 additions and 1 deletions

54
utility/Math.cs Normal file
View File

@@ -0,0 +1,54 @@
namespace Ecosystem.utility;
public class Math
{
/// <summary>
/// Re-maps a number from one range to another.
/// For example, calling map(2, 0, 10, 0, 100) returns 20.
/// The first three arguments set the original value to 2
/// and the original range from 0 to 10. The last two
/// arguments set the target range from 0 to 100. 20's
/// position in the target range [0, 100] is proportional
/// to 2's position in the original range [0, 10].
/// The sixth parameter, withinBounds, is optional.
/// </summary>
/// <example>
/// By default, map() can return values outside the
/// target range. For example, map(11, 0, 10, 0, 100)
/// returns 110. Passing true as the sixth parameter
/// constrains the remapped value to the target range.
/// For example, map(11, 0, 10, 0, 100, true) returns 100.
/// </example>
/// <param name="value">The value to be remapped</param>
/// <param name="start1">Lower bound of the value's current range</param>
/// <param name="stop1">Upper bound of the value's current range</param>
/// <param name="start2">Lower bound of the value's target range</param>
/// <param name="stop2">Upper bound of the value's target range</param>
/// <param name="withinBounds">Constrain the value to the newly mapped value</param>
/// <returns>Remapped number</returns>
public static float Map(float value, float start1, float stop1, float start2, float stop2, bool withinBounds = false)
{
var newval = (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
if (!withinBounds) {
return newval;
}
if (start2 < stop2) {
return float.Clamp(newval, start2, stop2);
} else {
return float.Clamp(newval, stop2, start2);
}
}
public static double Map(double value, double start1, double stop1, double start2, double stop2, bool withinBounds = false)
{
var newval = (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
if (!withinBounds) {
return newval;
}
if (start2 < stop2) {
return double.Clamp(newval, start2, stop2);
} else {
return double.Clamp(newval, stop2, start2);
}
}
}

1
utility/Math.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://ca2mnv07no1xb