15 std::lock_guard<std::mutex> lock(
m_mutex);
19 if (update->execution_path()) {
22 for (
auto id : *update->execution_path()) {
27 if (update->states()) {
28 bool isDelta = update->is_delta();
36 for (
const auto *state : *update->states()) {
41 int64_t nodeId = state->id();
49 if (oldStatus != newStatus) {
68 std::lock_guard<std::mutex> lock(
m_mutex);
70 if (!update->blackboard_id()) {
74 auto *blackboard =
m_tree->GetBlackboard(update->blackboard_id()->str());
79 if (update->updates()) {
80 for (
const auto *entryUpdate : *update->updates()) {
81 if (!entryUpdate || !entryUpdate->key()) {
85 auto *entry = blackboard->GetEntry(entryUpdate->key()->str());
86 if (entry && entryUpdate->value()) {
87 entry->SetValue(entryUpdate->value()->str());
94 std::lock_guard<std::mutex> lock(
m_mutex);
112 std::lock_guard<std::mutex> lock(
m_mutex);
122 std::lock_guard<std::mutex> lock(
m_mutex);
123 std::vector<int64_t> result;
129 std::lock_guard<std::mutex> lock(
m_mutex);
135 std::lock_guard<std::mutex> lock(
m_mutex);
141 std::lock_guard<std::mutex> lock(
m_mutex);
144 [tick_number](
const TickSnapshot &s) { return s.tick_number == tick_number; });
156 std::lock_guard<std::mutex> lock(
m_mutex);
161 std::lock_guard<std::mutex> lock(
m_mutex);
166 std::lock_guard<std::mutex> lock(
m_mutex);
174 callback(node_id, old_status, new_status);
182 callback(tick_number);
193 m_history.push_back(std::move(snapshot));
std::function< void(int64_t tick_number)> TickCallback
NodeStatus GetNodeStatus(int64_t node_id) const
void ApplyBlackboardUpdate(const Protocol::BlackboardUpdate *update)
void ApplyTickUpdate(const Protocol::TickUpdate *update)
std::vector< int64_t > m_changedNodeIds
void SeekToTick(int64_t tick_number)
std::vector< int64_t > GetAndClearChangedNodes()
std::unordered_map< int64_t, NodeStatus > m_nodeStates
void AddTickCallback(TickCallback callback)
std::vector< TickCallback > m_tickCallbacks
std::function< void(int64_t node_id, NodeStatus old_status, NodeStatus new_status)> StateChangeCallback
void AddStateChangeCallback(StateChangeCallback callback)
void NotifyStateChange(int64_t node_id, NodeStatus old_status, NodeStatus new_status)
void EnableHistory(size_t max_ticks=1000)
std::vector< int64_t > m_executionPath
std::vector< TickSnapshot > m_history
Protocol::NodeStatus NodeStatus
StateManager(std::shared_ptr< EmberCore::BehaviorTree > tree)
std::shared_ptr< EmberCore::BehaviorTree > m_tree
void NotifyTick(int64_t tick_number)
std::vector< StateChangeCallback > m_stateCallbacks
std::unordered_map< int64_t, NodeStatus > states
std::vector< int64_t > execution_path