using Encompass; using KavTest.Components; using KavTest.Messages; using Microsoft.Xna.Framework; namespace KavTest.Engines { [Reads(typeof(AngularVelocityComponent), typeof(ContinuousRotationComponent))] [Sends(typeof(LocalRotationMessage))] public class AngularVelocityEngine : Engine { public override void Update(double dt) { foreach (var entity in ReadEntities()) { ref readonly var angularVelocityComponent = ref GetComponent(entity); var angularVelocity = angularVelocityComponent.AngularVelocity * (float)dt; SendMessage(new LocalRotationMessage(entity, Quaternion.CreateFromYawPitchRoll(angularVelocity.X, angularVelocity.Y, angularVelocity.Z))); } foreach (var entity in ReadEntities()) { ref readonly var rotationComponent = ref GetComponent(entity); SendMessage(new LocalRotationMessage(entity, rotationComponent.Quaternion)); } } } }