chore: updated engine to use MonoGame integrations
This commit is contained in:
@@ -9,7 +9,7 @@ using Syntriax.Engine.Systems.Input;
|
||||
|
||||
namespace Pong.Behaviours;
|
||||
|
||||
public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : Behaviour2D, IPostPhysicsUpdate,
|
||||
public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : Behaviour2D, IFirstFrameUpdate, IPostPhysicsUpdate,
|
||||
IPacketListenerServer<PaddleBehaviour.PaddleKeyStatePacket>, IPacketListenerClient<PaddleBehaviour.PaddleKeyStatePacket>
|
||||
{
|
||||
private Keys Up { get; } = Up;
|
||||
@@ -32,7 +32,7 @@ public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Sp
|
||||
Transform.Position = new Vector2D(Transform.Position.X, MathF.Max(MathF.Min(Transform.Position.Y, High), Low));
|
||||
}
|
||||
|
||||
protected override void OnFirstActiveFrame()
|
||||
public void FirstActiveFrame()
|
||||
{
|
||||
physicsEngine2D = Universe.GetRequiredUniverseObject<IPhysicsEngine2D>();
|
||||
inputs = Universe.FindRequired<IButtonInputs<Keys>>();
|
||||
@@ -99,14 +99,18 @@ public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Sp
|
||||
public bool IsDownPressed { get; set; } = default!;
|
||||
public long Timestamp { get; set; } = 0;
|
||||
|
||||
public PaddleKeyStatePacket() { }
|
||||
public PaddleKeyStatePacket(PaddleBehaviour paddleBehaviour)
|
||||
public PaddleKeyStatePacket Set(PaddleBehaviour paddleBehaviour)
|
||||
{
|
||||
EntityId = paddleBehaviour.Id;
|
||||
Position = paddleBehaviour.Transform.Position;
|
||||
IsUpPressed = paddleBehaviour.isUpPressed;
|
||||
IsDownPressed = paddleBehaviour.isDownPressed;
|
||||
Timestamp = DateTime.UtcNow.Ticks;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PaddleKeyStatePacket() { }
|
||||
public PaddleKeyStatePacket(PaddleBehaviour paddleBehaviour) => Set(paddleBehaviour);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user