mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 22:13:35 +00:00
Working Pausing and Resuming
This commit is contained in:
parent
6a5ff30a32
commit
aa734ef7ae
@ -25,6 +25,7 @@ namespace {
|
||||
|
||||
MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : Component(parent) {
|
||||
m_Info = info;
|
||||
m_IsPaused = true;
|
||||
m_AtFinalWaypoint = true;
|
||||
|
||||
m_BaseCombatAI = nullptr;
|
||||
@ -70,8 +71,8 @@ void MovementAIComponent::Update(const float deltaTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Are we done?
|
||||
if (AtFinalWaypoint()) return;
|
||||
// Are we done or paused?
|
||||
if (AtFinalWaypoint() || IsPaused()) return;
|
||||
|
||||
if (m_HaltDistance > 0) {
|
||||
// Prevent us from hugging the target
|
||||
@ -207,6 +208,25 @@ bool MovementAIComponent::Warp(const NiPoint3& point) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MovementAIComponent::Pause() {
|
||||
if (AtFinalWaypoint() || IsPaused()) return;
|
||||
SetPosition(ApproximateLocation());
|
||||
SetVelocity(NiPoint3::ZERO);
|
||||
|
||||
// Clear this as we may be somewhere else when we resume movement.
|
||||
m_InterpolatedWaypoints.clear();
|
||||
m_IsPaused = true;
|
||||
m_PathIndex = 0;
|
||||
m_TimeToTravel = 0;
|
||||
m_TimeTravelled = 0;
|
||||
}
|
||||
|
||||
void MovementAIComponent::Resume() {
|
||||
if (AtFinalWaypoint() || !IsPaused()) return;
|
||||
m_IsPaused = false;
|
||||
SetDestination(GetCurrentPathWaypoint());
|
||||
}
|
||||
|
||||
void MovementAIComponent::Stop() {
|
||||
if (AtFinalWaypoint()) return;
|
||||
|
||||
@ -363,6 +383,7 @@ void MovementAIComponent::SetDestination(const NiPoint3& destination) {
|
||||
m_TimeToTravel = 0;
|
||||
|
||||
m_AtFinalWaypoint = false;
|
||||
m_IsPaused = false;
|
||||
}
|
||||
|
||||
NiPoint3 MovementAIComponent::GetDestination() const {
|
||||
|
@ -173,6 +173,12 @@ public:
|
||||
*/
|
||||
bool AtFinalWaypoint() const { return m_AtFinalWaypoint; }
|
||||
|
||||
bool IsPaused() const { return m_IsPaused; }
|
||||
|
||||
void Pause();
|
||||
|
||||
void Resume();
|
||||
|
||||
/**
|
||||
* Renders the entity stationary
|
||||
*/
|
||||
@ -322,6 +328,11 @@ private:
|
||||
* Whether or not the path is being read in reverse
|
||||
*/
|
||||
bool m_IsInReverse;
|
||||
|
||||
/**
|
||||
* Whether or not the current movement via pathing is paused.
|
||||
*/
|
||||
bool m_IsPaused;
|
||||
};
|
||||
|
||||
#endif // MOVEMENTAICOMPONENT_H
|
||||
|
Loading…
Reference in New Issue
Block a user