Add project files.
This commit is contained in:
25
Examples/Nodify.StateMachine/Runner/Actions/CopyKeyAction.cs
Normal file
25
Examples/Nodify.StateMachine/Runner/Actions/CopyKeyAction.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Nodify.StateMachine
|
||||
{
|
||||
[BlackboardItem("Copy Key")]
|
||||
public class CopyKeyAction : IBlackboardAction
|
||||
{
|
||||
[BlackboardProperty("Source", BlackboardKeyType.Object)]
|
||||
public BlackboardProperty Source { get; set; }
|
||||
|
||||
[BlackboardProperty("Target", BlackboardKeyType.Object)]
|
||||
public BlackboardProperty Target { get; set; }
|
||||
|
||||
public Task Execute(Blackboard blackboard)
|
||||
{
|
||||
if (Source != Target && Source.IsKey && Target.IsKey)
|
||||
{
|
||||
var value = blackboard[Source];
|
||||
blackboard[Target] = value;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Nodify.StateMachine
|
||||
{
|
||||
[BlackboardItem("Set Value")]
|
||||
public class SetKeyValueAction : IBlackboardAction
|
||||
{
|
||||
[BlackboardProperty(BlackboardKeyType.Object)]
|
||||
public BlackboardProperty Key { get; set; }
|
||||
|
||||
[BlackboardProperty(BlackboardKeyType.Object, CanChangeType = true)]
|
||||
public BlackboardProperty Value { get; set; }
|
||||
|
||||
public Task Execute(Blackboard blackboard)
|
||||
{
|
||||
var value = blackboard.GetValue<int>(Value);
|
||||
blackboard[Key] = value;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Nodify.StateMachine
|
||||
{
|
||||
[BlackboardItem("Set State Delay")]
|
||||
public class SetStateDelayAction : IBlackboardAction
|
||||
{
|
||||
[BlackboardProperty("Delay", BlackboardKeyType.Integer)]
|
||||
public BlackboardProperty Delay { get; set; }
|
||||
|
||||
[BlackboardProperty("Success", BlackboardKeyType.Boolean, Usage = BlackboardKeyUsage.Output)]
|
||||
public BlackboardProperty Success { get; set; }
|
||||
|
||||
public Task Execute(Blackboard blackboard)
|
||||
{
|
||||
var delay = blackboard.GetValue<int>(Delay);
|
||||
|
||||
if (delay.HasValue)
|
||||
{
|
||||
blackboard[DebugBlackboardDecorator.StateDelayKey] = delay;
|
||||
}
|
||||
|
||||
blackboard[Success] = delay.HasValue;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user