update position engine
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
ecd131a021
commit
5afc3fc29a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue