diff --git a/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs b/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs index 970a408..ade2e75 100644 --- a/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs +++ b/VisualPinball.Engine.DOF.Unity/Runtime/Player/DofPlugin.cs @@ -244,7 +244,7 @@ private IPluginRealtimeOutputSource FeedOf(PluginResourceBinding + /// Whether DOF can follow a feed in this numbering. DOF takes the numbers as they come, so the configuration's rows + /// must use the same: VPinMAME's for PinMAME games, the service manual's for games numbered that way. + /// + private static bool Reads(string numbering) + => numbering == RealtimeOutputNumbering.PinMame || numbering == RealtimeOutputNumbering.ServiceManual; + private IDisposable Subscribe(IPluginRealtimeOutputSource source, DofGameSession session) { - if (source.Numbering != RealtimeOutputNumbering.PinMame) { + if (!Reads(source.Numbering)) { // A replacement DOF cannot follow; the source it replaced already faulted the session when it went. return new Subscription(() => { }); } diff --git a/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs b/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs index fa0e802..f7bf812 100644 --- a/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs +++ b/VisualPinball.Engine.DOF.Unity/Tests/DofPluginTests.cs @@ -681,6 +681,30 @@ public IEnumerator IgnoresAnAbandonedSnapshotAttempt() yield return host.Await(host.Plugin.Quiescence, "quiescence"); } + [UnityTest] + public IEnumerator FollowsAFeedInServiceManualNumbers() + { + const int universe = 350; + var host = Host(); + host.Import(universe, "vpetest,S12,L160"); + var feed = host.PublishFeed(RealtimeOutputNumbering.ServiceManual); + yield return host.Await(host.Plugin.PrepareGameAsync(host.Game(), CancellationToken.None), "prepare"); + Assert.That(host.Plugin.FollowsFeed, Is.True); + Assert.That(feed.HasReceivers, Is.True); + yield return host.Await(host.Plugin.StartGameAsync(CancellationToken.None), "start"); + + Assert.That(feed.BeginSnapshot(), Is.True); + feed.PublishSnapshot(RealtimeOutputKind.Solenoid, 12, 0); + feed.PublishSnapshot(RealtimeOutputKind.Lamp, 160, 0); + feed.EndSnapshot(); + feed.Publish(RealtimeOutputKind.Solenoid, 12, 255); + feed.Publish(RealtimeOutputKind.Lamp, 160, 255); + Expect(universe, f => f[0] == 255 && f[1] == 255, "the manual's numbers reach the configuration's rows"); + + yield return host.Await(host.Plugin.StopGameAsync(CancellationToken.None), "stop"); + yield return host.Await(host.Plugin.Quiescence, "quiescence"); + } + [UnityTest] public IEnumerator FollowsOnlyTheTriggersOfAFeedItCannotRead() {