48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
// Copyright (c) 2022 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#pragma once
|
|
#include "Prefab.hpp"
|
|
#include "scene/SceneItem.hpp"
|
|
#include "game/DawnGame.hpp"
|
|
|
|
namespace Dawn {
|
|
template<class T>
|
|
class SceneItemPrefab :
|
|
public SceneItem,
|
|
public Prefab<T, Scene, T>
|
|
{
|
|
public:
|
|
/**
|
|
* Creates an instance of this prefab for the given scene.
|
|
*
|
|
* @param scene Scene that this prefab is going to be added to.
|
|
* @return The created prefab instance.
|
|
*/
|
|
static T * prefabCreate(Scene *scene) {
|
|
T *item = scene->createSceneItemOfType<T>();
|
|
item->prefabInit(&scene->game->assetManager);
|
|
return item;
|
|
}
|
|
|
|
/**
|
|
* Constructor for this SceneItemPrefab.
|
|
*
|
|
* @param scene Scene that this prefab belongs to.
|
|
* @param id ID of this scene item.
|
|
*/
|
|
SceneItemPrefab(Scene *scene, sceneitemid_t id) :
|
|
SceneItem(scene, id)
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Virtual method called by the subclass for initialization after the
|
|
* prefab has been created.
|
|
*/
|
|
virtual void prefabInit(AssetManager *man) = 0;
|
|
};
|
|
} |