Split out LUTriggers into it's own component (#986)

* Split out LUTriggers into it's own component

* some cleanup

* fix debug log

* use emplace and tryParse

* slight refactor to make the work on startup
rather than at runtime
Also TODO's for getting targets via all the possible methods

* address feedback
This commit is contained in:
Aaron Kimbrell
2023-02-10 02:29:53 -06:00
committed by GitHub
parent d17f51183e
commit 91c0c1fcfb
13 changed files with 437 additions and 137 deletions

View File

@@ -6,17 +6,20 @@
class Command;
class Event;
enum class eTriggerCommandType;
enum class eTriggerEventType;
namespace LUTriggers {
struct Command {
std::string id;
eTriggerCommandType id;
std::string target;
std::string targetName;
std::string args;
};
struct Event {
std::string eventID;
eTriggerEventType id;
std::vector<Command*> commands;
};

View File

@@ -14,6 +14,9 @@
#include "Spawner.h"
#include "dZoneManager.h"
#include "eTriggerCommandType.h"
#include "eTriggerEventType.h"
Zone::Zone(const LWOMAPID& mapID, const LWOINSTANCEID& instanceID, const LWOCLONEID& cloneID) :
m_ZoneID(mapID, instanceID, cloneID) {
m_NumberOfScenesLoaded = 0;
@@ -296,11 +299,11 @@ std::vector<LUTriggers::Trigger*> Zone::LoadLUTriggers(std::string triggerFile,
auto currentEvent = currentTrigger->FirstChildElement("event");
while (currentEvent) {
LUTriggers::Event* newEvent = new LUTriggers::Event();
newEvent->eventID = currentEvent->Attribute("id");
newEvent->id = TriggerEventType::StringToTriggerEventType(currentEvent->Attribute("id"));
auto currentCommand = currentEvent->FirstChildElement("command");
while (currentCommand) {
LUTriggers::Command* newCommand = new LUTriggers::Command();
newCommand->id = currentCommand->Attribute("id");
newCommand->id = TriggerCommandType::StringToTriggerCommandType(currentCommand->Attribute("id"));
newCommand->target = currentCommand->Attribute("target");
if (currentCommand->Attribute("targetName") != NULL) {
newCommand->targetName = currentCommand->Attribute("targetName");