17
17
using System ;
18
18
using System . Collections . Generic ;
19
19
using System . Collections . ObjectModel ;
20
+ using System . Linq ;
20
21
using Unity . VisualScripting ;
21
22
using UnityEngine ;
22
23
using VisualPinball . Engine . Game . Engines ;
@@ -58,6 +59,9 @@ public int inputCount
58
59
[ DoNotSerialize ]
59
60
public ValueInput Value { get ; private set ; }
60
61
62
+ [ DoNotSerialize ]
63
+ private readonly Dictionary < string , float > _intensityMultipliers = new ( ) ;
64
+
61
65
protected override void Definition ( )
62
66
{
63
67
InputTrigger = ControlInput ( nameof ( InputTrigger ) , Process ) ;
@@ -105,7 +109,7 @@ private ControlOutput Process(Flow flow)
105
109
Player . SetLamp ( lampId , flow . GetValue < LampStatus > ( Value ) ) ;
106
110
break ;
107
111
case LampDataType . Intensity :
108
- Player . SetLamp ( lampId , flow . GetValue < float > ( Value ) ) ;
112
+ Player . SetLamp ( lampId , flow . GetValue < float > ( Value ) * GetIntensityMultiplier ( lampId ) ) ;
109
113
break ;
110
114
case LampDataType . Color :
111
115
Player . SetLamp ( lampId , flow . GetValue < UnityEngine . Color > ( Value ) . ToEngineColor ( ) ) ;
@@ -117,5 +121,22 @@ private ControlOutput Process(Flow flow)
117
121
118
122
return OutputTrigger ;
119
123
}
124
+
125
+ private float GetIntensityMultiplier ( string id )
126
+ {
127
+ if ( _intensityMultipliers . ContainsKey ( id ) ) {
128
+ return _intensityMultipliers [ id ] ;
129
+ }
130
+
131
+ var mapping = Player . LampMapping . FirstOrDefault ( l => l . Id == id ) ;
132
+ if ( mapping == null ) {
133
+ Debug . LogError ( $ "Unknown lamp ID { id } .") ;
134
+ _intensityMultipliers [ id ] = 1 ;
135
+ return 1 ;
136
+ }
137
+
138
+ _intensityMultipliers [ id ] = mapping . Type == LampType . Rgb ? 255 : 1 ;
139
+ return _intensityMultipliers [ id ] ;
140
+ }
120
141
}
121
142
}
0 commit comments