mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-15 04:38:21 +00:00
772ac06e94
Update Zone.cpp Update Zone.h Update Zone.h Update MovingPlatformComponent.cpp Update ProximityMonitorComponent.cpp quick cleanup Use correct logging
36 lines
1.3 KiB
C++
36 lines
1.3 KiB
C++
#include "WanderingVendor.h"
|
|
#include "MovementAIComponent.h"
|
|
#include "ProximityMonitorComponent.h"
|
|
|
|
void WanderingVendor::OnStartup(Entity* self) {
|
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
|
if (!movementAIComponent) return;
|
|
movementAIComponent->Resume();
|
|
self->SetProximityRadius(10, "playermonitor");
|
|
}
|
|
|
|
void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
|
if (status == "ENTER" && entering->IsPlayer()) {
|
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
|
if (!movementAIComponent) return;
|
|
movementAIComponent->Pause();
|
|
self->CancelTimer("startWalking");
|
|
} else if (status == "LEAVE") {
|
|
auto* proximityMonitorComponent = self->GetComponent<ProximityMonitorComponent>();
|
|
if (!proximityMonitorComponent) {
|
|
LOG("Proximity monitor component not found!");
|
|
return;
|
|
}
|
|
const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor");
|
|
if (proxObjs.empty()) self->AddTimer("startWalking", 1.5);
|
|
}
|
|
}
|
|
|
|
void WanderingVendor::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName == "startWalking") {
|
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
|
if (!movementAIComponent) return;
|
|
movementAIComponent->Resume();
|
|
}
|
|
}
|