Added Custom Interaction Handlers to Interactable Parts#1984
Draft
TechTastic wants to merge 2 commits intoDonBruce64:masterfrom
Draft
Added Custom Interaction Handlers to Interactable Parts#1984TechTastic wants to merge 2 commits intoDonBruce64:masterfrom
TechTastic wants to merge 2 commits intoDonBruce64:masterfrom
Conversation
…InteractionHandler`, and `PartInteractable.registerCustomInteractionHandler` Expanded `PartInteractable` constructor switch case, `PartInteractable.interact` switch case, `PartInteractable.remove`, and `PartInteractable.update` switch case to handle the selected custom interaction handler
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.
So, as part of my addon, Computerized Vehicles, I wanted to add an onboard computer via an interactable part. Unfortunately, despite much trial and error, I did not succeed. So, I have made yet another PR to expand what IV/MTS can do for mod integration!
To do this in a way where it did not apply to just computer mods, I added the new
InteractableComponentType.CUSTOMenum value and a newcustomInteractionHandlerfield that is only required when the interaction type is set to custom.Within
PartInteractable, I proceeded to add the new staticCUSTOM_INTRACTION_HANDLERSfield which is aMap<String, CustomInteractionHandler>.CustomInteractionHandlerbeing a new nested interface with functions to be called. Inside the constructor, I expanded the switch statement to include the custom type and to call theCustomInteractionHandlerspecified by the JSON. Likewise, I did the same forinteract. and finally, withinremove,update, andsave, I also implemented the necessary calls forCustomInteraction Handler.So, for example, lets say Computerized Vehicles setup an
CustomInteractionHandlerlike so:To utilize this new handler, the
interactableJSON section would contain this:With this, not only can I add onboard CC: Tweaked computers to vehicles, but anyone wanting to add new interactables with custom behavior can as well!