cleanup logs, fix overrides, define LOTs in header

This commit is contained in:
Aaron Kimbre 2022-04-18 21:02:04 -05:00
parent 8fe5c00984
commit f3dd71ccb1
8 changed files with 18 additions and 22 deletions

View File

@ -2,7 +2,7 @@
#include "EntityManager.h" #include "EntityManager.h"
#include "GameMessages.h" #include "GameMessages.h"
void HydrantBroken::OnStartup(Entity* self) void HydrantBroken::OnStartup(Entity* self)
{ {
self->AddTimer("playEffect", 1); self->AddTimer("playEffect", 1);
@ -10,8 +10,6 @@ void HydrantBroken::OnStartup(Entity* self)
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
Game::logger->Log("HydrantBroken", "Broken Hydrant spawned (%s)\n", hydrant.c_str());
for (auto* bouncer : bouncers) for (auto* bouncer : bouncers)
{ {
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID()); self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
@ -20,11 +18,11 @@ void HydrantBroken::OnStartup(Entity* self)
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS);
} }
self->AddTimer("KillBroken", 25); self->AddTimer("KillBroken", 25);
} }
void HydrantBroken::OnTimerDone(Entity* self, std::string timerName) void HydrantBroken::OnTimerDone(Entity* self, std::string timerName)
{ {
if (timerName == "KillBroken") if (timerName == "KillBroken")
{ {

View File

@ -2,20 +2,18 @@
#include "EntityManager.h" #include "EntityManager.h"
#include "GeneralUtils.h" #include "GeneralUtils.h"
void HydrantSmashable::OnDie(Entity* self, Entity* killer) void HydrantSmashable::OnDie(Entity* self, Entity* killer)
{ {
const auto hydrantName = self->GetVar<std::u16string>(u"hydrant"); const auto hydrantName = self->GetVar<std::u16string>(u"hydrant");
LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName)); LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName));
EntityInfo info {}; EntityInfo info {};
info.lot = 7328; info.lot = HYDRANT_BROKEN;
info.pos = self->GetPosition(); info.pos = self->GetPosition();
info.rot = self->GetRotation(); info.rot = self->GetRotation();
info.settings = {data}; info.settings = {data};
info.spawnerID = self->GetSpawnerID(); info.spawnerID = self->GetSpawnerID();
Game::logger->Log("HydrantBroken", "Hydrant spawned (%s)\n", data->GetString().c_str());
auto* hydrant = EntityManager::Instance()->CreateEntity(info); auto* hydrant = EntityManager::Instance()->CreateEntity(info);

View File

@ -1,8 +1,10 @@
#pragma once #pragma once
#include "CppScripts.h" #include "CppScripts.h"
class HydrantSmashable : public CppScripts::Script class HydrantSmashable : public CppScripts::Script
{ {
public: public:
void OnDie(Entity* self, Entity* killer) override; void OnDie(Entity* self, Entity* killer) override;
private:
LOT HYDRANT_BROKEN = 7328;
}; };

View File

@ -10,8 +10,6 @@ void RockHydrantBroken::OnStartup(Entity* self)
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
Game::logger->Log("RockHydrantBroken", "Broken Rock Hydrant spawned (%s)\n", hydrant.c_str());
for (auto* bouncer : bouncers) for (auto* bouncer : bouncers)
{ {
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID()); self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());

View File

@ -9,15 +9,13 @@ void RockHydrantSmashable::OnDie(Entity* self, Entity* killer)
LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName)); LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName));
EntityInfo info {}; EntityInfo info {};
info.lot = 12293; info.lot = ROCK_HYDRANT_BROKEN;
info.pos = self->GetPosition(); info.pos = self->GetPosition();
info.rot = self->GetRotation(); info.rot = self->GetRotation();
info.settings = {data}; info.settings = {data};
info.spawnerID = self->GetSpawnerID(); info.spawnerID = self->GetSpawnerID();
Game::logger->Log("RockHydrantBroken", "Rock Hydrant spawned (%s)\n", data->GetString().c_str()); auto* hydrant = EntityManager::Instance()->CreateEntity(info);
auto* hydrant = EntityManager::Instance()->CreateEntity(info); EntityManager::Instance()->ConstructEntity(hydrant);
EntityManager::Instance()->ConstructEntity(hydrant);
} }

View File

@ -5,5 +5,7 @@ class RockHydrantSmashable : public CppScripts::Script
{ {
public: public:
void OnDie(Entity* self, Entity* killer); void OnDie(Entity* self, Entity* killer);
private:
LOT ROCK_HYDRANT_BROKEN = 12293;
}; };

View File

@ -66,4 +66,4 @@ void WhFans::OnDie(Entity* self, Entity* killer) {
ToggleFX(self, true); ToggleFX(self, true);
} }
self->SetVar<bool>(u"alive", false); self->SetVar<bool>(u"alive", false);
} }

View File

@ -7,8 +7,8 @@
class WhFans : public CppScripts::Script class WhFans : public CppScripts::Script
{ {
public: public:
void OnStartup(Entity* self); void OnStartup(Entity* self) override;
void OnDie(Entity* self, Entity* killer); void OnDie(Entity* self, Entity* killer) override;
void OnFireEventServerSide( void OnFireEventServerSide(
Entity *self, Entity *self,
Entity *sender, Entity *sender,
@ -16,7 +16,7 @@ public:
int32_t param1, int32_t param1,
int32_t param2, int32_t param2,
int32_t param3 int32_t param3
); ) override;
private: private:
void ToggleFX(Entity* self, bool hit); void ToggleFX(Entity* self, bool hit);
}; };