DarkflameServer/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp
David Markowitz 92006123b8 Another consistency pass
- change NotifyObject to use u16 string
- move stuff to header that is inline
- use u16strings instead of converting to u16 string
- move entity to dEntity
2023-06-16 01:01:13 -07:00

51 lines
1.4 KiB
C++

#include "FvConsoleRightQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
#include "Entity.h"
void FvConsoleRightQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
}
void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, u"ConsoleRightUp");
}
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, u"ConsoleRightDown");
}
}
}
void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"AmActive")) {
return;
}
if (self->GetVar<bool>(u"IAmBuilt")) {
self->SetVar(u"AmActive", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, u"ConsoleRightActive");
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
}