37 lines
791 B
C++
37 lines
791 B
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"
|
|
|
|
namespace Dawn {
|
|
template<class T>
|
|
class SceneItemPrefab :
|
|
public SceneItem,
|
|
public Prefab<T>
|
|
{
|
|
protected:
|
|
|
|
public:
|
|
static T * prefabCreate(Scene *scene, UICanvas *canvas) {
|
|
T *item = scene->createSceneItemOfType<T>();
|
|
item->prefabInit();
|
|
return 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() = 0;
|
|
};
|
|
} |