34
votes
Accepted
Improving an O(N^2) function (all entities iterating over all other entities)
I know you do not conceptualize this as collisions, however what you are doing is colliding a circle centered at the creature, with all food.
You really do not want to check food that you know is ...
16
votes
Improving an O(N^2) function (all entities iterating over all other entities)
You should adopt a space partitioning algorithm like BVH to reduce complexity. To be specific to your case, you need to make a tree that consists of axis-aligned bounding boxes that contain food ...
8
votes
Accepted
Unity Hybrid ECS with "old way"
It is perfectly possible to mix both styles. The same GameObject can have some of its functionality implemented with the new ECS system and other functionality in classic MonoBehaviour events.
What ...
7
votes
Should components in Entity Component System pattern have logic?
I was considering voting to close this question as opinion-based, but I think there are a couple of misunderstandings about Entity-Component Systems and Data-Oriented Design here that are worth ...
5
votes
Accepted
Should entities auto-register to systems based on their component signature?
TL;DR Entities SHOULD NOT auto-register to systems based on component signatures; prefer instead to explicitly declare component sets/nodes to register your entities to systems that operate on ...
5
votes
Accepted
How to implement n-body in an Entity Component System
One nice thing about systems in an ECS architecture is that they don't all necessarily need to follow the same structure of ...
5
votes
Accepted
How does ECS handle systems which need to know more about the environment of the entities it processes?
My solution to this would be to create a component AITarget which marks an entity as something zombies are supposed to attack (like a player or a civilian).
Now ...
4
votes
Accepted
ECS component dependencies / sharing and cache locality
Reducing cache misses doesn't need to mean getting rid of them entirely, so we do need to be wary of "making the perfect the enemy of the good enough"
After all, the absolute worst performance your ...
4
votes
Accepted
How "smart objects" are implemented and actually work?
Well, concerning "The Sims" article you are reffering to that actually could mean a lot of different things. But the core idea as I get it is that each object can expose a list of "...
3
votes
Accepted
Is there a "Least Terrible Method" for sharing Entities over Network?
Preface: I'm not familiar with Box2D, but these structures can be found in Boost Geometry (R-trees) if you are really interested, as well as other libraries:
Premature Optimization (Don't Do it)
...
3
votes
Accepted
Make the components of an ECS polymorphic
Both your possible solutions are unnecessarily complicated or brittle: generally, ill-advised.
Polymorphism
Your question title is
Make the components of an ECS polymorphic
but then you don't ...
3
votes
Accepted
Where is 'game logic' implemented in component based design?
Not everything in your game must be based on the ECS pattern you're using and the game logic might be a good candidate not to.
It could be a global script.
Or, as you mention, you can implement the ...
3
votes
Integrating Unity physics with Entitas
I literally just started looking at Entitas last night so there may be better solutions, but you could do something like the following:
Create a component to store the collisions
...
3
votes
Accepted
Implementation details of Command Pattern in conjunction with Entity Component System
How do I populate the execute command if there isn't any logic that
"belongs" to an entity?
But there is a mechanism for applying logic to an entity: Systems. In ECS, Systems map behavior to ...
3
votes
ECS in MMOs - How to handle IDs for different object types?
I would generally not put entity IDs and type IDs into the same number-space. That just leads to confusion about whether a specific ID refers to an entity type or an unique instance of that type.
...
3
votes
Improving an O(N^2) function (all entities iterating over all other entities)
While the space partition methods described indeed can reduce the time your main problem is not just the lookup. Its the sheer volume of lookups you make that makes your task slow. So your optimizing ...
3
votes
User-friendly scripting when using an ECS?
ECS has its pros and cons. User-friendly scripting is not one of its pros.
The problem ECS solves is the ability to have a large number of similar things in your game at the same time while ...
3
votes
User-friendly scripting when using an ECS?
You could create a system ScriptExecutionSystem which operates on all entities with a Script component. It obtains all components of the entity which could be useful to expose to the scripting system ...
3
votes
Accepted
Should fields in components in an ECS use polymorphism?
feels like I'm violating the ECS rule
There is no ECS police that will come and put you in ECS Jail. This is your architecture, you set it up how it fits your needs.
having any functionality in ...
3
votes
Cannot decide between using a MessageBus and entities for events in my ECS game
My approach was to have a PhysicsSystem which works on entities that have a ColliderComponent/PhysicsComponent/TransformComponent...
3
votes
How to Implement ECS Archetypes in C#?
Here is a sketch of how you can implement an archetype in C#:
...
2
votes
How to handle Entity Initialisation and Destruction
This is one of the common problems with ECS architecture: Intersystem communication.
There is no silver bullet solution, and research is ongoing, but common solutions are:
Observer patterns. Any ...
2
votes
Entity Component System: system and components relation
My point is: if the Systems are the ones responsible for the actual
game logic update (practically speaking, the game logic code is
written inside the system), is there a 1:1 relation between ...
2
votes
Accepted
How does Ashley keep systems up-to-date with its entities?
There is no way this array can be mutated.
Wrong. If you look at the source code of ImmutableArray you can see that one of the constructors takes an ...
2
votes
Accepted
ECS - should everything be a system?
Yes, all game objects should be entities with an appropriate component set, and each component should have a system that controls it.
The whole idea of ECS architecture is compartmentalisation of ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
entity-system × 401component-based × 129
architecture × 104
c++ × 79
entity-component × 79
c# × 33
libgdx × 26
java × 22
entity-component-system × 21
design-patterns × 20
entity × 18
xna × 12
javascript × 12
lua × 12
unity × 11
ai × 11
scripting × 11
collision-detection × 10
optimization × 9
state × 9
game-design × 8
events × 8
rendering × 7
software-engineering × 7
oop × 7