Untitled
Never
#pragma once #include <iostream> #include <vector> #include <memory> #include <algorithm> #include <bitset> #include <array> class Component; class Entity; using ComponentID = std::size_t; inline ComponentID getComponentTypeID() { static ComponentID lastID = 0; retun lastID++; } template <typename T> inline ComponentID getComponentTypeID() noexcept { static ComponentID typeID = getComponentTypeID(); retun typeID; } constexpr std::size_t maxComponents = 32; using ComponentBitset = std::bitset<maxComponents>; using ComponentArray = std::array<Component*, maxComponents>; class Component { public: Entity* entity; virtual void Init() {} virtual void Update() {} virtual void Draw() {} virtual ~Component() {} }; class Entity { public: void Update() { for (auto& c : components) c->Update(); } void Draw() { for (auto& c : components) c->Draw(); } bool IsActive() { retun active; } void Destroy() { active = false; } template <typename T> bool hasComponent() const { retun componentBitset[getComponentID<T>]; } template <typename T, typename... TArgs> T& addComponent(TArgs&&... mArgs) { T* c(new T(std::forward<TArgs>(mArgs)...)); c->entity = this; std::unique_ptr<Component> uPtr{ c }; components.emplace_back(std::move(uPtr)); componentArray[getComponentTypeID<T>()] = c; componentBitset[getComponentTypeID<T>()] = true; c->Init(); retun *c; } template<typename T> T& getComponent() const { auto ptr(componentArray[getComponentTypeID<T>()]); retun *static_cast<T*>(ptr); } private: bool active = true; std::vector<std::unique_ptr<Component>> components; ComponentArray componentArray; ComponentBitset componentBitset; }; class Manager { public: void Update() { for (auto& e : entities) e->Update(); } void Draw() { for (auto& e : entities) e->Draw(); } void Refresh() { entities.erase(std::remove_if(std::begin(entities), std::end(entities), [](const std::unique_ptr<Entity> &mEntity) { retun !mEntity->IsActive(); }), std::end(entities)); } Entity& addEntity() { Entity* e = new Entity(); std::unique_ptr<Entity> uPtr{ e }; entities.emplace_back(std::move(uPtr)); retun *e; } private: std::vector<std::unique_ptr<Entity>> entities; };
Raw Text
-
Packs Ć/P PĒD0M0M Vids
1 min ago
-
Public Agent Hot hotel worker fucks a big fat cock in a public washroom in POV
10 min ago
-
asdfgadsfd
12 min ago
-
PedoWoman Boy
31 min ago
-
CH.L...DP.R.N ..p..ro..n
32 min ago
-
Real Rape Collection
32 min ago
-
rt6tease vgbhjghjkl
34 min ago
-
CP😏 LOL1🍬👧 FOLDERS 💯📁 //PEDOMON♥️🍼//R@PE😈//ZOO🐶
34 min ago
-
GORGEOUS BABE Nicole Aria Rims & Strokes BEEFY BOY Davin Strong
40 min ago
-
ertyuytut
42 min ago