Base refactor

This commit is contained in:
2023-11-14 09:16:48 -06:00
parent 214082d00f
commit 1817dcaf3a
410 changed files with 749 additions and 20823 deletions

View File

@ -1,10 +0,0 @@
# 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

@ -1,38 +0,0 @@
// 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<std::shared_ptr<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 std::shared_ptr<O> create(J *context) {
assertNotNull(context, "Prefab::create: Context cannot be null");
return P::prefabCreate(context);
}
};
}

View File

@ -1,48 +0,0 @@
// 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 std::shared_ptr<O> prefabCreate(Scene *scene) {
std::shared_ptr<O> item = scene->createSceneItemOfType<O>();
auto game = scene->game.lock();
assertNotNull(game, "Game cannot be null!");
item->prefabInit(&game->assetManager);
return item;
}
/**
* Constructor for this SceneItemPrefab.
*
* @param scene Scene that this prefab belongs to.
* @param id ID of this scene item.
*/
SceneItemPrefab(std::weak_ptr<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;
};
}