Dawn/src/dawn/prefab/Prefab.hpp

36 lines
1.0 KiB
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/SceneItemComponent.hpp"
#include "util/array.hpp"
namespace Dawn {
template<class O, typename J, class P = O>
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 O * create(J *context) {
assertNotNull(context);
return P::prefabCreate(context);
}
};
}