Drag[en]gine Script Module DragonScript
1.23
|
List of properties organized as tree to find best matching property. More...
Classes | |
class | Entry |
Entry. More... | |
Public Member Functions | |
void | forEach (Block ablock) |
Visit properties with block. More... | |
void | forEach (String path, Block ablock) |
Visit all properties along path. More... | |
Object | getAt (String path) |
Get property best matching path. More... | |
Object | getAtExact (String path) |
Get property matching exactly path or null if absent. More... | |
bool | hasExact (String path) |
Property matching exactly path is present. More... | |
BestMatchTreeList | new () |
Create list. More... | |
BestMatchTreeList | new (byte separator) |
Create list. More... | |
void | removeAll () |
Remove all properties from the list. More... | |
void | setAt (String path, Object property) |
Set property replacing existing one if present. More... | |
Protected Member Functions | |
void | forEachEntry (Entry entry, String path, String pathAppend, Block ablock) |
Recursive visit entries with block String path, Entry entry. More... | |
List of properties organized as tree to find best matching property.
Helps finding best matching properties for elements. The desired property is defined using a path string. The tree is searched to find the property with the best matching path string. This list allows to apply properties to a specific path or to a group of properties sharing the same path components.
A typical example for use of this list is assigning game specific material parameters to Skin resources applied to components. Usually you have a small number of material classes fine tuned for your game and a larger amount of Skin resources that should map to these material classes. Defining the material for each and every Skin resource is cumbersome especially since many Skin resources with similar path share the same material class. Here the properties can be stored for a group of Skin resources sharing the same directory on disk. This is an example list of Skin resources:
You can not define these material classes:
"asphalt damaged" is the best match for the damaged asphalt skin only. All other asphalt skins will best match the generic "asphalt" material class. The same for the grass type skins covered by the generic "grass" material class. The crate skin does not match anything so null will be retrieved. If you want to use a default material class add an entry for "/" and it will cover everything not covered by a more specific path string.
The same object can be stored for different path strings.
void Dragengine.Utils.BestMatchTreeList.forEach | ( | Block | ablock | ) |
Visit properties with block.
Block has signature String path, Object property.
void Dragengine.Utils.BestMatchTreeList.forEach | ( | String | path, |
Block | ablock | ||
) |
Visit all properties along path.
A typical use case for this method is to merge properties along the path to get a final property to use. This avoids the need to fully define properties allowing to reuse and extend properties.
Block has signature String path, Object property.
|
protected |
Recursive visit entries with block String path, Entry entry.
Object Dragengine.Utils.BestMatchTreeList.getAt | ( | String | path | ) |
Get property best matching path.
Object Dragengine.Utils.BestMatchTreeList.getAtExact | ( | String | path | ) |
Get property matching exactly path or null if absent.
bool Dragengine.Utils.BestMatchTreeList.hasExact | ( | String | path | ) |
Property matching exactly path is present.
BestMatchTreeList Dragengine.Utils.BestMatchTreeList.new | ( | ) |
Create list.
BestMatchTreeList Dragengine.Utils.BestMatchTreeList.new | ( | byte | separator | ) |
Create list.
void Dragengine.Utils.BestMatchTreeList.removeAll | ( | ) |
Remove all properties from the list.
void Dragengine.Utils.BestMatchTreeList.setAt | ( | String | path, |
Object | property | ||
) |
Set property replacing existing one if present.
Path is not required to start with the path separator. If property is null the property is ignored during getAt().