diff --git a/src/dawn/games/visualnovel/CMakeLists.txt b/archive/visualnovel/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/CMakeLists.txt rename to archive/visualnovel/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/VisualNovelManager.cpp b/archive/visualnovel/VisualNovelManager.cpp similarity index 100% rename from src/dawn/games/visualnovel/VisualNovelManager.cpp rename to archive/visualnovel/VisualNovelManager.cpp diff --git a/src/dawn/games/visualnovel/VisualNovelManager.hpp b/archive/visualnovel/VisualNovelManager.hpp similarity index 100% rename from src/dawn/games/visualnovel/VisualNovelManager.hpp rename to archive/visualnovel/VisualNovelManager.hpp diff --git a/src/dawn/games/visualnovel/components/CMakeLists.txt b/archive/visualnovel/components/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/components/CMakeLists.txt rename to archive/visualnovel/components/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/components/SimpleVisualNovelBackground.cpp b/archive/visualnovel/components/SimpleVisualNovelBackground.cpp similarity index 100% rename from src/dawn/games/visualnovel/components/SimpleVisualNovelBackground.cpp rename to archive/visualnovel/components/SimpleVisualNovelBackground.cpp diff --git a/src/dawn/games/visualnovel/components/SimpleVisualNovelBackground.hpp b/archive/visualnovel/components/SimpleVisualNovelBackground.hpp similarity index 100% rename from src/dawn/games/visualnovel/components/SimpleVisualNovelBackground.hpp rename to archive/visualnovel/components/SimpleVisualNovelBackground.hpp diff --git a/src/dawn/games/visualnovel/components/VisualNovelCharacter.cpp b/archive/visualnovel/components/VisualNovelCharacter.cpp similarity index 100% rename from src/dawn/games/visualnovel/components/VisualNovelCharacter.cpp rename to archive/visualnovel/components/VisualNovelCharacter.cpp diff --git a/src/dawn/games/visualnovel/components/VisualNovelCharacter.hpp b/archive/visualnovel/components/VisualNovelCharacter.hpp similarity index 100% rename from src/dawn/games/visualnovel/components/VisualNovelCharacter.hpp rename to archive/visualnovel/components/VisualNovelCharacter.hpp diff --git a/src/dawn/games/visualnovel/events/CMakeLists.txt b/archive/visualnovel/events/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/events/CMakeLists.txt rename to archive/visualnovel/events/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/events/VisualNovelCallbackEvent.hpp b/archive/visualnovel/events/VisualNovelCallbackEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelCallbackEvent.hpp rename to archive/visualnovel/events/VisualNovelCallbackEvent.hpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.cpp b/archive/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.cpp rename to archive/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.cpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.hpp b/archive/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.hpp rename to archive/visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.hpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelEmptyEvent.cpp b/archive/visualnovel/events/VisualNovelEmptyEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelEmptyEvent.cpp rename to archive/visualnovel/events/VisualNovelEmptyEvent.cpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelEmptyEvent.hpp b/archive/visualnovel/events/VisualNovelEmptyEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelEmptyEvent.hpp rename to archive/visualnovel/events/VisualNovelEmptyEvent.hpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelFadeEvent.cpp b/archive/visualnovel/events/VisualNovelFadeEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelFadeEvent.cpp rename to archive/visualnovel/events/VisualNovelFadeEvent.cpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelFadeEvent.hpp b/archive/visualnovel/events/VisualNovelFadeEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelFadeEvent.hpp rename to archive/visualnovel/events/VisualNovelFadeEvent.hpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelTextboxEvent.cpp b/archive/visualnovel/events/VisualNovelTextboxEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelTextboxEvent.cpp rename to archive/visualnovel/events/VisualNovelTextboxEvent.cpp diff --git a/src/dawn/games/visualnovel/events/VisualNovelTextboxEvent.hpp b/archive/visualnovel/events/VisualNovelTextboxEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/VisualNovelTextboxEvent.hpp rename to archive/visualnovel/events/VisualNovelTextboxEvent.hpp diff --git a/src/dawn/games/visualnovel/events/animation/CMakeLists.txt b/archive/visualnovel/events/animation/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/events/animation/CMakeLists.txt rename to archive/visualnovel/events/animation/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/events/animation/VisualNovelAnimationEvent.cpp b/archive/visualnovel/events/animation/VisualNovelAnimationEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/animation/VisualNovelAnimationEvent.cpp rename to archive/visualnovel/events/animation/VisualNovelAnimationEvent.cpp diff --git a/src/dawn/games/visualnovel/events/animation/VisualNovelAnimationEvent.hpp b/archive/visualnovel/events/animation/VisualNovelAnimationEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/animation/VisualNovelAnimationEvent.hpp rename to archive/visualnovel/events/animation/VisualNovelAnimationEvent.hpp diff --git a/src/dawn/games/visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp b/archive/visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp rename to archive/visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp diff --git a/src/dawn/games/visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp b/archive/visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp rename to archive/visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp diff --git a/src/dawn/games/visualnovel/events/characters/CMakeLists.txt b/archive/visualnovel/events/characters/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/events/characters/CMakeLists.txt rename to archive/visualnovel/events/characters/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/events/characters/VisualNovelFadeCharacterEvent.cpp b/archive/visualnovel/events/characters/VisualNovelFadeCharacterEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/characters/VisualNovelFadeCharacterEvent.cpp rename to archive/visualnovel/events/characters/VisualNovelFadeCharacterEvent.cpp diff --git a/src/dawn/games/visualnovel/events/characters/VisualNovelFadeCharacterEvent.hpp b/archive/visualnovel/events/characters/VisualNovelFadeCharacterEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/characters/VisualNovelFadeCharacterEvent.hpp rename to archive/visualnovel/events/characters/VisualNovelFadeCharacterEvent.hpp diff --git a/src/dawn/games/visualnovel/events/characters/VisualNovelTransformItemEvent.cpp b/archive/visualnovel/events/characters/VisualNovelTransformItemEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/characters/VisualNovelTransformItemEvent.cpp rename to archive/visualnovel/events/characters/VisualNovelTransformItemEvent.cpp diff --git a/src/dawn/games/visualnovel/events/characters/VisualNovelTransformItemEvent.hpp b/archive/visualnovel/events/characters/VisualNovelTransformItemEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/characters/VisualNovelTransformItemEvent.hpp rename to archive/visualnovel/events/characters/VisualNovelTransformItemEvent.hpp diff --git a/src/dawn/games/visualnovel/events/timing/CMakeLists.txt b/archive/visualnovel/events/timing/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/events/timing/CMakeLists.txt rename to archive/visualnovel/events/timing/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/events/timing/VisualNovelBatchEvent.cpp b/archive/visualnovel/events/timing/VisualNovelBatchEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/timing/VisualNovelBatchEvent.cpp rename to archive/visualnovel/events/timing/VisualNovelBatchEvent.cpp diff --git a/src/dawn/games/visualnovel/events/timing/VisualNovelBatchEvent.hpp b/archive/visualnovel/events/timing/VisualNovelBatchEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/timing/VisualNovelBatchEvent.hpp rename to archive/visualnovel/events/timing/VisualNovelBatchEvent.hpp diff --git a/src/dawn/games/visualnovel/events/timing/VisualNovelPauseEvent.cpp b/archive/visualnovel/events/timing/VisualNovelPauseEvent.cpp similarity index 100% rename from src/dawn/games/visualnovel/events/timing/VisualNovelPauseEvent.cpp rename to archive/visualnovel/events/timing/VisualNovelPauseEvent.cpp diff --git a/src/dawn/games/visualnovel/events/timing/VisualNovelPauseEvent.hpp b/archive/visualnovel/events/timing/VisualNovelPauseEvent.hpp similarity index 100% rename from src/dawn/games/visualnovel/events/timing/VisualNovelPauseEvent.hpp rename to archive/visualnovel/events/timing/VisualNovelPauseEvent.hpp diff --git a/src/dawn/games/visualnovel/scene/CMakeLists.txt b/archive/visualnovel/scene/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/scene/CMakeLists.txt rename to archive/visualnovel/scene/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/scene/SimpleVNScene.cpp b/archive/visualnovel/scene/SimpleVNScene.cpp similarity index 100% rename from src/dawn/games/visualnovel/scene/SimpleVNScene.cpp rename to archive/visualnovel/scene/SimpleVNScene.cpp diff --git a/src/dawn/games/visualnovel/scene/SimpleVNScene.hpp b/archive/visualnovel/scene/SimpleVNScene.hpp similarity index 100% rename from src/dawn/games/visualnovel/scene/SimpleVNScene.hpp rename to archive/visualnovel/scene/SimpleVNScene.hpp diff --git a/src/dawn/games/visualnovel/ui/CMakeLists.txt b/archive/visualnovel/ui/CMakeLists.txt similarity index 100% rename from src/dawn/games/visualnovel/ui/CMakeLists.txt rename to archive/visualnovel/ui/CMakeLists.txt diff --git a/src/dawn/games/visualnovel/ui/VisualNovelFader.cpp b/archive/visualnovel/ui/VisualNovelFader.cpp similarity index 100% rename from src/dawn/games/visualnovel/ui/VisualNovelFader.cpp rename to archive/visualnovel/ui/VisualNovelFader.cpp diff --git a/src/dawn/games/visualnovel/ui/VisualNovelFader.hpp b/archive/visualnovel/ui/VisualNovelFader.hpp similarity index 100% rename from src/dawn/games/visualnovel/ui/VisualNovelFader.hpp rename to archive/visualnovel/ui/VisualNovelFader.hpp diff --git a/src/dawn/games/visualnovel/ui/VisualNovelTextbox.cpp b/archive/visualnovel/ui/VisualNovelTextbox.cpp similarity index 100% rename from src/dawn/games/visualnovel/ui/VisualNovelTextbox.cpp rename to archive/visualnovel/ui/VisualNovelTextbox.cpp diff --git a/src/dawn/games/visualnovel/ui/VisualNovelTextbox.hpp b/archive/visualnovel/ui/VisualNovelTextbox.hpp similarity index 100% rename from src/dawn/games/visualnovel/ui/VisualNovelTextbox.hpp rename to archive/visualnovel/ui/VisualNovelTextbox.hpp diff --git a/assets/games/liminal/example-scene.xml b/assets/games/liminal/example-scene.xml new file mode 100644 index 00000000..b1c198d8 --- /dev/null +++ b/assets/games/liminal/example-scene.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + Hi, I'm Ethereality. + + + + + + Hi, I'm Craig. + + + + + + + + + + + + + + + + + <string lang="en">Do you think Craig is cool?</string> + + + Yes + + + No + + + Maybe + + + + + + + Are you unsure? + + + + + + + I agree, Craig is cool. + + + + + I disagree, Craig is cool. + + + + + + + + + + + + + \ No newline at end of file diff --git a/cmake/targets/target-liminal-linux64-glfw/CMakeLists.txt b/cmake/targets/target-liminal-linux64-glfw/CMakeLists.txt new file mode 100644 index 00000000..559b577e --- /dev/null +++ b/cmake/targets/target-liminal-linux64-glfw/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2023 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +set(DAWN_BUILDING dawnliminal CACHE INTERNAL ${DAWN_CACHE_TARGET}) +set(DAWN_TARGET_LINUX64 true CACHE INTERNAL ${DAWN_CACHE_TARGET}) +set(DAWN_TARGET_GLFW true CACHE INTERNAL ${DAWN_CACHE_TARGET}) +set(DAWN_TARGET_NAME "Liminal" CACHE INTERNAL ${DAWN_CACHE_TARGET}) +set(DAWN_VISUAL_NOVEL true CACHE INTERNAL ${DAWN_CACHE_TARGET}) \ No newline at end of file diff --git a/src/dawn/games/CMakeLists.txt b/src/dawn/games/CMakeLists.txt index d3f4878f..302c92e9 100644 --- a/src/dawn/games/CMakeLists.txt +++ b/src/dawn/games/CMakeLists.txt @@ -4,9 +4,9 @@ # https://opensource.org/licenses/MIT # Subdirs -add_subdirectory(poker) +# add_subdirectory(poker) add_subdirectory(tictactoe) if(DAWN_VISUAL_NOVEL) - add_subdirectory(visualnovel) + add_subdirectory(vn) endif() \ No newline at end of file diff --git a/src/dawn/games/vn/CMakeLists.txt b/src/dawn/games/vn/CMakeLists.txt new file mode 100644 index 00000000..87a903f2 --- /dev/null +++ b/src/dawn/games/vn/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2023 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Subdirs +add_subdirectory(components) +add_subdirectory(events) \ No newline at end of file diff --git a/src/dawn/games/vn/components/CMakeLists.txt b/src/dawn/games/vn/components/CMakeLists.txt new file mode 100644 index 00000000..582b4b69 --- /dev/null +++ b/src/dawn/games/vn/components/CMakeLists.txt @@ -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 + VNManager.cpp +) \ No newline at end of file diff --git a/src/dawn/games/vn/components/VNManager.cpp b/src/dawn/games/vn/components/VNManager.cpp new file mode 100644 index 00000000..9f6a655f --- /dev/null +++ b/src/dawn/games/vn/components/VNManager.cpp @@ -0,0 +1,36 @@ +// Copyright (c) 2022 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "VNManager.hpp" +#include "games/vn/events/VNEvent.hpp" + +using namespace Dawn; + +VNManager::VNManager(SceneItem *item) : + SceneItemComponent(item) +{ +} + +void VNManager::onStart() { + if(this->currentEvent != nullptr) { + this->currentEvent->start(nullptr); + } +} + +void VNManager::setEvent(VNEvent *event) { + this->currentEvent = event; +} + +void VNManager::nextEvent() { + if(this->currentEvent == nullptr) return; + auto old = this->currentEvent; + old->end(); + this->currentEvent = old->getNextEvent(); + if(this->currentEvent != nullptr) this->currentEvent->start(old); +} + +void VNManager::onDispose() { + +} \ No newline at end of file diff --git a/src/dawn/games/vn/components/VNManager.hpp b/src/dawn/games/vn/components/VNManager.hpp new file mode 100644 index 00000000..8f999ffb --- /dev/null +++ b/src/dawn/games/vn/components/VNManager.hpp @@ -0,0 +1,60 @@ +// Copyright (c) 2022 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "scene/SceneItemComponent.hpp" + +namespace Dawn { + class VNEvent; + + class VNManager : public SceneItemComponent { + protected: + std::vector events; + VNEvent *currentEvent = nullptr; + + public: + /** + * Constructs a visual novel manager, scene item component. + * + * @param item Item that the VN manager belongs to. + */ + VNManager(SceneItem *item); + + /** + * Creats an event for you to decide how to queue. + */ + template + T * createEvent() { + auto event = new T(); + event->init(this); + this->events.push_back(event); + return event; + } + + /** + * Sets the currently active visual novel event. This is assumed to be + * the only way to handle events (no multiples currently). + * + * @param event Event to set. + */ + void setEvent(VNEvent *event); + + void nextEvent(); + + // template + // T * setEvent(T *event) { + // auto oldCurrent = this->currentEvent; + // this->currentEvent = event; + // if(this->hasInitialized && event != nullptr) event->start(oldCurrent); + // delete oldCurrent; + // return event; + // } + + void onStart() override; + void onDispose() override; + + friend class VNEvent; + }; +} \ No newline at end of file diff --git a/src/dawn/games/vn/events/CMakeLists.txt b/src/dawn/games/vn/events/CMakeLists.txt new file mode 100644 index 00000000..e80f467c --- /dev/null +++ b/src/dawn/games/vn/events/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/src/dawn/games/vn/events/VNDummyEvent.hpp b/src/dawn/games/vn/events/VNDummyEvent.hpp new file mode 100644 index 00000000..9a525be1 --- /dev/null +++ b/src/dawn/games/vn/events/VNDummyEvent.hpp @@ -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(); + } + }; +} \ No newline at end of file diff --git a/src/dawn/games/vn/events/VNEvent.cpp b/src/dawn/games/vn/events/VNEvent.cpp new file mode 100644 index 00000000..9212b795 --- /dev/null +++ b/src/dawn/games/vn/events/VNEvent.cpp @@ -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() {} \ No newline at end of file diff --git a/src/dawn/games/vn/events/VNEvent.hpp b/src/dawn/games/vn/events/VNEvent.hpp new file mode 100644 index 00000000..6dd4ae3e --- /dev/null +++ b/src/dawn/games/vn/events/VNEvent.hpp @@ -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 + T * then(T *next) { + this->doNext = next; + return next; + } + + friend class VNManager; + }; +} \ No newline at end of file diff --git a/src/dawn/prefabs/SimpleSpinningCubePrefab.hpp b/src/dawn/prefabs/SimpleSpinningCubePrefab.hpp index 888a2fdc..cfb41cb3 100644 --- a/src/dawn/prefabs/SimpleSpinningCubePrefab.hpp +++ b/src/dawn/prefabs/SimpleSpinningCubePrefab.hpp @@ -6,8 +6,8 @@ #pragma once #include "prefab/SceneItemPrefab.hpp" #include "display/mesh/CubeMesh.hpp" -#include "scene/components/display/MeshRenderer.hpp" -#include "scene/components/display/CubeMeshHost.hpp" +#include "scene/components/display/mesh/MeshRenderer.hpp" +#include "scene/components/display/mesh/CubeMeshHost.hpp" #include "scene/components/display/material/SimpleTexturedMaterial.hpp" #include "scene/components/example/ExampleSpin.hpp" #include "scene/components/physics/3d/CubeCollider.hpp" diff --git a/src/dawn/state/State.hpp b/src/dawn/state/State.hpp index 757156c3..281873c2 100644 --- a/src/dawn/state/State.hpp +++ b/src/dawn/state/State.hpp @@ -44,6 +44,36 @@ namespace Dawn { private: std::vector eventsSubscribed; std::vector eventLegacyBridge; + + protected: + /** + * Removes all currently subscribed effects and events. + */ + void unsubscribeAllEvents() { + auto providers = this->_stateProviderListeners; + auto itProvider = providers.begin(); + while(itProvider != providers.end()) { + (*itProvider)(); + ++itProvider; + } + + auto it = this->eventsSubscribed.begin(); + while(it != this->eventsSubscribed.end()) { + (*it)->_stateOwnerDestroyed(this); + ++it; + } + + auto itBridge = this->eventLegacyBridge.begin(); + while(itBridge != this->eventLegacyBridge.end()) { + (*itBridge)->removeListener(); + delete *itBridge; + ++itBridge; + } + + this->_stateProviderListeners.clear(); + this->eventsSubscribed.clear(); + this->eventLegacyBridge.clear(); + } public: std::vector> _stateProviderListeners; @@ -123,7 +153,11 @@ namespace Dawn { auto itProp = props.begin(); while(itProp != props.end()) { auto property = *itProp; - if(property->owner == nullptr) { property->owner = this; } else { assertTrue(property->owner == this); } + if(property->owner == nullptr) { + property->owner = this; + } else { + assertTrue(property->owner == this); + } property->_effectListners.push_back(fn); ++itProp; } @@ -230,25 +264,7 @@ namespace Dawn { * useEffects or useEvents. */ virtual ~StateOwner() { - auto providers = this->_stateProviderListeners; - auto itProvider = providers.begin(); - while(itProvider != providers.end()) { - (*itProvider)(); - ++itProvider; - } - - auto it = this->eventsSubscribed.begin(); - while(it != this->eventsSubscribed.end()) { - (*it)->_stateOwnerDestroyed(this); - ++it; - } - - auto itBridge = this->eventLegacyBridge.begin(); - while(itBridge != this->eventLegacyBridge.end()) { - (*itBridge)->removeListener(); - delete *itBridge; - ++itBridge; - } + this->unsubscribeAllEvents(); } }; } \ No newline at end of file diff --git a/src/dawnliminal/CMakeLists.txt b/src/dawnliminal/CMakeLists.txt new file mode 100644 index 00000000..8de667f3 --- /dev/null +++ b/src/dawnliminal/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2023 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Build Project +add_executable(${DAWN_TARGET_NAME}) + +# Includes +target_include_directories(${DAWN_TARGET_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + +# Subdirs +add_subdirectory(game) +add_subdirectory(save) \ No newline at end of file diff --git a/src/dawnliminal/game/CMakeLists.txt b/src/dawnliminal/game/CMakeLists.txt new file mode 100644 index 00000000..6ab23ef2 --- /dev/null +++ b/src/dawnliminal/game/CMakeLists.txt @@ -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 + LiminalGame.cpp +) \ No newline at end of file diff --git a/src/dawnliminal/game/LiminalGame.cpp b/src/dawnliminal/game/LiminalGame.cpp new file mode 100644 index 00000000..105be5d3 --- /dev/null +++ b/src/dawnliminal/game/LiminalGame.cpp @@ -0,0 +1,13 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "game/DawnGame.hpp" +#include "scenes/HelloWorldScene.hpp" + +using namespace Dawn; + +Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) { + return new HelloWorldScene(game); +} \ No newline at end of file diff --git a/src/dawnliminal/input/InputBinds.hpp b/src/dawnliminal/input/InputBinds.hpp new file mode 100644 index 00000000..32fc1016 --- /dev/null +++ b/src/dawnliminal/input/InputBinds.hpp @@ -0,0 +1,19 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "input/InputManager.hpp" + +#define INPUT_BIND(n) ((inputbind_t)n) + +#define INPUT_BIND_ACCEPT INPUT_BIND(1) +#define INPUT_BIND_NEGATIVE_X INPUT_BIND(2) +#define INPUT_BIND_POSITIVE_X INPUT_BIND(3) +#define INPUT_BIND_NEGATIVE_Y INPUT_BIND(4) +#define INPUT_BIND_POSITIVE_Y INPUT_BIND(5) +#define INPUT_BIND_MOUSE_X INPUT_BIND(6) +#define INPUT_BIND_MOUSE_Y INPUT_BIND(7) +#define INPUT_BIND_MOUSE_CLICK INPUT_BIND(8) +#define INPUT_BIND_CANCEL INPUT_BIND(9) \ No newline at end of file diff --git a/src/dawnliminal/save/CMakeLists.txt b/src/dawnliminal/save/CMakeLists.txt new file mode 100644 index 00000000..97158e97 --- /dev/null +++ b/src/dawnliminal/save/CMakeLists.txt @@ -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 + LiminalSave.cpp +) \ No newline at end of file diff --git a/src/dawnliminal/save/LiminalSave.cpp b/src/dawnliminal/save/LiminalSave.cpp new file mode 100644 index 00000000..3c029bd4 --- /dev/null +++ b/src/dawnliminal/save/LiminalSave.cpp @@ -0,0 +1,12 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "save/SaveManager.hpp" + +using namespace Dawn; + +bool_t Dawn::saveValidateFile(struct SaveFile raw) { + return false; +} \ No newline at end of file diff --git a/src/dawnliminal/scenes/HelloWorldScene.hpp b/src/dawnliminal/scenes/HelloWorldScene.hpp new file mode 100644 index 00000000..8629fddd --- /dev/null +++ b/src/dawnliminal/scenes/HelloWorldScene.hpp @@ -0,0 +1,48 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "scene/Scene.hpp" +#include "scene/components/display/Camera.hpp" +#include "prefabs/SimpleSpinningCubePrefab.hpp" +#include "games/vn/components/VNManager.hpp" +#include "games/vn/events/VNDummyEvent.hpp" + +namespace Dawn { + class HelloWorldScene : public Scene { + protected: + Camera *camera; + UICanvas *canvas; + + void stage() override { + canvas = UICanvas::create(this); + + camera = Camera::create(this); + camera->fov = 0.436332f; + camera->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0)); + + auto cube = SimpleSpinningCubePrefab::create(this); + + auto vnItem = this->createSceneItem(); + auto vnManager = vnItem->addComponent(); + + auto eventTest = vnManager->createEvent(); + eventTest + ->then(vnManager->createEvent()) + ->then(vnManager->createEvent()) + ; + vnManager->setEvent(eventTest); + } + + std::vector getRequiredAssets() override { + auto assMan = &this->game->assetManager; + std::vector assets; + return assets; + } + + public: + HelloWorldScene(DawnGame *game) : Scene(game) {} + }; +} \ No newline at end of file diff --git a/src/dawnrose/scene/components/HurtHazard.cpp b/src/dawnrose/scene/components/HurtHazard.cpp index 05cd6ebe..bd4c6a1d 100644 --- a/src/dawnrose/scene/components/HurtHazard.cpp +++ b/src/dawnrose/scene/components/HurtHazard.cpp @@ -40,8 +40,6 @@ void HurtHazard::onStart() { otherHealth->damage({ .amount = damage }); - - std::cout << "Trigger" << std::endl; }, this->trigger->eventTriggerEnter); }, this->trigger)(); } \ No newline at end of file diff --git a/src/dawnrose/scene/components/entity/EntityInteractable.cpp b/src/dawnrose/scene/components/entity/EntityInteractable.cpp new file mode 100644 index 00000000..e52dec04 --- /dev/null +++ b/src/dawnrose/scene/components/entity/EntityInteractable.cpp @@ -0,0 +1,17 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "EntityInteractable.hpp" + +using namespace Dawn; + +EntityInteractable::EntityInteractable(SceneItem* item) : SceneItemComponent(item) { + +} + + +void EntityInteractable::interact() { + std::cout << "Interact!" << std::endl; +} \ No newline at end of file diff --git a/src/dawnrose/scene/components/entity/EntityInteractable.hpp b/src/dawnrose/scene/components/entity/EntityInteractable.hpp new file mode 100644 index 00000000..bb8fef80 --- /dev/null +++ b/src/dawnrose/scene/components/entity/EntityInteractable.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "scene/SceneItemComponent.hpp" +#include "scene/components/physics/2d/TriggerController2D.hpp" + +namespace Dawn { + class EntityInteractable : public SceneItemComponent { + public: + EntityInteractable(SceneItem *item); + + /** + * Called when one entity interacts with this entity. + */ + void interact(); + }; +} \ No newline at end of file diff --git a/src/dawnrose/scene/components/entity/EntityInteractor.cpp b/src/dawnrose/scene/components/entity/EntityInteractor.cpp new file mode 100644 index 00000000..2e675c2d --- /dev/null +++ b/src/dawnrose/scene/components/entity/EntityInteractor.cpp @@ -0,0 +1,27 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "EntityInteractor.hpp" + +using namespace Dawn; + +EntityInteractor::EntityInteractor(SceneItem* item) : + trigger(nullptr), + SceneItemComponent(item) +{ +} + +void EntityInteractor::onStart() { + this->evtTriggerEnter = [&]{}; + + useEffect([&]{ + this->evtTriggerEnter(); + if(this->trigger == nullptr) return; + + this->evtTriggerEnter = useEvent([&](EntityInteractable *interactable) { + interactable->interact(); + }, this->trigger->eventTriggerEnter); + }, this->trigger)(); +} diff --git a/src/dawnrose/scene/components/entity/EntityInteractor.hpp b/src/dawnrose/scene/components/entity/EntityInteractor.hpp new file mode 100644 index 00000000..05e1abe7 --- /dev/null +++ b/src/dawnrose/scene/components/entity/EntityInteractor.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "EntityInteractable.hpp" + +namespace Dawn { + class EntityInteractor : public SceneItemComponent { + private: + std::function evtTriggerEnter; + + public: + // @optional + StateProperty trigger; + + EntityInteractor(SceneItem* item); + void onStart() override; + }; +} \ No newline at end of file diff --git a/src/dawntools/CMakeLists.txt b/src/dawntools/CMakeLists.txt index 0cec211a..e915ff6b 100644 --- a/src/dawntools/CMakeLists.txt +++ b/src/dawntools/CMakeLists.txt @@ -20,4 +20,5 @@ include(util/CMakeLists.txt) # Tools add_subdirectory(prefabtool) -add_subdirectory(texturetool) \ No newline at end of file +add_subdirectory(texturetool) +# add_subdirectory(vnscenetool) \ No newline at end of file diff --git a/src/dawntools/vnscenetool/CMakeLists.txt b/src/dawntools/vnscenetool/CMakeLists.txt new file mode 100644 index 00000000..83b8fefd --- /dev/null +++ b/src/dawntools/vnscenetool/CMakeLists.txt @@ -0,0 +1,63 @@ +# Copyright (c) 2023 Dominic Msters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Texture Build Tool +project(vnscenetool VERSION 1.0) +add_executable(vnscenetool) + +# Subdirs +add_subdirectory(events) + +# Sources +target_sources(vnscenetool + PRIVATE + ${DAWN_SHARED_SOURCES} + ${DAWN_TOOL_SOURCES} + VNSceneTool.cpp + VNSceneParser.cpp + VNSceneEventsParser.cpp +) + +# Includes +target_include_directories(vnscenetool + PUBLIC + ${DAWN_SHARED_INCLUDES} + ${DAWN_TOOL_INCLUDES} + ${CMAKE_CURRENT_LIST_DIR} +) + +# Definitions +target_compile_definitions(vnscenetool + PUBLIC + ${DAWN_SHARED_DEFINITIONS} + DAWN_TOOL_INSTANCE=VNSceneTool + DAWN_TOOL_HEADER="VNSceneTool.hpp" +) + +# Libraries +target_link_libraries(vnscenetool + PUBLIC + ${DAWN_BUILD_HOST_LIBS} +) + +# Tool Function +function(tool_vnscene in) + set(DEPS "") + if(DAWN_BUILD_TOOLS) + set(DEPS vnscenetool) + endif() + + STRING(REGEX REPLACE "[\.|\\|\/]" "-" prefab_name ${in}) + add_custom_target(prefab_${prefab_name} + COMMAND vnscenetool --input="${DAWN_ASSETS_SOURCE_DIR}/${in}" + COMMENT "Generating prefab from ${in}" + DEPENDS ${DEPS} + ) + target_include_directories(${DAWN_TARGET_NAME} + PUBLIC + ${DAWN_GENERATED_DIR}/generatedprefabs + ) + add_dependencies(${DAWN_TARGET_NAME} prefab_${prefab_name}) +endfunction() \ No newline at end of file diff --git a/src/dawntools/vnscenetool/VNSceneEventsParser.cpp b/src/dawntools/vnscenetool/VNSceneEventsParser.cpp new file mode 100644 index 00000000..281a0a6e --- /dev/null +++ b/src/dawntools/vnscenetool/VNSceneEventsParser.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "VNSceneEventsParser.hpp" + +using namespace Dawn; + +std::vector VNSceneEventsParser::getRequiredAttributes() { + return { }; +} + +std::map VNSceneEventsParser::getOptionalAttributes() { + return { }; +} + +int32_t VNSceneEventsParser::onParse( + Xml *node, + std::map values, + struct VNSceneEvent *out, + std::string *error +) { + int32_t ret; + + auto itChildren = node->children.begin(); + while(itChildren != node->children.end()) { + Xml *child = *itChildren; + + // Parse event(s) + if(child->node == "position") { + struct VNPosition position; + ret = (VNPositionParser()).parse(child, &position, error); + if(ret != 0) return ret; + out->position = position; + } + + itChildren++; + } + + return 0; +} \ No newline at end of file diff --git a/src/dawntools/vnscenetool/VNSceneEventsParser.hpp b/src/dawntools/vnscenetool/VNSceneEventsParser.hpp new file mode 100644 index 00000000..7c35cc6c --- /dev/null +++ b/src/dawntools/vnscenetool/VNSceneEventsParser.hpp @@ -0,0 +1,26 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "util/XmlParser.hpp" +#include "events/VNPositionParser.hpp" + +namespace Dawn { + struct VNSceneEvent { + int32_t bruh; + }; + + class VNSceneEventsParser : public XmlParser { + protected: + std::vector getRequiredAttributes() override; + std::map getOptionalAttributes() override; + int32_t onParse( + Xml *node, + std::map values, + struct VNSceneEvent *out, + std::string *error + ) override; + }; +} \ No newline at end of file diff --git a/src/dawntools/vnscenetool/VNSceneParser.cpp b/src/dawntools/vnscenetool/VNSceneParser.cpp new file mode 100644 index 00000000..16c901ca --- /dev/null +++ b/src/dawntools/vnscenetool/VNSceneParser.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "VNSceneParser.hpp" + +using namespace Dawn; + +std::vector VNSceneParser::getRequiredAttributes() { + return { }; +} + +std::map VNSceneParser::getOptionalAttributes() { + return { }; +} + +int32_t VNSceneParser::onParse( + Xml *node, + std::map values, + struct VNScene *out, + std::string *error +) { + // + int32_t ret; + + auto itChildren = node->children.begin(); + while(itChildren != node->children.end()) { + Xml *child = *itChildren; + + // Parse event(s) + if(child->node == "events") { + struct VNSceneEvent scene; + ret = (VNSceneEventsParser()).parse(child, &scene, error); + if(ret != 0) return ret; + out->events.push_back(scene); + } + + + itChildren++; + } + + return 0; +} \ No newline at end of file diff --git a/src/dawntools/vnscenetool/VNSceneParser.hpp b/src/dawntools/vnscenetool/VNSceneParser.hpp new file mode 100644 index 00000000..e4140ac3 --- /dev/null +++ b/src/dawntools/vnscenetool/VNSceneParser.hpp @@ -0,0 +1,25 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "VNSceneEventsParser.hpp" + +namespace Dawn { + struct VNScene { + std::vector events; + }; + + class VNSceneParser : public XmlParser { + protected: + std::vector getRequiredAttributes() override; + std::map getOptionalAttributes() override; + int32_t onParse( + Xml *node, + std::map values, + struct VNScene *out, + std::string *error + ) override; + }; +} \ No newline at end of file diff --git a/src/dawntools/vnscenetool/VNSceneTool.cpp b/src/dawntools/vnscenetool/VNSceneTool.cpp new file mode 100644 index 00000000..79f9a69b --- /dev/null +++ b/src/dawntools/vnscenetool/VNSceneTool.cpp @@ -0,0 +1,43 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "VNSceneTool.hpp" + +using namespace Dawn; + +std::vector VNSceneTool::getRequiredFlags() { + return { "input" }; +} + +std::map VNSceneTool::getOptionalFlags() { + return std::map(); +} + +int32_t VNSceneTool::start() { + File input = File(flags["input"]); + if(!input.exists()) { + std::cout << "Input file does not exist!" << std::endl; + return 1; + } + + std::string data; + if(!input.readString(&data)) { + std::cout << "Failed to read input file!" << std::endl; + return 1; + } + + auto xml = Xml::load(data); + std::string error; + struct VNScene scene; + auto result = ((VNSceneParser()).parse(&xml, &scene, &error)); + if(result != 0) { + std::cout << "Failed to parse scene: " << error << std::endl; + return result; + } + + // Generate output + + return 0; +} \ No newline at end of file diff --git a/src/dawntools/vnscenetool/VNSceneTool.hpp b/src/dawntools/vnscenetool/VNSceneTool.hpp new file mode 100644 index 00000000..b6da5ec1 --- /dev/null +++ b/src/dawntools/vnscenetool/VNSceneTool.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "util/DawnTool.hpp" +#include "VNSceneParser.hpp" +#include "util/File.hpp" + +namespace Dawn { + class VNSceneTool : public DawnTool { + protected: + std::vector getRequiredFlags() override; + std::map getOptionalFlags() override; + + public: + int32_t start(); + }; +} \ No newline at end of file diff --git a/src/dawntools/vnscenetool/events/CMakeLists.txt b/src/dawntools/vnscenetool/events/CMakeLists.txt new file mode 100644 index 00000000..825fa31d --- /dev/null +++ b/src/dawntools/vnscenetool/events/CMakeLists.txt @@ -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(vnscenetool + PRIVATE + VNPositionParser.cpp +) \ No newline at end of file diff --git a/src/dawntools/vnscenetool/events/VNPositionParser.cpp b/src/dawntools/vnscenetool/events/VNPositionParser.cpp new file mode 100644 index 00000000..380abc39 --- /dev/null +++ b/src/dawntools/vnscenetool/events/VNPositionParser.cpp @@ -0,0 +1,25 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "VNPositionParser.hpp" + +using namespace Dawn; + +std::vector VNPositionParser::getRequiredAttributes() { + return { }; +} + +std::map VNPositionParser::getOptionalAttributes() { + return { }; +} + +int32_t VNPositionParser::onParse( + Xml *node, + std::map values, + struct VNPosition *out, + std::string *error +) { + return 0; +} \ No newline at end of file diff --git a/src/dawntools/vnscenetool/events/VNPositionParser.hpp b/src/dawntools/vnscenetool/events/VNPositionParser.hpp new file mode 100644 index 00000000..55bff476 --- /dev/null +++ b/src/dawntools/vnscenetool/events/VNPositionParser.hpp @@ -0,0 +1,6 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once