67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "VisualNovelBatchEvent.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
VisualNovelBatchEvent::VisualNovelBatchEvent(
|
|
VisualNovelManager *man,
|
|
std::vector<IVisualNovelEvent*> events
|
|
) : IVisualNovelEvent(man) {
|
|
this->activeEvents = events;
|
|
}
|
|
|
|
void VisualNovelBatchEvent::onStart(IVisualNovelEvent *previous) {
|
|
auto it = this->activeEvents.begin();
|
|
while(it != this->activeEvents.end()) {
|
|
auto evt = *it;
|
|
evt->start(previous);
|
|
++it;
|
|
}
|
|
}
|
|
|
|
bool_t VisualNovelBatchEvent::onUpdate() {
|
|
bool_t result;
|
|
auto it = this->activeEvents.begin();
|
|
while(it != this->activeEvents.end()) {
|
|
auto evt = *it;
|
|
result = evt->update();
|
|
if(result) {
|
|
++it;
|
|
continue;
|
|
}
|
|
|
|
auto subNext = evt->end();
|
|
|
|
// In future I may remove this and instead immediately queue the next thing.
|
|
assertNull(subNext);
|
|
|
|
it = this->activeEvents.erase(it);
|
|
this->inactiveEvents.push_back(evt);
|
|
}
|
|
return this->activeEvents.size() > 0;
|
|
}
|
|
|
|
void VisualNovelBatchEvent::onEnd() {
|
|
|
|
}
|
|
|
|
VisualNovelBatchEvent::~VisualNovelBatchEvent() {
|
|
auto itActive = this->activeEvents.begin();
|
|
while(itActive != this->activeEvents.end()) {
|
|
auto evt = *itActive;
|
|
delete evt;
|
|
++itActive;
|
|
}
|
|
|
|
auto itInactive = this->inactiveEvents.begin();
|
|
while(itInactive != this->inactiveEvents.end()) {
|
|
auto evt = *itInactive;
|
|
delete evt;
|
|
++itInactive;
|
|
}
|
|
}
|