1414// You should have received a copy of the GNU General Public License
1515// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
17+ using System . Collections . Generic ;
1718using Unity . VisualScripting ;
19+ using UnityEngine ;
1820
1921namespace VisualPinball . Unity . VisualScripting
2022{
@@ -23,9 +25,19 @@ namespace VisualPinball.Unity.VisualScripting
2325 [ UnitCategory ( "Events\\ Visual Pinball" ) ]
2426 public class SwitchEnabledEventUnit : GleEventUnit < SwitchEventArgs2 >
2527 {
28+ [ SerializeAs ( nameof ( idCount ) ) ]
29+ private int _idCount = 1 ;
30+
2631 [ DoNotSerialize ]
27- [ PortLabel ( "Switch ID" ) ]
28- public ValueInput Id { get ; private set ; }
32+ [ Inspectable , UnitHeaderInspectable ( "Switch IDs" ) ]
33+ public int idCount
34+ {
35+ get => _idCount ;
36+ set => _idCount = Mathf . Clamp ( value , 1 , 10 ) ;
37+ }
38+
39+ [ DoNotSerialize ]
40+ public List < ValueInput > Ids { get ; private set ; }
2941
3042 [ DoNotSerialize ]
3143 protected override bool register => true ;
@@ -36,12 +48,24 @@ public class SwitchEnabledEventUnit : GleEventUnit<SwitchEventArgs2>
3648 protected override void Definition ( )
3749 {
3850 base . Definition ( ) ;
39- Id = ValueInput ( nameof ( Id ) , string . Empty ) ;
51+
52+ Ids = new List < ValueInput > ( ) ;
53+
54+ for ( var i = 0 ; i < idCount ; i ++ ) {
55+ var id = ValueInput < string > ( "Switch ID " + ( i + 1 ) , string . Empty ) ;
56+ Ids . Add ( id ) ;
57+ }
4058 }
4159
4260 protected override bool ShouldTrigger ( Flow flow , SwitchEventArgs2 args )
4361 {
44- return flow . GetValue < string > ( Id ) == args . Id && args . IsEnabled ;
62+ foreach ( var id in Ids ) {
63+ if ( flow . GetValue < string > ( id ) == args . Id && args . IsEnabled ) {
64+ return true ;
65+ }
66+ }
67+
68+ return false ;
4569 }
4670 }
4771}
0 commit comments