public void AddComponent(int entityId, Type type) { if (HasComponent(entityId, type)) { return; } _entityComponentPairs.Add(HashPair(entityId, type)); var storage = GetStorage(type); storage.StoreComponentForEntity(entityId); OnEntityComponentAdded?.Invoke(this, new EntityComponentEventArgs(entityId, type)); }
// TODO: I don't like the way I made the methods InvokeComponentAdded, InvokeComponentRemoved... /// <summary> /// Invokes the <see cref="OnEntityComponentAdded" /> event. Used internally because you can't invoke an event from other classes. /// </summary> /// <param name="entity"></param> internal void InvokeComponentAdded(Entity entity) { OnEntityComponentAdded?.Invoke(this, entity); }