Just breaking stuff

This commit is contained in:
2023-03-14 22:27:46 -07:00
parent 795e69237c
commit 09cb20271b
156 changed files with 4218 additions and 4389 deletions

View File

@ -0,0 +1,11 @@
# 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
CharacterPrefab.cpp
DeathPrefab.cpp
)

View File

@ -0,0 +1,8 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "CharacterPrefab.hpp"
using namespace Dawn;

View File

@ -0,0 +1,82 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefab/SceneItemPrefab.hpp"
#include "scene/Scene.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/AnimationController.hpp"
#include "scene/components/display/MeshHost.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
#include "scene/components/audio/AudioSource.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
namespace Dawn {
template<class O>
class CharacterPrefab : public SceneItemPrefab<O> {
protected:
/**
* Character Prefab will request you to initialize your characters'
* emotions here, including loading assets,
*
* @return struct VisualNovelCharacterEmotion
*/
virtual struct VisualNovelCharacterEmotion defineAndGetInitialEmotion(
AssetManager *assMan
) = 0;
public:
static std::vector<Asset*> prefabAssets(AssetManager *assMan) {
return std::vector<Asset*>{
assMan->get<TextureAsset>(O::getCharacterTexture()),
assMan->get<TilesetAsset>(O::getCharacterTileset())
};
}
// Instance
VisualNovelCharacter *vnCharacter;
AnimationController *animation;
TextureAsset *characterTexture;
TilesetAsset *characterTileset;
MeshRenderer *meshRenderer;
MeshHost *meshHost;
SimpleTexturedMaterial *material;
TiledSprite *tiledSprite;
AudioSource *audioSource;
CharacterPrefab(Scene *s, sceneitemid_t i) : SceneItemPrefab<O>(s, i) {}
void prefabInit(AssetManager *man) override {
characterTexture = man->get<TextureAsset>(O::getCharacterTexture());
characterTileset = man->get<TilesetAsset>(O::getCharacterTileset());
// Emotions
auto emotion = this->defineAndGetInitialEmotion(man);
// Components
meshRenderer = this->template addComponent<MeshRenderer>();
meshHost = this->template addComponent<MeshHost>();
material = this->template addComponent<SimpleTexturedMaterial>();
material->texture = &characterTexture->texture;
vnCharacter = this->template addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = O::getLanguagePrefix() + ".name";
animation = this->template addComponent<AnimationController>();
tiledSprite = this->template addComponent<TiledSprite>();
tiledSprite->setTileset(&characterTileset->tileset);
float_t ratio = characterTileset->tileset.getTileWidth() / characterTileset->tileset.getTileHeight();
tiledSprite->setSize(glm::vec2(ratio, 1.0f));
tiledSprite->setTile(emotion.tile);
audioSource = this->template addComponent<AudioSource>();
this->transform.setLocalPosition(glm::vec3(0, 0, 0));
}
};
}

View File

@ -0,0 +1,32 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DeathPrefab.hpp"
using namespace Dawn;
std::string DeathPrefab::getCharacterTexture() {
return "texture_death";
}
std::string DeathPrefab::getCharacterTileset() {
return "tileset_death";
}
std::string DeathPrefab::getLanguagePrefix() {
return "character.death";
}
struct VisualNovelCharacterEmotion DeathPrefab::defineAndGetInitialEmotion(
AssetManager *man
) {
this->emotionHappy.tile = 0;
this->emotionConcerned.tile = 1;
this->emotionSurprised.tile = 2;
return this->emotionHappy;
}

View File

@ -0,0 +1,29 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefabs/characters/CharacterPrefab.hpp"
namespace Dawn {
class DeathPrefab : public CharacterPrefab<DeathPrefab> {
protected:
struct VisualNovelCharacterEmotion defineAndGetInitialEmotion(
AssetManager *man
) override;
public:
static std::string getCharacterTexture();
static std::string getCharacterTileset();
static std::string getLanguagePrefix();
struct VisualNovelCharacterEmotion emotionHappy;
struct VisualNovelCharacterEmotion emotionConcerned;
struct VisualNovelCharacterEmotion emotionSurprised;
struct VisualNovelCharacterEmotion emotionUnset;
DeathPrefab(Scene *s, sceneitemid_t i) : CharacterPrefab(s,i) {}
};
}

View File

@ -0,0 +1,68 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefab/SceneItemPrefab.hpp"
#include "asset/AssetManager.hpp"
#include "poker/PokerPlayer.hpp"
#include "scene/components/Components.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "display/animation/TiledSpriteAnimation.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class PennyPrefab : public SceneItemPrefab<PennyPrefab> {
public:
VisualNovelCharacter *vnCharacter;
PokerPlayer *pokerPlayer;
SimpleTexturedMaterial *material;
struct VisualNovelCharacterEmotion emotionHappy;
struct VisualNovelCharacterEmotion emotionSurprised;
struct VisualNovelCharacterEmotion emotionConcerned;
static std::vector<Asset*> prefabAssets(AssetManager *assMan) {
return std::vector<Asset*>{
assMan->get<TextureAsset>("texture_penny"),
assMan->get<TilesetAsset>("tileset_penny")
};
}
PennyPrefab(Scene *scene, sceneitemid_t id) : SceneItemPrefab(scene, id){}
void prefabInit(AssetManager *man) override {
// Assets
auto textureAsset = man->get<TextureAsset>("texture_penny");
auto tilesetAsset = man->get<TilesetAsset>("tileset_penny");
// Emotions
this->emotionHappy.tile = 0;
this->emotionSurprised.tile = 1;
this->emotionConcerned.tile = 2;
// Components
auto meshRenderer = this->addComponent<MeshRenderer>();
auto meshHost = this->addComponent<MeshHost>();
material = this->addComponent<SimpleTexturedMaterial>();
material->texture = &textureAsset->texture;
auto animation = this->addComponent<AnimationController>();
pokerPlayer = this->addComponent<PokerPlayer>();
vnCharacter = this->addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = "character.penny.name";
auto tiledSprite = this->addComponent<TiledSprite>();
tiledSprite->setTilesetAndSize(&tilesetAsset->tileset);
tiledSprite->setTile(0);
this->transform.setLocalPosition(glm::vec3(0, 0, 0));
}
};
}