update position engine
continuous-integration/drone/push Build is passing Details

main
Evan Hemsley 2020-07-27 12:47:54 -07:00
parent ecd131a021
commit 5afc3fc29a
1 changed files with 24 additions and 0 deletions

View File

@ -195,6 +195,30 @@ namespace PongFE.Messages
This is pretty straightforward. We'll use this message to set an entity's position.
In **PongFE/Engines/UpdatePositionEngine.cs**:
```cs
using Encompass;
using PongFE.Components;
using PongFE.Messages;
namespace PongFE.Engines
{
[Receives(typeof(UpdatePositionMessage))]
[Writes(typeof(PositionComponent))]
public class UpdatePositionEngine : Engine
{
public override void Update(double dt)
{
foreach (ref readonly var message in ReadMessages<UpdatePositionMessage>())
{
SetComponent(message.Entity, new PositionComponent(message.Position));
}
}
}
}
```
Now we can send these messages in **MotionEngine**.
```cs