当前位置:网站首页>Introduction to common classes on the runtime side

Introduction to common classes on the runtime side

2022-06-26 09:06:00 LixiSchool

https://www.behaviac.com/basic_classes/

In the use of behaviac Runtime end (Runtime) Source code or API when , There are a few of the most commonly used classes worth noting : Such as Workspace、Agent、Config etc. .

Workspace class

Workspace Class is mainly used to manage the export of type information , load 、 uninstall 、 perform 、 Stop executing the behavior tree , Set the time, frame number, etc .

  • GetInstance() : Used to get Workspace Single instance of .
  • ExportMetas(const char*) : Export the type information file to the specified path , See documentation 《C++ Registration and export of type information in the runtime side 》.
  • SetFilePath(const char*) : Used to specify the directory where the behavior tree file is located when loading the behavior tree .
  • SetFileFormat(EFileFormat) : Used to specify the format of the loading behavior tree file , Include Xml、Bson、Cpp/Cs、Default. among Default Means to try to load first Xml Format , If not, try loading again Bson Format , Finally, try loading Cpp/Cs Format , This function can be used for hot update of behavior tree .
  • Update() : Used to perform all Agent Current behavior tree for , The behavior tree can also be executed without passing the API, You can call it by yourself Agent Of btexec() Method , See documentation 《 The update process on the runtime side 》.
  • DebugUpdate() : Methods for performing debugging and hot loading , If already used Update() Method to execute , It is not necessary to call this... During continuous debugging or hot loading DebugUpdate() Method .
  • SetIsExecAgents(bool) : Used to stop / Continue with all Agent Current behavior tree for , The premise is that the behavior tree is implemented through Update() Method initiated . If it is called by itself Agent Of btexec() Method , Through Agent Of SetActive(bool) Method to stop / Carry on .
  • SetTimeSinceStartup(double) : Used to set the total time of the game from start to current , This total time is mainly used for time 、 Waiting time and other time-related node execution . If you do not set this value every frame , These nodes will not work properly .
  • SetFrameSinceStartup(int) : Used to set the total number of frames of the game from start to current , This total number of frames is mainly used for the number of frames 、 Wait for the execution of nodes related to the number of frames, such as the number of frames . If you do not set this value every frame , These nodes will not work properly .

The specific code can be viewed behaviac/base/workspace.h

Agent class

Static methods :

  • Create(const char*, int, short) : Used to create Agent Example .
  • Destroy(Agent*) : Used to destroy Agent Example .
  • Register() : Register the Agent class , Used to record the type information of this class .
  • UnRegister() : Unregister the Agent class .
  • RegisterInstanceName(const char*, const wchar_t*, const wchar_t*) : Register instance name , As part of the type information , After export, it can be used to configure nodes in the editor .
  • UnRegisterInstanceName(const char*) : Unregister instance name .
  • BindInstance(Agent*, const char*, int) : Will be a Agent Instance is bound to a name .
  • UnbindInstance(const char*, int) : Cancel a certain Agent The binding of an instance to a name .

Member method :

  • btload(const char*, bool) : Used to load the behavior tree with the specified name , No suffix is required ( File format ).
  • btunload(const char*) : Used to unload the behavior tree with the specified name .
  • btsetcurrent(const char*) : Used to set the current behavior tree .
  • btexec() : Execute the current behavior tree .
  • SetActive(bool) : Used to stop / Continue executing the current behavior tree , If set to false, Indicates to stop executing the current behavior tree ; otherwise , Indicates continued execution .
  • FireEvent(const char*) : Used to issue events , So that the events bound in the behavior tree can be responded .
  • SetIdFlag(uint32_t) : This node is used to set whether to track this... During continuous debugging Agent. By static method SetIdMask() Set all Agent Of Mask value , And then through SetIdFlag() Set up current Agent Of Flag value . If IsMasked() Return to true , Indicates that the Agent.
  • SetName(const char*) : Used to set the name .

The specific code can be viewed behaviac/agent/agent.h

Config class

See documentation 《 Development function switch 》.

原网站

版权声明
本文为[LixiSchool]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260841060571.html