This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dragengine:modules:dragonscript:behavior_customcolor [2020/12/20 23:17] – dragonlord | dragengine:modules:dragonscript:behavior_customcolor [2025/05/04 13:39] (current) – dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
{{tag> | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
- | [[: | + | [[: |
</ | </ | ||
Line 8: | Line 8: | ||
====== ECBehaviorCustomColor ====== | ====== ECBehaviorCustomColor ====== | ||
- | |||
- | Behavior element behavior adding custom color support. | ||
- | |||
- | Custom colors are typically used to allow players to customize the look of their player actor by altering the color of individual body parts. This behavior allows to define custom color slots the player or artist can manipulate. This behavior does not define how custom colors are applied. This is left for other behaviors or game scripts to do. | ||
- | |||
- | Custom colors compose of a display name and the currently assigned color. This color can be null to use the assigned default color. An optional list of colors can be used to restrict the colors the player can select. If the list is empty the player can choose the color unrestricted. In addition a display description can be added in case the game developer would like to communicate additional information about the custom color. | ||
<WRAP center 100%> | <WRAP center 100%> | ||
<WRAP center box 450px> | <WRAP center box 450px> | ||
- | {{youtube> | + | {{youtube> |
<WRAP centeralign> | <WRAP centeralign> | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | Behavior element behavior adding custom color support. | ||
+ | |||
+ | Custom colors are typically used to allow players to customize the look of their player actor by altering the color of individual body parts. This behavior allows to define custom color slots the player or artist can manipulate. This behavior does not define how custom colors are applied. This is left for other behaviors or game scripts to do. | ||
+ | |||
+ | Custom colors compose of a display name and the currently assigned color. This color can be null to use the assigned default color. An optional list of colors can be used to restrict the colors the player can select. If the list is empty the player can choose the color unrestricted. In addition a display description can be added in case the game developer would like to communicate additional information about the custom color. | ||
====== Instance Counts ====== | ====== Instance Counts ====== | ||
Line 43: | Line 43: | ||
===== allowedColors ===== | ===== allowedColors ===== | ||
- | Optional list of allowed colors. If this list is not empty the player is only allowed to select one of the colors from this list. If the list is empty all colors are allowed. Typically this means the UI shows a list or combo box instead of a set of sliders for each color component. In XML Element Class files this is defined as a list-tag containing color-tag entries. | + | Optional list of allowed colors. If this list is not empty the player is only allowed to select one of the colors from this list. If the list is empty all colors are allowed. Typically this means the UI shows a list or combo box instead of a set of sliders for each color component. In XML Element Class files this is defined as a list-tag containing color-tag entries. |
* Full name: " | * Full name: " | ||
- | * Type: list of color (3-component) | + | * Type: list of color (3-component) |
* Default Value: empty list | * Default Value: empty list | ||
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
Line 52: | Line 53: | ||
<color r=' | <color r=' | ||
</ | </ | ||
+ | * Example (*.deeclass) <code xml>< | ||
+ | In stub properties the coding is of the form " | ||
===== defaultColor ===== | ===== defaultColor ===== | ||
Sets the default color for the custom color. If the user selects no color (null value) then the default color is used. This can also be used to reset the color to the default color. | Sets the default color for the custom color. If the user selects no color (null value) then the default color is used. This can also be used to reset the color to the default color. | ||
Line 68: | Line 71: | ||
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
- | ===== Events ===== | + | ====== Events |
Since this behavior provides no support to apply the chosen color listening is used. Behaviors knowing how to apply the color add a listener and are notified if the color changes. These events can be received: | Since this behavior provides no support to apply the chosen color listening is used. Behaviors knowing how to apply the color add a listener and are notified if the color changes. These events can be received: | ||
- | ==== colorChanged ==== | + | ===== colorChanged |
Selected color changed. Use behavior to get the newly set color. | Selected color changed. Use behavior to get the newly set color. | ||
+ | |||
+ | ====== Behavior Tree Actions ====== | ||
+ | |||
+ | This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace '' | ||
+ | |||
+ | ===== customColor.set ===== | ||
+ | |||
+ | Set one or more force field parameters. | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |color|'' | ||
+ | |||
+ | This is an example of using this action: | ||
+ | <code xml> | ||
+ | <action name=' | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== customColor.check ===== | ||
+ | |||
+ | Check one or more force field parameters. Action succeeds if all parameter value matches their respective force field parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a force field parameter matches (or not). | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |color.red.less|float|Red color component is less than float value| | ||
+ | |color.red.greater|float|Red color component is greater than float value| | ||
+ | |color.green.less|float|Green color component is less than float value| | ||
+ | |color.green.greater|float|Green color component is greater than float value| | ||
+ | |color.blue.less|float|Blue color component is less than float value| | ||
+ | |color.blue.greater|float|Blue color component is greater than float value| | ||
+ | |wait| |If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled| | ||
+ | |||
+ | This is an example of using this action: | ||
+ | <code xml> | ||
+ | < | ||
+ | <action name=' | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <!-- actions here run only if all color components are less than 0.5 --> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Behavior Tree Conditions ====== | ||
+ | |||
+ | This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace '' | ||
+ | |||
+ | ===== customColor.check ===== | ||
+ | |||
+ | Check one or more force field parameters. Conditions returns true if all parameter value match their respective force field parameter. This condition is typically used to run an action or sequence of actions as long as force field conditions are true. | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |customColor.color.red.less|float|Red color component is less than float value| | ||
+ | |customColor.color.red.greater|float|Red color component is greater than float value| | ||
+ | |customColor.color.green.less|float|Green color component is less than float value| | ||
+ | |customColor.color.green.greater|float|Green color component is greater than float value| | ||
+ | |customColor.color.blue.less|float|Blue color component is less than float value| | ||
+ | |customColor.color.blue.greater|float|Blue color component is greater than float value| | ||
+ | |||
+ | This is an example of using this condition: | ||
+ | <code xml> | ||
+ | <action name=' | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== State Machine Actions ====== | ||
+ | |||
+ | Same as [[# | ||
+ | |||
+ | ====== State Machine Conditions ====== | ||
+ | |||
+ | Same as [[# | ||
+ | |||
+ | ====== State Machine Events ====== | ||
+ | |||
+ | This behavior sends these state machine events. If behavior has non-empty identifier replace '' | ||
+ | |||
+ | ===== customColor.color ===== | ||
+ | |||
+ | Color changed. | ||
====== Required Behaviors ====== | ====== Required Behaviors ====== | ||
Line 90: | Line 178: | ||
====== API Documentation ====== | ====== API Documentation ====== | ||
- | [[https:// | + | # |
Since DragonScript Module Version **1.5** | Since DragonScript Module Version **1.5** | ||
Line 110: | Line 198: | ||
end | end | ||
end | end | ||
+ | </ | ||
+ | |||
+ | ====== Behavior Factory ====== | ||
+ | |||
+ | Using element class supporting adding behaviors the behavior can be added like this: | ||
+ | <code xml> | ||
+ | <?xml version=' | ||
+ | < | ||
+ | < | ||
+ | <!-- set element properties. omit property prefix if used inside behavior tag --> | ||
+ | <string name=' | ||
+ | </ | ||
+ | | ||
+ | <!-- for adding multiple behaviors use unique identifiers --> | ||
+ | < | ||
+ | </ | ||
</ | </ | ||