Skip to content

Add Trough Component#229

Merged
freezy merged 36 commits into
masterfrom
feature/trough
Nov 12, 2020
Merged

Add Trough Component#229
freezy merged 36 commits into
masterfrom
feature/trough

Conversation

@freezy
Copy link
Copy Markdown
Owner

@freezy freezy commented Oct 30, 2020

This PR adds support for trough devices and refactors the switch- and coil mapping so it supports multi-switch/coil devices. Closes #211. Supersedes and closes #228. User documentation can be found here.

The UI was solved a bit differently, since I didn't want to overload the source/destination dropdown. Mockup:

Final screen:

So in case of a Device, the Element column has now two fields, one for the device, and one for the switch/coil within the device.

Switch/Coil Devices

For coils, we now have ICoilableDevice (item), IApiCoilDevice (API) and ICoilDeviceAuthoring (component), for switches it's ISwitchableDevice, IApiSwitchDevice and ISwitchDeviceAuthoring.

In terms of auto-population, two more fields were added to the switch/coil objects, in order to match the necessary elements for the default tables.

Trough

For troughs, we now have a new GameItem with ID 101 that is read and written to the .vpx file. While the trough's runtime logic is in TroughApi, the switches and triggers are generated in the main Trough class based on its properties.

During runtime, the following happens:

  1. The player initializes all playfield items (including switch/coil devices)
  2. During Init(), the trough (which is both of the above) creates switch objects based on its configuration
  3. The player sets up the switch and coil mapping. Now the devices have generated their switch objects, the player can link them to the gamelogic engine.
  4. Game starts

The mentioned switch objects are instances of DeviceSwitch, which is a standalone implementation of IApiSwitch. It's basically a proxy where OnSwitch() can be called on and the event will be dispatched to the switch input(s) of the gamelogic engine.

Import: The converter automatically adds a trough when there is none. It also tries to bind it to Drain and BallRelease. The result is that importing the default table results with a working and fully set up trough.

Editor: In order to keep the inspector code DRY, the SurfaceField method has been refactored to be generic, so it supports the now necessary kicker- and trigger picker.

Other Changes

  • When an Item doesn't define its ItemGroupName, it's attached to the table root directly.
  • Item APIs now have a OnDestroy() method they can override in case they need to unsubscribe from any events.
  • Fixed a bug where rubber wasn't transformed. Fixes Rubbers: Height, Rot* related issues. #234.

TODO

  • Port actual trough logic from core.vbs
  • Check if we keep the jam switch and entry coil and discard if not
  • Proof-read documentation
  • Update switch- and coil documentation
  • Update switch- and coil unit tests
  • Refactor: Change components so we don't need to implement IRenderable
  • Fix: Ball Release doesn't always seem to work

@freezy freezy added unity Concerns the Unity project editor Editor-related changes for Unity player Related to the player scripting labels Oct 30, 2020
@freezy freezy added this to the Usable Player milestone Oct 30, 2020
@freezy freezy requested a review from ecurtz October 30, 2020 23:33
@freezy freezy requested a review from jsm174 October 30, 2020 23:34
@ecurtz
Copy link
Copy Markdown
Collaborator

ecurtz commented Oct 31, 2020

Did a sanity check on the documentation.

Copy link
Copy Markdown
Collaborator

@jsm174 jsm174 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome PR. Just a few nitpicks, nothing crazy. Can not wait to try this with WPCEmu!

Comment thread VisualPinball.Engine/VPT/Mappings/Mappings.cs Outdated
Comment thread VisualPinball.Engine/VPT/Trough/Trough.cs
Comment thread VisualPinball.Engine/VPT/Trough/TroughData.cs Outdated
@freezy freezy merged commit 20561dd into master Nov 12, 2020
@freezy freezy deleted the feature/trough branch November 12, 2020 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor Editor-related changes for Unity player Related to the player unity Concerns the Unity project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rubbers: Height, Rot* related issues. Switch Manager: Add support for additional sources

3 participants