Add TryGetNpc (#19553)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user