mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 21:47:24 +00:00
8cdb388915
* Implement Precompiled Headers * First volume of optimizations * Scripts A-B Gonna be doing this in alphabetical order now. * C Scripts and remove unneeded includes from base cppscripts header Remove the MissionComponent and Loot includes from all base scripts and place their needed includes in the respective scripts. * D scripts * F scripts * F scripts 2 Finish up removing extraneous includes from scripts that start with the letter F * G scripts Removing extraneous includes from scripts that start with the letter G * I scripts Removing extraneous includes from scripts that start with the letter I * M-Z scripts Removing extraneous includes from scripts that start with the letter M-Z * Revert "Implement Precompiled Headers" This reverts commitd79d8d4991
. * Revert "Revert "Implement Precompiled Headers"" This reverts commit0597faf308
. * Add back in PCH Add back in PCH * Fix CMake Whitespace Remove duplicate file glob Remove newline
65 lines
2.3 KiB
C++
65 lines
2.3 KiB
C++
#include "NsConcertChoiceBuildManager.h"
|
|
#include "EntityManager.h"
|
|
|
|
const std::vector<Crate> NsConcertChoiceBuildManager::crates {
|
|
{ "laser", 11203, 5.0, "Concert_Laser_QB_" },
|
|
{ "rocket", 11204, 3.0, "Concert_Rocket_QB_" },
|
|
{ "speaker", 11205, 5.0, "Concert_Speaker_QB_" },
|
|
{ "spotlight", 11206, 5.0, "Concert_Spotlight_QB_" }
|
|
};
|
|
|
|
void NsConcertChoiceBuildManager::OnStartup(Entity *self) {
|
|
NsConcertChoiceBuildManager::SpawnCrate(self);
|
|
}
|
|
|
|
void NsConcertChoiceBuildManager::SpawnCrate(Entity *self) {
|
|
const auto spawnNumber = self->GetVar<uint32_t>(u"spawnNumber") % crates.size();
|
|
const auto crate = crates[spawnNumber];
|
|
|
|
const auto groups = self->GetGroups();
|
|
if (groups.empty())
|
|
return;
|
|
|
|
// Groups are of the form CB_1, CB_2, etc.
|
|
auto group = groups.at(0);
|
|
const auto splitGroup = GeneralUtils::SplitString(group, '_');
|
|
if (splitGroup.size() < 2)
|
|
return;
|
|
const auto groupNumber = std::stoi(splitGroup.at(1));
|
|
|
|
EntityInfo info {};
|
|
info.lot = crate.lot;
|
|
info.pos = self->GetPosition();
|
|
info.rot = self->GetRotation();
|
|
info.spawnerID = self->GetObjectID();
|
|
info.settings = {
|
|
new LDFData<bool>(u"startsQBActivator", true),
|
|
new LDFData<std::string>(u"grpNameQBShowBricks", crate.group + std::to_string(groupNumber)),
|
|
new LDFData<std::u16string>(u"groupID", GeneralUtils::ASCIIToUTF16("Crate_" + group)),
|
|
new LDFData<float>(u"crateTime", crate.time),
|
|
};
|
|
|
|
auto* spawnedCrate = EntityManager::Instance()->CreateEntity(info);
|
|
EntityManager::Instance()->ConstructEntity(spawnedCrate);
|
|
|
|
spawnedCrate->AddDieCallback([self]() {
|
|
self->CancelAllTimers(); // Don't switch if the crate was smashed
|
|
self->SetVar<LWOOBJID>(u"currentCrate", LWOOBJID_EMPTY);
|
|
});
|
|
|
|
self->SetVar<uint32_t>(u"spawnNumber", spawnNumber + 1);
|
|
self->SetVar<float>(u"currentTimer", crate.time);
|
|
self->SetVar<LWOOBJID>(u"currentCrate", spawnedCrate->GetObjectID());
|
|
|
|
// Timer that rotates the crates
|
|
self->AddCallbackTimer(crate.time, [self]() {
|
|
auto crateID = self->GetVar<LWOOBJID>(u"currentCrate");
|
|
if (crateID != LWOOBJID_EMPTY) {
|
|
EntityManager::Instance()->DestroyEntity(crateID);
|
|
self->SetVar<LWOOBJID>(u"currentCrate", LWOOBJID_EMPTY);
|
|
}
|
|
|
|
SpawnCrate(self);
|
|
});
|
|
}
|