Drag[en]gine Script Module DragonScript  1.23
Dragengine.Utils.BestMatchTreeList Class Reference

List of properties organized as tree to find best matching property. More...

Inheritance diagram for Dragengine.Utils.BestMatchTreeList:

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...
 

Detailed Description

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:

  • /content/materials/asphalt/clean.deskin
  • /content/materials/asphalt/dirty.deskin
  • /content/materials/asphalt/weathered.deskin
  • /content/materials/asphalt/damaged.deskin
  • /content/materials/grass/lawn1.deskin
  • /content/materials/grass/lawn2.deskin
  • /content/materials/misc/crate.deskin

You can not define these material classes:

  • "asphalt" => "/content/materials/asphalt"
  • "asphalt damaged" => "/content/materials/asphalt/damaged.deskin"
  • "grass" => "/content/materials/grass"

"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.

Member Function Documentation

◆ forEach() [1/2]

void Dragengine.Utils.BestMatchTreeList.forEach ( Block  ablock)

Visit properties with block.

Block has signature String path, Object property.

◆ forEach() [2/2]

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.

◆ forEachEntry()

void Dragengine.Utils.BestMatchTreeList.forEachEntry ( Entry  entry,
String  path,
String  pathAppend,
Block  ablock 
)
protected

Recursive visit entries with block String path, Entry entry.

◆ getAt()

Object Dragengine.Utils.BestMatchTreeList.getAt ( String  path)

Get property best matching path.

◆ getAtExact()

Object Dragengine.Utils.BestMatchTreeList.getAtExact ( String  path)

Get property matching exactly path or null if absent.

◆ hasExact()

bool Dragengine.Utils.BestMatchTreeList.hasExact ( String  path)

Property matching exactly path is present.

◆ new() [1/2]

BestMatchTreeList Dragengine.Utils.BestMatchTreeList.new ( )

Create list.

◆ new() [2/2]

BestMatchTreeList Dragengine.Utils.BestMatchTreeList.new ( byte  separator)

Create list.

◆ removeAll()

void Dragengine.Utils.BestMatchTreeList.removeAll ( )

Remove all properties from the list.

◆ setAt()

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().


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