Core/Movement: minor MotionMaster refactor

This commit is contained in:
hondacrx
2018-03-12 12:55:35 -04:00
parent d953507178
commit 54520c3c18
2 changed files with 26 additions and 26 deletions
+1
View File
@@ -181,6 +181,7 @@ namespace Game.Entities
UpdateSplineMovement(diff);
GetMotionMaster().UpdateMotion(diff);
UpdateUnderwaterState(GetMap(), GetPositionX(), GetPositionY(), GetPositionZ());
}
void _UpdateSpells(uint diff)
{
+25 -26
View File
@@ -81,35 +81,14 @@ namespace Game.Movement
Contract.Assert(!empty());
_cleanFlag |= MMCleanFlag.Update;
if (!top().Update(_owner, diff))
{
_cleanFlag &= ~MMCleanFlag.Update;
bool isMoveGenUpdateSuccess = top().Update(_owner, diff);
_cleanFlag &= ~MMCleanFlag.Update;
if (!isMoveGenUpdateSuccess)
MovementExpired();
}
else
_cleanFlag &= ~MMCleanFlag.Update;
if (_expireList != null)
{
for (int i = 0; i < _expireList.Count; ++i)
{
IMovementGenerator mg = _expireList[i];
DirectDelete(mg);
}
_expireList = null;
if (empty())
Initialize();
else if (NeedInitTop())
InitTop();
else if (Convert.ToBoolean(_cleanFlag & MMCleanFlag.Reset))
top().Reset(_owner);
_cleanFlag &= ~MMCleanFlag.Reset;
}
_owner.UpdateUnderwaterState(_owner.GetMap(), _owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ());
ClearExpireList();
}
public void Clear(bool reset = true)
@@ -126,6 +105,26 @@ namespace Game.Movement
DirectClean(reset);
}
void ClearExpireList()
{
for (int i = 0; i < _expireList.Count; ++i)
{
IMovementGenerator mg = _expireList[i];
DirectDelete(mg);
}
_expireList = null;
if (empty())
Initialize();
else if (NeedInitTop())
InitTop();
else if (Convert.ToBoolean(_cleanFlag & MMCleanFlag.Reset))
top().Reset(_owner);
_cleanFlag &= ~MMCleanFlag.Reset;
}
public void MovementExpired(bool reset = true)
{
if (Convert.ToBoolean(_cleanFlag & MMCleanFlag.Update))