template<typename... Args>
MotionState* MotionMaster::CreateStandartState(MotionStateId stateId, Args... args)
{
std::tuple<Args...> params = std::make_tuple(std::forward<Args>(args)...);
MotionState* state = nullptr;
switch (stateId)
{
/*...*/
case MOTION_STATE_RANDOM:
{
float x = std::get<0>(params);
float y = std::get<1>(params);
float z = std::get<2>(params);
float radius = std::get<3>(params);
float vz = std::get<4>(params);
state = new RandomState<Creature>(x, y, z, radius, vz);
break;
}
case MOTION_STATE_POINT:
{
uint32 id = std::get<0>(params);
float x = std::get<1>(params);
float y = std::get<2>(params);
float z = std::get<3>(params);
bool generatePath = std::get<4>(params);
state = new PointState<Creature>(id, x, y, z, generatePath);
break;
}
case MOTION_STATE_WAYPOINT:
{
uint32 id = std::get<0>(params);
uint32 source = std::get<1>(params);
uint32 initialDelay = std::get<2>(params);
uint32 overwriteEntry = std::get<3>(params);
Creature* creature = (Creature*)m_owner;
state = new WaypointState<Creature>(*creature);
((WaypointState<Creature>*)state)->InitializeWaypointPath(*creature, id, (WaypointPathOrigin)source, initialDelay, overwriteEntry);
break;
}
/* ... */
}
return state;
}