@@ -101,8 +101,12 @@ public GamelogicEngineLamp[] RequestedLamps {
101101
102102 [ NonSerialized ] private Player _player ;
103103 [ NonSerialized ] private PinMame . PinMame _pinMame ;
104+ [ NonSerialized ] private BallManager _ballManager ;
105+ [ NonSerialized ] private PlayfieldComponent _playfieldComponent ;
106+
104107 [ SerializeReference ] private PinMameGame _game ;
105108
109+
106110 private Dictionary < string , GamelogicEngineSwitch > _switches = new ( ) ;
107111 private Dictionary < int , string > _pinMameIdToSwitchIdMappings = new ( ) ;
108112 private Dictionary < string , int > _switchIdToPinMameIdMappings = new ( ) ;
@@ -218,6 +222,8 @@ private void OnDestroy()
218222 public void OnInit ( Player player , TableApi tableApi , BallManager ballManager )
219223 {
220224 string vpmPath = null ;
225+ _ballManager = ballManager ;
226+ _playfieldComponent = GetComponentInChildren < PlayfieldComponent > ( ) ;
221227
222228 #if ( UNITY_IOS || UNITY_ANDROID ) && ! UNITY_EDITOR
223229 vpmPath = Path . Combine ( Application . persistentDataPath , "pinmame" ) ;
@@ -712,6 +718,10 @@ public void Switch(string id, bool isClosed)
712718 }
713719 Logger . Info ( $ "[PinMAME] => sw { id } : { isClosed } | { _switches [ id ] . Description } ") ;
714720 _pinMame . SetSwitch ( _switchIdToPinMameIdMappings [ _switches [ id ] . Id ] , isClosed ) ;
721+ } else if ( id == "s_spawn_ball" ) {
722+ if ( isClosed ) {
723+ _ballManager . CreateBall ( new DebugBallCreator ( 630 , _playfieldComponent . Height / 2f , _playfieldComponent . TableHeight ) ) ;
724+ }
715725 } else {
716726 Logger . Error ( $ "[PinMAME] Unknown switch \" { id } \" .") ;
717727 }
0 commit comments