28 lines
991 B
C#
28 lines
991 B
C#
using Encompass;
|
|
using KavTest.Components;
|
|
using Microsoft.Xna.Framework;
|
|
|
|
namespace KavTest.Engines
|
|
{
|
|
[Reads(typeof(Transform3DComponent), typeof(AngularVelocityComponent))]
|
|
[Writes(typeof(Transform3DComponent))]
|
|
public class RotationEngine : Engine
|
|
{
|
|
public override void Update(double dt)
|
|
{
|
|
foreach (var entity in ReadEntities<AngularVelocityComponent>())
|
|
{
|
|
if (HasComponent<Transform3DComponent>(entity))
|
|
{
|
|
ref readonly var angularVelocityComponent = ref GetComponent<AngularVelocityComponent>(entity);
|
|
ref readonly var transformComponent = ref GetComponent<Transform3DComponent>(entity);
|
|
|
|
var angularVelocity = angularVelocityComponent.AngularVelocity * (float)dt;
|
|
|
|
SetComponent(entity, new Transform3DComponent(transformComponent.Transform.Rotate(angularVelocity)));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|