Compare commits
	
		
			1 Commits
		
	
	
		
			bc1c76d746
			...
			c8bb991865
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c8bb991865 | 
@@ -4,7 +4,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Integration.MonoGame;
 | 
			
		||||
 | 
			
		||||
public class DrawableShapeBehaviour : Behaviour2D, IDrawableTriangle, IPreDraw
 | 
			
		||||
public class DrawableShape : Behaviour2D, IDrawableTriangle, IPreDraw
 | 
			
		||||
{
 | 
			
		||||
    private readonly Shape2D shape = new([]);
 | 
			
		||||
    private readonly List<Triangle> worldTriangles = [];
 | 
			
		||||
@@ -23,7 +23,7 @@ public class DrawableShapeBehaviour : Behaviour2D, IDrawableTriangle, IPreDraw
 | 
			
		||||
 | 
			
		||||
    protected void UpdateWorldShape() => shape.Transform(Transform, worldShape);
 | 
			
		||||
 | 
			
		||||
    public DrawableShapeBehaviour() => shape = Shape2D.Triangle;
 | 
			
		||||
    public DrawableShapeBehaviour(Shape2D shape) => this.shape = shape;
 | 
			
		||||
    public DrawableShapeBehaviour(Shape2D shape, ColorRGB color) { this.shape = shape; this.color = color; }
 | 
			
		||||
    public DrawableShape() => shape = Shape2D.Triangle;
 | 
			
		||||
    public DrawableShape(Shape2D shape) => this.shape = shape;
 | 
			
		||||
    public DrawableShape(Shape2D shape, ColorRGB color) { this.shape = shape; this.color = color; }
 | 
			
		||||
}
 | 
			
		||||
@@ -8,7 +8,7 @@ using Syntriax.Engine.Systems.Input;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Integration.MonoGame;
 | 
			
		||||
 | 
			
		||||
public class KeyboardInputsBehaviour : Behaviour, IButtonInputs<Keys>, IUpdate
 | 
			
		||||
public class KeyboardInputs : Behaviour, IButtonInputs<Keys>, IUpdate
 | 
			
		||||
{
 | 
			
		||||
    public Event<IButtonInputs<Keys>, IButtonInputs<Keys>.ButtonCallbackArguments> OnAnyButtonPressed { get; } = new();
 | 
			
		||||
    public Event<IButtonInputs<Keys>, IButtonInputs<Keys>.ButtonCallbackArguments> OnAnyButtonReleased { get; } = new();
 | 
			
		||||
@@ -5,7 +5,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Integration.MonoGame;
 | 
			
		||||
 | 
			
		||||
public class MonoGameCamera2DBehaviour : BehaviourBase, ICamera2D, IFirstFrameUpdate, IPreDraw
 | 
			
		||||
public class MonoGameCamera2D : BehaviourBase, ICamera2D, IFirstFrameUpdate, IPreDraw
 | 
			
		||||
{
 | 
			
		||||
    public event MatrixTransformChangedArguments? OnMatrixTransformChanged = null;
 | 
			
		||||
    public event ViewportChangedArguments? OnViewportChanged = null;
 | 
			
		||||
@@ -103,7 +103,7 @@ public class MonoGameCamera2DBehaviour : BehaviourBase, ICamera2D, IFirstFrameUp
 | 
			
		||||
    protected sealed override void InitializeInternal() => Transform = BehaviourController.GetRequiredBehaviour<ITransform2D>();
 | 
			
		||||
    protected sealed override void FinalizeInternal() => Transform = null!;
 | 
			
		||||
 | 
			
		||||
    public delegate void MatrixTransformChangedArguments(MonoGameCamera2DBehaviour sender);
 | 
			
		||||
    public delegate void ViewportChangedArguments(MonoGameCamera2DBehaviour sender);
 | 
			
		||||
    public delegate void ZoomChangedArguments(MonoGameCamera2DBehaviour sender);
 | 
			
		||||
    public delegate void MatrixTransformChangedArguments(MonoGameCamera2D sender);
 | 
			
		||||
    public delegate void ViewportChangedArguments(MonoGameCamera2D sender);
 | 
			
		||||
    public delegate void ZoomChangedArguments(MonoGameCamera2D sender);
 | 
			
		||||
}
 | 
			
		||||
@@ -9,14 +9,14 @@ public class SpriteBatcher : BehaviourBase, IFirstFrameUpdate, IDraw
 | 
			
		||||
    private static Comparer<IBehaviour> SortByPriority() => Comparer<IBehaviour>.Create((x, y) => y.Priority.CompareTo(x.Priority));
 | 
			
		||||
 | 
			
		||||
    private ISpriteBatch spriteBatch = null!;
 | 
			
		||||
    private MonoGameCamera2DBehaviour camera2D = null!;
 | 
			
		||||
    private MonoGameCamera2D camera2D = null!;
 | 
			
		||||
 | 
			
		||||
    private readonly ActiveBehaviourCollectorSorted<IDrawableSprite> drawableSprites = new() { SortBy = SortByPriority() };
 | 
			
		||||
 | 
			
		||||
    public void FirstActiveFrame()
 | 
			
		||||
    {
 | 
			
		||||
        MonoGameWindowContainer windowContainer = Universe.FindRequiredBehaviour<MonoGameWindowContainer>();
 | 
			
		||||
        camera2D = Universe.FindRequiredBehaviour<MonoGameCamera2DBehaviour>();
 | 
			
		||||
        camera2D = Universe.FindRequiredBehaviour<MonoGameCamera2D>();
 | 
			
		||||
 | 
			
		||||
        spriteBatch = new SpriteBatchWrapper(windowContainer.Window.GraphicsDevice);
 | 
			
		||||
        drawableSprites.Unassign();
 | 
			
		||||
 
 | 
			
		||||
@@ -11,13 +11,13 @@ public class TriangleBatcher : BehaviourBase, ITriangleBatch, IFirstFrameUpdate,
 | 
			
		||||
    private static Comparer<IBehaviour> SortByAscendingPriority() => Comparer<IBehaviour>.Create((x, y) => x.Priority.CompareTo(y.Priority));
 | 
			
		||||
 | 
			
		||||
    private TriangleBatch triangleBatch = null!;
 | 
			
		||||
    private MonoGameCamera2DBehaviour camera2D = null!;
 | 
			
		||||
    private MonoGameCamera2D camera2D = null!;
 | 
			
		||||
    private readonly ActiveBehaviourCollectorSorted<IDrawableTriangle> drawableShapes = new() { SortBy = SortByAscendingPriority() };
 | 
			
		||||
 | 
			
		||||
    public void FirstActiveFrame()
 | 
			
		||||
    {
 | 
			
		||||
        MonoGameWindowContainer windowContainer = BehaviourController.UniverseObject.Universe.FindRequiredBehaviour<MonoGameWindowContainer>();
 | 
			
		||||
        camera2D = BehaviourController.UniverseObject.Universe.FindRequiredBehaviour<MonoGameCamera2DBehaviour>();
 | 
			
		||||
        camera2D = BehaviourController.UniverseObject.Universe.FindRequiredBehaviour<MonoGameCamera2D>();
 | 
			
		||||
 | 
			
		||||
        triangleBatch = new(windowContainer.Window.GraphicsDevice);
 | 
			
		||||
        drawableShapes.Unassign();
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Physics2D;
 | 
			
		||||
 | 
			
		||||
public abstract class Collider2DBehaviourBase : Behaviour2D, ICollider2D
 | 
			
		||||
public abstract class Collider2DBase : Behaviour2D, ICollider2D
 | 
			
		||||
{
 | 
			
		||||
    public Event<ICollider2D, CollisionDetectionInformation> OnCollisionDetected { get; } = new();
 | 
			
		||||
    public Event<ICollider2D, CollisionDetectionInformation> OnCollisionResolved { get; } = new();
 | 
			
		||||
@@ -18,7 +18,7 @@ public abstract class Collider2DBehaviourBase : Behaviour2D, ICollider2D
 | 
			
		||||
    protected bool NeedsRecalculation { get; set; } = true;
 | 
			
		||||
    protected IRigidBody2D? _rigidBody2D = null;
 | 
			
		||||
 | 
			
		||||
    protected Collider2DBehaviourBase()
 | 
			
		||||
    protected Collider2DBase()
 | 
			
		||||
    {
 | 
			
		||||
        delegateOnBehaviourAddedToController = OnBehaviourAddedToController;
 | 
			
		||||
        delegateOnBehaviourRemovedFromController = OnBehaviourRemovedFromController;
 | 
			
		||||
@@ -2,7 +2,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Physics2D;
 | 
			
		||||
 | 
			
		||||
public class Collider2DCircleBehaviour : Collider2DBehaviourBase, ICircleCollider2D
 | 
			
		||||
public class Collider2DCircle : Collider2DBase, ICircleCollider2D
 | 
			
		||||
{
 | 
			
		||||
    private Circle _circleLocal = Circle.UnitCircle;
 | 
			
		||||
 | 
			
		||||
@@ -19,6 +19,6 @@ public class Collider2DCircleBehaviour : Collider2DBehaviourBase, ICircleCollide
 | 
			
		||||
 | 
			
		||||
    public override void CalculateCollider() => CircleWorld = Transform.Transform(_circleLocal);
 | 
			
		||||
 | 
			
		||||
    public Collider2DCircleBehaviour() { }
 | 
			
		||||
    public Collider2DCircleBehaviour(Circle circle) => CircleLocal = circle;
 | 
			
		||||
    public Collider2DCircle() { }
 | 
			
		||||
    public Collider2DCircle(Circle circle) => CircleLocal = circle;
 | 
			
		||||
}
 | 
			
		||||
@@ -2,7 +2,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Physics2D;
 | 
			
		||||
 | 
			
		||||
public class Collider2DShapeBehaviour : Collider2DBehaviourBase, IShapeCollider2D
 | 
			
		||||
public class Collider2DShape : Collider2DBase, IShapeCollider2D
 | 
			
		||||
{
 | 
			
		||||
    public Shape2D ShapeWorld { get => _shapeWorld; protected set => _shapeWorld = value; }
 | 
			
		||||
    public Shape2D ShapeLocal
 | 
			
		||||
@@ -20,8 +20,8 @@ public class Collider2DShapeBehaviour : Collider2DBehaviourBase, IShapeCollider2
 | 
			
		||||
 | 
			
		||||
    public override void CalculateCollider() => ShapeLocal.Transform(Transform, _shapeWorld);
 | 
			
		||||
 | 
			
		||||
    public Collider2DShapeBehaviour() { }
 | 
			
		||||
    public Collider2DShapeBehaviour(Shape2D shape)
 | 
			
		||||
    public Collider2DShape() { }
 | 
			
		||||
    public Collider2DShape(Shape2D shape)
 | 
			
		||||
    {
 | 
			
		||||
        ShapeLocal = shape;
 | 
			
		||||
    }
 | 
			
		||||
@@ -2,7 +2,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Systems.Time;
 | 
			
		||||
 | 
			
		||||
public class StopwatchBehaviour : Behaviour, IUpdate, IStopwatch
 | 
			
		||||
public class Stopwatch : Behaviour, IUpdate, IStopwatch
 | 
			
		||||
{
 | 
			
		||||
    public Event<IReadOnlyStopwatch> OnStarted { get; } = new();
 | 
			
		||||
    public Event<IReadOnlyStopwatch, IReadOnlyStopwatch.StopwatchDeltaArguments> OnDelta { get; } = new();
 | 
			
		||||
@@ -2,7 +2,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Systems.Time;
 | 
			
		||||
 | 
			
		||||
public class TickerBehaviour : StopwatchBehaviour, ITicker
 | 
			
		||||
public class Ticker : Stopwatch, ITicker
 | 
			
		||||
{
 | 
			
		||||
    public Event<ITicker> OnTick { get; } = new();
 | 
			
		||||
 | 
			
		||||
@@ -2,7 +2,7 @@ using Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Systems.Time;
 | 
			
		||||
 | 
			
		||||
public class TimerBehaviour : Behaviour, IUpdate, ITimer
 | 
			
		||||
public class Timer : Behaviour, IUpdate, ITimer
 | 
			
		||||
{
 | 
			
		||||
    public Event<IReadOnlyTimer> OnStarted { get; } = new();
 | 
			
		||||
    public Event<IReadOnlyTimer, IReadOnlyTimer.TimerDeltaArguments> OnDelta { get; } = new();
 | 
			
		||||
		Reference in New Issue
	
	Block a user