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

@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.NPC.Components;
using Content.Server.NPC.HTN;
using Content.Shared.CCVar;
@@ -77,6 +78,20 @@ namespace Content.Server.NPC.Systems
return Resolve(uid, ref active, false);
}
public bool TryGetNpc(EntityUid uid, [NotNullWhen(true)] out NPCComponent? component)
{
// If you add your own NPC components then add them here.
if (TryComp<HTNComponent>(uid, out var htn))
{
component = htn;
return true;
}
component = null;
return false;
}
/// <summary>
/// Allows the NPC to actively be updated.
/// </summary>