Core/Movement: add new helper that cleans the referenced MovementSlot

This commit is contained in:
ccrs
2017-08-08 19:35:13 +02:00
parent 9fa68855d7
commit ee2d7c1d53
2 changed files with 41 additions and 17 deletions

View File

@@ -119,23 +119,6 @@ void MotionMaster::Clear(bool reset /*= true*/)
DirectClean(reset);
}
void MotionMaster::ClearExpireList()
{
for (auto itr : _expireList)
DirectDelete(itr);
_expireList.clear();
if (empty())
Initialize();
else if (NeedInitTop())
InitTop();
else if (_cleanFlag & MMCF_RESET)
top()->Reset(_owner);
_cleanFlag &= ~MMCF_RESET;
}
void MotionMaster::MovementExpired(bool reset /*= true*/)
{
if (_cleanFlag & MMCF_UPDATE)
@@ -150,6 +133,29 @@ void MotionMaster::MovementExpired(bool reset /*= true*/)
DirectExpire(reset);
}
void MotionMaster::ExpireMovement(MovementSlot slot)
{
if (empty() || slot >= MAX_MOTION_SLOT)
return;
if (MovementGenerator* motion = GetMotionSlot(slot))
{
DirectDelete(motion);
_slot[slot] = nullptr;
}
if (!top())
{
while (!empty() && !top())
--_top;
if (empty())
Initialize();
else if (NeedInitTop())
InitTop();
}
}
MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const
{
if (empty())
@@ -832,3 +838,20 @@ void MotionMaster::DelayedDelete(MovementGenerator* curr)
_expireList.push_back(curr);
}
void MotionMaster::ClearExpireList()
{
for (auto itr : _expireList)
DirectDelete(itr);
_expireList.clear();
if (empty())
Initialize();
else if (NeedInitTop())
InitTop();
else if (_cleanFlag & MMCF_RESET)
top()->Reset(_owner);
_cleanFlag &= ~MMCF_RESET;
}

View File

@@ -106,6 +106,7 @@ class TC_GAME_API MotionMaster
void Clear(bool reset = true);
void MovementExpired(bool reset = true);
void ExpireMovement(MovementSlot slot);
MovementGeneratorType GetCurrentMovementGeneratorType() const;
MovementGeneratorType GetMotionSlotType(int slot) const;