Context steering for NPCs (#12915)
This commit is contained in:
32
Content.Shared/NPC/Events/NPCSteeringDebugEvent.cs
Normal file
32
Content.Shared/NPC/Events/NPCSteeringDebugEvent.cs
Normal 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;
|
||||
}
|
||||
12
Content.Shared/NPC/Events/RequestNPCSteeringDebugEvent.cs
Normal file
12
Content.Shared/NPC/Events/RequestNPCSteeringDebugEvent.cs
Normal 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;
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
16
Content.Shared/NPC/SharedNPCSteeringSystem.cs
Normal file
16
Content.Shared/NPC/SharedNPCSteeringSystem.cs
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user