Context steering for NPCs (#12915)

This commit is contained in:
metalgearsloth
2022-12-12 14:33:43 +11:00
committed by GitHub
parent 881ba0d48d
commit 7910bd3ff4
17 changed files with 952 additions and 228 deletions

View File

@@ -0,0 +1,32 @@
using Robust.Shared.Serialization;
namespace Content.Shared.NPC.Events;
/// <summary>
/// Client debug data for NPC steering
/// </summary>
[Serializable, NetSerializable]
public sealed class NPCSteeringDebugEvent : EntityEventArgs
{
public List<NPCSteeringDebugData> Data;
public NPCSteeringDebugEvent(List<NPCSteeringDebugData> data)
{
Data = data;
}
}
[Serializable, NetSerializable]
public readonly record struct NPCSteeringDebugData(
EntityUid EntityUid,
Vector2 Direction,
float[] Interest,
float[] Danger,
List<Vector2> DangerPoints)
{
public readonly EntityUid EntityUid = EntityUid;
public readonly Vector2 Direction = Direction;
public readonly float[] Interest = Interest;
public readonly float[] Danger = Danger;
public readonly List<Vector2> DangerPoints = DangerPoints;
}

View File

@@ -0,0 +1,12 @@
using Robust.Shared.Serialization;
namespace Content.Shared.NPC.Events;
/// <summary>
/// Raised from client to server to request NPC steering debug info.
/// </summary>
[Serializable, NetSerializable]
public sealed class RequestNPCSteeringDebugEvent : EntityEventArgs
{
public bool Enabled;
}

View File

@@ -23,24 +23,26 @@ public enum PathfindingDebugMode : ushort
/// <summary>
/// Shows all of the pathfinding polys.
/// </summary>
Polys = 1 << 6,
Polys = 1 << 3,
/// <summary>
/// Shows the edges between pathfinding polys.
/// </summary>
PolyNeighbors = 1 << 7,
PolyNeighbors = 1 << 4,
/// <summary>
/// Shows the nearest poly to the mouse cursor.
/// </summary>
Poly = 1 << 8,
Poly = 1 << 5,
/// <summary>
/// Gets a path from the current attached entity to the mouse cursor.
/// </summary>
Path = 1 << 9,
// Path = 1 << 6,
Routes = 1 << 10,
Routes = 1 << 6,
RouteCosts = 1 << 11,
RouteCosts = 1 << 7,
Steering = 1 << 8,
}

View File

@@ -0,0 +1,16 @@
namespace Content.Shared.NPC;
public abstract class SharedNPCSteeringSystem : EntitySystem
{
public const byte InterestDirections = 12;
/// <summary>
/// How many radians between each interest direction.
/// </summary>
public const float InterestRadians = MathF.Tau / InterestDirections;
/// <summary>
/// How many degrees between each interest direction.
/// </summary>
public const float InterestDegrees = 360f / InterestDirections;
}