30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
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<AngularVelocityComponent>())
|
|
{
|
|
ref readonly var angularVelocityComponent = ref GetComponent<AngularVelocityComponent>(entity);
|
|
var angularVelocity = angularVelocityComponent.AngularVelocity * (float)dt;
|
|
|
|
SendMessage(new LocalRotationMessage(entity, Quaternion.CreateFromYawPitchRoll(angularVelocity.X, angularVelocity.Y, angularVelocity.Z)));
|
|
}
|
|
|
|
foreach (var entity in ReadEntities<ContinuousRotationComponent>())
|
|
{
|
|
ref readonly var rotationComponent = ref GetComponent<ContinuousRotationComponent>(entity);
|
|
SendMessage(new LocalRotationMessage(entity, rotationComponent.Quaternion));
|
|
}
|
|
}
|
|
}
|
|
}
|