A game about forced loneliness, made by TACStudios
1#pragma warning disable 618 2 3namespace Unity.VisualScripting 4{ 5 [UnitShortTitle("Get Variable")] 6 public abstract class GetVariableUnit : VariableUnit 7 { 8 protected GetVariableUnit() : base() { } 9 10 protected GetVariableUnit(string defaultName) : base(defaultName) { } 11 12 /// <summary> 13 /// The value of the variable. 14 /// </summary> 15 [DoNotSerialize] 16 [PortLabelHidden] 17 public ValueOutput value { get; private set; } 18 19 protected override void Definition() 20 { 21 base.Definition(); 22 23 value = ValueOutput(nameof(value), Get).PredictableIf(IsDefined); 24 25 Requirement(name, value); 26 } 27 28 protected virtual bool IsDefined(Flow flow) 29 { 30 var name = flow.GetValue<string>(this.name); 31 32 return GetDeclarations(flow)?.IsDefined(name) ?? false; 33 } 34 35 protected virtual object Get(Flow flow) 36 { 37 var name = flow.GetValue<string>(this.name); 38 39 return GetDeclarations(flow).Get(name); 40 } 41 } 42}