Add bounds hazards and triggers

This commit is contained in:
2026-04-16 11:50:37 +02:00
parent c79d5c8f0a
commit 45181d1f78
17 changed files with 405 additions and 25 deletions

View File

@@ -0,0 +1,28 @@
using System.Diagnostics.CodeAnalysis;
using SideScrollerGame.Sim.Math;
namespace SideScrollerGame.Sim.Definitions;
[ExcludeFromCodeCoverage]
public sealed record AxisAlignedBounds
{
public AxisAlignedBounds(FixPointVector2 min, FixPointVector2 max)
{
Min = min;
Max = max;
}
public bool Contains(FixPointVector2 position)
{
return position.m_X >= Min.m_X && position.m_X <= Max.m_X && position.m_Y >= Min.m_Y && position.m_Y <= Max.m_Y;
}
public FixPointVector2 Clamp(FixPointVector2 position)
{
return new(FixPoint16.Clamp(position.m_X, Min.m_X, Max.m_X), FixPoint16.Clamp(position.m_Y, Min.m_Y, Max.m_Y));
}
public FixPointVector2 Min { get; init; }
public FixPointVector2 Max { get; init; }
}