Add pathfinding support for NPCs climbing tables (#17415)

This commit is contained in:
Vordenburg
2023-07-28 02:37:29 -04:00
committed by GitHub
parent 494b9e5b93
commit 49f3f07e30
11 changed files with 114 additions and 15 deletions

View File

@@ -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();