mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 13:33:35 +00:00
fix: movement ai remove goto, do todo, remove unused call (#1505)
* remove goto * Update MovementAIComponent.cpp
This commit is contained in:
parent
3262bc3a86
commit
2b253a8248
@ -162,7 +162,6 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
// Check if we should stop the tether effect
|
||||
if (m_TetherEffectActive) {
|
||||
m_TetherTime -= deltaTime;
|
||||
const auto& info = m_MovementAI->GetInfo();
|
||||
if (m_Target != LWOOBJID_EMPTY || (NiPoint3::DistanceSquared(
|
||||
m_StartPosition,
|
||||
m_Parent->GetPosition()) < 20 * 20 && m_TetherTime <= 0)
|
||||
|
@ -96,33 +96,29 @@ void MovementAIComponent::Update(const float deltaTime) {
|
||||
|
||||
if (m_NextWaypoint == source) {
|
||||
m_TimeToTravel = 0.0f;
|
||||
} else {
|
||||
if (m_CurrentSpeed < m_MaxSpeed) {
|
||||
m_CurrentSpeed += m_Acceleration;
|
||||
}
|
||||
|
||||
goto nextAction;
|
||||
m_CurrentSpeed = std::min(m_CurrentSpeed, m_MaxSpeed);
|
||||
|
||||
const auto speed = m_CurrentSpeed * m_BaseSpeed; // scale speed based on base speed
|
||||
|
||||
const auto delta = m_NextWaypoint - source;
|
||||
|
||||
// Normalize the vector
|
||||
const auto length = delta.Length();
|
||||
if (length > 0.0f) {
|
||||
velocity = (delta / length) * speed;
|
||||
}
|
||||
|
||||
// Calclute the time it will take to reach the next waypoint with the current speed
|
||||
m_TimeTravelled = 0.0f;
|
||||
m_TimeToTravel = length / speed;
|
||||
|
||||
SetRotation(NiQuaternion::LookAt(source, m_NextWaypoint));
|
||||
}
|
||||
|
||||
if (m_CurrentSpeed < m_MaxSpeed) {
|
||||
m_CurrentSpeed += m_Acceleration;
|
||||
}
|
||||
|
||||
if (m_CurrentSpeed > m_MaxSpeed) {
|
||||
m_CurrentSpeed = m_MaxSpeed;
|
||||
}
|
||||
|
||||
const auto speed = m_CurrentSpeed * m_BaseSpeed; // scale speed based on base speed
|
||||
|
||||
const auto delta = m_NextWaypoint - source;
|
||||
|
||||
// Normalize the vector
|
||||
const auto length = delta.Length();
|
||||
if (length > 0) {
|
||||
velocity = (delta / length) * speed;
|
||||
}
|
||||
|
||||
// Calclute the time it will take to reach the next waypoint with the current speed
|
||||
m_TimeTravelled = 0.0f;
|
||||
m_TimeToTravel = length / speed;
|
||||
|
||||
SetRotation(NiQuaternion::LookAt(source, m_NextWaypoint));
|
||||
} else {
|
||||
// Check if there are more waypoints in the queue, if so set our next destination to the next waypoint
|
||||
if (m_CurrentPath.empty()) {
|
||||
@ -135,8 +131,6 @@ void MovementAIComponent::Update(const float deltaTime) {
|
||||
m_CurrentPath.pop();
|
||||
}
|
||||
|
||||
nextAction:
|
||||
|
||||
SetVelocity(velocity);
|
||||
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
@ -319,8 +313,7 @@ void MovementAIComponent::SetDestination(const NiPoint3& destination) {
|
||||
auto step = delta / 10.0f;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// TODO: Replace this with += when the NiPoint3::operator+= is fixed
|
||||
start = start + step;
|
||||
start += step;
|
||||
|
||||
computedPath.push_back(start);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user