GameObjectPool
This commit is contained in:
@@ -1,15 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include "../math.hpp"
|
||||
#include <set>
|
||||
#include "../UsefulException.hpp"
|
||||
#include "../Mono/Mono.hpp"
|
||||
|
||||
class GameObject {
|
||||
class GameObject;
|
||||
|
||||
class Component {
|
||||
Mono::ObjectHandle object_handle;
|
||||
GameObject* owner;
|
||||
public:
|
||||
Vec2 scale = { 1, 1 };
|
||||
Vec2 position;
|
||||
angle_t rotation;
|
||||
|
||||
private:
|
||||
// std::set<Component> components;
|
||||
inline Component(Mono::Object managed_obj, GameObject* owner)
|
||||
: object_handle(managed_obj), owner(owner) {}
|
||||
};
|
||||
|
||||
struct Transform {
|
||||
Vec2 scale = { 1, 1 };
|
||||
Vec2 position = { 0, 0 };
|
||||
angle_t rotation = 0;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, Transform& t);
|
||||
|
||||
|
||||
class GameObject {
|
||||
Transform transform;
|
||||
std::map<std::u16string, Component> components;
|
||||
Mono::ObjectHandle object_handle;
|
||||
GameObject* parent;
|
||||
public:
|
||||
GameObject(Mono::Object managed_obj, GameObject* parent);
|
||||
|
||||
GameObject& operator=(GameObject&& o);
|
||||
|
||||
inline Transform& getTransform(){ return transform; }
|
||||
bool tryGetComponent(const std::u16string& name, Component** out_component);
|
||||
bool tryAddComponent(const std::u16string& name, Component&& component);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user