34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using Microsoft.Xna.Framework;
|
|
|
|
using Apos.Shapes;
|
|
|
|
using Syntriax.Engine.Core.Abstract;
|
|
using Syntriax.Engine.Physics2D.Primitives;
|
|
|
|
namespace Pong.Behaviours;
|
|
|
|
public class ShapeBehaviour : Syntriax.Engine.Physics2D.Collider2DShapeBehaviour, IDisplayableShape
|
|
{
|
|
public Color Color { get; set; } = Color.White;
|
|
public float Thickness { get; set; } = .5f;
|
|
|
|
public void Draw(ShapeBatch shapeBatch)
|
|
{
|
|
if (!IsActive)
|
|
return;
|
|
|
|
Recalculate();
|
|
|
|
int count = ShapeWorld.Vertices.Count;
|
|
|
|
for (int i = 0; i < count - 1; i++)
|
|
shapeBatch.DrawLine(ShapeWorld[i].ToDisplayVector2(), ShapeWorld[i + 1].ToDisplayVector2(), Thickness, Color, Color);
|
|
shapeBatch.DrawLine(ShapeWorld[0].ToDisplayVector2(), ShapeWorld[^1].ToDisplayVector2(), Thickness, Color, Color);
|
|
}
|
|
|
|
public ShapeBehaviour(Shape shape) : base(shape) { }
|
|
public ShapeBehaviour(Shape shape, float thickness) : base(shape) { Thickness = thickness; }
|
|
public ShapeBehaviour(Shape shape, Color color) : base(shape) { Color = color; }
|
|
public ShapeBehaviour(Shape shape, Color color, float thickness) : base(shape) { Thickness = thickness; Color = color; }
|
|
}
|