Skip to content

Commit c616745

Browse files
committed
debug: Add span ball for switch s_spawn_ball.
1 parent 479bc2f commit c616745

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

VisualPinball.Engine.PinMAME.Unity/Runtime/PinMameGamelogicEngine.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)