From 5afc3fc29ae7eabbb923e1b940049c0cb950f917 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Mon, 27 Jul 2020 12:47:54 -0700 Subject: [PATCH] update position engine --- content/pong/ball/bouncing/motion_engine.md | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) 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