using System.Collections; using Artemis.Core; using Artemis.VisualScripting.Nodes.List.Screens; namespace Artemis.VisualScripting.Nodes.List; [Node("List Operator (Simple)", "Checks if any/all/no value in the input list matches the input value", "List", InputType = typeof(IEnumerable), OutputType = typeof(bool))] public class ListOperatorNode : Node { public ListOperatorNode() : base("List Operator", "Checks if any/all/no value in the input list matches the input value") { InputList = CreateInputPin(); InputValue = CreateInputPin(); Ouput = CreateOutputPin(); } public InputPin InputList { get; } public InputPin InputValue { get; } public OutputPin Ouput { get; } /// public override void Evaluate() { if (InputList.Value == null) { Ouput.Value = Storage == ListOperator.None; return; } object? input = InputValue.Value; if (Storage == ListOperator.Any) Ouput.Value = InputList.Value.Cast().Any(v => v.Equals(input)); else if (Storage == ListOperator.All) Ouput.Value = InputList.Value.Cast().All(v => v.Equals(input)); else if (Storage == ListOperator.All) Ouput.Value = InputList.Value.Cast().All(v => !v.Equals(input)); } } public enum ListOperator { Any, All, None }