private ComponentMapper <T> CreateMapperForType <T>(EntityBits componentTypeId) where T : class { if (typeof(T) == typeof(Component)) { throw new Exception("Mapper using Component Base Class was created!"); } var mapper = new ComponentMapper <T>(componentTypeId, ComponentsChanged); _componentMappers[componentTypeId] = mapper; return(mapper); }
//DO NOT CHANGE IT WILL BREAK THE LOOKUP FUNCTION FOR THE ARCHETYPE SYSTEM internal T AddComponent <T>(Entity entity) where T : Component, new() { T item = new T(); ComponentMapper <T> myMap = GetMapper <T>(); myMap.Put(entity.ID, item); var entityOriginalArray = entity.myEntityManager.GetEntityEntityBits(entity); entityOriginalArray = entityOriginalArray | ComponentRegistration.GetComponentBitset(typeof(T)); ComponentAddWatcher?.Invoke(entity, entityOriginalArray); return(item); }