A game about forced loneliness, made by TACStudios
1using System.Collections.Generic; 2using System.Collections.ObjectModel; 3using UnityEngine; 4 5namespace Unity.VisualScripting 6{ 7 public interface IMultiInputUnit : IUnit 8 { 9 int inputCount { get; set; } 10 11 ReadOnlyCollection<ValueInput> multiInputs { get; } 12 } 13 14 public abstract class MultiInputUnit<T> : Unit, IMultiInputUnit 15 { 16 [SerializeAs(nameof(inputCount))] 17 private int _inputCount = 2; 18 19 [DoNotSerialize] 20 protected virtual int minInputCount => 2; 21 22 [DoNotSerialize] 23 [Inspectable, UnitHeaderInspectable("Inputs")] 24 public virtual int inputCount 25 { 26 get 27 { 28 return _inputCount; 29 } 30 set 31 { 32 _inputCount = Mathf.Clamp(value, minInputCount, 10); 33 } 34 } 35 36 [DoNotSerialize] 37 public ReadOnlyCollection<ValueInput> multiInputs { get; protected set; } 38 39 protected override void Definition() 40 { 41 var _multiInputs = new List<ValueInput>(); 42 43 multiInputs = _multiInputs.AsReadOnly(); 44 45 for (var i = 0; i < inputCount; i++) 46 { 47 _multiInputs.Add(ValueInput<T>(i.ToString())); 48 } 49 } 50 51 protected void InputsAllowNull() 52 { 53 foreach (var input in multiInputs) 54 { 55 input.AllowsNull(); 56 } 57 } 58 } 59}