Dawn/src/dawnliminal/vnscenes/ScenePrologue8.cpp

117 lines
3.7 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "ScenePrologue8.hpp"
using namespace Dawn;
void ScenePrologue8CustomEventForChoiceSet::onStart() {
auto scene = dynamic_cast<ScenePrologue8*>(this->manager->getScene());
assertNotNull(scene, "ScenePrologue8CustomEventForChoiceSet - Scene is null?");
this->choices = scene->remainingChoices;
this->key = "killer";
this->text = "It is...";
VNChoiceEvent::onStart();
}
void ScenePrologue8CustomEventForAfterChoice::onStart() {
auto prev = dynamic_cast<ScenePrologue8CustomEventForChoiceSet*>(this->previous);
assertNotNull(prev, "ScenePrologue8CustomEventForAfterChoice - Previous is null?");
auto scene = dynamic_cast<ScenePrologue8*>(this->manager->getScene());
assertNotNull(scene, "ScenePrologue8CustomEventForAfterChoice - Scene is null?");
auto key = prev->getChoiceKey();
scene->remainingChoices.erase(key);
this->next();
}
void ScenePrologue8CustomEventForAfterCharacterFollowup::onStart() {
auto scene = dynamic_cast<ScenePrologue8*>(this->manager->getScene());
assertNotNull(scene, "ScenePrologue8CustomEventForAfterChoice - Scene is null?");
if(scene->remainingChoices.empty()) {
auto sceneChange = this->manager->createEvent<VNSceneChangeEvent<ScenePrologue9>>();
this->then(sceneChange);
} else {
auto choiceSet = this->manager->createEvent<ScenePrologue8CustomEventForChoiceSet>();
this->then(choiceSet);
}
}
ScenePrologue8::ScenePrologue8(DawnGame *game) : SceneMonologue(game) {
}
std::vector<Asset*> ScenePrologue8::getRequiredAssets() {
auto man = &this->game->assetManager;
std::vector<Asset*> assets = SceneMonologue::getRequiredAssets();
return assets;
}
void ScenePrologue8::stage() {
SceneMonologue::stage();
remainingChoices["ave"] = "Ave?";
remainingChoices["ronin"] = "Ronin?";
remainingChoices["craig"] = "Craig?";
auto man = &this->game->assetManager;
assertNotNull(vnManager, "VNSceneGenInit - VN Manager is null?");
VNEvent *previous = vnManager->createEvent<VNDummyEvent>();
auto eventStart = previous;
auto event0 = vnManager->createEvent<VNSetDefaultFontEvent>();
event0->font = "<font font=\"font_main\" size=\"32.0f\">{{ text }}</font>";
auto eventChoice = vnManager->createEvent<ScenePrologue8CustomEventForChoiceSet>();
auto eventAfterChoice = vnManager->createEvent<ScenePrologue8CustomEventForAfterChoice>();
auto eventFollowUp = vnManager->createEvent<ScenePrologue8CustomEventForAfterCharacterFollowup>();
// Ave
auto eventIfAve = vnManager->createEvent<VNIfEvent>();
eventIfAve->key = "killer";
eventIfAve->value = "ave";
auto eventTestAve = vnManager->createEvent<VNTextEvent>();
eventTestAve->text = "Ave?";
eventIfAve->ifTrue = eventTestAve;
eventIfAve->ifEnd = eventTestAve;
// Craig
auto eventIfCraig = vnManager->createEvent<VNIfEvent>();
eventIfCraig->key = "killer";
eventIfCraig->value = "craig";
auto eventTestCraig = vnManager->createEvent<VNTextEvent>();
eventTestCraig->text = "Craig?";
eventIfCraig->ifTrue = eventTestCraig;
eventIfCraig->ifEnd = eventTestCraig;
// Ronin
auto eventIfRonin = vnManager->createEvent<VNIfEvent>();
eventIfRonin->key = "killer";
eventIfRonin->value = "ronin";
auto eventTestRonin = vnManager->createEvent<VNTextEvent>();
eventTestRonin->text = "Ronin?";
eventIfRonin->ifTrue = eventTestRonin;
eventIfRonin->ifEnd = eventTestRonin;
// End
eventStart->then(event0);
event0->then(eventChoice);
eventChoice->then(eventAfterChoice);
eventAfterChoice->then(eventIfAve);
eventIfAve->then(eventIfCraig);
eventIfCraig->then(eventIfRonin);
eventIfRonin->then(eventFollowUp);
vnManager->setEvent(eventStart);
}