Merge pull request #518 from EmosewaMC/popup-fix

Pop up now appears for life containers
This commit is contained in:
David Markowitz 2022-04-24 18:39:35 -07:00 committed by GitHub
commit 7b32d2f609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 15 deletions

View File

@ -215,6 +215,8 @@ void DestroyableComponent::SetHealth(int32_t value) {
void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
m_DirtyHealth = true;
// Used for playAnim if opted in for.
int32_t difference = static_cast<int32_t>(std::abs(m_fMaxHealth - value));
m_fMaxHealth = value;
if (m_iHealth > m_fMaxHealth) {
@ -225,23 +227,21 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
// Now update the player bar
if (!m_Parent->GetParentUser()) return;
AMFStringValue* amount = new AMFStringValue();
amount->SetStringValue(std::to_string(value));
amount->SetStringValue(std::to_string(difference));
AMFStringValue* type = new AMFStringValue();
type->SetStringValue("health");
AMFArrayValue args;
args.InsertValue("amount", amount);
args.InsertValue("type", type);
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
delete amount;
delete type;
}
else {
EntityManager::Instance()->SerializeEntity(m_Parent);
}
}
void DestroyableComponent::SetArmor(int32_t value) {
m_DirtyHealth = true;
@ -287,10 +287,9 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) {
delete amount;
delete type;
}
else {
EntityManager::Instance()->SerializeEntity(m_Parent);
}
}
void DestroyableComponent::SetImagination(int32_t value) {
m_DirtyHealth = true;
@ -310,6 +309,8 @@ void DestroyableComponent::SetImagination(int32_t value) {
void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
m_DirtyHealth = true;
// Used for playAnim if opted in for.
int32_t difference = static_cast<int32_t>(std::abs(m_fMaxImagination - value));
m_fMaxImagination = value;
if (m_iImagination > m_fMaxImagination) {
@ -320,23 +321,20 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
// Now update the player bar
if (!m_Parent->GetParentUser()) return;
AMFStringValue* amount = new AMFStringValue();
amount->SetStringValue(std::to_string(value));
amount->SetStringValue(std::to_string(difference));
AMFStringValue* type = new AMFStringValue();
type->SetStringValue("imagination");
AMFArrayValue args;
args.InsertValue("amount", amount);
args.InsertValue("type", type);
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
delete amount;
delete type;
}
else {
EntityManager::Instance()->SerializeEntity(m_Parent);
}
}
void DestroyableComponent::SetDamageToAbsorb(int32_t value)
{

View File

@ -528,11 +528,11 @@ void Mission::YieldRewards() {
}
if (info->reward_maxhealth > 0) {
destroyableComponent->SetMaxHealth(destroyableComponent->GetMaxHealth() + static_cast<float>(info->reward_maxhealth));
destroyableComponent->SetMaxHealth(destroyableComponent->GetMaxHealth() + static_cast<float>(info->reward_maxhealth), true);
}
if (info->reward_maximagination > 0) {
destroyableComponent->SetMaxImagination(destroyableComponent->GetMaxImagination() + static_cast<float>(info->reward_maximagination));
destroyableComponent->SetMaxImagination(destroyableComponent->GetMaxImagination() + static_cast<float>(info->reward_maximagination), true);
}
EntityManager::Instance()->SerializeEntity(entity);