A game about forced loneliness, made by TACStudios
1using System; 2 3namespace Unity.VisualScripting 4{ 5 public sealed class UnitPortDescription : IDescription 6 { 7 private string _label; 8 9 private bool _isLabelVisible = true; 10 11 internal IUnitPort portType; 12 13 public EditorTexture icon 14 { 15 get 16 { 17 if (_icon == null || !_icon.IsValid()) 18 { 19 _icon = GetIcon(portType); 20 } 21 22 return _icon; 23 } 24 set => _icon = value; 25 } 26 27 private EditorTexture _icon; 28 29 public string fallbackLabel { get; set; } 30 31 public string label 32 { 33 get => _label ?? fallbackLabel; 34 set => _label = value; 35 } 36 37 public bool showLabel 38 { 39 get => !BoltFlow.Configuration.hidePortLabels || _isLabelVisible; 40 set => _isLabelVisible = value; 41 } 42 43 string IDescription.title => label; 44 45 public string summary { get; set; } 46 47 public Func<Metadata, Metadata> getMetadata { get; set; } 48 49 public void CopyFrom(UnitPortDescription other) 50 { 51 _label = other._label; 52 _isLabelVisible = other._isLabelVisible; 53 summary = other.summary; 54 portType = other.portType ?? portType; 55 getMetadata = other.getMetadata ?? getMetadata; 56 } 57 58 private static EditorTexture GetIcon(IUnitPort portType) 59 { 60 if (portType is IUnitControlPort) 61 { 62 return typeof(Flow).Icon(); 63 } 64 else if (portType is IUnitValuePort) 65 { 66 return Icons.Type(((IUnitValuePort)portType).type); 67 } 68 else if (portType is IUnitInvalidPort) 69 { 70 return BoltCore.Resources.icons.errorState; 71 } 72 else 73 { 74 // throw new NotSupportedException(); 75 return null; 76 } 77 } 78 } 79}