Tree Operations

Table of contents

1. Start to execute a tree
2. Start to execute a tree with a target loop count and basic play mode
3. Pause a tree
4. Resume to execute a tree that was paused
5. Stop a tree
6. Reset a tree
7. Load a tree from XML files
8. Destroy a tree

1. Start to execute a tree
Signature:
static bool BtEngine.Play(string ForestName, string TreeName)
static bool BtEngine.Play(uint ForestIndex, uint TreeIndex)
Description:
Asynchronously starts to execute a tree instance with the specified (forest, tree) names/indices, previously specified target loop count (0 by default) and basic play mode (StopByExecuteLoopCount by default).
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
Return Value:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t), where f is the count of forest instance and t is the count of whose child tree instance.
2. Start to execute a tree with a target loop count and basic play mode
Signature:
static bool BtEngine.Play(string ForestName, string TreeName, uint TgtLoopCount, BasicPlayMode Mode)
static bool BtEngine.Play(uint ForestIndex, uint TreeIndex, uint TgtLoopCount, BasicPlayMode Mode)
Description:
Asynchronously starts to execute a tree instance with the specified (forest, tree) names/indices, target loop count and basic play mode.
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
TgtLoopCount The target loop count for this execution as specified by basic play mode. Enter 0 for an infinite loop.
Mode The basic play mode for this execution which specifies the way to count the loop number and stop execution.
Return Value:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t), where f is the count of forest instance and t is the count of whose child tree instance.
3. Pause a tree
Signature:
static bool BtEngine.Pause(string ForestName, string TreeName, bool Sync)
static bool BtEngine.Pause(uint ForestIndex, uint TreeIndex, bool Sync)
Description:
Asynchronously pauses a tree instance with the specified (forest, tree) names/indices.
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
Sync True to keep the tree instance’s state unchanged until whose OnPause operation returns; false otherwise.
Return Values:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t), where f is the count of forest instance and t is the count of whose child tree instance.
4. Resume to execute a tree that was paused
Signature:
static bool BtEngine.Resume(string ForestName, string TreeName)
static bool BtEngine.Resume(uint ForestIndex, uint TreeIndex)
Description:
Asynchronously resumes to execute a tree instance if it was paused with the specified (forest, tree) names/indices and its remaining loop count.
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
Return Value:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t), where f is the count of forest instance and t is the count of whose child tree instance.
5. Stop a tree
Signature:
static bool BtEngine.Stop(string ForestName, string TreeName, bool Sync)
static bool BtEngine.Stop(uint ForestIndex, uint TreeIndex, bool Sync)
Description:
Asynchronously stops a tree instance with the specified (forest, tree) names/indices.
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
Sync True to keep the tree instance’s state unchanged until whose OnStop operation returns; false otherwise.
Return Value:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t), where f is the count of forest instance and t is the count of whose child tree instance.
6. Reset a tree
Signature:
static bool BtEngine.Reset(string ForestName, string TreeName, bool Sync)
static bool BtEngine.Reset(uint ForestIndex, uint TreeIndex, bool Sync)
Description:
Asynchronously resets a tree instance with the specified (forest, tree) names/indices.
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
Sync True to keep the tree instance’s state unchanged until whose OnReset operation returns; false otherwise.
Return Value:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t), where f is the count of forest instance and t is the count of whose child tree instance.
7. Load a tree from XML files
Signature:
static bool BtEngine.Load(string ForestName, string TreeName, bool Sync)
static bool BtEngine.Load(uint ForestIndex, uint TreeIndex, bool Sync)
Description:
Asynchronously instantiates a tree if its instance doesn’t exist with the specified (forest, tree) names/indices, as well as the forest itself if its instance doesn’t exist, from the forest xml file and tree xml file.
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
Sync True to keep the tree (and forest) instance’s state unchanged until whose OnConstruct operation returns; false otherwise.
Return Value:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t + n), where f is the count of forest instance, t is the count of whose child tree instance and n is the count of whose child node instance.
8. Destroy a tree
Signature:
static bool BtEngine.Destroy(string ForestName, string TreeName, bool Sync)
static bool BtEngine.Destroy(uint ForestIndex, uint TreeIndex, bool Sync)
Description:
Asynchronously deletes a tree instance with the specified (forest, tree) names/indices, as well as the forest instance if there is no other tree instance left in the forest. If parallel operation, i.e., tree specific operation queue, is enabled, this operation cancels all the parallel tree specific queued operations of Play, Pause, Resume, Stop and Reset that were issued before it and then gets invoked right away.
Parameters:
ForestName The name of the forest instance to locate and invoke.
TreeName The name of the tree instance to locate and invoke.
ForestIndex The index of the forest instance to locate and invoke.
TreeIndex The index of the tree instance to locate and invoke.
Sync True to keep the tree (and forest) instance’s state unchanged until whose OnDestruct operation returns; false otherwise.
Return Value:
True if the operation was enqueued; false otherwise.
Complexity:
O(log f + log t + n), where f is the count of forest instance, t is the count of whose child tree instance and n is the count of whose child node instance.