mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-25 23:13:35 +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
100 lines
2.1 KiB
C++
100 lines
2.1 KiB
C++
#include "GfBanana.h"
|
|
|
|
#include "Entity.h"
|
|
#include "DestroyableComponent.h"
|
|
#include "EntityManager.h"
|
|
|
|
void GfBanana::SpawnBanana(Entity* self)
|
|
{
|
|
auto position = self->GetPosition();
|
|
const auto rotation = self->GetRotation();
|
|
|
|
position.y += 12;
|
|
position.x -= rotation.GetRightVector().x * 5;
|
|
position.z -= rotation.GetRightVector().z * 5;
|
|
|
|
EntityInfo info {};
|
|
|
|
info.pos = position;
|
|
info.rot = rotation;
|
|
info.lot = 6909;
|
|
info.spawnerID = self->GetObjectID();
|
|
|
|
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
|
|
|
EntityManager::Instance()->ConstructEntity(entity);
|
|
|
|
self->SetVar(u"banana", entity->GetObjectID());
|
|
|
|
entity->AddDieCallback([self]()
|
|
{
|
|
self->SetVar(u"banana", LWOOBJID_EMPTY);
|
|
|
|
self->AddTimer("bananaTimer", 30);
|
|
});
|
|
}
|
|
|
|
void GfBanana::OnStartup(Entity* self)
|
|
{
|
|
SpawnBanana(self);
|
|
}
|
|
|
|
void GfBanana::OnHit(Entity* self, Entity* attacker)
|
|
{
|
|
auto* destroyable = self->GetComponent<DestroyableComponent>();
|
|
|
|
destroyable->SetHealth(9999);
|
|
|
|
const auto bananaId = self->GetVar<LWOOBJID>(u"banana");
|
|
|
|
if (bananaId == LWOOBJID_EMPTY) return;
|
|
|
|
auto* bananaEntity = EntityManager::Instance()->GetEntity(bananaId);
|
|
|
|
if (bananaEntity == nullptr)
|
|
{
|
|
self->SetVar(u"banana", LWOOBJID_EMPTY);
|
|
|
|
self->AddTimer("bananaTimer", 30);
|
|
|
|
return;
|
|
}
|
|
|
|
bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3::UNIT_Y * 8);
|
|
|
|
auto* bananaDestroyable = bananaEntity->GetComponent<DestroyableComponent>();
|
|
|
|
bananaDestroyable->SetHealth(0);
|
|
|
|
bananaDestroyable->Smash(attacker->GetObjectID());
|
|
|
|
/*
|
|
auto position = self->GetPosition();
|
|
const auto rotation = self->GetRotation();
|
|
|
|
position.y += 12;
|
|
position.x -= rotation.GetRightVector().x * 5;
|
|
position.z -= rotation.GetRightVector().z * 5;
|
|
|
|
EntityInfo info {};
|
|
|
|
info.pos = position;
|
|
info.rot = rotation;
|
|
info.lot = 6718;
|
|
info.spawnerID = self->GetObjectID();
|
|
|
|
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
|
|
|
EntityManager::Instance()->ConstructEntity(entity, UNASSIGNED_SYSTEM_ADDRESS);
|
|
*/
|
|
|
|
EntityManager::Instance()->SerializeEntity(self);
|
|
}
|
|
|
|
void GfBanana::OnTimerDone(Entity* self, std::string timerName)
|
|
{
|
|
if (timerName == "bananaTimer")
|
|
{
|
|
SpawnBanana(self);
|
|
}
|
|
} |