9#include "../system/system_utils.h"
42 SYSTEM_LOG <<
"[BlackboardSystem] CreateEntry failed: empty name" << std::endl;
48 SYSTEM_LOG <<
"[BlackboardSystem] CreateEntry failed: duplicate name '"
49 << name <<
"'" << std::endl;
56 SYSTEM_LOG <<
"[BlackboardSystem] Created entry '" << name
66 SYSTEM_LOG <<
"[BlackboardSystem] RemoveEntry: not found '" << name <<
"'" << std::endl;
70 SYSTEM_LOG <<
"[BlackboardSystem] Removed entry '" << name <<
"'" << std::endl;
78 SYSTEM_LOG <<
"[BlackboardSystem] RenameEntry failed: empty new name" << std::endl;
85 SYSTEM_LOG <<
"[BlackboardSystem] RenameEntry: source not found '" <<
oldName <<
"'" << std::endl;
91 SYSTEM_LOG <<
"[BlackboardSystem] RenameEntry failed: target name already exists '"
108 SYSTEM_LOG <<
"[BlackboardSystem] SetValue: not found '" << name <<
"'" << std::endl;
112 if (
it->second.type != value.
type)
114 SYSTEM_LOG <<
"[BlackboardSystem] SetValue: type mismatch for '" << name <<
"'" << std::endl;
140 const std::string& name =
it->first;
144 entry[
"name"] = name;
150 case BlackboardType::Int:
153 case BlackboardType::Float:
156 case BlackboardType::Bool:
159 case BlackboardType::String:
162 case BlackboardType::Vector3:
185 for (
size_t i = 0;
i <
j.size(); ++
i)
188 if (!
entry.is_object())
205 if (
entry.contains(
"value") &&
entry[
"value"].is_object())
210 case BlackboardType::Int:
213 case BlackboardType::Float:
216 case BlackboardType::Bool:
219 case BlackboardType::String:
222 case BlackboardType::Vector3:
244 case BlackboardType::Int:
return "Int";
245 case BlackboardType::Float:
return "Float";
246 case BlackboardType::Bool:
return "Bool";
247 case BlackboardType::String:
return "String";
248 case BlackboardType::Vector3:
return "Vector3";
249 default:
return "Int";
255 if (
s ==
"Float")
return BlackboardType::Float;
256 if (
s ==
"Bool")
return BlackboardType::Bool;
257 if (
s ==
"String")
return BlackboardType::String;
258 if (
s ==
"Vector3")
return BlackboardType::Vector3;
259 return BlackboardType::Int;
Blackboard system for shared graph variables (Phase 2.1)
ComponentTypeID GetComponentTypeID_Static()
bool CreateEntry(const std::string &name, BlackboardType type, const BlackboardValue &initialValue)
Create a new entry.
bool RenameEntry(const std::string &oldName, const std::string &newName)
Rename an entry.
bool RemoveEntry(const std::string &name)
Remove an entry.
const std::map< std::string, BlackboardValue > & GetAll() const
Get all entries (for UI / serialization)
bool SetValue(const std::string &name, const BlackboardValue &value)
Update the value of an existing entry.
std::map< std::string, BlackboardValue > m_entries
const BlackboardValue * GetEntry(const std::string &name) const
Get a const pointer to an entry.
static BlackboardType StringToType(const std::string &s)
Convert a string to BlackboardType (returns Int on unknown)
json ToJson() const
Serialize blackboard to JSON.
void FromJson(const json &j)
Deserialize blackboard from JSON.
bool HasEntry(const std::string &name) const
Check if an entry exists.
static std::string TypeToString(BlackboardType t)
Convert a BlackboardType to its string representation.
std::string GetString(const json &j, const std::string &key, const std::string &defaultValue="")
Safely get a string value from JSON.
int GetInt(const json &j, const std::string &key, int defaultValue=0)
Safely get an integer value from JSON.
float GetFloat(const json &j, const std::string &key, float defaultValue=0.0f)
Safely get a float value from JSON.
bool GetBool(const json &j, const std::string &key, bool defaultValue=false)
Safely get a boolean value from JSON.
< Provides AssetID and INVALID_ASSET_ID
Stores a typed value for a blackboard entry.