ECS NPCs (#9941)
* ECS * A * parity * Remove dummy update * abs * thanks rider
This commit is contained in:
7
Content.Server/AI/Components/ActiveNPCComponent.cs
Normal file
7
Content.Server/AI/Components/ActiveNPCComponent.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.AI.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Added to NPCs that are actively being updated.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class ActiveNPCComponent : Component {}
|
||||
@@ -1,60 +0,0 @@
|
||||
using Content.Server.AI.EntitySystems;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.AI.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Virtual]
|
||||
public class AiControllerComponent : Component
|
||||
{
|
||||
[DataField("logic")] private float _visionRadius = 8.0f;
|
||||
|
||||
// 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;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float VisionRadius
|
||||
{
|
||||
get => _visionRadius;
|
||||
set => _visionRadius = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the entity Sprinting (running)?
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool Sprinting { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Calculated linear velocity direction of the entity.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public Vector2 VelocityDir { get; set; }
|
||||
|
||||
public virtual void Update(float frameTime) {}
|
||||
}
|
||||
}
|
||||
17
Content.Server/AI/Components/NPCComponent.cs
Normal file
17
Content.Server/AI/Components/NPCComponent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Content.Server.AI.EntitySystems;
|
||||
|
||||
namespace Content.Server.AI.Components
|
||||
{
|
||||
[Access(typeof(NPCSystem))]
|
||||
public abstract class NPCComponent : Component
|
||||
{
|
||||
// TODO: Soon. I didn't realise how much effort it was to deprecate the old one.
|
||||
/// <summary>
|
||||
/// Contains all of the world data for a particular NPC in terms of how it sees the world.
|
||||
/// </summary>
|
||||
//[ViewVariables, DataField("blackboardA")]
|
||||
//public Dictionary<string, object> BlackboardA = new();
|
||||
|
||||
public float VisionRadius => 7f;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user