Context
- The
sideEffect of a message represents the game state changes caused when a message is rendered. It's stored on the message object and called by the Dialogue component
selectFollowup is also included on a message, in particular when this message is an optional choice to be made by the player (returned by the getResponses method). It is provided by the DialogueContext and executed in getResponse - ultimately called when the response choice is clicked by the player
Current Behaviour
Reproducible 1: When a dialogue response choice has a method selectFollowup containing logic which checks game state before choosing which message to display (such as hasRelationshipPair), and it also has a sideEffect method which changes the same game state properties, the selectFollowup code will run before sideEffect and the messages will have been queued with an out-of-date game state
Reproducible 2: Writing a selectFollowup method which queues many messages, when one of those messages includes a sideEffect, the later messages in the queue will have been
Expected Behaviour
The selectFollowup code should not be running until the game state is up-to-date with previous messages
Fixing it now
Moving game state changing code into selectFollowup to maintain the correct order
Context
sideEffectof a message represents the game state changes caused when a message is rendered. It's stored on the message object and called by theDialoguecomponentselectFollowupis also included on a message, in particular when this message is an optional choice to be made by the player (returned by thegetResponsesmethod). It is provided by theDialogueContextand executed ingetResponse- ultimately called when the response choice is clicked by the playerCurrent Behaviour
Reproducible 1: When a dialogue response choice has a method
selectFollowupcontaining logic which checks game state before choosing which message to display (such ashasRelationshipPair), and it also has asideEffectmethod which changes the same game state properties, theselectFollowupcode will run beforesideEffectand the messages will have been queued with an out-of-date game stateReproducible 2: Writing a
selectFollowupmethod which queues many messages, when one of those messages includes asideEffect, the later messages in the queue will have beenExpected Behaviour
The
selectFollowupcode should not be running until the game state is up-to-date with previous messagesFixing it now
Moving game state changing code into
selectFollowupto maintain the correct order