Skip to content

Commit 81f233d

Browse files
committed
mechs: Fix startup check.
1 parent d50a05f commit 81f233d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ public void OnInit(Player player, TableApi tableApi, BallManager ballManager)
174174
public void RegisterMech(PinMameMechComponent mechComponent)
175175
{
176176
var id = _numMechs++;
177-
if (id > _pinMame.GetMaxMechs()) {
178-
Logger.Error($"PinMAME only supports up to {_pinMame.GetMaxMechs()} custom mechs, ignoring {mechComponent.name}.");
179-
return;
180-
}
181177
_registeredMechs[id] = mechComponent;
182178
}
183179

@@ -489,7 +485,12 @@ public void SendInitialSwitches()
489485

490486
private void SendMechs()
491487
{
488+
var max = _pinMame.GetMaxMechs();
492489
foreach (var (id, mech) in _registeredMechs) {
490+
if (id > max) {
491+
Logger.Error($"PinMAME only supports up to {max} custom mechs, ignoring {mech.name}.");
492+
return;
493+
}
493494
var mechConfig = mech.Config(_player.SwitchMapping, _player.CoilMapping);
494495
_pinMame.SetMech(id, mechConfig);
495496
foreach (var c in mechConfig.SwitchList) {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,16 @@ public IEnumerable<GamelogicEngineCoil> AvailableCoils {
201201
private void Awake()
202202
{
203203
_gle = GetComponentInParent<PinMameGamelogicEngine>();
204-
if (_gle) {
204+
if (_gle && enabled) {
205205
_gle.RegisterMech(this);
206206
}
207207
}
208208

209+
private void Start()
210+
{
211+
// show disable checkbox in editor
212+
}
213+
209214
public void UpdateMech(PinMameMechInfo data)
210215
{
211216
OnMechUpdate?.Invoke(this, new MechEventArgs(data.Speed, data.Pos));

0 commit comments

Comments
 (0)