DarkflameServer/dScripts/NtImagBeamBuffer.cpp

54 lines
1.4 KiB
C++
Raw Normal View History

#include "NtImagBeamBuffer.h"
#include "EntityManager.h"
#include "SkillComponent.h"
2022-07-28 13:39:57 +00:00
void NtImagBeamBuffer::OnStartup(Entity* self) {
self->SetProximityRadius(100, "ImagZone");
2022-07-28 13:39:57 +00:00
self->AddTimer("BuffImag", 2.0f);
}
2022-07-28 13:39:57 +00:00
void NtImagBeamBuffer::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
if (name != "ImagZone" || !entering->IsPlayer()) {
return;
}
2022-07-28 13:39:57 +00:00
if (status == "ENTER") {
const auto& iter = std::find(m_EntitiesInProximity.begin(), m_EntitiesInProximity.end(), entering->GetObjectID());
2022-07-28 13:39:57 +00:00
if (iter == m_EntitiesInProximity.end()) {
m_EntitiesInProximity.push_back(entering->GetObjectID());
}
} else if (status == "LEAVE") {
const auto& iter = std::find(m_EntitiesInProximity.begin(), m_EntitiesInProximity.end(), entering->GetObjectID());
2022-07-28 13:39:57 +00:00
if (iter != m_EntitiesInProximity.end()) {
m_EntitiesInProximity.erase(iter);
}
}
}
2022-07-28 13:39:57 +00:00
void NtImagBeamBuffer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName != "BuffImag") {
return;
}
2022-07-28 13:39:57 +00:00
auto* skillComponent = self->GetComponent<SkillComponent>();
2022-07-28 13:39:57 +00:00
if (skillComponent == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
for (const auto entityID : m_EntitiesInProximity) {
auto* entity = EntityManager::Instance()->GetEntity(entityID);
2022-07-28 13:39:57 +00:00
if (entity == nullptr) {
continue;
}
2022-07-28 13:39:57 +00:00
skillComponent->CalculateBehavior(1311, 30235, entityID, true);
}
2022-07-28 13:39:57 +00:00
self->AddTimer("BuffImag", 2.0f);
}