DarkflameServer/dScripts/FvFacilityBrick.cpp
David Markowitz 8cdb388915
Optimize scripts for faster compilation (#597)
* 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 commit d79d8d4991.

* Revert "Revert "Implement Precompiled Headers""

This reverts commit 0597faf308.

* Add back in PCH

Add back in PCH

* Fix CMake

Whitespace

Remove duplicate file glob

Remove newline
2022-07-04 23:00:10 -07:00

120 lines
4.2 KiB
C++

#include "FvFacilityBrick.h"
#include "GameMessages.h"
#include "dZoneManager.h"
#include "EntityManager.h"
void FvFacilityBrick::OnStartup(Entity* self)
{
self->SetVar(u"ConsoleLEFTActive", false);
self->SetVar(u"ConsoleRIGHTtActive", false);
}
void FvFacilityBrick::OnNotifyObject(Entity *self, Entity *sender, const std::string& name, int32_t param1, int32_t param2)
{
auto* brickSpawner = dZoneManager::Instance()->GetSpawnersByName("ImaginationBrick")[0];
auto* bugSpawner = dZoneManager::Instance()->GetSpawnersByName("MaelstromBug")[0];
auto* canisterSpawner = dZoneManager::Instance()->GetSpawnersByName("BrickCanister")[0];
if (name == "ConsoleLeftUp")
{
GameMessages::SendStopFXEffect(self, true, "LeftPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2775, u"create", "LeftPipeEnergy");
}
else if (name == "ConsoleLeftDown")
{
self->SetVar(u"ConsoleLEFTActive", false);
GameMessages::SendStopFXEffect(self, true, "LeftPipeEnergy");
GameMessages::SendStopFXEffect(self, true, "LeftPipeOn");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2774, u"create", "LeftPipeOff");
}
else if (name == "ConsoleLeftActive")
{
self->SetVar(u"ConsoleLEFTActive", true);
GameMessages::SendStopFXEffect(self, true, "LeftPipeEnergy");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2776, u"create", "LeftPipeOn");
}
else if (name == "ConsoleRightUp")
{
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2778, u"create", "RightPipeEnergy");
}
else if (name == "ConsoleRightDown")
{
self->SetVar(u"ConsoleRIGHTActive", false);
GameMessages::SendStopFXEffect(self, true, "RightPipeEnergy");
GameMessages::SendStopFXEffect(self, true, "RightPipeOn");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2777, u"create", "RightPipeOff");
}
else if (name == "ConsoleRightActive")
{
self->SetVar(u"ConsoleRIGHTActive", true);
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2779, u"create", "RightPipeEnergy");
}
if (self->GetVar<bool>(u"ConsoleLEFTActive") && self->GetVar<bool>(u"ConsoleRIGHTActive"))
{
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
if (object != nullptr)
{
GameMessages::SendPlayFXEffect(object->GetObjectID(), 122, u"create", "bluebrick");
GameMessages::SendPlayFXEffect(object->GetObjectID(), 1034, u"cast", "imaginationexplosion");
}
object = EntityManager::Instance()->GetEntitiesInGroup("Canister")[0];
if (object != nullptr)
{
object->Smash(self->GetObjectID(), SILENT);
}
canisterSpawner->Reset();
canisterSpawner->Deactivate();
}
else if (self->GetVar<bool>(u"ConsoleLEFTActive") || self->GetVar<bool>(u"ConsoleRIGHTActive"))
{
brickSpawner->Activate();
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
if (object != nullptr)
{
GameMessages::SendStopFXEffect(object, true, "bluebrick");
}
bugSpawner->Reset();
bugSpawner->Deactivate();
canisterSpawner->Reset();
canisterSpawner->Activate();
}
else
{
brickSpawner->Reset();
brickSpawner->Deactivate();
bugSpawner->Reset();
bugSpawner->Activate();
}
}
void FvFacilityBrick::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2,
int32_t param3)
{
if (args != "PlayFX")
{
return;
}
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2774, u"create", "LeftPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2777, u"create", "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2750, u"create", "imagination_canister");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2751, u"create", "canister_light_filler");
}