Hot answers tagged

13 votes

Cache misses and usability in Entity Systems

First, I wouldn't say that in this case you are optimising too early, depending on your use case. In any case though, you've asked an interesting question and as I have experience with this myself, I'...
user avatar
  • 701
11 votes
Accepted

Updating a multithreaded Entity-Component-System

The simple version: don't. One could argue that you have perhaps a slight misunderstandings about how to build an ECS (why would you sent a list of Entity* to a system to update? the System is ...
user avatar
5 votes

Cache misses and usability in Entity Systems

To answer just this: My question is, since I am not iterating linearly one contiguous array at a time in these cases, am I immediately sacrificing the performance gains from allocating ...
user avatar
  • 821
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 ...
user avatar
4 votes

Intersystem communication in a ECS game

Basically speaking, your systems should not need to talk to each other. There may be cases where systems implicitly interact, but this interaction should not be explicit. If you need to have systems ...
user avatar
  • 2,826
3 votes
Accepted

Where should I put the SDL_Renderer* using the ECS with SDL2 and C++?

If you only have a single SDL_Renderer, it should be managed outside of the ECS code and just passed to the rendering system when you call it to render the visual data for each entity. In this way it'...
user avatar
  • 161
3 votes

entity component - get object from entity system without knowing it's ID

I think the Observer Pattern may fit here. Instead of sending a message to your button, let your button observe some component.
user avatar
3 votes

Should entities store other other entities that they spawned?

I almost voted that this is too opinion-based, but on thinking on it further, I think it's safe to say with some sureness that the second option presented is just bad. Don't do that. Among other ...
user avatar
3 votes

How to progress an entity-component gamestate in a turn-based game?

It's a year old question but now I'm facing the same trubles with my home made game while studying ECS, thus some necromany. Hopefully it will end up in a discussion or at least few comments. I`m not ...
user avatar
3 votes

Should entities auto-register to systems based on their component signature?

I think you may be overthinking this. The point of ECS is to be simple: An entity is nothing more than an aggregate of components. A system is only interested in a subset of those components. For ...
user avatar
  • 2,545
2 votes
Accepted

How to progress an entity-component gamestate in a turn-based game?

Posting the solution I finally settled on, similar to Yakovlev's. Basically, I ended up using an event system since I found it very intuitive to follow its logic over turns. The system ended up ...
user avatar
  • 111
2 votes

Cache misses and usability in Entity Systems

Short Answer: Profile then optimize. Long Answer: But, when I am to iterate component arrays to do something with them from a system on an actual gameplay implementation, I notice that I ...
user avatar
  • 12.5k
2 votes

How to send components in an ECS System?

Serialization can be implemented in any number of ways, but I would strongly suggest that you find ways to decouple entity/component semantics from network serialization as it will make it easier as ...
user avatar
  • 1,987
2 votes

Entity System and "composite" entities

You are possibly conflating two separate things. I'll explain them below, but first I'll strongly note that you should spend some time playing around with existing game engines and get a sense for how ...
user avatar
2 votes
Accepted

How to propagate component updates? (Changing components at runtime)

Whenever a Entity is added to a Entity Controller (EC), this EC registers to ComponentAdded and ComponentRemoved events from the Entity. When a Component is added or removed from an Entity, fire the ...
user avatar
  • 457
2 votes
Accepted

How can I make an entity invulnerable to fall damage?

Your onEntityFall method is not registered to the event bus. Notice where your yourPlayerHarvestEvent method is and how its ...
user avatar
1 vote

entity component - get object from entity system without knowing it's ID

The game layer probably shouldn't know about the HUD layer. The HUD layer should maybe listen to events from the game layer. Your example is a bit vague, so let's say there is a button above each ...
user avatar
  • 111
1 vote
Accepted

The most correct/efficient way to update millions of entities that change over time in an mmo?

Both scenarios are useful, there are object that will require to be implemented in the second scenario. Yet, I suggest to use the first one as much as possible. Scenario 1 Using scenario 1 falls ...
user avatar
  • 18k
1 vote

Creating Multiple Render System to Draw Different Entities in Entity-Component-System

What you should ask yourself is what is the actual difference between the two types? An animated entity typically has both some form of a skeleton of bones which are animated through various ...
user avatar
  • 1,987
1 vote

How to convert and handle (controlling) OOP game objects via ECS?

Both dispatcher and calling systems directly from systems breaks the architecture. A system should never be called directly to update, if anything, only call methods to set some flag or data to be ...
user avatar
  • 166
1 vote

How to convert and handle (controlling) OOP game objects via ECS?

I'm not too familiar with Ashley's ECS system. The reason they are using the dispatcher is to share information across multiple objects. This is usually to reduce coupling in classes, which makes ...
user avatar
1 vote
Accepted

Handling data logic on libgdx ai state machine or in ashley system?

Unless there's a specific reason you'd need (want) to process the data in a State you should probably stick to Ashley's own ...
user avatar
  • 7,599
1 vote
Accepted

Data model design using Core Data and Spritekit

I can see you going about this two ways without changing too much of your core data model. Kind of a lazy way to do it if you know that there will be no more than 3 bonuses per item. bonus_1_type (...
user avatar
1 vote

Data model design using Core Data and Spritekit

That is a fine way to do it. Alternatives would be A field on the item specifying which attribute the bonus applies to, with a modifier ie [{"fire_rate", 5}, {"health", 10}] Each item could have a ...
user avatar
  • 3,775
1 vote

How do I efficiently deal with entities moving between chunks?

If you need to store entities in chunks it's probably better to actually store them in the chunks rather than a separate array. ...
user avatar
  • 3,775
1 vote
Accepted

Undefined reference error when trying to access a component using ECS

Your template definition needs to be in the header file. More specifically: ...
user avatar
  • 860
1 vote

Undefined reference error when trying to access a component using ECS

Move the definition of Entity::GetComponent to the header, Entity.h. In general, template definitions must be put into header files. See this related question: https://stackoverflow.com/questions/...
user avatar
  • 880

Only top scored, non community-wiki answers of a minimum length are eligible