Add TryGetNpc (#19553)

This commit is contained in:
metalgearsloth
2023-08-26 13:45:29 +10:00
committed by GitHub
parent d1eea3f6f6
commit 7dbd8f8b7a
3 changed files with 20 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Content.Server.Administration.Managers;
using Content.Server.Destructible;
using Content.Server.NPC.HTN;
using Content.Server.NPC.Systems;
using Content.Shared.Administration;
using Content.Shared.NPC;
using Robust.Server.Player;
@@ -44,10 +45,9 @@ namespace Content.Server.NPC.Pathfinding
[Dependency] private readonly DestructibleSystem _destructible = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
private ISawmill _sawmill = default!;
private readonly Dictionary<ICommonSession, PathfindingDebugMode> _subscribedSessions = new();
[ViewVariables]
@@ -66,7 +66,6 @@ namespace Content.Server.NPC.Pathfinding
public override void Initialize()
{
base.Initialize();
_sawmill = Logger.GetSawmill("nav");
_playerManager.PlayerStatusChanged += OnPlayerChange;
InitializeGrid();
SubscribeNetworkEvent<RequestPathfindingDebugMessage>(OnBreadcrumbs);
@@ -418,7 +417,7 @@ namespace Content.Server.NPC.Pathfinding
public PathFlags GetFlags(EntityUid uid)
{
if (!TryComp<HTNComponent>(uid, out var npc))
if (!_npc.TryGetNpc(uid, out var npc))
{
return PathFlags.None;
}