Add NPC stuck detection (#14410)

This commit is contained in:
metalgearsloth
2023-03-05 16:13:09 +11:00
committed by GitHub
parent bb4d5064ad
commit 28dbbbb734
3 changed files with 127 additions and 70 deletions

View File

@@ -2,6 +2,7 @@ using System.Threading;
using Content.Server.NPC.Pathfinding;
using Content.Shared.NPC;
using Robust.Shared.Map;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.NPC.Components;
@@ -39,12 +40,25 @@ public sealed class NPCSteeringComponent : Component
/// <summary>
/// Next time we can change our steering direction.
/// </summary>
[DataField("nextSteer", customTypeSerializer:typeof(TimeOffsetSerializer))]
public TimeSpan NextSteer = TimeSpan.Zero;
[DataField("lastSteerDirection")]
public Vector2 LastSteerDirection = Vector2.Zero;
public const int SteeringFrequency = 10;
/// <summary>
/// Last position we considered for being stuck.
/// </summary>
[DataField("lastStuckCoordinates")]
public EntityCoordinates LastStuckCoordinates;
[DataField("lastStuckTime", customTypeSerializer:typeof(TimeOffsetSerializer))]
public TimeSpan LastStuckTime;
public const float StuckDistance = 0.5f;
/// <summary>
/// Have we currently requested a path.
/// </summary>