namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Linq;
[StepType(StepTypeAttribute.TesterStep)]
public class DoubleTester : OutputStep<double>
{
[UnityEngine.SerializeField]
SinglePort<double> _in = new();
[UnityEngine.SerializeField]
double _value;
[UnityEngine.SerializeField]
string _displayName = nameof(DoubleTester);
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
public override bool IsValid => true;
public override double Run(EffectInput blackBoard) {
var value = _in.Node.Run(blackBoard);
if (value == _value) {
UnityEngine.Debug.Log($"<color=green>PASSED: {this} Got {value}</color>");
}
else {
UnityEngine.Debug.Log($"<color=red>FAILED: {this} Got {value}</color>");
}
return value;
}
public override string ToString() {
return $"{_displayName} Expected {_value}";
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Const = new() { _value };
effectStepNodeData.DisplayName = _displayName;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
_value = effectStepNodeData.Const != null ? effectStepNodeData.Const.FirstOrDefault() : default;
_displayName = effectStepNodeData.DisplayName;
return true;
}
}
}