Starting new VN Structure
This commit is contained in:
11
archive/visualnovel/events/timing/CMakeLists.txt
Normal file
11
archive/visualnovel/events/timing/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
VisualNovelBatchEvent.cpp
|
||||
VisualNovelPauseEvent.cpp
|
||||
)
|
66
archive/visualnovel/events/timing/VisualNovelBatchEvent.cpp
Normal file
66
archive/visualnovel/events/timing/VisualNovelBatchEvent.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
27
archive/visualnovel/events/timing/VisualNovelBatchEvent.hpp
Normal file
27
archive/visualnovel/events/timing/VisualNovelBatchEvent.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/VisualNovelManager.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VisualNovelBatchEvent : public IVisualNovelEvent {
|
||||
protected:
|
||||
std::vector<IVisualNovelEvent*> activeEvents;
|
||||
std::vector<IVisualNovelEvent*> inactiveEvents;
|
||||
|
||||
void onStart(IVisualNovelEvent *previous) override;
|
||||
bool_t onUpdate() override;
|
||||
void onEnd() override;
|
||||
|
||||
public:
|
||||
VisualNovelBatchEvent(
|
||||
VisualNovelManager *man,
|
||||
std::vector<IVisualNovelEvent*> events
|
||||
);
|
||||
|
||||
~VisualNovelBatchEvent();
|
||||
};
|
||||
}
|
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.cpp
Normal file
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "VisualNovelPauseEvent.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
VisualNovelPauseEvent::VisualNovelPauseEvent(
|
||||
VisualNovelManager *manager, float_t duration
|
||||
) : IVisualNovelEvent(manager) {
|
||||
this->duration = duration;
|
||||
}
|
||||
|
||||
void VisualNovelPauseEvent::onStart(IVisualNovelEvent *prev) {
|
||||
this->time = 0;
|
||||
}
|
||||
|
||||
bool_t VisualNovelPauseEvent::onUpdate() {
|
||||
this->time += this->manager->getGame()->timeManager.delta;
|
||||
return this->time < this->duration;
|
||||
}
|
||||
|
||||
void VisualNovelPauseEvent::onEnd() {
|
||||
|
||||
}
|
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.hpp
Normal file
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/VisualNovelManager.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VisualNovelPauseEvent : public IVisualNovelEvent {
|
||||
protected:
|
||||
float_t time;
|
||||
float_t duration;
|
||||
|
||||
void onStart(IVisualNovelEvent *previous) override;
|
||||
bool_t onUpdate() override;
|
||||
void onEnd() override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a new Visual Novel Pause Event.
|
||||
*
|
||||
* @param manager Manager this event belongs to.
|
||||
* @param duration Duration to pause for.
|
||||
*/
|
||||
VisualNovelPauseEvent(VisualNovelManager *manager, float_t duration);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user