2021-12-05 17:54:36 +00:00
|
|
|
#include "PrSeagullFly.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "Entity.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PrSeagullFly::OnStartup(Entity* self) {
|
2021-12-05 17:54:36 +00:00
|
|
|
self->SetVar<int32_t>(u"playersNear", 0);
|
2022-07-28 13:39:57 +00:00
|
|
|
self->SetProximityRadius(15, "birdMonitor");
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PrSeagullFly::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
|
|
|
if (!entering->IsPlayer()) return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (status == "ENTER") {
|
2021-12-05 17:54:36 +00:00
|
|
|
self->SetVar<int32_t>(u"playersNear", self->GetVar<int32_t>(u"playersNear") + 1);
|
2022-07-28 13:39:57 +00:00
|
|
|
} else if (status == "LEAVE") {
|
2021-12-05 17:54:36 +00:00
|
|
|
self->SetVar<int32_t>(u"playersNear", self->GetVar<int32_t>(u"playersNear") - 1);
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->SetNetworkVar(u"BirdLanded", self->GetVar<int32_t>(u"playersNear") == 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|