46 lines
1.2 KiB
C++
46 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 "game/DawnGame.hpp"
|
|
|
|
namespace Dawn {
|
|
template<class O>
|
|
class SceneItemPrefab :
|
|
public SceneItem,
|
|
public Prefab<O, Scene, O>
|
|
{
|
|
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 O * prefabCreate(Scene *scene) {
|
|
O *item = scene->createSceneItemOfType<O>();
|
|
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;
|
|
};
|
|
} |