mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-28 08:27:22 +00:00
WIP
This commit is contained in:
parent
199c73cf75
commit
848732e01a
@ -16,9 +16,9 @@ std::map<LOT, float> MovementAIComponent::m_PhysicsSpeedCache = {};
|
|||||||
MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : Component(parent) {
|
MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : Component(parent) {
|
||||||
m_Info = std::move(info);
|
m_Info = std::move(info);
|
||||||
m_Done = true;
|
m_Done = true;
|
||||||
|
m_IsPaused = false;
|
||||||
|
|
||||||
m_BaseCombatAI = nullptr;
|
m_BaseCombatAI = nullptr;
|
||||||
|
|
||||||
m_BaseCombatAI = reinterpret_cast<BaseCombatAIComponent*>(m_Parent->GetComponent(COMPONENT_TYPE_BASE_COMBAT_AI));
|
m_BaseCombatAI = reinterpret_cast<BaseCombatAIComponent*>(m_Parent->GetComponent(COMPONENT_TYPE_BASE_COMBAT_AI));
|
||||||
|
|
||||||
//Try and fix the insane values:
|
//Try and fix the insane values:
|
||||||
@ -36,16 +36,21 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) :
|
|||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
m_CurrentSpeed = 0;
|
m_CurrentSpeed = 0;
|
||||||
m_Speed = 0;
|
m_Speed = 0;
|
||||||
|
|
||||||
m_TotalTime = 0;
|
m_TotalTime = 0;
|
||||||
m_LockRotation = false;
|
m_LockRotation = false;
|
||||||
|
|
||||||
|
|
||||||
m_MovementPath = nullptr;
|
m_MovementPath = nullptr;
|
||||||
m_isReverse = false;
|
m_isReverse = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MovementAIComponent::~MovementAIComponent() = default;
|
MovementAIComponent::~MovementAIComponent() = default;
|
||||||
|
|
||||||
void MovementAIComponent::Update(const float deltaTime) {
|
void MovementAIComponent::Update(const float deltaTime) {
|
||||||
|
if (m_IsPaused) return;
|
||||||
if (m_Interrupted) {
|
if (m_Interrupted) {
|
||||||
const auto source = GetCurrentWaypoint();
|
const auto source = GetCurrentWaypoint();
|
||||||
|
|
||||||
@ -66,7 +71,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AtFinalWaypoint()) return; // Are we donw?
|
if (AtFinalWaypoint()) return; // Are we done?
|
||||||
|
|
||||||
if (m_HaltDistance > 0) {
|
if (m_HaltDistance > 0) {
|
||||||
if (Vector3::DistanceSquared(ApproximateLocation(), GetDestination()) < m_HaltDistance * m_HaltDistance) { // Prevent us from hugging the target
|
if (Vector3::DistanceSquared(ApproximateLocation(), GetDestination()) < m_HaltDistance * m_HaltDistance) { // Prevent us from hugging the target
|
||||||
@ -78,15 +83,13 @@ void MovementAIComponent::Update(const float deltaTime) {
|
|||||||
// Game::logger->Log("MovementAIComponent", "timer %f", m_Timer);
|
// Game::logger->Log("MovementAIComponent", "timer %f", m_Timer);
|
||||||
if (m_Timer > 0) {
|
if (m_Timer > 0) {
|
||||||
m_Timer -= deltaTime;
|
m_Timer -= deltaTime;
|
||||||
|
if (m_Timer > 0) return;
|
||||||
if (m_Timer > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const auto source = GetCurrentWaypoint();
|
const auto source = GetCurrentWaypoint();
|
||||||
|
// We've arrived at a waypoint, do the things if we need to
|
||||||
|
|
||||||
SetPosition(source);
|
SetPosition(source);
|
||||||
|
|
||||||
@ -107,7 +110,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
|||||||
m_CurrentSpeed = m_Speed;
|
m_CurrentSpeed = m_Speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto speed = m_CurrentSpeed * m_BaseSpeed;
|
const auto speed = m_BaseSpeed;
|
||||||
|
|
||||||
const auto delta = m_NextWaypoint - source;
|
const auto delta = m_NextWaypoint - source;
|
||||||
|
|
||||||
|
@ -343,6 +343,17 @@ private:
|
|||||||
* If we are reversing on a path
|
* If we are reversing on a path
|
||||||
*/
|
*/
|
||||||
bool m_isReverse;
|
bool m_isReverse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we are waiting on a delay before moving
|
||||||
|
*/
|
||||||
|
bool m_IsWaiting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we are paused for some reason
|
||||||
|
*/
|
||||||
|
bool m_IsPaused;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MOVEMENTAICOMPONENT_H
|
#endif // MOVEMENTAICOMPONENT_H
|
||||||
|
Loading…
Reference in New Issue
Block a user