68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
// 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));
|
|
}
|
|
};
|
|
} |