fix stewblaster stopping for non-players (#1521)

fixes an issue when stew blaster would stop for non-players and would stand still permanently due to enemy hitboxes being removed.  Tested that stewblaster only stops for players and starts moving when there are no players in the vicinity
This commit is contained in:
David Markowitz
2024-03-30 06:17:56 -07:00
committed by GitHub
parent 150031861d
commit 5996f3cbf4
2 changed files with 13 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
#include "WanderingVendor.h"
#include "MovementAIComponent.h"
#include "ProximityMonitorComponent.h"
#include <ranges>
void WanderingVendor::OnStartup(Entity* self) {
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
@@ -19,7 +20,16 @@ void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::str
if (!proximityMonitorComponent) self->AddComponent<ProximityMonitorComponent>();
const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor");
if (proxObjs.empty()) self->AddTimer("startWalking", 1.5);
bool foundPlayer = false;
for (const auto id : proxObjs | std::views::keys) {
auto* entity = Game::entityManager->GetEntity(id);
if (entity && entity->IsPlayer()) {
foundPlayer = true;
break;
}
}
if (!foundPlayer) self->AddTimer("startWalking", 1.5);
}
}