26 const int32_t nodeId = readInt(in);
27 const std::string& condition = readString(in);
28 const int64_t lastRun = readLong(in);
29 const TreeNodeStatus status =
static_cast<TreeNodeStatus
>(readByte(in));
30 const bool running = readBool(in);
31 const int16_t childrenCount = readShort(in);
32 AIStateNode node(nodeId, condition, lastRun, status, running);
33 for (uint8_t i = 0; i < childrenCount; ++i) {
35 node.addChildren(child);
40 void writeNode (streamContainer& out,
const AIStateNode& node)
const {
41 addInt(out, node.getNodeId());
42 addString(out, node.getCondition());
46 const std::vector<AIStateNode>& children = node.getChildren();
47 addShort(out, static_cast<int16_t>(children.size()));
48 for (std::vector<AIStateNode>::const_iterator i = children.begin(); i != children.end(); ++i) {
53 void writeAggro(streamContainer& out,
const AIStateAggro& aggro)
const {
54 const std::vector<AIStateAggroEntry>& a = aggro.getAggro();
55 addShort(out, static_cast<int16_t>(a.size()));
56 for (std::vector<AIStateAggroEntry>::const_iterator i = a.begin(); i != a.end(); ++i) {
58 addFloat(out, i->aggro);
62 void readAggro(streamContainer& in,
AIStateAggro& aggro)
const {
63 const int size = readShort(in);
64 for (
int i = 0; i < size; ++i) {
65 const CharacterId chrId = readInt(in);
66 const float aggroVal = readFloat(in);
77 IProtocolMessage(PROTO_CHARACTER_DETAILS), _chrId(id), _aggroPtr(&aggro), _rootPtr(&root) {
81 IProtocolMessage(PROTO_CHARACTER_DETAILS), _aggroPtr(nullptr), _rootPtr(nullptr) {
83 readAggro(in, _aggro);
87 void serialize(streamContainer& out)
const override {
90 writeAggro(out, *_aggroPtr);
91 writeNode(out, *_rootPtr);
94 inline const CharacterId& getCharacterId()
const {
98 inline const AIStateAggro& getAggro()
const {
104 inline const AIStateNode& getNode()
const {
bool isRunning() const
Some nodes have a state that holds which children is currently running.
Definition: AIStubTypes.h:166
TreeNodeStatus getStatus() const
Definition: AIStubTypes.h:158
A protocol message is used for the serialization of the ai states for remote debugging.
Definition: IProtocolMessage.h:60
int64_t getLastRun() const
Definition: AIStubTypes.h:151
The list of aggro entry for a character.
Definition: AIStubTypes.h:30
Message for the remote debugging interface.
Definition: AICharacterDetailsMessage.h:17
AICharacterDetailsMessage(const CharacterId &id, const AIStateAggro &aggro, const AIStateNode &root)
Definition: AICharacterDetailsMessage.h:76
The aggro entry for the AIStateAggro.
Definition: AIStubTypes.h:19
This is a representation of a behaviour tree node for the serialization.
Definition: AIStubTypes.h:106