Fix NPC door prying (#15605)

This commit is contained in:
metalgearsloth
2023-04-21 15:05:29 +10:00
committed by GitHub
parent 2744ef81d8
commit e780c6a98a
7 changed files with 40 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ using Content.Server.Destructible;
using Content.Server.NPC.Components;
using Content.Server.NPC.Pathfinding;
using Content.Shared.CombatMode;
using Content.Shared.DoAfter;
using Content.Shared.Doors.Components;
using Content.Shared.NPC;
using Robust.Shared.Physics;
@@ -55,14 +56,27 @@ public sealed partial class NPCSteeringSystem
if ((poly.Data.CollisionLayer & mask) != 0x0 ||
(poly.Data.CollisionMask & layer) != 0x0)
{
var id = component.DoAfterId;
// Still doing what we were doing before.
var doAfterStatus = _doAfter.GetStatus(id);
switch (doAfterStatus)
{
case DoAfterStatus.Running:
return SteeringObstacleStatus.Continuing;
case DoAfterStatus.Cancelled:
return SteeringObstacleStatus.Failed;
}
var obstacleEnts = new List<EntityUid>();
GetObstacleEntities(poly, mask, layer, bodyQuery, obstacleEnts);
var isDoor = (poly.Data.Flags & PathfindingBreadcrumbFlag.Door) != 0x0;
var isAccess = (poly.Data.Flags & PathfindingBreadcrumbFlag.Access) != 0x0;
var isAccessRequired = (poly.Data.Flags & PathfindingBreadcrumbFlag.Access) != 0x0;
// Just walk into it stupid
if (isDoor && !isAccess)
if (isDoor && !isAccessRequired)
{
var doorQuery = GetEntityQuery<DoorComponent>();
@@ -80,16 +94,12 @@ public sealed partial class NPCSteeringSystem
return SteeringObstacleStatus.Continuing;
}
}
else
{
return SteeringObstacleStatus.Failed;
}
}
return SteeringObstacleStatus.Completed;
// If we get to here then didn't succeed for reasons.
}
if ((component.Flags & PathFlags.Prying) != 0x0 && isAccess && isDoor)
if ((component.Flags & PathFlags.Prying) != 0x0 && isDoor)
{
var doorQuery = GetEntityQuery<DoorComponent>();
@@ -101,8 +111,9 @@ public sealed partial class NPCSteeringSystem
// TODO: Use the verb.
if (door.State != DoorState.Opening)
_doors.TryPryDoor(ent, uid, uid, door, true);
_doors.TryPryDoor(ent, uid, uid, door, out id, force: true);
component.DoAfterId = id;
return SteeringObstacleStatus.Continuing;
}
}