42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using Microsoft.Xna.Framework;
|
|
|
|
using Apos.Shapes;
|
|
|
|
using Syntriax.Engine.Core;
|
|
using Syntriax.Engine.Physics2D.Primitives;
|
|
using Syntriax.Engine.Physics2D.Abstract;
|
|
|
|
namespace Pong.Behaviours;
|
|
|
|
public class ShapeAABBBehaviour : BehaviourOverride, IDisplayableShape
|
|
{
|
|
private Shape transformedShape = new([]);
|
|
private IShapeCollider2D? shapeCollider = null;
|
|
private readonly static Vector2D screenScale = Vector2D.Down + Vector2D.Right;
|
|
|
|
public ShapeAABBBehaviour() { }
|
|
public ShapeAABBBehaviour(float Thickness) { this.Thickness = Thickness; }
|
|
public ShapeAABBBehaviour(Color color) { Color = color; }
|
|
public ShapeAABBBehaviour(Color color, float Thickness) { this.Thickness = Thickness; Color = color; }
|
|
|
|
public Color Color { get; set; } = Color.White;
|
|
public float Thickness { get; set; } = .5f;
|
|
|
|
protected override void OnFirstActiveFrame()
|
|
{
|
|
BehaviourController.TryGetBehaviour(out shapeCollider);
|
|
}
|
|
|
|
public void Draw(ShapeBatch shapeBatch)
|
|
{
|
|
if (shapeCollider is null)
|
|
return;
|
|
|
|
AABB aabb = AABB.FromVectors(shapeCollider.ShapeWorld);
|
|
|
|
shapeBatch.BorderCircle(aabb.Center.ToDisplayVector2(), 7.5f, Color.Beige);
|
|
|
|
shapeBatch.DrawRectangle(aabb.Center.Scale(screenScale).Subtract(aabb.SizeHalf).ToVector2(), aabb.Size.ToVector2(), Color.Transparent, Color.Blue);
|
|
}
|
|
}
|