mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 14:03:34 +00:00
455f9470a5
* Move EntityManager to Game namespace * move initialization to later Need to wait for dZoneManager to be initialized. * Fix bugs - Cannot delete from a RandomAccessIterator while in a range based for loop. Touchup zone manager initialize replace magic numbers with better named constants replace magic zonecontrol id with a more readable hex alternative condense stack variables move initializers closer to their use initialize entity manager with zone control change initialize timings If zone is not zero we expect to initialize the entity manager during zone manager initialization Add constexpr for zone control LOT * Add proper error handling * revert vanity changes * Update WorldServer.cpp * Update dZoneManager.cpp
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#include "StinkyFishTarget.h"
|
|
#include "EntityManager.h"
|
|
#include "EntityInfo.h"
|
|
#include "Entity.h"
|
|
|
|
void StinkyFishTarget::OnStartup(Entity* self) {
|
|
auto position = self->GetPosition();
|
|
position.SetY(position.GetY() - 0.5f);
|
|
self->SetPosition(position);
|
|
}
|
|
|
|
void StinkyFishTarget::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
|
|
if (message != "stinkfish" || self->GetVar<bool>(u"used"))
|
|
return;
|
|
|
|
self->SetVar<bool>(u"used", true);
|
|
self->SetVar<LWOOBJID>(u"player", caster->GetObjectID());
|
|
|
|
EntityInfo entityInfo{};
|
|
entityInfo.lot = SHARK_LOT;
|
|
entityInfo.pos = self->GetPosition();
|
|
entityInfo.rot = self->GetRotation();
|
|
entityInfo.spawnerID = self->GetObjectID();
|
|
entityInfo.settings = {
|
|
new LDFData<bool>(u"no_timed_spawn", true)
|
|
};
|
|
|
|
auto* fish = Game::entityManager->CreateEntity(entityInfo);
|
|
Game::entityManager->ConstructEntity(fish);
|
|
|
|
self->SetVar<LWOOBJID>(u"fish", fish->GetObjectID());
|
|
self->AddTimer("smash", 5.0f);
|
|
}
|
|
|
|
void StinkyFishTarget::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName == "smash") {
|
|
const auto playerID = self->GetVar<LWOOBJID>(u"player");
|
|
auto* fish = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"fish"));
|
|
|
|
if (fish) {
|
|
fish->Smash(playerID);
|
|
self->Smash(playerID);
|
|
}
|
|
}
|
|
}
|