Drag[en]gine Script Module DragonScript
1.21
|
Resolve element links. More...
Classes | |
class | Request |
Resolve request. More... | |
class | ResolveException |
Resolve failure. More... | |
Public Member Functions | |
void | add (UniqueID id, Block ablock) |
Add resolve request. More... | |
Request | getAt (int index) |
Pending request at index. More... | |
int | getCount () |
Number of pending requests. More... | |
ElementResolver | new () |
Create resolver. More... | |
Resolve element links.
Helper class to resolve element identifiers read from file readers. While loading elements from files the elements referenced by identifiers very well can not be present yet in the game world since they show up in the file at a later time. To support such links the UniqueID of an element is saved. Once read it has to be resolved once all elements are present in the game world. The best time for this is during a call to Element.enterFrame(). An instance of this class has to be placed in elements requiring resolving behavior. To resolve an encountered element add a resolve request to the instance of this class with a block to use. The following code example shows how to use this class.
This class is also able to resolve BehaviorElement behaviors. During saving you have to store both the BehaviorElement UniqueID as well as the behavior instance index. The DefaultECBehavior class provides this information. While resolving the block is called with BehaviorInstance as parameter. In general you will change this to parameter type to match the behavior stored.
void Dragengine.Utils.ElementResolver.add | ( | UniqueID | id, |
Block | ablock | ||
) |
Add resolve request.
Add request to resolve element by identifier. Once resolved ablock is called with the resolved element as parameter. If resolving fails ablock is called with null as parameter.
Request Dragengine.Utils.ElementResolver.getAt | ( | int | index | ) |
Pending request at index.
int Dragengine.Utils.ElementResolver.getCount | ( | ) |
Number of pending requests.
ElementResolver Dragengine.Utils.ElementResolver.new | ( | ) |
Create resolver.