Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Forge.Tests/Statescript/ExpressionResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Comparison_resolver_greater_than_returns_true_when_left_exceeds_righ
ComparisonOperation.GreaterThan,
new VariantResolver(new Variant128(10.0), typeof(double))));

var condition = new ExpressionConditionNode("isAboveThreshold");
var condition = new ExpressionNode("isAboveThreshold");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -71,7 +71,7 @@ public void Comparison_resolver_greater_than_returns_false_when_left_is_less()
ComparisonOperation.GreaterThan,
new VariantResolver(new Variant128(10.0), typeof(double))));

var condition = new ExpressionConditionNode("isAboveThreshold");
var condition = new ExpressionNode("isAboveThreshold");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -108,7 +108,7 @@ public void Comparison_resolver_equal_returns_true_for_matching_values()
ComparisonOperation.Equal,
new VariantResolver(new Variant128(42.0), typeof(double))));

var condition = new ExpressionConditionNode("isEqual");
var condition = new ExpressionNode("isEqual");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -148,7 +148,7 @@ public void Comparison_resolver_compares_two_graph_variables()
ComparisonOperation.GreaterThan,
new VariableResolver("threshold", typeof(double))));

var condition = new ExpressionConditionNode("isHealthAboveThreshold");
var condition = new ExpressionNode("isHealthAboveThreshold");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -185,7 +185,7 @@ public void Comparison_resolver_less_than_or_equal_at_boundary()
ComparisonOperation.LessThanOrEqual,
new VariantResolver(new Variant128(10.0), typeof(double))));

var condition = new ExpressionConditionNode("atBoundary");
var condition = new ExpressionNode("atBoundary");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -222,7 +222,7 @@ public void Comparison_resolver_not_equal_returns_true_for_different_values()
ComparisonOperation.NotEqual,
new VariantResolver(new Variant128(2.0), typeof(double))));

var condition = new ExpressionConditionNode("isDifferent");
var condition = new ExpressionNode("isDifferent");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -253,7 +253,7 @@ public void Expression_condition_node_returns_false_for_missing_property()
{
var graph = new Graph();

var condition = new ExpressionConditionNode("nonexistent");
var condition = new ExpressionNode("nonexistent");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -293,7 +293,7 @@ public void Comparison_resolver_works_with_int_operands()
ComparisonOperation.GreaterThanOrEqual,
new VariableResolver("requiredScore", typeof(int))));

var condition = new ExpressionConditionNode("hasEnoughScore");
var condition = new ExpressionNode("hasEnoughScore");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down Expand Up @@ -334,7 +334,7 @@ public void Comparison_resolver_works_with_attribute_resolver()
ComparisonOperation.GreaterThanOrEqual,
new VariableResolver("required", typeof(int))));

var condition = new ExpressionConditionNode("hasEnoughAttribute");
var condition = new ExpressionNode("hasEnoughAttribute");
var trueAction = new TrackingActionNode();
var falseAction = new TrackingActionNode();

Expand Down
5 changes: 5 additions & 0 deletions Forge/Statescript/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public abstract class Node
/// <param name="outputPorts">The list to add output ports to.</param>
protected abstract void DefinePorts(List<InputPort> inputPorts, List<OutputPort> outputPorts);

/// <summary>
/// Gets a description of the node type, which is used in editor tooltips and documentation.
/// </summary>
public virtual string Description => $"{GetType().Name.Replace("Node", string.Empty)} node.";

/// <summary>
/// Gets or sets the unique identifier for this node.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Forge/Statescript/Nodes/Action/SetVariableNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class SetVariableNode(StringKey sourcePropertyName, StringKey targetVaria

private readonly StringKey _targetVariableName = targetVariableName;

/// <inheritdoc/>
public override string Description => "Sets a graph variable to the value of a property.";

/// <inheritdoc/>
protected override void Execute(GraphContext graphContext)
{
Expand Down
3 changes: 3 additions & 0 deletions Forge/Statescript/Nodes/ActionNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public abstract class ActionNode : Node
/// <param name="graphContext">The current graph context.</param>
protected abstract void Execute(GraphContext graphContext);

/// <inheritdoc/>
public override string Description => $"A {GetType().Name.Replace("Node", string.Empty)} action node.";

/// <inheritdoc/>
#pragma warning disable SA1202 // Elements should be ordered by access
internal override IEnumerable<int> GetReachableOutputPorts(byte inputPortIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ namespace Gamesmiths.Forge.Statescript.Nodes.Condition;
/// </remarks>
/// <param name="conditionPropertyName">The name of the graph property that provides the condition result. Must resolve
/// to a <see langword="bool"/> value.</param>
public class ExpressionConditionNode(StringKey conditionPropertyName) : ConditionNode
public class ExpressionNode(StringKey conditionPropertyName) : ConditionNode
{
private readonly StringKey _conditionPropertyName = conditionPropertyName;

/// <inheritdoc/>
public override string Description => "Evaluates the given property to determine which port to activate.";

/// <inheritdoc/>
protected override bool Test(GraphContext graphContext)
{
Expand Down
3 changes: 3 additions & 0 deletions Forge/Statescript/Nodes/ConditionNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public abstract class ConditionNode : Node
/// <returns><see langword="true"/> if the condition is met; otherwise, <see langword="false"/>.</returns>
protected abstract bool Test(GraphContext graphContext);

/// <inheritdoc/>
public override string Description => $"A {GetType().Name.Replace("Node", string.Empty)} condition node.";

/// <inheritdoc/>
#pragma warning disable SA1202 // Elements should be ordered by access
internal override IEnumerable<int> GetReachableOutputPorts(byte inputPortIndex)
Expand Down
3 changes: 3 additions & 0 deletions Forge/Statescript/Nodes/EntryNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class EntryNode : Node
/// </summary>
public const byte OutputPort = 0;

/// <inheritdoc/>
public override string Description => "Entry point of the graph. Emits a message to start execution.";

/// <summary>
/// Starts the graph execution by emitting a message through the output port.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Forge/Statescript/Nodes/ExitNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class ExitNode : Node
/// </summary>
public const byte InputPort = 0;

/// <inheritdoc/>
public override string Description => "Exit point of the graph. Stops execution when a message is received.";

/// <inheritdoc/>
internal override IEnumerable<int> GetReachableOutputPorts(byte inputPortIndex)
{
Expand Down
3 changes: 3 additions & 0 deletions Forge/Statescript/Nodes/State/TimerNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class TimerNode(StringKey durationPropertyName) : StateNode<TimerNodeCont
{
private readonly StringKey _durationPropertyName = durationPropertyName;

/// <inheritdoc/>
public override string Description => "Remains active for a configured duration, then deactivates.";

/// <inheritdoc/>
protected override void OnActivate(GraphContext graphContext)
{
Expand Down
3 changes: 3 additions & 0 deletions Forge/Statescript/Nodes/StateNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public abstract class StateNode<T> : Node
/// <param name="graphContext">The graph's context.</param>
protected abstract void OnDeactivate(GraphContext graphContext);

/// <inheritdoc/>
public override string Description => $"A {GetType().Name.Replace("Node", string.Empty)} state node.";

/// <summary>
/// Updates this state node with the given delta time. Only processes the update if the node is currently active.
/// </summary>
Expand Down
Loading