๐ฆ Conditional Object Choosers Overview
Short Description
Conditional Object Choosers provide a mechanism for dynamically selecting an Object Variable based on runtime conditions.
Long Description
The Chooser system adds a layer of logic to variable retrieval. Instead of asking for a specific variable by path, you ask a Chooser to provide the "best" variable based on the current state. This is useful for things like platform-specific settings, difficulty-based multipliers, or context-aware gameplay parameters.
๐๏ธ How it Works
- A
UGorgeousConditionalObjectChoosercontains a reference to aUGorgeousConditionand an array ofUGorgeousObjectVariableinstances. - When
DecideConditionis called, the Chooser evaluates the Condition and returns the corresponding Object Variable based on the evaluation result.
Feed the Pool
The Chooser's Conditions array serves as the pool of potential variables to select from. Each entry corresponds to a specific condition outcome, allowing for flexible and dynamic selection logic.
By feeding any numer of candidate objects into the Conditions array, you can create complex selection logic that goes beyond simple true/false checks. The Chooser will evaluate the assigned Condition and return the appropriate variable based on the defined logic.
Define Conditions
The ConditionCheck can be any subclass of UGorgeousCondition, allowing for a wide range of evaluation logic. This could be as simple as a boolean check or as complex as a multi-faceted evaluation that considers various gameplay states, player attributes, or external factors.
Decide Conditions
When DecideCondition is called, the Chooser evaluates the assigned Condition and returns the corresponding Object Variable from the Conditions array. The specific variable returned depends on the logic defined in the Condition, allowing for dynamic selection based on runtime data.
Byte based Access
The Condition evaluation returns a uint8 that serves as an index or state identifier, conditions directly correlate to this byte value.
While UGorgeousIsValidCondition & UGorgeousBooleanCondition only support feeding 0 or 1, custom conditions can utilize the full range of 0-255 to represent more complex states.
๐ฏ Why it Matters
Traditional variable retrieval is static and requires hardcoding logic to select different variables based on conditions. Choosers abstract this logic, allowing for more flexible and maintainable code. This is especially beneficial in large projects where multiple variables may need to be selected based on various conditions.
By using Choosers, developers can centralize their selection logic, making it easier to manage and update as the project evolves. This leads to cleaner code and reduces the risk of errors when conditions change or new variables are added.
๐ ๏ธ What Developers Can Do With It
Think in Systems
What chooses the next quest objective? A Chooser that evaluates the player's current progress and selects the appropriate objective variable.
What determines the current music track? A Chooser that checks the player's location, time of day, and current events to select the right track variable.
What defines the current difficulty multiplier? A Chooser that evaluates the player's performance and adjusts the multiplier variable accordingly.
What decides dialogue options? A Chooser that checks the player's relationship status with NPCs and selects the appropriate dialogue variable.
What drives outcomes in a branching narrative? A Chooser that evaluates the player's choices and selects the next plot variable based on the current story state.
๐ Sub-Documents
- Choosers: Detailed API and evaluation logic.
- Conditions: Overview of built-in condition types.
- Examples: Practical use cases and implementation examples.