* 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
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators;
|
|
|
|
/// <summary>
|
|
/// Waits the specified amount of time. Removes the key when finished.
|
|
/// </summary>
|
|
public sealed class WaitOperator : HTNOperator
|
|
{
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
/// <summary>
|
|
/// Blackboard key for the time we'll wait for.
|
|
/// </summary>
|
|
[DataField("key", required: true)] public string Key = string.Empty;
|
|
|
|
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
|
|
{
|
|
if (!blackboard.TryGetValue<float>(Key, out var timer, _entManager))
|
|
{
|
|
return HTNOperatorStatus.Finished;
|
|
}
|
|
|
|
timer -= frameTime;
|
|
blackboard.SetValue(Key, timer);
|
|
|
|
return timer <= 0f ? HTNOperatorStatus.Finished : HTNOperatorStatus.Continuing;
|
|
}
|
|
|
|
public override void TaskShutdown(NPCBlackboard blackboard, HTNOperatorStatus status)
|
|
{
|
|
base.TaskShutdown(blackboard, status);
|
|
|
|
// The replacement plan may want this value so only dump it if we're successful.
|
|
if (status != HTNOperatorStatus.BetterPlan)
|
|
{
|
|
blackboard.Remove<float>(Key);
|
|
}
|
|
}
|
|
}
|