mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 06:57:28 +00:00
5942182486
* Logger: Rename logger to Logger from dLogger * Logger: Add compile time filename Fix include issues Add writers Add macros Add macro to force compilation * Logger: Replace calls with macros Allows for filename and line number to be logged * Logger: Add comments and remove extra define Logger: Replace with unique_ptr also flush console at exit. regular file writer should be flushed on file close. Logger: Remove constexpr on variable * Logger: Simplify code * Update Logger.cpp
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#include "TriggerGas.h"
|
|
#include "InventoryComponent.h"
|
|
#include "SkillComponent.h"
|
|
#include "Entity.h"
|
|
#include "Logger.h"
|
|
|
|
|
|
void TriggerGas::OnStartup(Entity* self) {
|
|
self->AddTimer(this->m_TimerName, this->m_Time);
|
|
}
|
|
|
|
void TriggerGas::OnCollisionPhantom(Entity* self, Entity* target) {
|
|
if (!target->IsPlayer()) return;
|
|
auto players = self->GetVar<std::vector<Entity*>>(u"players");
|
|
players.push_back(target);
|
|
self->SetVar(u"players", players);
|
|
}
|
|
|
|
void TriggerGas::OnOffCollisionPhantom(Entity* self, Entity* target) {
|
|
auto players = self->GetVar<std::vector<Entity*>>(u"players");
|
|
if (!target->IsPlayer() || players.empty()) return;
|
|
auto position = std::find(players.begin(), players.end(), target);
|
|
if (position != players.end()) players.erase(position);
|
|
self->SetVar(u"players", players);
|
|
}
|
|
|
|
void TriggerGas::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName != this->m_TimerName) return;
|
|
auto players = self->GetVar<std::vector<Entity*>>(u"players");
|
|
for (auto player : players) {
|
|
if (player->GetIsDead() || !player){
|
|
auto position = std::find(players.begin(), players.end(), player);
|
|
if (position != players.end()) players.erase(position);
|
|
continue;
|
|
}
|
|
auto inventoryComponent = player->GetComponent<InventoryComponent>();
|
|
if (inventoryComponent) {
|
|
if (!inventoryComponent->IsEquipped(this->m_MaelstromHelmet)) {
|
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
|
if (skillComponent) {
|
|
skillComponent->CastSkill(this->m_FogDamageSkill, player->GetObjectID());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
self->SetVar(u"players", players);
|
|
self->AddTimer(this->m_TimerName, this->m_Time);
|
|
}
|
|
|