Skip to content

Commit 45904d9

Browse files
committed
api: Support bridge API
1 parent 54cff39 commit 45904d9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public GamelogicEngineLamp[] AvailableLamps {
7979
public GamelogicEngineWire[] AvailableWires => _game?.AvailableWires ?? Array.Empty<GamelogicEngineWire>();
8080

8181
public event EventHandler<CoilEventArgs> OnCoilChanged;
82+
public event EventHandler<SwitchEventArgs2> OnSwitchChanged;
8283
public event EventHandler<LampEventArgs> OnLampChanged;
8384
public event EventHandler<LampsEventArgs> OnLampsChanged;
8485
public event EventHandler<LampColorEventArgs> OnLampColorChanged;
@@ -559,6 +560,8 @@ public void Switch(string id, bool isClosed)
559560
} else {
560561
Logger.Error($"[PinMAME] Unknown switch \"{id}\".");
561562
}
563+
564+
OnSwitchChanged?.Invoke(this, new SwitchEventArgs2(id, isClosed));
562565
}
563566

564567
public static DisplayFrameFormat GetDisplayFrameFormat(PinMameDisplayLayout layout)
@@ -611,5 +614,22 @@ public static DisplayFrameFormat GetDisplayFrameFormat(PinMameDisplayLayout layo
611614

612615
throw new NotImplementedException($"Still unsupported segmented display format: {layout}.");
613616
}
617+
618+
619+
public void SetCoil(string n, bool value)
620+
{
621+
OnCoilChanged?.Invoke(this, new CoilEventArgs(n, value));
622+
}
623+
624+
public void SetLamp(string id, int value, bool isCoil = false, LampSource source = LampSource.Lamp)
625+
{
626+
OnLampChanged?.Invoke(this, new LampEventArgs(id, value, isCoil, source));
627+
}
628+
629+
public void SetLamp(string id, Color color)
630+
{
631+
OnLampColorChanged?.Invoke(this, new LampColorEventArgs(id, color));
632+
}
633+
614634
}
615635
}

0 commit comments

Comments
 (0)