sschmid / Entitas

Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
MIT License
7.08k stars 1.11k forks source link

Should you always favor reactivity over initialization? #969

Closed olaf-svenson closed 2 years ago

olaf-svenson commented 3 years ago

Hi, I want to create a very simple minesweeper game to get started. Currently I'm thinking about creating the board, placing the mines and calculating the mine counter for each field.

When starting the game there are components holding information about

Each field has the PrimaryEntityIndex attribute to make sure a field index is unique. What I don't know yet is if I should do it with initialize systems only or make use of reactivity. I thought about four different approaches with increasing complexity but also flexibility.


Approach 1


Approach 2


Approach 3


Approach 4


Besides your own opinions, are there any technical reasons to favor one over another approach?

I think I will try sticking to approach 4 since its the most flexible one but maybe I should avoid this approach because ... ? ... :)

WeslomPo commented 3 years ago

If I understand 3 and 4 approach - are impossible. You can't wait before all field is inited, because they are all initialized at that time.

You don't need reactive systems here, because there are no activity at all, you don't need make generating algorithm more complex than it should be.

Use one reactive, or one initialize system, or simple method (depends on how you provide settings for field) - that create field and place all mines and do not try break that on ECS, because that not how should you use that.

I trying say that ECS has different task, this is how use hammer instead of spoon.

WeslomPo commented 3 years ago

Just generate field in simple plain method. But instead of generating CellClassObject - you will create entity, that have id, position, isOpen, isMine, isExploded, isFlagged, neighbourMinesAmount components, and on that entities you will create systems that will react.