Added new HTN operations and preconditions (#27486)
* Added new HTN operations & preconditions * Ok I forgot about partial * Namespace pierce the skies * Some fixes, debug and new operators * Bruh git eat my files
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Math;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key, and adds the value to that float
|
||||
/// </summary>
|
||||
public sealed partial class AddFloatOperator : HTNOperator
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
[DataField(required: true)]
|
||||
public string TargetKey = string.Empty;
|
||||
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float Amount;
|
||||
|
||||
public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard,
|
||||
CancellationToken cancelToken)
|
||||
{
|
||||
if (!blackboard.TryGetValue<float>(TargetKey, out var value, _entManager))
|
||||
return (false, null);
|
||||
|
||||
return (
|
||||
true,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ TargetKey, value + Amount }
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user