entity-component-system

Component based game engine design [closed]

久未见 提交于 2021-01-29 22:30:07
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I have been looking at game engine design (specifically focused on 2d game engines, but also applicable to 3d

Spliting component in Entity-Component-System demands too much refactoring

ε祈祈猫儿з 提交于 2020-07-08 05:56:17
问题 I have an existing working C++ game library that use Entity-Component-System (ECS). User of my library would like to create some components e.g. Cat :- class Cat{ public: int hp; float flyPower; }; He can modify hp of every cat by e.g. :- for(SmartComponentPtr<Cat> cat : getAll<Cat>()){ cat->hp-=5; //#1 } Some days later, he want to split Cat to HP and Flyable :- class HP{ public: int hp; }; class Flyable{ public: float flyPower; }; Thus, every cat that access hp will compile error (e.g. at

Spliting component in Entity-Component-System demands too much refactoring

老子叫甜甜 提交于 2020-07-08 05:55:11
问题 I have an existing working C++ game library that use Entity-Component-System (ECS). User of my library would like to create some components e.g. Cat :- class Cat{ public: int hp; float flyPower; }; He can modify hp of every cat by e.g. :- for(SmartComponentPtr<Cat> cat : getAll<Cat>()){ cat->hp-=5; //#1 } Some days later, he want to split Cat to HP and Flyable :- class HP{ public: int hp; }; class Flyable{ public: float flyPower; }; Thus, every cat that access hp will compile error (e.g. at

Spliting component in Entity-Component-System demands too much refactoring

◇◆丶佛笑我妖孽 提交于 2020-07-08 05:53:10
问题 I have an existing working C++ game library that use Entity-Component-System (ECS). User of my library would like to create some components e.g. Cat :- class Cat{ public: int hp; float flyPower; }; He can modify hp of every cat by e.g. :- for(SmartComponentPtr<Cat> cat : getAll<Cat>()){ cat->hp-=5; //#1 } Some days later, he want to split Cat to HP and Flyable :- class HP{ public: int hp; }; class Flyable{ public: float flyPower; }; Thus, every cat that access hp will compile error (e.g. at

Efficient way of matching entities to systems in an entity component system

余生颓废 提交于 2019-12-20 09:18:22
问题 I'm working on a data-oriented entity component system where component types and system signatures are known at compile-time. An entity is an aggregate of components. Components can be added/removed from entities at run-time. A component is a small logic-less class. A signature is a compile-time list of component types. An entity is said to match a signature if it contains all component types required by the signature. A short code sample will show you how the user syntax looks and what the

Entity Component System and multiple components sharing common base type

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 15:34:50
问题 I'm trying to implement a simple ECS for my game engine. I know that my implementation is not strictly ECS, but I'm refactoring my code to be more component-based. So far I have the following classes: Entity : it is a container of components, and since I want my entity to have multiple components of the same type, it stores them in a std::map<ComponentID,std::vector<std::unique_ptr<Component>>> . Each component has a unique ID (an unsigned int), that I get from a simple template trick I

Alternative for quad-nested unordered_map monstrosity?

回眸只為那壹抹淺笑 提交于 2019-12-10 19:03:44
问题 I've been trying out to figure an effective way to store and retrieve a number of objects. Let me explain what I'm trying to achieve, then list the options I've come up with ( But am unhappy with ). The following technically does what I need it to do, but is an obvious no-no: std::unordered_map<uint32_t, std::unordered_map<uint32_t, std::unordered_map<uint32_t, std::unordered_map<uint32_t, Component*>>>> //Scene -> Layer -> Type -> Id -> Component* The most inner map holds the Components