mirror of
https://gitlab.com/voidframe/voidframe-cpp.git
synced 2026-09-22 02:47:16 -04:00
Add worlds
This commit is contained in:
+11
-2
@@ -1,25 +1,34 @@
|
||||
#ifndef VOID_ENTITY_H
|
||||
#define VOID_ENTITY_H
|
||||
#include "component.h"
|
||||
#include "world.h"
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace VoidFrame {
|
||||
|
||||
class World;
|
||||
|
||||
class Entity {
|
||||
public:
|
||||
template <typename CompT, typename... Args>
|
||||
CompT *AddComponent(Args &&...args);
|
||||
Entity *AddComponent(Args &&...args);
|
||||
template <typename CompT> CompT *GetComponent();
|
||||
template <typename CompT> bool HasComponent();
|
||||
template <typename CompT> void RemoveComponent();
|
||||
template <typename CompT> Entity *RemoveComponent();
|
||||
|
||||
void Destroy();
|
||||
void Update();
|
||||
|
||||
private:
|
||||
Entity();
|
||||
std::vector<std::unique_ptr<Component>> components;
|
||||
World *world;
|
||||
|
||||
friend class World;
|
||||
};
|
||||
|
||||
#include "../src/entity_i.cpp"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "entity.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace VoidFrame {
|
||||
|
||||
class World {
|
||||
public:
|
||||
Entity *Spawn();
|
||||
void Destroy(Entity *entity);
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Entity>> entities;
|
||||
};
|
||||
|
||||
} // namespace VoidFrame
|
||||
Reference in New Issue
Block a user