mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-25 11:21:58 +01:00
Core/Movement: move DelayedAction into MotionMaster and add a couple defines
(cherry picked from commit 2b78c70810)
This commit is contained in:
@@ -97,7 +97,7 @@ void MotionMaster::Initialize()
|
||||
{
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this]()
|
||||
DelayedActionDefine action = [this]()
|
||||
{
|
||||
Initialize();
|
||||
};
|
||||
@@ -324,7 +324,7 @@ void MotionMaster::Add(MovementGenerator* movement, MovementSlot slot/* = MOTION
|
||||
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this, movement, slot]()
|
||||
DelayedActionDefine action = [this, movement, slot]()
|
||||
{
|
||||
Add(movement, slot);
|
||||
};
|
||||
@@ -341,7 +341,7 @@ void MotionMaster::Remove(MovementGenerator* movement, MovementSlot slot/* = MOT
|
||||
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this, movement, slot]()
|
||||
DelayedActionDefine action = [this, movement, slot]()
|
||||
{
|
||||
Remove(movement, slot);
|
||||
};
|
||||
@@ -379,7 +379,7 @@ void MotionMaster::Remove(MovementGeneratorType type, MovementSlot slot/* = MOTI
|
||||
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this, type, slot]()
|
||||
DelayedActionDefine action = [this, type, slot]()
|
||||
{
|
||||
Remove(type, slot);
|
||||
};
|
||||
@@ -417,7 +417,7 @@ void MotionMaster::Clear()
|
||||
{
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this]()
|
||||
DelayedActionDefine action = [this]()
|
||||
{
|
||||
Clear();
|
||||
};
|
||||
@@ -436,7 +436,7 @@ void MotionMaster::Clear(MovementSlot slot)
|
||||
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this, slot]()
|
||||
DelayedActionDefine action = [this, slot]()
|
||||
{
|
||||
Clear(slot);
|
||||
};
|
||||
@@ -464,7 +464,7 @@ void MotionMaster::Clear(MovementGeneratorMode mode)
|
||||
{
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this, mode]()
|
||||
DelayedActionDefine action = [this, mode]()
|
||||
{
|
||||
Clear(mode);
|
||||
};
|
||||
@@ -486,7 +486,7 @@ void MotionMaster::Clear(MovementGeneratorPriority priority)
|
||||
{
|
||||
if (HasFlag(MOTIONMASTER_FLAG_UPDATE))
|
||||
{
|
||||
std::function<void()> action = [this, priority]()
|
||||
DelayedActionDefine action = [this, priority]()
|
||||
{
|
||||
Clear(priority);
|
||||
};
|
||||
|
||||
@@ -87,23 +87,26 @@ static bool EmptyValidator()
|
||||
return true;
|
||||
}
|
||||
|
||||
class MotionMasterDelayedAction
|
||||
{
|
||||
public:
|
||||
explicit MotionMasterDelayedAction(std::function<void()>&& action, std::function<bool()>&& validator, MotionMasterDelayedActionType type) : Action(std::move(action)), Validator(std::move(validator)), Type(type) { }
|
||||
explicit MotionMasterDelayedAction(std::function<void()>&& action, MotionMasterDelayedActionType type) : Action(std::move(action)), Validator(EmptyValidator), Type(type) { }
|
||||
~MotionMasterDelayedAction() { }
|
||||
|
||||
void Resolve() { if (Validator()) Action(); }
|
||||
|
||||
std::function<void()> Action;
|
||||
std::function<bool()> Validator;
|
||||
uint8 Type;
|
||||
};
|
||||
|
||||
class TC_GAME_API MotionMaster
|
||||
{
|
||||
public:
|
||||
typedef std::function<void()> DelayedActionDefine;
|
||||
typedef std::function<bool()> DelayedActionValidator;
|
||||
|
||||
class DelayedAction
|
||||
{
|
||||
public:
|
||||
explicit DelayedAction(DelayedActionDefine&& action, DelayedActionValidator&& validator, MotionMasterDelayedActionType type) : Action(std::move(action)), Validator(std::move(validator)), Type(type) { }
|
||||
explicit DelayedAction(DelayedActionDefine&& action, MotionMasterDelayedActionType type) : Action(std::move(action)), Validator(EmptyValidator), Type(type) { }
|
||||
~DelayedAction() { }
|
||||
|
||||
void Resolve() { if (Validator()) Action(); }
|
||||
|
||||
DelayedActionDefine Action;
|
||||
DelayedActionValidator Validator;
|
||||
uint8 Type;
|
||||
};
|
||||
|
||||
explicit MotionMaster(Unit* unit);
|
||||
~MotionMaster();
|
||||
|
||||
@@ -214,7 +217,7 @@ class TC_GAME_API MotionMaster
|
||||
MovementGeneratorPointer _defaultGenerator;
|
||||
MotionMasterContainer _generators;
|
||||
MotionMasterUnitStatesContainer _baseUnitStatesMap;
|
||||
std::deque<MotionMasterDelayedAction> _delayedActions;
|
||||
std::deque<DelayedAction> _delayedActions;
|
||||
uint8 _flags;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user