Core/Movement: Implement speed changes for PointMovementGenerator
This commit is contained in:
@@ -33,6 +33,7 @@ void PointMovementGenerator<T>::Initialize(T &unit)
|
|||||||
unit.StopMoving();
|
unit.StopMoving();
|
||||||
|
|
||||||
unit.AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
|
unit.AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
|
||||||
|
i_recalculateSpeed = false;
|
||||||
Movement::MoveSplineInit init(unit);
|
Movement::MoveSplineInit init(unit);
|
||||||
init.MoveTo(i_x, i_y, i_z);
|
init.MoveTo(i_x, i_y, i_z);
|
||||||
if (speed > 0.0f)
|
if (speed > 0.0f)
|
||||||
@@ -53,6 +54,17 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 & /*diff*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unit.AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
unit.AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||||
|
|
||||||
|
if (i_recalculateSpeed && !unit.movespline->Finalized())
|
||||||
|
{
|
||||||
|
i_recalculateSpeed = false;
|
||||||
|
Movement::MoveSplineInit init(unit);
|
||||||
|
init.MoveTo(i_x, i_y, i_z);
|
||||||
|
if (speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit
|
||||||
|
init.SetVelocity(speed);
|
||||||
|
init.Launch();
|
||||||
|
}
|
||||||
|
|
||||||
return !unit.movespline->Finalized();
|
return !unit.movespline->Finalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementG
|
|||||||
|
|
||||||
void MovementInform(T &);
|
void MovementInform(T &);
|
||||||
|
|
||||||
|
void unitSpeedChanged() { i_recalculateSpeed = true; }
|
||||||
|
|
||||||
MovementGeneratorType GetMovementGeneratorType() { return POINT_MOTION_TYPE; }
|
MovementGeneratorType GetMovementGeneratorType() { return POINT_MOTION_TYPE; }
|
||||||
|
|
||||||
bool GetDestination(float& x, float& y, float& z) const { x=i_x; y=i_y; z=i_z; return true; }
|
bool GetDestination(float& x, float& y, float& z) const { x=i_x; y=i_y; z=i_z; return true; }
|
||||||
@@ -43,6 +45,7 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementG
|
|||||||
uint32 id;
|
uint32 id;
|
||||||
float i_x, i_y, i_z;
|
float i_x, i_y, i_z;
|
||||||
float speed;
|
float speed;
|
||||||
|
bool i_recalculateSpeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AssistanceMovementGenerator : public PointMovementGenerator<Creature>
|
class AssistanceMovementGenerator : public PointMovementGenerator<Creature>
|
||||||
|
|||||||
Reference in New Issue
Block a user