Implement Interact Trigger API for mods #1051
Open
+367
−2
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.
What is an Interact Trigger?
the Interact Trigger is a generalised trigger of which the function is to play a cutscene upon being interacted with, by pressing [Interact] while the player is within its bounds.
one particular feature of it is that it can have one or multiple events.
when it first appears, its "event index" begins at 0. this is used to get the current event, and is incremented on playing each event.
upon incrementing, a Session flag called
it_plus the name of the current event, is also set. this is used to keep track of which events are done even if the player goes to a different room and comes back.on the first interaction, the trigger plays event 1. then, given it has multiple events, on subsequent interactions it will play events 2, 3, and so on. when it has no more events to play (i.e. when its event index reaches the number of events it has), it disappears.
one thing to note however is that the event index increments on a local flag in the method, which is
trueby default.certain events have that flag set to
false, in which case the event index won't increment, theit_Session flag won't be set, no subsequent events will play, and the trigger won't disappear.this PR implements an interface which modders can use to write events for the Interact Trigger.
Everest.Events.InteractTrigger.OnInteractTriggerthis Everest Event accepts a method that returns a
booland has the following parameters:InteractTrigger trigger, Player player, string eventID, ref bool progressEvent.the method should check the
eventIDif it matches a custom event. if there's a match, it should set up the event in some way (e.g. by adding the appropriateCutsceneEntityto the scene) and then returntrue. if there are no matches, it should returnfalse.the parameters are explained as follows:
InteractTrigger trigger- the trigger that the player is using.Player player- the player using the trigger.string eventID- the ID for the current event.ref bool progressEvent- whether to progress to the next event (i.e. by incrementing the event index and setting the appropriate Session flag) or not. this istrueby default.[CustomInteract]attributethis attribute may be placed on a class that extends
CutsceneEntity(or any class that extendsEntity).it accepts a string (can accept multiple) that represents the ID of the event. it's recommended that each string be unique to the mod (e.g.
myCampaignMod_ch1_theo).it can also take an optional property argument
ProgressEvent =, which is a boolean andtrueby default. this indicates whether the trigger should progress to the next event and set the appropriate Session flag based on the event ID, or not.when this attribute is in place, the class requires a
publicconstructor of one of certain signatures for it to be registered. the following is checked in order:(InteractTrigger trigger, Player player, string eventID, ref bool progressEvent)(InteractTrigger trigger, Player player, string eventID)(Player player)()alternatively, the modder may also use a generator method. Everest looks for one called
Loadby default, but a different generator may be specified with the ID in the attribute (e.g.myCampaignMod_ch1_theo = LoadTheo).the matching generator method must be
public static, returnEntity, and have one of the following signatures:(InteractTrigger trigger, Player player, string eventID, ref bool progressEvent)(InteractTrigger trigger, Player player, string eventID)note that if the
ref bool progressEventparameter is included, theProgressEventproperty of the attribute is ignored, and that is left to be handled within the method / constructor.Other changes
(Player)as a valid signature for entities marked with[CustomEvent].[CustomEvent]has been edited, clarifying that it is for use with anEventTrigger.Additional notes
for map making tools such as Lönn, the Interact Trigger (entity name:
interactTrigger) has the following features:event,event_2,event_3... up toevent_99, whose numbers each correspond to the index of the event, and determines the order in which the events are played out.here's a simple Lönn plugin to try it out: