Add pathfinding support for NPCs climbing tables (#17415)
This commit is contained in:
@@ -20,8 +20,13 @@ public enum PathFlags : byte
|
||||
/// </summary>
|
||||
Smashing = 1 << 2,
|
||||
|
||||
/// <summary>
|
||||
/// Can we climb it like a table or railing.
|
||||
/// </summary>
|
||||
Climbing = 1 << 3,
|
||||
|
||||
/// <summary>
|
||||
/// Can we open stuff that requires interaction (e.g. click-open doors).
|
||||
/// </summary>
|
||||
Interact = 1 << 3,
|
||||
Interact = 1 << 4,
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public sealed partial class PathfindingSystem
|
||||
{
|
||||
var isDoor = (end.Data.Flags & PathfindingBreadcrumbFlag.Door) != 0x0;
|
||||
var isAccess = (end.Data.Flags & PathfindingBreadcrumbFlag.Access) != 0x0;
|
||||
var isClimb = (end.Data.Flags & PathfindingBreadcrumbFlag.Climb) != 0x0;
|
||||
|
||||
// TODO: Handling power + door prying
|
||||
// Door we should be able to open
|
||||
@@ -71,6 +72,10 @@ public sealed partial class PathfindingSystem
|
||||
{
|
||||
modifier += 10f + end.Data.Damage / 100f;
|
||||
}
|
||||
else if (isClimb && (request.Flags & PathFlags.Climbing) != 0x0)
|
||||
{
|
||||
modifier += 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0f;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Destructible;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Climbing;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.NPC;
|
||||
using Content.Shared.Physics;
|
||||
@@ -154,11 +155,12 @@ public sealed partial class PathfindingSystem
|
||||
var accessQuery = GetEntityQuery<AccessReaderComponent>();
|
||||
var destructibleQuery = GetEntityQuery<DestructibleComponent>();
|
||||
var doorQuery = GetEntityQuery<DoorComponent>();
|
||||
var climbableQuery = GetEntityQuery<ClimbableComponent>();
|
||||
var fixturesQuery = GetEntityQuery<FixturesComponent>();
|
||||
var physicsQuery = GetEntityQuery<PhysicsComponent>();
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
BuildBreadcrumbs(dirt[i], mapGridComp, accessQuery, destructibleQuery, doorQuery, fixturesQuery,
|
||||
physicsQuery, xformQuery);
|
||||
BuildBreadcrumbs(dirt[i], mapGridComp, accessQuery, destructibleQuery, doorQuery, climbableQuery,
|
||||
fixturesQuery, physicsQuery, xformQuery);
|
||||
});
|
||||
|
||||
const int Division = 4;
|
||||
@@ -423,6 +425,7 @@ public sealed partial class PathfindingSystem
|
||||
EntityQuery<AccessReaderComponent> accessQuery,
|
||||
EntityQuery<DestructibleComponent> destructibleQuery,
|
||||
EntityQuery<DoorComponent> doorQuery,
|
||||
EntityQuery<ClimbableComponent> climbableQuery,
|
||||
EntityQuery<FixturesComponent> fixturesQuery,
|
||||
EntityQuery<PhysicsComponent> physicsQuery,
|
||||
EntityQuery<TransformComponent> xformQuery)
|
||||
@@ -540,6 +543,11 @@ public sealed partial class PathfindingSystem
|
||||
flags |= PathfindingBreadcrumbFlag.Door;
|
||||
}
|
||||
|
||||
if (climbableQuery.HasComponent(ent))
|
||||
{
|
||||
flags |= PathfindingBreadcrumbFlag.Climb;
|
||||
}
|
||||
|
||||
if (destructibleQuery.TryGetComponent(ent, out var damageable))
|
||||
{
|
||||
damage += _destructible.DestroyedAt(ent, damageable).Float();
|
||||
|
||||
@@ -7,6 +7,7 @@ using Content.Server.Administration.Managers;
|
||||
using Content.Server.Destructible;
|
||||
using Content.Server.NPC.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Climbing;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.NPC;
|
||||
using Robust.Server.Player;
|
||||
@@ -436,6 +437,11 @@ namespace Content.Server.NPC.Pathfinding
|
||||
flags |= PathFlags.Smashing;
|
||||
}
|
||||
|
||||
if (blackboard.TryGetValue<bool>(NPCBlackboard.NavClimb, out var climb, EntityManager) && climb)
|
||||
{
|
||||
flags |= PathFlags.Climbing;
|
||||
}
|
||||
|
||||
if (blackboard.TryGetValue<bool>(NPCBlackboard.NavInteract, out var interact, EntityManager) && interact)
|
||||
{
|
||||
flags |= PathFlags.Interact;
|
||||
|
||||
Reference in New Issue
Block a user