Starting new VN Structure
This commit is contained in:
10
src/dawn/games/vn/events/CMakeLists.txt
Normal file
10
src/dawn/games/vn/events/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2023 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
VNEvent.cpp
|
||||
)
|
17
src/dawn/games/vn/events/VNDummyEvent.hpp
Normal file
17
src/dawn/games/vn/events/VNDummyEvent.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "VNEvent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VNDummyEvent : public VNEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
std::cout << "Test" << std::endl;
|
||||
this->next();
|
||||
}
|
||||
};
|
||||
}
|
38
src/dawn/games/vn/events/VNEvent.cpp
Normal file
38
src/dawn/games/vn/events/VNEvent.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "VNEvent.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void VNEvent::init(VNManager *manager) {
|
||||
this->manager = manager;
|
||||
}
|
||||
|
||||
void VNEvent::start(VNEvent *previous) {
|
||||
this->onStart();
|
||||
}
|
||||
|
||||
Scene * VNEvent::getScene() {
|
||||
return this->manager->getScene();
|
||||
}
|
||||
|
||||
VNEvent * VNEvent::getNextEvent() {
|
||||
return this->doNext;
|
||||
}
|
||||
|
||||
void VNEvent::next() {
|
||||
assertNotNull(this->manager);
|
||||
assertTrue(this->manager->currentEvent == this);
|
||||
this->manager->nextEvent();
|
||||
}
|
||||
|
||||
void VNEvent::end() {
|
||||
this->unsubscribeAllEvents();
|
||||
this->onEnd();
|
||||
}
|
||||
|
||||
void VNEvent::onStart() {}
|
||||
void VNEvent::onEnd() {}
|
79
src/dawn/games/vn/events/VNEvent.hpp
Normal file
79
src/dawn/games/vn/events/VNEvent.hpp
Normal file
@ -0,0 +1,79 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "games/vn/components/VNManager.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VNEvent : public StateOwner {
|
||||
protected:
|
||||
VNManager *manager = nullptr;
|
||||
VNEvent *doNext = nullptr;
|
||||
VNEvent *previous = nullptr;
|
||||
|
||||
/**
|
||||
* Initializes the event. This is called by the VNManager, and should not
|
||||
* be called by anything else.
|
||||
* @param manager The VNManager that is running this event.
|
||||
*/
|
||||
void init(VNManager *manager);
|
||||
|
||||
/**
|
||||
* Invoked by the VNManager, this is the start of the event.
|
||||
* @param previous The previous event that was running before this one.
|
||||
*/
|
||||
void start(VNEvent *previous);
|
||||
|
||||
/**
|
||||
* Invoked by the VNManager, this is the end of the event. Perform the
|
||||
* necessary cleanup, but remember that events may be re-started again
|
||||
* later.
|
||||
*/
|
||||
void end();
|
||||
|
||||
/**
|
||||
* Overrideable method that is called when the event is started.
|
||||
*/
|
||||
virtual void onStart();
|
||||
|
||||
/**
|
||||
* Overrideable method that is called when the event is ended.
|
||||
*/
|
||||
virtual void onEnd();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Returns the scene this event is running in.
|
||||
* @return Pointer to the scene.
|
||||
*/
|
||||
Scene * getScene();
|
||||
|
||||
/**
|
||||
* End this event and move on to the next event.
|
||||
*/
|
||||
void next();
|
||||
|
||||
/**
|
||||
* Returns the next event to be executed after this one. Can be overridden
|
||||
* to return a different event other than the doNext event.
|
||||
* @return Pointer to the next event.
|
||||
*/
|
||||
virtual VNEvent * getNextEvent();
|
||||
|
||||
/**
|
||||
* Chains an event to be executed after this event has finished.
|
||||
*
|
||||
* @param next Event to process next.
|
||||
* @return Whatever you pass in to next.
|
||||
*/
|
||||
template<class T>
|
||||
T * then(T *next) {
|
||||
this->doNext = next;
|
||||
return next;
|
||||
}
|
||||
|
||||
friend class VNManager;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user