Another consistency pass

- change NotifyObject to use u16 string
- move stuff to header that is inline
- use u16strings instead of converting to u16 string
- move entity to dEntity
This commit is contained in:
David Markowitz
2023-06-16 01:01:13 -07:00
parent 9a9b9aa813
commit 92006123b8
29 changed files with 142 additions and 183 deletions

View File

@@ -1,5 +1,6 @@
#include "AmBridge.h"
#include "EntityManager.h"
#include "Entity.h"
void AmBridge::OnStartup(Entity* self) {
@@ -14,7 +15,7 @@ void AmBridge::OnRebuildComplete(Entity* self, Entity* target) {
auto* console = consoles[0];
console->NotifyObject(self, "BridgeBuilt");
console->NotifyObject(self, u"BridgeBuilt");
self->AddTimer("SmashBridge", 50);
}

View File

@@ -3,6 +3,7 @@
#include "GameMessages.h"
#include "SimplePhysicsComponent.h"
#include "eTerminateType.h"
#include "Entity.h"
void AmDrawBridge::OnStartup(Entity* self) {
self->SetNetworkVar(u"InUse", false);
@@ -72,8 +73,8 @@ void AmDrawBridge::OnTimerDone(Entity* self, std::string timerName) {
}
}
void AmDrawBridge::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
if (name == "BridgeBuilt") {
void AmDrawBridge::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
if (name == u"BridgeBuilt") {
self->SetVar(u"BridgeID", sender->GetObjectID());
self->AddTimer("SmashEffectBridge", 45);

View File

@@ -7,7 +7,7 @@ public:
void OnStartup(Entity* self) override;
void OnUse(Entity* self, Entity* user) override;
void OnTimerDone(Entity* self, std::string timerName) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void MoveBridgeDown(Entity* self, Entity* bridge, bool down);
void NotifyDie(Entity* self, Entity* other);

View File

@@ -10,7 +10,7 @@ void AmSkullkinDrillStand::OnStartup(Entity* self) {
self->SetProximityRadius(new dpEntity(self->GetObjectID(), { 6, 14, 6 }), "knockback");
}
void AmSkullkinDrillStand::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
void AmSkullkinDrillStand::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
}

View File

@@ -6,7 +6,7 @@ class AmSkullkinDrillStand : public CppScripts::Script
public:
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
};

View File

@@ -1,6 +1,7 @@
#include "NjRailPostServer.h"
#include "QuickBuildComponent.h"
#include "EntityManager.h"
#include "Entity.h"
void NjRailPostServer::OnStartup(Entity* self) {
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
@@ -9,11 +10,11 @@ void NjRailPostServer::OnStartup(Entity* self) {
}
}
void NjRailPostServer::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1,
void NjRailPostServer::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1,
int32_t param2) {
if (name == "PostRebuilt") {
if (name == u"PostRebuilt") {
self->SetNetworkVar<bool>(NetworkNotActiveVariable, false);
} else if (name == "PostDied") {
} else if (name == u"PostDied") {
self->SetNetworkVar<bool>(NetworkNotActiveVariable, true);
}
}
@@ -24,7 +25,7 @@ void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (relatedRail == nullptr)
return;
relatedRail->NotifyObject(self, "PostRebuilt");
relatedRail->NotifyObject(self, u"PostRebuilt");
if (self->GetVar<bool>(NotActiveVariable))
return;
@@ -35,7 +36,7 @@ void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (relatedRail == nullptr)
return;
relatedRail->NotifyObject(self, "PostDied");
relatedRail->NotifyObject(self, u"PostDied");
}
}

View File

@@ -3,7 +3,7 @@
class NjRailPostServer : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
private:
Entity* GetRelatedRail(Entity* self);

View File

@@ -4,8 +4,8 @@
#include "Entity.h"
#include "RenderComponent.h"
void CatapultBaseServer::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
if (name == "BouncerBuilt") {
void CatapultBaseServer::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
if (name == u"BouncerBuilt") {
// start a timer for the arm to player the with bouncer animation
self->AddTimer("PlatAnim", .75);
@@ -46,7 +46,7 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) {
if (bouncer == nullptr) return;
// bounce all players
bouncer->NotifyObject(bouncer, "bounceAllInProximity"); // Likely to trigger server side bounce, bodging this
bouncer->NotifyObject(bouncer, u"bounceAllInProximity"); // Likely to trigger server side bounce, bodging this
// add a delay to play the animation
self->AddTimer("launchAnim", .3);
} else if (timerName == "resetArm") {

View File

@@ -3,7 +3,7 @@
class CatapultBaseServer : public CppScripts::Script {
public:
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnTimerDone(Entity* self, std::string timerName) override;
};

View File

@@ -1,6 +1,7 @@
#include "CatapultBouncerServer.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "Entity.h"
void CatapultBouncerServer::OnRebuildComplete(Entity* self, Entity* target) {
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"Built", 0, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS);
@@ -10,6 +11,6 @@ void CatapultBouncerServer::OnRebuildComplete(Entity* self, Entity* target) {
const auto base = EntityManager::Instance()->GetEntitiesInGroup(self->GetVarAsString(u"BaseGroup"));
for (auto* obj : base) {
obj->NotifyObject(self, "BouncerBuilt");
obj->NotifyObject(self, u"BouncerBuilt");
}
}

View File

@@ -12,11 +12,9 @@ class InvalidScript;
enum class eMissionState : int32_t;
enum class ePetTamingNotifyType : uint32_t;
enum class eRebuildState : uint32_t;
enum class eCinematicEvent : uint32_t;
namespace CppScripts {
extern std::unique_ptr<InvalidScript> invalidScript;
extern std::map<std::string, CppScripts::Script*> m_Scripts;
/**
* Base class for all scripts. Includes virtual methods to be overridden to handle LUA equivelent events.
*
@@ -76,7 +74,7 @@ namespace CppScripts {
*
* Equivalent to 'function onNotifyObject(self, msg)'
*/
virtual void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) {};
virtual void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1 = 0, int32_t param2 = 0) {};
/**
* Invoked upon a player exiting the modular build minigame.
@@ -363,6 +361,8 @@ namespace CppScripts {
*/
virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {};
};
Script* GetScript(Entity* parent, const std::string& scriptName);
extern std::unique_ptr<InvalidScript> invalidScript;
extern std::map<std::string, CppScripts::Script*> m_Scripts;
};

View File

@@ -3,6 +3,7 @@
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
#include "Entity.h"
void FvConsoleLeftQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
@@ -16,7 +17,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftUp");
objects[0]->NotifyObject(self, u"ConsoleLeftUp");
}
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
@@ -25,7 +26,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftDown");
objects[0]->NotifyObject(self, u"ConsoleLeftDown");
}
}
}
@@ -41,7 +42,7 @@ void FvConsoleLeftQuickbuild::OnUse(Entity* self, Entity* user) {
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftActive");
objects[0]->NotifyObject(self, u"ConsoleLeftActive");
}
}

View File

@@ -3,6 +3,7 @@
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
#include "Entity.h"
void FvConsoleRightQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
@@ -16,7 +17,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightUp");
objects[0]->NotifyObject(self, u"ConsoleRightUp");
}
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
@@ -25,7 +26,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightDown");
objects[0]->NotifyObject(self, u"ConsoleRightDown");
}
}
}
@@ -41,7 +42,7 @@ void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) {
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightActive");
objects[0]->NotifyObject(self, u"ConsoleRightActive");
}
}

View File

@@ -8,37 +8,37 @@ void FvFacilityBrick::OnStartup(Entity* self) {
self->SetVar(u"ConsoleRIGHTtActive", false);
}
void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& 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") {
if (name == u"ConsoleLeftUp") {
GameMessages::SendStopFXEffect(self, true, "LeftPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2775, u"create", "LeftPipeEnergy");
} else if (name == "ConsoleLeftDown") {
} else if (name == u"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") {
} else if (name == u"ConsoleLeftActive") {
self->SetVar(u"ConsoleLEFTActive", true);
GameMessages::SendStopFXEffect(self, true, "LeftPipeEnergy");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2776, u"create", "LeftPipeOn");
}
else if (name == "ConsoleRightUp") {
else if (name == u"ConsoleRightUp") {
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2778, u"create", "RightPipeEnergy");
} else if (name == "ConsoleRightDown") {
} else if (name == u"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") {
} else if (name == u"ConsoleRightActive") {
self->SetVar(u"ConsoleRIGHTActive", true);
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");

View File

@@ -5,7 +5,7 @@ class FvFacilityBrick : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) override;
};

View File

@@ -5,9 +5,9 @@ void WildNinjaBricks::OnStartup(Entity* self) {
self->AddToGroups("Ninjastuff");
}
void WildNinjaBricks::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
if (name == "Crane") GameMessages::SendPlayAnimation(self, u"crane");
else if (name == "Tiger") GameMessages::SendPlayAnimation(self, u"tiger");
else if (name == "Mantis") GameMessages::SendPlayAnimation(self, u"mantis");
void WildNinjaBricks::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
if (name == u"Crane") GameMessages::SendPlayAnimation(self, u"crane");
else if (name == u"Tiger") GameMessages::SendPlayAnimation(self, u"tiger");
else if (name == u"Mantis") GameMessages::SendPlayAnimation(self, u"mantis");
}

View File

@@ -4,6 +4,6 @@
class WildNinjaBricks : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1 = 0, int32_t param2 = 0) override;
};

View File

@@ -9,27 +9,27 @@ void WildNinjaSensei::OnStartup(Entity* self) {
void WildNinjaSensei::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "CraneStart") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Crane");
for (auto ninja : ninjas) ninja->NotifyObject(self, u"Crane");
self->AddTimer("Bow", 15.5f);
self->AddTimer("TigerStart", 25);
GameMessages::SendPlayAnimation(self, u"crane");
} else if (timerName == "TigerStart") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
GameMessages::SendPlayAnimation(self, u"bow");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Tiger");
for (auto ninja : ninjas) ninja->NotifyObject(self, u"Tiger");
self->AddTimer("Bow", 15.5f);
self->AddTimer("MantisStart", 25);
GameMessages::SendPlayAnimation(self, u"tiger");
} else if (timerName == "MantisStart") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
GameMessages::SendPlayAnimation(self, u"tiger");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Mantis");
for (auto ninja : ninjas) ninja->NotifyObject(self, u"Mantis");
self->AddTimer("Bow", 15.5f);
self->AddTimer("CraneStart", 25);
GameMessages::SendPlayAnimation(self, u"mantis");
} else if (timerName == "Bow") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Bow");
for (auto ninja : ninjas) ninja->NotifyObject(self, u"Bow");
GameMessages::SendPlayAnimation(self, u"bow");
}
}

View File

@@ -1,14 +1,15 @@
#include "WildNinjaStudent.h"
#include "GameMessages.h"
#include "Entity.h"
void WildNinjaStudent::OnStartup(Entity* self) {
self->AddToGroups("Ninjastuff");
GameMessages::SendPlayAnimation(self, u"bow");
}
void WildNinjaStudent::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
if (name == "Crane") GameMessages::SendPlayAnimation(self, u"crane");
else if (name == "Tiger") GameMessages::SendPlayAnimation(self, u"tiger");
else if (name == "Mantis") GameMessages::SendPlayAnimation(self, u"mantis");
else if (name == "Bow") GameMessages::SendPlayAnimation(self, u"bow");
void WildNinjaStudent::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
if (name == u"Crane") GameMessages::SendPlayAnimation(self, u"crane");
else if (name == u"Tiger") GameMessages::SendPlayAnimation(self, u"tiger");
else if (name == u"Mantis") GameMessages::SendPlayAnimation(self, u"mantis");
else if (name == u"Bow") GameMessages::SendPlayAnimation(self, u"bow");
}

View File

@@ -4,6 +4,6 @@
class WildNinjaStudent : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1 = 0, int32_t param2 = 0) override;
};