Add AI components and systems for enhanced enemy behavior and pathfinding
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Input;
|
||||
using GameCore.Player;
|
||||
|
||||
namespace GameCore.Movement;
|
||||
|
||||
@@ -18,10 +19,28 @@ public class RotationSystem : ISystem
|
||||
var rotation = world.GetComponent<RotationComponent>(entity);
|
||||
|
||||
if (input == null || rotation == null)
|
||||
{
|
||||
world.Logger.Warn("RotationSystem: Missing InputStateComponent or RotationComponent.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (world.GetComponent<PlayerComponent>(entity) != null)
|
||||
{
|
||||
rotation.Rotation.Y += input.LookDirection.Y;
|
||||
rotation.Rotation.X += input.LookDirection.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.LookDirection.Length() > 0.001f)
|
||||
{
|
||||
var lookDir = input.LookDirection;
|
||||
rotation.Rotation.Y = (float)System.Math.Atan2(lookDir.X, lookDir.Z);
|
||||
|
||||
var horizontalDist = (float)System.Math.Sqrt(lookDir.X * lookDir.X + lookDir.Z * lookDir.Z);
|
||||
rotation.Rotation.X = -(float)System.Math.Atan2(lookDir.Y, horizontalDist);
|
||||
}
|
||||
}
|
||||
|
||||
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