2021-12-05 17:54:36 +00:00
|
|
|
#include "EnemyRoninSpawner.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
#include "RenderComponent.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void EnemyRoninSpawner::OnStartup(Entity* self) {
|
|
|
|
self->SetProximityRadius(15, "ronin");
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void EnemyRoninSpawner::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "hatchTime") {
|
|
|
|
auto* renderComponent = self->GetComponent<RenderComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (renderComponent != nullptr) {
|
|
|
|
renderComponent->PlayEffect(644, u"create", "BurstFX1");
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
EntityInfo info{};
|
|
|
|
info.lot = 7815;
|
|
|
|
info.pos = self->GetPosition();
|
|
|
|
info.rot = self->GetRotation();
|
|
|
|
info.spawnerID = self->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* spawnedEntity = EntityManager::Instance()->CreateEntity(info);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (spawnedEntity == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
EntityManager::Instance()->ConstructEntity(spawnedEntity);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
spawnedEntity->AddCallbackTimer(60, [spawnedEntity]() {
|
|
|
|
spawnedEntity->Smash(spawnedEntity->GetObjectID());
|
|
|
|
});
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->Smash(self->GetObjectID());
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
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);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (skillComponent != nullptr) {
|
|
|
|
skillComponent->CalculateBehavior(305, 3568, LWOOBJID_EMPTY);
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void EnemyRoninSpawner::OnHit(Entity* self, Entity* attacker) {
|
|
|
|
if (!self->GetVar<bool>(u"hatching")) {
|
|
|
|
StartHatching(self);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void EnemyRoninSpawner::StartHatching(Entity* self) {
|
|
|
|
self->SetVar(u"hatching", true);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* renderComponent = self->GetComponent<RenderComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (renderComponent != nullptr) {
|
|
|
|
renderComponent->PlayEffect(2260, u"rebuild_medium", "WakeUpFX1");
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->AddTimer("hatchTime", 2);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|