21 lines
594 B
C#
21 lines
594 B
C#
using Encompass;
|
|
using PongFE.Components;
|
|
using PongFE.Messages;
|
|
|
|
namespace PongFE.Engines
|
|
{
|
|
[Sends(typeof(MotionMessage))]
|
|
[QueryWith(typeof(PositionComponent), typeof(VelocityComponent))]
|
|
public class VelocityEngine : Engine
|
|
{
|
|
public override void Update(double dt)
|
|
{
|
|
foreach (var entity in TrackedEntities)
|
|
{
|
|
ref readonly var velocityComponent = ref GetComponent<VelocityComponent>(entity);
|
|
SendMessage(new MotionMessage(entity, velocityComponent.Velocity * (float)dt));
|
|
}
|
|
}
|
|
}
|
|
}
|