diff --git a/content/pong/ball/bouncing/motion_engine.md b/content/pong/ball/bouncing/motion_engine.md index 579c253..5b115f6 100644 --- a/content/pong/ball/bouncing/motion_engine.md +++ b/content/pong/ball/bouncing/motion_engine.md @@ -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()) + { + SetComponent(message.Entity, new PositionComponent(message.Position)); + } + } + } +} +``` + Now we can send these messages in **MotionEngine**. ```cs