fix: prevent negative imagination

And fail switch if we don't have enough imagination
This commit is contained in:
Aaron Kimbre 2023-05-09 22:14:46 -05:00
parent 4ff5afd9f7
commit 051395e4c9
2 changed files with 2 additions and 2 deletions

View File

@ -30,7 +30,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
Game::logger->LogDebug("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination()); Game::logger->LogDebug("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
if (state || (entity->GetLOT() == 8092 && destroyableComponent->GetImagination() >= m_imagination)) { if (state && destroyableComponent->GetImagination() >= m_imagination) {
this->m_actionTrue->Handle(context, bitStream, branch); this->m_actionTrue->Handle(context, bitStream, branch);
} else { } else {
this->m_actionFalse->Handle(context, bitStream, branch); this->m_actionFalse->Handle(context, bitStream, branch);

View File

@ -203,7 +203,7 @@ void RebuildComponent::Update(float deltaTime) {
++m_DrainedImagination; ++m_DrainedImagination;
if (newImagination == 0 && m_DrainedImagination < m_TakeImagination) { if (newImagination <= 0 && m_DrainedImagination < m_TakeImagination) {
CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true); CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true);
break; break;