mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
feat(scripts): L_FIRETEMPLE_BOSS_ACTIVATORS_SERVER
The boss room's rail activators: used once built, they work as rail activators and tell the boss manager (group BossManager) their spawner node (ActivatorUsed, param1 = spawner_node_id). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL_NINJAGO
|
||||
"NjRailActivatorsServer.cpp"
|
||||
"FireTempleBossActivatorsServer.cpp"
|
||||
"NjRailPostServer.cpp"
|
||||
"NjIceRailActivator.cpp"
|
||||
"NjhubLavaPlayerDeathTrigger.cpp"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "FireTempleBossActivatorsServer.h"
|
||||
#include "Entity.h"
|
||||
#include "EntityManager.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "eQuickBuildState.h"
|
||||
|
||||
void FireTempleBossActivatorsServer::OnUse(Entity* self, Entity* user) {
|
||||
auto* const quickBuild = self->GetComponent<QuickBuildComponent>();
|
||||
if (quickBuild && quickBuild->GetState() != eQuickBuildState::COMPLETED) return;
|
||||
NjRailActivatorsServer::OnUse(self, user);
|
||||
const auto node = self->GetVarAs<int32_t>(u"spawner_node_id");
|
||||
for (auto* const manager : Game::entityManager->GetEntitiesInGroup("BossManager")) {
|
||||
if (manager) manager->NotifyObject(self, "ActivatorUsed", node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "NjRailActivatorsServer.h"
|
||||
|
||||
// L_FIRETEMPLE_BOSS_ACTIVATORS_SERVER.lua (LOTs 16906-16910): the Fire Temple boss room's rail activators. Used once
|
||||
// built, they work as any rail activator, then tell the boss manager (group BossManager) which spawner node they
|
||||
// stand at (ActivatorUsed, param1 = spawner_node_id).
|
||||
class FireTempleBossActivatorsServer : public NjRailActivatorsServer {
|
||||
public:
|
||||
void OnUse(Entity* self, Entity* user) override;
|
||||
};
|
||||
@@ -2,5 +2,6 @@
|
||||
#include "NjRailPostServer.h"
|
||||
|
||||
class NjRailActivatorsServer : public NjRailPostServer {
|
||||
public:
|
||||
void OnUse(Entity* self, Entity* user) override;
|
||||
};
|
||||
|
||||
@@ -285,6 +285,7 @@
|
||||
#include "BossGarmadonTornado.h"
|
||||
#include "WavesManagerServer.h"
|
||||
#include "BossManagerServer.h"
|
||||
#include "FireTempleBossActivatorsServer.h"
|
||||
#include "SimpleOnceOnlyMoverSpinnerEvent.h"
|
||||
#include "ImaginationShrineServer.h"
|
||||
#include "Lieutenant.h"
|
||||
@@ -707,6 +708,7 @@ namespace {
|
||||
{"scripts\\02_server\\Map\\firetemple\\L_ZONE_FIRE_TEMPLE_SERVER.lua", []() {return new ZoneFireTempleServer();}},
|
||||
{"scripts\\02_server\\Map\\firetemple\\L_WAVES_MANAGER_SERVER.lua", []() {return new WavesManagerServer();}},
|
||||
{"scripts\\02_server\\Map\\firetemple\\L_BOSS_MANAGER_SERVER.lua", []() {return new BossManagerServer();}},
|
||||
{"scripts\\02_server\\Map\\General\\Ninjago\\L_FIRETEMPLE_BOSS_ACTIVATORS_SERVER.lua", []() {return new FireTempleBossActivatorsServer();}},
|
||||
// (the CDServer row writes this path with forward slashes)
|
||||
{"scripts/02_server/Map/firetemple/L_BOSS_GARMADON_TORNADO.lua", []() {return new BossGarmadonTornado();}},
|
||||
{"scripts\\02_server\\Map\\General\\L_KILL_COUNTER_UTIL.lua", []() {return new KillCounterUtil();}},
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "02_server/Map/General/BossGarmadonTornado.h"
|
||||
#include "02_server/Map/General/WavesManagerServer.h"
|
||||
#include "02_server/Map/General/BossManagerServer.h"
|
||||
#include "02_server/Map/General/Ninjago/FireTempleBossActivatorsServer.h"
|
||||
#include "ScriptComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "BitStream.h"
|
||||
|
||||
@@ -289,3 +291,32 @@ TEST_F(FireTempleScriptsTest, BossManagerBranchesOnTheCelebrationItStarted) {
|
||||
player->NotifyCelebrationCompleted();
|
||||
EXPECT_EQ(manager->GetVar<int32_t>(u"PlayersInCutscene"), 0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
class ActivatorListener : public CppScripts::Script {
|
||||
public:
|
||||
std::vector<int32_t> nodes;
|
||||
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) override {
|
||||
if (name == "ActivatorUsed") nodes.push_back(param1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// L_FIRETEMPLE_BOSS_ACTIVATORS_SERVER: used (no quick build to wait for), it tells the boss manager its spawner node
|
||||
TEST_F(FireTempleScriptsTest, BossActivatorTellsTheManagerItsNode) {
|
||||
CDClientDatabase::Connect(":memory:");
|
||||
CDClientDatabase::ExecuteDML("CREATE TABLE IF NOT EXISTS ComponentsRegistry (id INTEGER, component_type INTEGER, component_id INTEGER);");
|
||||
CDClientDatabase::ExecuteDML("CREATE TABLE IF NOT EXISTS Objects (id INTEGER, name TEXT, type TEXT, interactionDistance REAL);");
|
||||
auto* const manager = Game::entityManager->CreateEntity(info, nullptr, nullptr, false, 288300744895900250);
|
||||
ActivatorListener listener;
|
||||
manager->AddComponent<ScriptComponent>(-1, "", false)->SetScript(&listener);
|
||||
manager->AddToGroup("BossManager");
|
||||
auto activatorInfo = info;
|
||||
activatorInfo.settings.Insert<int32_t>(u"spawner_node_id", 3);
|
||||
auto* const activator = Game::entityManager->CreateEntity(activatorInfo, nullptr, nullptr, false, 288300744895900251);
|
||||
auto* const player = Game::entityManager->CreateEntity(info, nullptr, nullptr, false, 288300744895900252);
|
||||
FireTempleBossActivatorsServer script;
|
||||
script.OnUse(activator, player);
|
||||
ASSERT_EQ(listener.nodes.size(), 1u);
|
||||
EXPECT_EQ(listener.nodes[0], 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user