Added basic prefabs finally

This commit is contained in:
2023-01-03 16:44:16 -08:00
parent 562e6644ef
commit 659ab3d760
29 changed files with 193 additions and 108 deletions

View File

@ -0,0 +1,10 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
# target_sources(${DAWN_TARGET_NAME}
# PRIVATE
# Prefab.cpp
# )

View File

@ -0,0 +1,24 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "asset/AssetManager.hpp"
#include "scene/Scene.hpp"
namespace Dawn {
template<class T>
class Prefab {
public:
static std::vector<Asset*> getRequiredAssets() {
return T::prefabAssets();
}
static T * create(Scene *scene) {
T *item = scene->createSceneItemOfType<T>();
item->prefabInit();
return item;
}
};
}

View File

@ -0,0 +1,27 @@
// 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:
SceneItemPrefab(Scene *scene, sceneitemid_t id) :
SceneItem(scene, id)
{
}
virtual void prefabInit() = 0;
};
}