Update Waypoint System and Commands

Update Waypoint System and Commands
This commit is contained in:
Charles A Edwards 2016-08-30 11:15:20 +01:00 committed by Antz
parent 870b4dd0a4
commit 6ac38a0d65
48 changed files with 455 additions and 323 deletions

View file

@ -59,8 +59,10 @@ void MotionMaster::Initialize()
if (m_owner->GetTypeId() == TYPEID_UNIT && !m_owner->hasUnitState(UNIT_STAT_CONTROLLED))
{
MovementGenerator* movement = FactorySelector::selectMovementGenerator((Creature*)m_owner);
push(movement == NULL ? &si_idleMovement : movement);
push(movement == nullptr ? &si_idleMovement : movement);
top()->Initialize(*m_owner);
if (top()->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
(static_cast<WaypointMovementGenerator<Creature>*>(top()))->InitializeWaypointPath(*((Creature*)(m_owner)), 0, PATH_NO_PATH, 0, 0);
}
else
push(&si_idleMovement);
@ -376,20 +378,22 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
}
}
void MotionMaster::MoveWaypoint()
void MotionMaster::MoveWaypoint(int32 id /*=0*/, uint32 source /*=0==PATH_NO_PATH*/, uint32 initialDelay /*=0*/, uint32 overwriteEntry /*=0*/)
{
if (m_owner->GetTypeId() == TYPEID_UNIT)
{
if (GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
{
sLog.outError("Creature %s (Entry %u) attempt to MoveWaypoint() but creature is already using waypoint", m_owner->GetGuidStr().c_str(), m_owner->GetEntry());
sLog.outError("%s attempt to MoveWaypoint() but is already using waypoint", m_owner->GetGuidStr().c_str());
return;
}
Creature* creature = (Creature*)m_owner;
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature %s (Entry %u) start MoveWaypoint()", m_owner->GetGuidStr().c_str(), m_owner->GetEntry());
Mutate(new WaypointMovementGenerator<Creature>(*creature));
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s start MoveWaypoint()", m_owner->GetGuidStr().c_str());
WaypointMovementGenerator<Creature>* newWPMMgen = new WaypointMovementGenerator<Creature>(*creature);
Mutate(newWPMMgen);
newWPMMgen->InitializeWaypointPath(*creature, id, (WaypointPathOrigin)source, initialDelay, overwriteEntry);
}
else
{
@ -469,6 +473,16 @@ void MotionMaster::propagateSpeedChange()
}
}
bool MotionMaster::SetNextWaypoint(uint32 pointId)
{
for (Impl::container_type::reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr)
{
if ((*rItr)->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
return (static_cast<WaypointMovementGenerator<Creature>*>(*rItr))->SetNextWaypoint(pointId);
}
return false;
}
uint32 MotionMaster::getLastReachedWaypoint() const
{
for (Impl::container_type::const_reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr)
@ -487,6 +501,18 @@ MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const
return top()->GetMovementGeneratorType();
}
void MotionMaster::GetWaypointPathInformation(std::ostringstream& oss) const
{
for (Impl::container_type::const_reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr)
{
if ((*rItr)->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
{
static_cast<WaypointMovementGenerator<Creature>*>(*rItr)->GetPathInformation(oss);
return;
}
}
}
bool MotionMaster::GetDestination(float& x, float& y, float& z)
{
if (m_owner->movespline->Finalized())