Worked a bit on prefabs of all things
This commit is contained in:
7
src/dawnrpg/component/CMakeLists.txt
Normal file
7
src/dawnrpg/component/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# Copyright (c) 2024 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_subdirectory(entity)
|
||||
add_subdirectory(world)
|
9
src/dawnrpg/component/entity/CMakeLists.txt
Normal file
9
src/dawnrpg/component/entity/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2024 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
Entity.cpp
|
||||
)
|
18
src/dawnrpg/component/entity/Entity.cpp
Normal file
18
src/dawnrpg/component/entity/Entity.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Entity.hpp"
|
||||
#include "assert/assert.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void Entity::onInit() {
|
||||
auto world = this->world.lock();
|
||||
assertNotNull(world, "World is no longer active.");
|
||||
}
|
||||
|
||||
void Entity::onDispose() {
|
||||
|
||||
}
|
21
src/dawnrpg/component/entity/Entity.hpp
Normal file
21
src/dawnrpg/component/entity/Entity.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/SceneComponent.hpp"
|
||||
|
||||
typedef uint32_t entityid_t;
|
||||
|
||||
namespace Dawn {
|
||||
class World;
|
||||
|
||||
class Entity final : public SceneComponent {
|
||||
public:
|
||||
std::weak_ptr<World> world;
|
||||
|
||||
void onInit() override;
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
9
src/dawnrpg/component/world/CMakeLists.txt
Normal file
9
src/dawnrpg/component/world/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2024 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
World.cpp
|
||||
)
|
14
src/dawnrpg/component/world/World.cpp
Normal file
14
src/dawnrpg/component/world/World.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "World.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void World::onInit() {
|
||||
}
|
||||
|
||||
void World::onDispose() {
|
||||
}
|
18
src/dawnrpg/component/world/World.hpp
Normal file
18
src/dawnrpg/component/world/World.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "component/entity/Entity.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class World : public SceneComponent {
|
||||
private:
|
||||
std::map<entityid_t, std::shared_ptr<Entity>> entities;
|
||||
|
||||
public:
|
||||
void onInit() override;
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user