Skip to content

Commit 76b4abd

Browse files
Remove many MonoBehaviour inheritances
1 parent 8d2dcd2 commit 76b4abd

File tree

53 files changed

+335
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+335
-206
lines changed

Editor/Inspector/MpfMonitorInspector.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1010
// SOFTWARE.
1111

12-
using System;
1312
using System.Linq;
1413
using UnityEditor;
1514
using UnityEditor.UIElements;
1615
using UnityEngine;
1716
using UnityEngine.UIElements;
18-
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages;
17+
using VisualPinball.Engine.Mpf.Unity.MediaController.Ui;
1918

2019
namespace VisualPinball.Engine.Mpf.Unity.Editor
2120
{
22-
[CustomEditor(typeof(MonitorBase), editorForChildClasses: true), CanEditMultipleObjects]
21+
[
22+
CustomEditor(typeof(MonitoredVariableTextBase), editorForChildClasses: true),
23+
CanEditMultipleObjects
24+
]
2325
public class MpfMonitorInspector : UnityEditor.Editor
2426
{
2527
private HelpBox _missingGleHelpBox;

Runtime/MediaController/Core/BcpMessageHandlers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.Error;
1616
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.Goodbye;
1717
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.Hello;
18-
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.MachineVar;
18+
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.MachineVariable;
1919
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.Mode;
2020
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.PlayerAdded;
2121
using VisualPinball.Engine.Mpf.Unity.MediaController.Messages.PlayerTurnStart;

Runtime/MediaController/Messages/Device/Autofire/AutofireDeviceMonitor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class AutofireDeviceMonitor
2020
protected override ParseStateDelegate ParseState => AutofireDeviceMessage.FromStateJson;
2121
public event EventHandler<DeviceAttributeChangeEventArgs<bool>> EnabledChanged;
2222

23+
public AutofireDeviceMonitor(BcpInterface bcpInterface, string deviceName)
24+
: base(bcpInterface, deviceName) { }
25+
2326
protected override void HandleAttributeChange(DeviceAttributeChange change)
2427
{
2528
if (change.AttributeName == nameof(AutofireDeviceMessage.StateJson.enabled))

Runtime/MediaController/Messages/Device/BallDevice/BallDeviceMonitor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
namespace VisualPinball.Engine.Mpf.Unity.MediaController.Messages.Device.BallDevice
1515
{
16-
public class BallDeviceMonitor
17-
: DeviceMonitor<BallDeviceMessage, BallDeviceMessage.StateJson>
16+
public class BallDeviceMonitor : DeviceMonitor<BallDeviceMessage, BallDeviceMessage.StateJson>
1817
{
1918
protected override string Type => "ball_device";
2019
protected override ParseStateDelegate ParseState => BallDeviceMessage.FromStateJson;
@@ -23,6 +22,9 @@ public class BallDeviceMonitor
2322
public event EventHandler<DeviceAttributeChangeEventArgs<BallDeviceStatus>> StatusChanged;
2423
public event EventHandler<DeviceAttributeChangeEventArgs<int>> BallsChanged;
2524

25+
public BallDeviceMonitor(BcpInterface bcpInterface, string deviceName)
26+
: base(bcpInterface, deviceName) { }
27+
2628
protected override void HandleAttributeChange(DeviceAttributeChange change)
2729
{
2830
switch (change.AttributeName)

Runtime/MediaController/Messages/Device/ComboSwitch/ComboSwitchDeviceMonitor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class ComboSwitchDeviceMonitor
2020
protected override ParseStateDelegate ParseState => ComboSwitchDeviceMessage.FromStateJson;
2121
public event EventHandler<DeviceAttributeChangeEventArgs<ComboSwitchStatus>> StatusChanged;
2222

23+
public ComboSwitchDeviceMonitor(BcpInterface bcpInterface, string deviceName)
24+
: base(bcpInterface, deviceName) { }
25+
2326
protected override void HandleAttributeChange(DeviceAttributeChange change)
2427
{
2528
if (change.AttributeName == nameof(ComboSwitchDeviceMessage.StateJson.state))

Runtime/MediaController/Messages/Device/SpecificDeviceMonitor.cs renamed to Runtime/MediaController/Messages/Device/DeviceMonitor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ public abstract class DeviceMonitor<TMessage, TDeviceState>
1919
: MonitorBase<TMessage, DeviceMessage>
2020
where TMessage : SpecificDeviceMessageBase, IEquatable<TMessage>
2121
{
22-
[SerializeField]
2322
private string _deviceName;
2423

24+
protected DeviceMonitor(BcpInterface bcpInterface, string deviceName)
25+
: base(bcpInterface)
26+
{
27+
_deviceName = deviceName;
28+
}
29+
2530
protected override string BcpCommand => DeviceMessage.Command;
2631
protected abstract string Type { get; }
2732
protected delegate TMessage ParseStateDelegate(
File renamed without changes.

Runtime/MediaController/Messages/Device/Flipper/FlipperDeviceMonitor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class FlipperDeviceMonitor
2020
protected override ParseStateDelegate ParseState => FlipperDeviceMessage.FromStateJson;
2121
public event EventHandler<DeviceAttributeChangeEventArgs<bool>> EnabledChanged;
2222

23+
public FlipperDeviceMonitor(BcpInterface bcpInterface, string deviceName)
24+
: base(bcpInterface, deviceName) { }
25+
2326
protected override void HandleAttributeChange(DeviceAttributeChange change)
2427
{
2528
if (change.AttributeName == nameof(FlipperDeviceMessage.StateJson.enabled))

Runtime/MediaController/Messages/Device/Light/LightDeviceMonitor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class LightDeviceMonitor
2121
protected override ParseStateDelegate ParseState => LightDeviceMessage.FromStateJson;
2222
public event EventHandler<DeviceAttributeChangeEventArgs<Color>> ColorChanged;
2323

24+
public LightDeviceMonitor(BcpInterface bcpInterface, string deviceName)
25+
: base(bcpInterface, deviceName) { }
26+
2427
protected override void HandleAttributeChange(DeviceAttributeChange change)
2528
{
2629
if (change.AttributeName == nameof(LightDeviceMessage.StateJson.color))

Runtime/MediaController/Messages/Device/Playfield/PlayfieldDeviceMonitor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace VisualPinball.Engine.Mpf.Unity.MediaController.Messages.Device.Playfield
1515
{
16-
public class PlayfieldDeviceMessageHandler
16+
public class PlayfieldDeviceMonitor
1717
: DeviceMonitor<PlayfieldDeviceMessage, PlayfieldDeviceMessage.StateJson>
1818
{
1919
protected override string Type => "playfield";
@@ -23,6 +23,9 @@ public class PlayfieldDeviceMessageHandler
2323
public event EventHandler<DeviceAttributeChangeEventArgs<int>> BallsRequestedChanged;
2424
public event EventHandler<DeviceAttributeChangeEventArgs<int>> BallsChanged;
2525

26+
public PlayfieldDeviceMonitor(BcpInterface bcpInterface, string deviceName)
27+
: base(bcpInterface, deviceName) { }
28+
2629
protected override void HandleAttributeChange(DeviceAttributeChange change)
2730
{
2831
switch (change.AttributeName)

0 commit comments

Comments
 (0)