Add attribute system with core stats and gameplay components
This commit is contained in:
29
GameCore/Movement/RotationSystem.cs
Normal file
29
GameCore/Movement/RotationSystem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Input;
|
||||
|
||||
namespace GameCore.Movement;
|
||||
|
||||
public class RotationSystem : ISystem
|
||||
{
|
||||
private const float MinPitch = -(float)System.Math.PI / 2f;
|
||||
private const float MaxPitch = (float)System.Math.PI / 2f;
|
||||
|
||||
public void Update(World world, float deltaTime)
|
||||
{
|
||||
var entities = world.GetEntitiesWith<InputStateComponent>();
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var input = world.GetComponent<InputStateComponent>(entity);
|
||||
var rotation = world.GetComponent<RotationComponent>(entity);
|
||||
|
||||
if (input == null || rotation == null)
|
||||
continue;
|
||||
|
||||
rotation.Rotation.Y += input.LookDirection.Y;
|
||||
rotation.Rotation.X += input.LookDirection.X;
|
||||
|
||||
rotation.Rotation.X = System.Math.Clamp(rotation.Rotation.X, MinPitch, MaxPitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user