using Shooter.Core.Components;
using Shooter.Core.Entities;
namespace Shooter.Gameplay.Components;
///
/// Navigation module that stores movement parameters for AI-controlled entities.
/// Based on Unity's NavigationModule pattern from the FPS sample.
///
/// UNITY COMPARISON:
/// Unity: NavigationModule as configuration component for NavMeshAgent
/// MonoGame: NavigationModule as configuration for manual movement system
///
public class NavigationModule : EntityComponent
{
///
/// Maximum movement speed in units per second.
/// Unity default: varies by enemy type (HoverBot: 5.0)
///
public float MoveSpeed { get; set; } = 5.0f;
///
/// Maximum rotation speed in degrees per second.
/// Unity default: 120 degrees/sec
///
public float AngularSpeed { get; set; } = 120f;
///
/// How quickly the entity accelerates to max speed (units per second squared).
/// Unity default: 50.0
///
public float Acceleration { get; set; } = 50.0f;
///
/// Current velocity (managed by movement system).
/// Unity equivalent: NavMeshAgent.velocity
///
public float CurrentSpeed { get; set; } = 0f;
///
/// Distance at which entity considers it has reached its destination.
/// Unity default: 2.0 units
///
public float PathReachingRadius { get; set; } = 2.0f;
///
/// Apply acceleration to current speed, clamped to MoveSpeed.
///
public void UpdateSpeed(float deltaTime, bool isMoving)
{
if (isMoving)
{
// Accelerate toward max speed
CurrentSpeed += Acceleration * deltaTime;
CurrentSpeed = Math.Min(CurrentSpeed, MoveSpeed);
}
else
{
// Decelerate to stop
CurrentSpeed -= Acceleration * deltaTime * 2f; // Decelerate faster than accelerate
CurrentSpeed = Math.Max(CurrentSpeed, 0f);
}
}
public override void Initialize()
{
base.Initialize();
CurrentSpeed = 0f;
}
}