7#include "../json_helper.h"
8#include "../system/system_utils.h"
24 SYSTEM_LOG <<
"AnimationGraph: Failed to load file: " << filePath <<
"\n";
45 if (
j.contains(
"parameters") &&
j[
"parameters"].is_array())
79 if (
j.contains(
"states") &&
j[
"states"].is_array())
101 if (
j.contains(
"transitions") &&
j[
"transitions"].is_array())
103 for (
const auto&
transJson :
j[
"transitions"])
158 <<
"' with " <<
m_states.size() <<
" states and "
162 catch (
const std::exception&
e)
164 SYSTEM_LOG <<
"AnimationGraph: Error parsing JSON: " <<
e.what() <<
"\n";
193 return it->second.boolValue;
201 return it->second.floatValue;
209 return it->second.intValue;
217 return it->second.stringValue;
233 return it->second.animationName;
324 if (
trans.fromState ==
"ANY")
ComponentTypeID GetComponentTypeID_Static()
std::string m_defaultState
std::unordered_map< std::string, ParameterValue > m_parameters
std::string m_description
float GetParameterFloat(const std::string &name, float defaultValue=0.0f) const
bool ParseJSON(const std::string &jsonContent)
bool LoadFromFile(const std::string &filePath)
std::string GetParameterString(const std::string &name, const std::string &defaultValue="") const
bool EvaluateCondition(const Condition &condition) const
int GetParameterInt(const std::string &name, int defaultValue=0) const
bool GetParameterBool(const std::string &name, bool defaultValue=false) const
std::vector< Transition > m_transitions
std::string m_animationBankPath
void SetParameter(const std::string &name, bool value)
void SetCurrentState(const std::string &stateName)
bool Update(float deltaTime)
std::string GetCurrentAnimationName() const
bool EvaluateTransition(const Transition &transition) const
const Transition * FindValidTransition() const
std::string m_currentState
std::unordered_map< std::string, AnimationState > m_states
std::string GetString(const json &j, const std::string &key, const std::string &defaultValue="")
Safely get a string value from JSON.
bool LoadJsonFromFile(const std::string &filepath, json &j)
Load and parse a JSON file.
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.
std::string animationName