8 #include <unordered_set>
25 class AIStateNodeStatic;
33 class DeleteNodeHandler;
34 class UpdateNodeHandler;
52 typedef std::unordered_set<Zone*> Zones;
53 typedef Zones::const_iterator ZoneConstIter;
54 typedef Zones::iterator ZoneIter;
58 CharacterId _selectedCharacterId;
69 std::atomic_bool _pause;
71 std::atomic<Zone*> _zone;
73 std::vector<std::string> _names;
74 uint32_t _broadcastMask = 0u;
79 EV_UPDATESTATICCHRDETAILS,
92 CharacterId characterId;
98 std::string strData =
"";
101 std::vector<Event> _events;
103 void resetSelection();
105 void addChildren(
const TreeNodePtr& node, std::vector<AIStateNodeStatic>& out)
const;
106 void addChildren(
const TreeNodePtr& node,
AIStateNode& parent,
const AIPtr& ai)
const;
109 void broadcastState(
const Zone* zone);
110 void broadcastCharacterDetails(
const Zone* zone);
111 void broadcastStaticCharacterDetails(
const Zone* zone);
113 void onConnect(
Client* client)
override;
114 void onDisconnect(
Client* client)
override;
116 void handleEvents(Zone* zone,
bool pauseState);
117 void enqueueEvent(
const Event& event);
119 Server(
AIRegistry& aiRegistry,
short port = 10001,
const std::string& hostname =
"0.0.0.0");
140 bool updateNode(
const CharacterId& characterId, int32_t nodeId,
const std::string& name,
const std::string& type,
const std::string& condition);
155 bool addNode(
const CharacterId& characterId, int32_t parentNodeId,
const std::string& name,
const std::string& type,
const std::string& condition);
164 bool deleteNode(
const CharacterId& characterId, int32_t nodeId);
189 void setDebug(
const std::string& zoneName);
200 void select(
const ClientId& clientId,
const CharacterId&
id);
205 void pause(
const ClientId& clientId,
bool pause);
210 void step(int64_t stepMillis = 1L);
215 void update(int64_t deltaTime);
bool deleteNode(const CharacterId &characterId, int32_t nodeId)
Delete the specified node from the ICharacter's behaviour tree and all the other characters that are ...
Definition: ServerImpl.h:400
Definition: SelectHandler.h:12
bool start()
Start to listen on the specified port.
Definition: ServerImpl.h:90
The place to register your TreeNode and ICondition factories at.
Definition: AIRegistry.h:64
void removeZone(Zone *zone)
Removes a Zone from the server. After this call the given zone is no longer available for debugging p...
Definition: ServerImpl.h:432
Definition: UpdateNodeHandler.h:14
bool addNode(const CharacterId &characterId, int32_t parentNodeId, const std::string &name, const std::string &type, const std::string &condition)
Add a new node with the given values to the specified ICharacter and all the other characters that ar...
Definition: ServerImpl.h:363
Definition: StepHandler.h:14
void select(const ClientId &clientId, const CharacterId &id)
Select a particular character (resp. AI instance) and send detail information to all the connected cl...
Definition: ServerImpl.h:457
Definition: ChangeHandler.h:14
bool updateNode(const CharacterId &characterId, int32_t nodeId, const std::string &name, const std::string &type, const std::string &condition)
Update the specified node with the given values for the specified ICharacter and all the other charac...
Definition: ServerImpl.h:317
Definition: IProtocolHandler.h:42
Definition: AddNodeHandler.h:13
void reset()
Resets the AI states.
Definition: ServerImpl.h:446
Definition: PauseHandler.h:14
void pause(const ClientId &clientId, bool pause)
Will pause/unpause the execution of the behaviour trees for all watched AI instances.
Definition: ServerImpl.h:464
Definition: DeleteNodeHandler.h:14
Definition: ResetHandler.h:11
This is a representation of a behaviour tree node for the serialization.
Definition: AIStubTypes.h:106
void setDebug(const std::string &zoneName)
Activate the debugging for this particular zone. And disables the debugging for every other zone...
Definition: ServerImpl.h:439
void addZone(Zone *zone)
Adds a new zone to this server instance that can be debugged. The server does not own this pointer so...
Definition: ServerImpl.h:425
The server can serialize the state of the AI and broadcast it to all connected clients.
Definition: Server.h:50
void update(int64_t deltaTime)
call this to update the server - should get called somewhere from your game tick
Definition: ServerImpl.h:478
void step(int64_t stepMillis=1L)
Performs one step of the AI in pause mode.
Definition: ServerImpl.h:471