Variant Function::InvokeVariadic(ArgumentList &arguments) const { #ifdef CONFIG_DEBUG UAssert( IsValid( ), "Invalid function invocation" ); #endif return m_invoker( arguments ); }
ClassType Type::DeserializeJson(const Json &value) { auto type = typeof( ClassType ); UAssert( type.IsValid( ), "Invalid type created." ); return type.DeserializeJson( value ).GetValue<ClassType>( ); }
Variant Function::InvokeVariadic(ArgumentList &arguments) const { #if defined(_DEBUG) UAssert( IsValid( ), "Invalid function invocation." ); #endif return m_invoker->Invoke( arguments ); }
AIAction &GOAPlanner::AddAction(const std::string &name, ActionHandler func) { auto itr = _actions.find(name); UAssert(itr == _actions.end(), "The action \"%s\" has already been added.", name.c_str()); // add the action to the actions map _actions.emplace(std::make_pair(name, AIAction(name, func))); return _actions[name]; }
Variant Invoke(Variant &obj, const ArgumentList &arguments) override { UAssert( arguments.size( ) == THIS_ARG_COUNT, "Invalid method arguments.\nExpected %i args but got %i.", THIS_ARG_COUNT, arguments.size( ) ); invoke<void, ArgTypes...>( obj, arguments ); return { }; }
Json Type::SerializeJson(const ClassType &instance, bool invokeHook) { auto type = typeof( ClassType ); UAssert( type.IsValid( ), "Invalid type serialized." ); Variant variant = instance; return type.SerializeJson( variant, invokeHook ); }
void JsonSerializer::Deserialize(const Json &data, Collider * &collider) { static std::string path = "Assets/Meshes/"; ECS::Transform &transform = collider->transform; const Json &pos = data["position"]; transform.SetPosition({ static_cast<float>(pos["x"].number_value()), static_cast<float>(pos["y"].number_value()), 0}); const Json &scale = data["scale"]; float x = static_cast<float>(scale["x"].number_value()); float y = static_cast<float>(scale["y"].number_value()); UAssert(!Math::IsZero(x) && !Math::IsZero(y), "Scale components cannot be zero on colliders."); transform.SetScale({ Math::IsZero(x) ? 1 : x, Math::IsZero(y) ? 1 : y, 0}); const Json &rot = data["rotation"]; transform.SetRotation2D(static_cast<float>(rot["z"].number_value())); // polygon if (!data["mesh"].is_null()) { Polygon *poly = new Polygon(); collider->shape = poly; poly->Set(path + data["mesh"].string_value()); } else { Ellipse *ellipse = new Ellipse(); collider->shape = ellipse; ellipse->Set(transform.RootRotation2D(), { x, y }, Vector2(transform.LocalPosition())); } auto &children = data["children"]; if (children.is_array()) { Deserialize<Colliders>(children, collider->children); } }
Variant Method::Invoke( Variant &instance, ArgumentList &arguments ) const { #if defined(_DEBUG) UAssert( IsValid( ), "Invalid method invoked." ); UAssert( !(instance.IsConst( ) && !m_isConst), "Non-const method invoked on const object." ); UAssert( instance.GetType( ) == m_classType, "Incompatible method invoked with instance." ); #endif return m_invoker->Invoke( instance, arguments ); }
void GOAPAstar::reconstructPlan(GOAPlanner *ap, astarnode *goal_node) { astarnode *curr = goal_node; auto &plan = ap->_plan; auto &actions = ap->_actions; // clear the plan plan.clear(); while(curr && curr->action_name.length()) { // find the action auto it = actions.find(curr->action_name); UAssert(it != actions.end(), "Action \"%s\" does not exist.", curr->action_name.c_str()); // add the action handler to the plan plan.push_back(it->second.GetFunc()); // check to see if parent is in the closed list int i = nodeInClosed(curr->parent_ws); curr = (i == -1) ? nullptr : &_closed[i]; } }