DarkflameServer/dScripts/ai/FV/ActParadoxPipeFix.cpp

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

63 lines
1.8 KiB
C++
Raw Normal View History

#include "ActParadoxPipeFix.h"
#include "EntityManager.h"
#include "QuickBuildComponent.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "eEndBehavior.h"
void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
const auto myGroup = "AllPipes";
2022-07-28 13:39:57 +00:00
const auto groupObjs = EntityManager::Instance()->GetEntitiesInGroup(myGroup);
2022-07-28 13:39:57 +00:00
auto indexCount = 0;
2022-07-28 13:39:57 +00:00
self->SetVar(u"PlayerID", target->GetObjectID());
2022-07-28 13:39:57 +00:00
for (auto* object : groupObjs) {
if (object == self) {
continue;
}
2022-07-28 13:39:57 +00:00
auto* quickBuildComponent = object->GetComponent<QuickBuildComponent>();
2022-07-28 13:39:57 +00:00
if (quickBuildComponent->GetState() == eRebuildState::COMPLETED) {
indexCount++;
}
}
2022-07-28 13:39:57 +00:00
if (indexCount >= 2) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
2022-07-28 13:39:57 +00:00
if (!refinery.empty()) {
GameMessages::SendPlayFXEffect(refinery[0]->GetObjectID(), 3999, u"create", "pipeFX");
}
2022-07-28 13:39:57 +00:00
for (auto* object : groupObjs) {
auto* player = EntityManager::Instance()->GetEntity(object->GetVar<LWOOBJID>(u"PlayerID"));
2022-07-28 13:39:57 +00:00
if (player != nullptr) {
auto* missionComponent = player->GetComponent<MissionComponent>();
2022-07-28 13:39:57 +00:00
if (missionComponent != nullptr) {
missionComponent->ForceProgressTaskType(769, 1, 1, false);
}
2022-07-28 13:39:57 +00:00
GameMessages::SendPlayCinematic(player->GetObjectID(), u"ParadoxPipeFinish", player->GetSystemAddress(), true, true, false, false, eEndBehavior::RETURN, false, 2.0f);
}
2022-07-28 13:39:57 +00:00
object->SetVar(u"PlayerID", LWOOBJID_EMPTY);
}
}
}
void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::RESETTING) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
2022-07-28 13:39:57 +00:00
if (!refinery.empty()) {
GameMessages::SendStopFXEffect(refinery[0], true, "pipeFX");
}
}
}