Add AI components and systems for enhanced enemy behavior and pathfinding

This commit is contained in:
2025-10-30 21:53:20 +01:00
parent f65277e6b4
commit c7739de7d9
11 changed files with 370 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
using GameCore.AI;
using GameCore.ECS;
using GameCore.ECS.Interfaces;
using GameCore.Player;
@@ -8,12 +9,26 @@ public class PlayerInputSystem : ISystem
{
public void Update(World world, float deltaTime)
{
var playerEntities = world.GetEntitiesWith<PlayerComponent>();
if (!playerEntities.Any()) return;
var playerEntities = world.GetEntitiesWith<PlayerComponent>().ToList();
if (!playerEntities.Any())
{
world.Logger.Warn("No player entity found for input processing.");
return;
}
var playerEntity = playerEntities.First();
if (world.GetComponent<AIComponent>(playerEntity) != null)
{
world.Logger.Warn("Player entity has AIComponent; skipping input processing.");
return;
}
var inputState = world.GetComponent<InputStateComponent>(playerEntity);
if (inputState == null) return;
if (inputState == null)
{
world.Logger.Warn("Player entity is missing InputStateComponent; cannot process input.");
return;
}
inputState.MoveDirection = world.InputService.MoveDirection.Normalize();
inputState.LookDirection = world.InputService.LookDirection;