Dawn/src/dawn/prefab/Prefab.hpp
2023-01-06 21:01:06 -08:00

35 lines
979 B
C++

// 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, typename J, class P = T>
class Prefab {
public:
/**
* Returns the list of assets required for this prefab.
*
* @param man Asset Manasger for getting required assets from.
* @return List of required assets this prefab.
*/
static std::vector<Asset*> getRequiredAssets(AssetManager *man) {
return P::prefabAssets(man);
}
/**
* Creates a new instance of this prefabricated asset.
*
* @param context Custom context that this prefab needs to initialize.
* @return The instance of the created prefab.
*/
static T * create(J *context) {
assertNotNull(context);
return P::prefabCreate(context);
}
};
}