2022-04-10 16:48:11 +12:00
|
|
|
using Content.Server.AI.EntitySystems;
|
2022-05-10 13:43:30 -05:00
|
|
|
using Content.Server.Station.Systems;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Movement.Components;
|
2020-08-25 04:11:32 +10:00
|
|
|
using Content.Shared.Roles;
|
2019-08-10 05:19:52 -07:00
|
|
|
using Robust.Shared.Map;
|
2020-08-25 04:11:32 +10:00
|
|
|
using Robust.Shared.Prototypes;
|
2019-04-04 16:18:43 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.AI.Components
|
2019-04-04 16:18:43 +02:00
|
|
|
{
|
2021-03-08 04:09:59 +11:00
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
[Virtual]
|
2022-06-26 15:20:45 +10:00
|
|
|
public class AiControllerComponent : Component
|
2019-04-04 16:18:43 +02:00
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("logic")] private float _visionRadius = 8.0f;
|
2019-04-04 16:18:43 +02:00
|
|
|
|
2021-12-05 14:08:35 +11:00
|
|
|
// TODO: Need to ECS a lot more of the AI first before we can ECS this
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether the AI is actively iterated.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Awake
|
|
|
|
|
{
|
|
|
|
|
get => _awake;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_awake == value) return;
|
|
|
|
|
|
|
|
|
|
_awake = value;
|
|
|
|
|
|
|
|
|
|
if (_awake)
|
|
|
|
|
EntitySystem.Get<NPCSystem>().WakeNPC(this);
|
|
|
|
|
else
|
|
|
|
|
EntitySystem.Get<NPCSystem>().SleepNPC(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataField("awake")]
|
|
|
|
|
private bool _awake = true;
|
|
|
|
|
|
2019-08-10 05:19:52 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2019-04-04 16:18:43 +02:00
|
|
|
public float VisionRadius
|
|
|
|
|
{
|
|
|
|
|
get => _visionRadius;
|
|
|
|
|
set => _visionRadius = value;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-10 05:19:52 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Is the entity Sprinting (running)?
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables]
|
2020-06-24 02:21:20 +02:00
|
|
|
public bool Sprinting { get; } = true;
|
2019-08-10 05:19:52 -07:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Calculated linear velocity direction of the entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public Vector2 VelocityDir { get; set; }
|
|
|
|
|
|
2021-02-20 17:37:17 +11:00
|
|
|
public virtual void Update(float frameTime) {}
|
2019-04-04 16:18:43 +02:00
|
|
|
}
|
|
|
|
|
}
|