DarkflameServer/dScripts/02_server/Map/FV/EnemyRoninSpawner.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.8 KiB
C++
Raw Permalink Normal View History

#include "EnemyRoninSpawner.h"
#include "SkillComponent.h"
#include "RenderComponent.h"
#include "EntityInfo.h"
#include "EntityManager.h"
void EnemyRoninSpawner::OnStartup(Entity* self) {
self->SetProximityRadius(15, "ronin");
}
void EnemyRoninSpawner::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "hatchTime") {
auto* renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {
renderComponent->PlayEffect(644, u"create", "BurstFX1");
}
EntityInfo info{};
info.lot = 7815;
info.pos = self->GetPosition();
info.rot = self->GetRotation();
info.spawnerID = self->GetObjectID();
auto* spawnedEntity = Game::entityManager->CreateEntity(info);
if (spawnedEntity == nullptr) {
return;
}
Game::entityManager->ConstructEntity(spawnedEntity);
spawnedEntity->AddCallbackTimer(60, [spawnedEntity]() {
spawnedEntity->Smash(spawnedEntity->GetObjectID());
});
self->Smash(self->GetObjectID());
}
}
void EnemyRoninSpawner::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
if (entering->IsPlayer() && name == "ronin" && status == "ENTER" && !self->GetVar<bool>(u"hatching")) {
StartHatching(self);
auto* skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(305, 3568, LWOOBJID_EMPTY);
}
}
}
void EnemyRoninSpawner::OnHit(Entity* self, Entity* attacker) {
if (!self->GetVar<bool>(u"hatching")) {
StartHatching(self);
}
}
void EnemyRoninSpawner::StartHatching(Entity* self) {
self->SetVar(u"hatching", true);
auto* renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {
renderComponent->PlayEffect(2260, u"rebuild_medium", "WakeUpFX1");
}
self->AddTimer("hatchTime", 2);
}