Drag[en]gine Script Module DragonScript  1.21
Dragengine.Scenery.ECBehaviorCustomColor Class Reference

Behavior element behavior adding custom color support. More...

Inheritance diagram for Dragengine.Scenery.ECBehaviorCustomColor:
Dragengine.Scenery.DefaultECBehavior Dragengine.Scenery.ECBehavior Dragengine.Scenery.BehaviorCompatiblePersistency

Classes

class  BlockListenerFactory
 Factory creating listeners using block. More...
 
class  DefaultListener
 Default implementation of behavior instance listener. More...
 
class  Instance
 Behavior instance. More...
 
interface  Listener
 Listener for behavior instance events. More...
 
interface  ListenerFactory
 Factory creating listeners. More...
 

Public Member Functions

void addListenerFactory (Block blockFactory)
 Add listener factory using block. More...
 
void addListenerFactory (ListenerFactory factory)
 Add listener factory. More...
 
void createListeners (Instance instance)
 Create listeners from factories adding them to behavior instance. More...
 
void dispose ()
 Dispose of behavior. More...
 
void forEachListenerFactory (Block ablock)
 Visit listener factories with block with argument ListenerFactory. More...
 
ECPColorList getAllowedColors ()
 List of allowed colors or empty list to allow all colors. More...
 
ECPColor getColor ()
 Color or null to use the default color. More...
 
ECPColor getDefaultColor ()
 Default color if color is null. More...
 
ECPUnicodeString getDescription ()
 Description to display in UI. More...
 
ECPUnicodeString getName ()
 Name to display in UI. More...
 
ECBehaviorCustomColor new (BehaviorElementClass eclass)
 Create behavior element class. More...
 
ECBehaviorCustomColor new (BehaviorElementClass eclass, String id)
 Create default composeable behavior. More...
 
ECBehaviorCustomColor new (BehaviorElementClass eclass, String id, String subID)
 
ECBehaviorCustomColor new (BehaviorElementClass eclass, String id, String subID, String prefix)
 
- Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
void assignInstanceIndex (int instanceIndex)
 Assign instance index. More...
 
String getBehaviorID ()
 Unique identifier of behavior. More...
 
String getID ()
 Identifier. More...
 
int getInstanceIndex ()
 Instance index. More...
 
void loadSupportedData (String identifier, PersistencyEnvironment env, FileReader reader, ECBehaviorInstance instance)
 Load instance data of another behavior. More...
 
bool supportsBehaviorID (String identifier)
 Behavior supports loading instance data of another behavior. More...
 
- Public Member Functions inherited from Dragengine.Scenery.ECBehavior
ECBehaviorInstance createInstance (BehaviorElement element)
 Create Behavior instance. More...
 

Static Public Member Functions

static ECBehaviorCustomColor getBehaviorIn (BehaviorElementClass eclass)
 Get behavior in element class or null if absent. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
void setBehaviorID (String identifier)
 Set behavior identifier. More...
 
void useClassNameAsBehaviorID ()
 Set behavior identifier to "<class-name>:<identifier>". More...
 
void useFullyQualifiedClassNameAsBehaviorID ()
 Set behavior identifier to "<fully-qualified-class-name>:<identifier>". More...
 

Detailed Description

Behavior element behavior adding custom color support.

Version
1.5

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.

This behavior can be added multiple times to an element. Each instance creates one custom color the player can manipulate. To distinguish the custom colors each instance has an identifier which can be used to retrieve a specific instance. The prefix of the element class properties is "customColor." . If the identifier is not empty the element class properties have the prefix "{id}.customColor.". This can be overwritten if required. This is an example of the typical use of this behavior:

class MyElement extends BehaviorElementClass
public func new()
ECBehaviorCustomColor.new(this, "color1", "Color 1", Color.blue)
ECBehaviorCustomColor.new(this, "color2", "Color 2", Color.red)
end
end
ECBehaviorCustomColor new(BehaviorElementClass eclass)
Create behavior element class.

This defines an element which contains two custom colors the player can choose at will. You can now define the parameters to use for both custom colors using for example the properties "customColor(color1).color" for the first custom color and "customColor(color2).color" for the second custom color.

It is recommended to always specify an identifier even if only one custom color is used. This avoids potentially name conflicts especially if other behaviors are added custom colors.

Element class properties have the prefix "customColor{(id)}.".

Listening

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.

Persistency

This behavior supports persistable element class (setPersistable). Persists the selected color.

Member Function Documentation

◆ addListenerFactory() [1/2]

void Dragengine.Scenery.ECBehaviorCustomColor.addListenerFactory ( Block  blockFactory)

Add listener factory using block.

Block receives as parameter Instance and returns Listener.

◆ addListenerFactory() [2/2]

void Dragengine.Scenery.ECBehaviorCustomColor.addListenerFactory ( ListenerFactory  factory)

Add listener factory.

◆ createListeners()

void Dragengine.Scenery.ECBehaviorCustomColor.createListeners ( Instance  instance)

Create listeners from factories adding them to behavior instance.

◆ dispose()

void Dragengine.Scenery.ECBehaviorCustomColor.dispose ( )

Dispose of behavior.

Reimplemented from Dragengine.Scenery.DefaultECBehavior.

◆ forEachListenerFactory()

void Dragengine.Scenery.ECBehaviorCustomColor.forEachListenerFactory ( Block  ablock)

Visit listener factories with block with argument ListenerFactory.

◆ getAllowedColors()

ECPColorList Dragengine.Scenery.ECBehaviorCustomColor.getAllowedColors ( )

List of allowed colors or empty list to allow all colors.

◆ getBehaviorIn()

static ECBehaviorCustomColor Dragengine.Scenery.ECBehaviorCustomColor.getBehaviorIn ( BehaviorElementClass  eclass)
static

Get behavior in element class or null if absent.

Use this method to check if a particular BehaviorElementClass contains a behavior of type ECBehaviorCollider.

◆ getColor()

ECPColor Dragengine.Scenery.ECBehaviorCustomColor.getColor ( )

Color or null to use the default color.

◆ getDefaultColor()

ECPColor Dragengine.Scenery.ECBehaviorCustomColor.getDefaultColor ( )

Default color if color is null.

◆ getDescription()

ECPUnicodeString Dragengine.Scenery.ECBehaviorCustomColor.getDescription ( )

Description to display in UI.

◆ getName()

ECPUnicodeString Dragengine.Scenery.ECBehaviorCustomColor.getName ( )

Name to display in UI.

◆ new() [1/4]

ECBehaviorCustomColor Dragengine.Scenery.ECBehaviorCustomColor.new ( BehaviorElementClass  eclass)

Create behavior element class.

Reimplemented from Dragengine.Scenery.DefaultECBehavior.

◆ new() [2/4]

ECBehaviorCustomColor Dragengine.Scenery.ECBehaviorCustomColor.new ( BehaviorElementClass  eclass,
String  id 
)

Create default composeable behavior.

Reimplemented from Dragengine.Scenery.DefaultECBehavior.

◆ new() [3/4]

ECBehaviorCustomColor Dragengine.Scenery.ECBehaviorCustomColor.new ( BehaviorElementClass  eclass,
String  id,
String  subID 
)

◆ new() [4/4]

ECBehaviorCustomColor Dragengine.Scenery.ECBehaviorCustomColor.new ( BehaviorElementClass  eclass,
String  id,
String  subID,
String  prefix 
)

The documentation for this class was generated from the following file: