Added IF Event Parsing

This commit is contained in:
2023-04-25 23:06:23 -07:00
parent aec17f614e
commit e1f615c774
9 changed files with 121 additions and 13 deletions

View File

@ -10,7 +10,6 @@ namespace Dawn {
class VNDummyEvent : public VNEvent {
protected:
void onStart() override {
std::cout << "Dummy VN Event" << std::endl;
this->next();
}
};

View File

@ -34,7 +34,7 @@ void VNEvent::next() {
this->end();
auto next = this->getNextEvent();
this->manager->currentEvent = next;
this->parent->currentEvent = next;
if(next != nullptr) next->start(this->parent, this);
}

View File

@ -7,22 +7,29 @@
#include "VNEvent.hpp"
namespace Dawn {
class VNIfEvent : public VNEvent {
class VNIfEvent :
public VNEvent,
public IVNEventParent
{
public:
std::string key;
std::string value;
VNEvent *ifTrue = nullptr;
VNEvent * getNextEvent() override {
if(this->manager.getFlag(key) == value) {
return ifTrue;
}
return VNEvent::getNextEvent();
}
VNEvent *ifEnd = nullptr;
protected:
void onStart() override {
this->next();
assertNotNull(ifTrue);
assertNotNull(ifEnd);
if(this->manager->getFlag(key) == value) {
useEvent([&]{
if(ifEnd->getNextEvent() == nullptr) this->next();
}, ifEnd->eventFinished);
ifTrue->start(this, nullptr);
} else {
this->next();
}
}
}
};
}