using Artemis.VisualScripting.Attributes; using Artemis.VisualScripting.Model; namespace Artemis.VisualScripting.Nodes { [UI("To String", "Converts the input to a string.")] public class ConvertToStringNode : Node { #region Properties & Fields public InputPin Input { get; } public OutputPin String { get; } #endregion #region Constructors public ConvertToStringNode() : base("To String", "Converts the input to a string.") { Input = CreateInputPin(); String = CreateOutputPin(); } #endregion #region Methods public override void Evaluate() { String.Value = Input.Value?.ToString(); } #endregion } [UI("To Integer", "Converts the input to an integer.")] public class ConvertToIntegerNode : Node { #region Properties & Fields public InputPin Input { get; } public OutputPin Integer { get; } #endregion #region Constructors public ConvertToIntegerNode() : base("To Integer", "Converts the input to an integer.") { Input = CreateInputPin(); Integer = CreateOutputPin(); } #endregion #region Methods public override void Evaluate() { if (!int.TryParse(Input.Value?.ToString(), out int value)) value = 0; Integer.Value = value; } #endregion } [UI("To Double", "Converts the input to a double.")] public class ConvertToDoubleNode : Node { #region Properties & Fields public InputPin Input { get; } public OutputPin Double { get; } #endregion #region Constructors public ConvertToDoubleNode() : base("To Double", "Converts the input to a double.") { Input = CreateInputPin(); Double = CreateOutputPin(); } #endregion #region Methods public override void Evaluate() { if (!double.TryParse(Input.Value?.ToString(), out double value)) value = 0; Double.Value = value; } #endregion } }