2023-05-01 03:04:23 -04:00
|
|
|
using Content.Shared.Buckle;
|
2022-09-06 00:28:23 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.NPC.HTN.Preconditions;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the owner is buckled or not
|
|
|
|
|
/// </summary>
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class BuckledPrecondition : HTNPrecondition
|
2022-09-06 00:28:23 +10:00
|
|
|
{
|
2023-05-01 03:04:23 -04:00
|
|
|
private SharedBuckleSystem _buckle = default!;
|
2022-09-06 00:28:23 +10:00
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)] [DataField("isBuckled")] public bool IsBuckled = true;
|
|
|
|
|
|
|
|
|
|
public override void Initialize(IEntitySystemManager sysManager)
|
|
|
|
|
{
|
|
|
|
|
base.Initialize(sysManager);
|
2023-05-01 03:04:23 -04:00
|
|
|
_buckle = sysManager.GetEntitySystem<SharedBuckleSystem>();
|
2022-09-06 00:28:23 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsMet(NPCBlackboard blackboard)
|
|
|
|
|
{
|
|
|
|
|
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
|
|
|
|
|
|
|
|
|
return IsBuckled && _buckle.IsBuckled(owner) ||
|
|
|
|
|
!IsBuckled && !_buckle.IsBuckled(owner);
|
|
|
|
|
}
|
|
|
|
|
}
|