mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 10:51:14 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
24 lines
875 B
C#
24 lines
875 B
C#
using Content.Shared.Hands.EntitySystems;
|
|
|
|
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Interactions;
|
|
|
|
/// <summary>
|
|
/// Uses the item in the NPC's active hand.
|
|
/// </summary>
|
|
public sealed partial class UseItemInHandOperator : HTNOperator
|
|
{
|
|
[Dependency] private IEntityManager _entManager = default!;
|
|
|
|
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
|
|
{
|
|
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
|
|
|
if (!blackboard.TryGetValue<string>(NPCBlackboard.ActiveHand, out var activeHand, _entManager))
|
|
return HTNOperatorStatus.Failed;
|
|
|
|
var handsSystem = _entManager.System<SharedHandsSystem>();
|
|
var success = handsSystem.TryUseItemInHand(owner, handName: activeHand);
|
|
|
|
return success ? HTNOperatorStatus.Finished : HTNOperatorStatus.Failed;
|
|
}
|
|
}
|