@@ -100,20 +100,20 @@ public GamelogicEngineLamp[] RequestedLamps {
100
100
[ NonSerialized ] private PinMame . PinMame _pinMame ;
101
101
[ SerializeReference ] private PinMameGame _game ;
102
102
103
- private Dictionary < string , GamelogicEngineSwitch > _switches = new Dictionary < string , GamelogicEngineSwitch > ( ) ;
104
- private Dictionary < int , GamelogicEngineCoil > _coils = new Dictionary < int , GamelogicEngineCoil > ( ) ;
105
- private Dictionary < int , GamelogicEngineLamp > _lamps = new Dictionary < int , GamelogicEngineLamp > ( ) ;
103
+ private Dictionary < string , GamelogicEngineSwitch > _switches = new ( ) ;
104
+ private Dictionary < int , GamelogicEngineCoil > _coils = new ( ) ;
105
+ private Dictionary < int , GamelogicEngineLamp > _lamps = new ( ) ;
106
106
107
107
private bool _isRunning ;
108
108
private int _numMechs ;
109
- private Dictionary < int , byte [ ] > _frameBuffer = new Dictionary < int , byte [ ] > ( ) ;
110
- private Dictionary < int , Dictionary < byte , byte > > _dmdLevels = new Dictionary < int , Dictionary < byte , byte > > ( ) ;
109
+ private Dictionary < int , byte [ ] > _frameBuffer = new ( ) ;
110
+ private Dictionary < int , Dictionary < byte , byte > > _dmdLevels = new ( ) ;
111
111
112
112
private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
113
- private static readonly Color Tint = new Color ( 1 , 0.18f , 0 ) ;
113
+ private static readonly Color Tint = new ( 1 , 0.18f , 0 ) ;
114
114
115
- private readonly Queue < Action > _dispatchQueue = new Queue < Action > ( ) ;
116
- private readonly Queue < float [ ] > _audioQueue = new Queue < float [ ] > ( ) ;
115
+ private readonly Queue < Action > _dispatchQueue = new ( ) ;
116
+ private readonly Queue < float [ ] > _audioQueue = new ( ) ;
117
117
118
118
private int _audioFilterChannels ;
119
119
private PinMameAudioInfo _audioInfo ;
@@ -570,26 +570,25 @@ public bool GetCoil(string id)
570
570
571
571
private void OnSolenoidUpdated ( int internalId , bool isActive )
572
572
{
573
- if ( _coils . ContainsKey ( internalId ) )
574
- {
575
- if ( ! _solenoidsEnabled )
576
- {
577
- _solenoidsEnabled = ( DateTimeOffset . Now . ToUnixTimeMilliseconds ( ) - _solenoidDelayStart ) >= SolenoidDelay ;
573
+ if ( _coils . ContainsKey ( internalId ) ) {
578
574
579
- if ( _solenoidsEnabled )
580
- {
575
+ if ( ! _solenoidsEnabled ) {
576
+ _solenoidsEnabled = DateTimeOffset . Now . ToUnixTimeMilliseconds ( ) - _solenoidDelayStart >= SolenoidDelay ;
577
+
578
+ if ( _solenoidsEnabled ) {
581
579
Logger . Info ( $ "Solenoids enabled, { SolenoidDelay } ms passed") ;
582
580
}
583
581
}
584
582
585
- if ( _solenoidsEnabled )
586
- {
587
- Logger . Info ( $ "[PinMAME] <= coil { _coils [ internalId ] . Id } ({ internalId } ): { isActive } | { _coils [ internalId ] . Description } ") ;
583
+ if ( _solenoidsEnabled ) {
584
+ var coil = _coils [ internalId ] ;
585
+ var id = coil != null ? coil . Id : internalId . ToString ( ) ;
586
+ var desc = coil != null ? coil . Description : "-" ;
587
+ Logger . Info ( $ "[PinMAME] <= coil { id } ({ internalId } ): { isActive } | { desc } ") ;
588
588
589
- lock ( _dispatchQueue )
590
- {
591
- _dispatchQueue . Enqueue ( ( ) =>
592
- OnCoilChanged ? . Invoke ( this , new CoilEventArgs ( _coils [ internalId ] . Id , isActive ) ) ) ;
589
+ lock ( _dispatchQueue ) {
590
+ id = _coils [ internalId ] . Id ;
591
+ _dispatchQueue . Enqueue ( ( ) => OnCoilChanged ? . Invoke ( this , new CoilEventArgs ( id , isActive ) ) ) ;
593
592
}
594
593
}
595
594
else
0 commit comments