2022-05-18 00:12:43 +00:00
|
|
|
#include "ActMine.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
#include "DestroyableComponent.h"
|
2023-12-29 04:24:30 +00:00
|
|
|
#include "QuickBuildComponent.h"
|
2022-05-18 00:12:43 +00:00
|
|
|
|
|
|
|
void ActMine::OnStartup(Entity* self) {
|
2023-12-29 04:24:30 +00:00
|
|
|
self->SetVar(u"QuickBuildComplete", false);
|
2022-05-18 00:12:43 +00:00
|
|
|
self->SetProximityRadius(MINE_RADIUS, "mineRadius");
|
|
|
|
}
|
|
|
|
|
2023-12-29 04:24:30 +00:00
|
|
|
void ActMine::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
|
|
|
|
if (state == eQuickBuildState::COMPLETED) {
|
|
|
|
auto* rebuild = self->GetComponent<QuickBuildComponent>();
|
2022-05-18 00:12:43 +00:00
|
|
|
if (rebuild) {
|
|
|
|
auto* builder = rebuild->GetBuilder();
|
|
|
|
self->SetVar(u"Builder", builder->GetObjectID());
|
|
|
|
}
|
|
|
|
|
2023-12-29 04:24:30 +00:00
|
|
|
self->SetVar(u"QuickBuildComplete", true);
|
2022-05-18 00:12:43 +00:00
|
|
|
self->SetVar(u"NumWarnings", 0);
|
|
|
|
self->AddToGroup("reset");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActMine::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
|
|
|
auto* detroyable = self->GetComponent<DestroyableComponent>();
|
|
|
|
if (!detroyable) return;
|
2023-12-29 04:24:30 +00:00
|
|
|
if (status == "ENTER" && self->GetVar<bool>(u"QuickBuildComplete") == true && detroyable->IsEnemy(entering)) {
|
2022-05-18 00:12:43 +00:00
|
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 242, u"orange", "sirenlight_B");
|
|
|
|
self->AddTimer("Tick", TICK_TIME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActMine::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "Tick") {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (self->GetVar<int>(u"NumWarnings") >= MAX_WARNINGS) {
|
2022-05-18 00:12:43 +00:00
|
|
|
auto* skill = self->GetComponent<SkillComponent>();
|
|
|
|
if (!skill) return;
|
|
|
|
skill->CalculateBehavior(SKILL_ID, BEHAVIOR_ID, LWOOBJID_EMPTY);
|
|
|
|
self->AddTimer("BlowedUp", BLOWED_UP_TIME);
|
|
|
|
} else {
|
|
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 242, u"orange", "sirenlight_B");
|
|
|
|
self->AddTimer("Tick", TICK_TIME);
|
|
|
|
self->SetVar(u"NumWarnings", self->GetVar<int>(u"NumWarnings") + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timerName == "BlowedUp") {
|
|
|
|
self->Kill(self);
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|