sschmid / Entitas

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

Group.UpdateEntity #1001

Closed Ecstasyzzz closed 2 years ago

Ecstasyzzz commented 2 years ago

Hi,

I don't know why UpdateEntity function trigger all the three callback。what if just trigger OnEntityUpdated,Will this lead to other problems?

Here's some code

        /// This is used by the context to manage the group.
        public void UpdateEntity(TEntity entity, int index, IComponent previousComponent, IComponent newComponent) {
            if (_entities.Contains(entity)) {
                if (OnEntityRemoved != null) {
                    OnEntityRemoved(this, entity, index, previousComponent);
                }
                if (OnEntityAdded != null) {
                    OnEntityAdded(this, entity, index, newComponent);
                }
                if (OnEntityUpdated != null) {
                    OnEntityUpdated(
                        this, entity, index, previousComponent, newComponent
                    );
                }
            }
        }

Cheers

sschmid commented 2 years ago

Hi @Ecstasyzzz Yes, all of them are needed to let collectors and indexes know that sth changed.