/// <summary>
        /// Adds an <see cref="IComponent"/> instance of type T to the specified <see cref="Entity"/>.
        /// </summary>
        /// <typeparam name="T">Type of the <see cref="IComponent"/> being added.</typeparam>
        /// <param name="entity">The <see cref="Entity"/> instance to which the component will be added.</param>
        /// <param name="component">The <see cref="IComponent"/> instance to be added.</param>
        public void AddComponent <T>(Entity entity, T component) where T : IComponent
        {
            ComponentType type   = ComponentTypeManager.GetTypeFor <T>();
            int           typeId = type.Id;

            if (!_componentsByType.ContainsKey(typeId))
            {
                _componentsByType.Add(typeId, new Dictionary <int, IComponent>());
            }

            int entityId = entity.Id;

            if (!_componentsByType[typeId].ContainsKey(entityId))
            {
                _componentsByType[typeId].Add(entityId, component);
                entity.AddTypeBit(type.Bit);

                OnComponentAdded(entity, component);
            }
        }
        /// <summary>
        /// Removes an <see cref="IComponent"/> instance of type T from the specified <see cref="Entity"/>.
        /// </summary>
        /// <typeparam name="T">Type of <see cref="IComponent"/> to be removed.</typeparam>
        /// <param name="entity">The <see cref="Entity"/> instance from which the component will be removed.</param>
        /// <param name="component">The <see cref="ComponentType"/> instance describing the type of component to removed.</param>
        public void RemoveComponent <T>(Entity entity, T component) where T : IComponent
        {
            ComponentType type = ComponentTypeManager.GetTypeFor <T>();

            RemoveComponent(entity, type);
        }