mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-17 04:48:13 +00:00
Make it more robust like speedboost
add check for default Fix error in GetActiveSpeedboosts
This commit is contained in:
@@ -388,3 +388,29 @@ void ControllablePhysicsComponent::SetStunImmunity(
|
||||
bImmuneToStunUseItem
|
||||
);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::AddFallSpeed(float value) {
|
||||
m_ActiveFallSpeeds.push_back(value);
|
||||
m_FallSpeed = value;
|
||||
SetGravityScale(value);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::RemoveFallSpeed(float value) {
|
||||
const auto pos = std::find(m_ActiveFallSpeeds.begin(), m_ActiveFallSpeeds.end(), value);
|
||||
if (pos != m_ActiveFallSpeeds.end()) {
|
||||
m_ActiveFallSpeeds.erase(pos);
|
||||
} else {
|
||||
Game::logger->LogDebug("ControllablePhysicsComponent", "Warning: Could not find FallSpeed %f in list of active FallSpeeds. List has %i active FallSpeeds.", value, m_ActiveFallSpeeds.size());
|
||||
return;
|
||||
}
|
||||
|
||||
// Recalculate FallSpeed since we removed one
|
||||
m_FallSpeed = 0.0f;
|
||||
if (m_ActiveFallSpeeds.size() == 0) { // no active fall speeds left, so return to base gravity
|
||||
m_FallSpeed = 1;
|
||||
} else { // Used the last applied FallSpeed
|
||||
m_FallSpeed = m_ActiveFallSpeeds.back();
|
||||
}
|
||||
SetSpeedMultiplier(m_FallSpeed); // 500 being the base speed
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
@@ -276,7 +276,7 @@ public:
|
||||
* The speed boosts of this component.
|
||||
* @return All active Speed boosts for this component.
|
||||
*/
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActivePickupRadiusScales; };
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActiveSpeedBoosts; };
|
||||
|
||||
/**
|
||||
* Activates the Bubble Buff
|
||||
@@ -317,6 +317,24 @@ public:
|
||||
const bool GetImmuneToStunTurn() { return m_ImmuneToStunTurnCount > 0;};
|
||||
const bool GetImmuneToStunUseItem() { return m_ImmuneToStunUseItemCount > 0;};
|
||||
|
||||
/**
|
||||
* Add a Fall Speed to the entity
|
||||
* This will recalculate the Fall Speed based on what is being added
|
||||
*/
|
||||
void AddFallSpeed(float value);
|
||||
|
||||
/**
|
||||
* Remove Fall Speed from entity
|
||||
* This will recalculate the Fall Speed based on what is the last one in te vector
|
||||
*/
|
||||
void RemoveFallSpeed(float value);
|
||||
|
||||
/**
|
||||
* The Fall Speeds of this component.
|
||||
* @return All active Fall Speeds for this component.
|
||||
*/
|
||||
std::vector<float> GetActiveFallSpeeds() { return m_ActiveFallSpeeds; };
|
||||
|
||||
private:
|
||||
/**
|
||||
* The entity that owns this component
|
||||
@@ -473,6 +491,16 @@ private:
|
||||
int32_t m_ImmuneToStunMoveCount;
|
||||
int32_t m_ImmuneToStunTurnCount;
|
||||
int32_t m_ImmuneToStunUseItemCount;
|
||||
|
||||
/**
|
||||
* The list of fall speeds for this entity
|
||||
*/
|
||||
std::vector<float> m_ActiveFallSpeeds;
|
||||
|
||||
/**
|
||||
* The active fall speed for this entity
|
||||
*/
|
||||
float m_FallSpeed;
|
||||
};
|
||||
|
||||
#endif // CONTROLLABLEPHYSICSCOMPONENT_H
|
||||
|
Reference in New Issue
Block a user