Shooting NPCs and more (#18042)

* Add pirate shooting

* Shooting working

* Basics working

* Refactor time

* More conversion

* Update primitives

* Update yml

* weh

* Building again

* Draft

* weh

* b

* Start shutdown

* Starting to take form

* Code side done

* is it worky

* Fix prototypes

* stuff

* Shitty working

* Juke events working

* Even more cleanup

* RTX

* Fix interaction combat mode and compquery

* GetAmmoCount relays

* Fix rotation speed

* Juke fixes

* fixes

* weh

* The collision avoidance never ends

* Fixes

* Pause support

* framework

* lazy

* Fix idling

* Fix drip

* goobed

* Fix takeover shutdown bug

* Merge fixes

* shitter

* Fix carpos
This commit is contained in:
metalgearsloth
2023-08-02 10:48:56 +10:00
committed by GitHub
parent 018e465fad
commit c31c848afd
103 changed files with 2089 additions and 810 deletions

View File

@@ -0,0 +1,53 @@
using System.Threading;
using System.Threading.Tasks;
using Content.Server.Hands.Systems;
using Content.Shared.Hands.Components;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Interactions;
/// <summary>
/// Swaps to any free hand.
/// </summary>
public sealed class SwapToFreeHandOperator : HTNOperator
{
[Dependency] private readonly IEntityManager _entManager = default!;
public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard, CancellationToken cancelToken)
{
if (!blackboard.TryGetValue<List<string>>(NPCBlackboard.FreeHands, out var hands, _entManager) ||
!_entManager.TryGetComponent<HandsComponent>(blackboard.GetValue<EntityUid>(NPCBlackboard.Owner), out var handsComp))
{
return (false, null);
}
foreach (var hand in hands)
{
return (true, new Dictionary<string, object>()
{
{
NPCBlackboard.ActiveHand, handsComp.Hands[hand]
},
{
NPCBlackboard.ActiveHandFree, true
},
});
}
return (false, null);
}
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
{
// TODO: Need interaction cooldown
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
var handSystem = _entManager.System<HandsSystem>();
if (!handSystem.TrySelectEmptyHand(owner))
{
return HTNOperatorStatus.Failed;
}
return HTNOperatorStatus.Finished;
}
}