Lamp Manager#282
Merged
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #282 +/- ##
==========================================
+ Coverage 56.89% 57.39% +0.49%
==========================================
Files 160 162 +2
Lines 9474 9599 +125
Branches 941 960 +19
==========================================
+ Hits 5390 5509 +119
- Misses 3855 3860 +5
- Partials 229 230 +1
Continue to review full report at Codecov.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a lamp manager to the editor and handles lamps during game play. Please check out the documentation for a more detailed high-level description.
It was a bit tested with the PinMAME branch, so it somewhat works. Thanks to @ecurtz who did the ground work.
Lamp changes can be sent in batches or individually. Gamelogic that knows about RGB lamps can also just send color changes (e.g. PinMAME doesn't, it just exposes three wires per lamp and we need to figure out ourselves which wires go together). If a batch of lamps contains RGB values for the same lamp, they are grouped and sent together. In short, the gamelogic engine has these events at its disposal to trigger lamp changes:
OnLampChanged- takes in an ID and an int valueOnLampsChanged- takes in a list of IDs and int valuesOnLampColorChanged- takes in an ID and a colorNote we always emit ints, although most lamps are typically binary. How the value is interpreted is set by the mapping config (0-1 vs 0-255). This makes it easy to re-use the same struct.
We've also implemented fading over multiple frames using Coroutines. Fading time should be calculated correctly, for example if a lamp has only faded out halfway when it's triggered again, fading in will only take half the time. Also, blinking was implemented. All this is part of
LightAuthoring.Player Changes
The
Playerclass got too big, so I've split it up:Player- lifecycle code and registrations, and a few APIs forwarded to the other classesLampPlayer- Lamp assignment and gameplay handlingCoilPlayer- Coil assignment and gameplay handing - has a reference toLampPlayerso it can forward coil lampsSwitchPlayer- Switch assignment and gamplay handling - has a reference to the input managerWirePlayer- Idem, references the input manager and the switches so it can hook into the sources.Those four are pretty much autonomous anyway, so having them in separate classes is much cleaner.
Other Changes
MonoBehaviours, which makes it less complicated to fetch them and customize the inspector.TODO