Code/Nodes/Core/Constant.cs
namespace Nodebox.Nodes {
    [Description("Outputs a value of your choosing")]
    [Tag("Core")]
    public class Constant<T> : Node {
        public override (List<Pin> In, List<Pin> Out) InitialPins => (
            [
                Pin.New<T>()
            ],
            [
                Pin.New<T>()
            ]
        );

        public Constant() : base() {
            Value = default;
            if (typeof(T) == typeof(Color)) {
                Value = (T)(object)new Color(1f, 1f, 1f);
            }
        }

        public Constant(T value) : base() {
            Value = value;
        }

        public T Value {
            get => (T)this[0];
            set => this[0] = value;
        }

        public override void SetProperty(string name, object obj) {
            if (name == nameof(Value)) {
                Value = (T)obj;
            }
        }
    }
}


namespace Nodebox.Execution {
    using Nodebox.Nodes;
    using static ExecutionContext;

    public class ConstantImplementation<T> : Implementation {
        public override Type Target => typeof(Constant<T>);
        public override void Evaluate(ExecutionContext context, Node node) {
            var io = context.Store[node];
            io.SetOutput(0, io.GetInput<T>(0));
        }
    }
}