fish-station/Content.Server/_Sunrise/NPC/HTN/StandingStatePrecondition.cs
iertis d5ec9f0e5b
Фиксы апстрима (#2778)
Co-authored-by: Vigers Ray <vigersray@gmail.com>
2025-08-15 12:45:53 +03:00

25 lines
763 B
C#

using Content.Server.NPC.HTN.Preconditions;
using Content.Server.NPC;
using Content.Shared.Standing;
namespace Content.Server._Sunrise.NPC.HTN;
public sealed partial class StandingStatePrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("isStanding")]
public bool IsStanding = true;
public override bool IsMet(NPCBlackboard blackboard)
{
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
if (!_entManager.TryGetComponent<StandingStateComponent>(owner, out var standing))
return false;
return IsStanding && standing.Standing ||
!IsStanding && !standing.Standing;
}
}