public void AddEntity(Entity mEntity, bool mNeedsUpdate)
        {
            Debug.Assert(mEntity != null);
            Debug.Assert(!Entities.Contains(mEntity));

            Entities.Add(mEntity);
            if (mNeedsUpdate)
            {
                Debug.Assert(!EntitiesToUpdate.Contains(mEntity));
                EntitiesToUpdate.Add(mEntity);
            }
            EntitiesToDrawSorted.Add(mEntity);

            foreach (var group in mEntity.Groups)
            {
                Debug.Assert(!EntityDictionary[group].Contains(mEntity));
                EntityDictionary[group].Add(mEntity);
            }

            _isSortNeeded = true;
        }
        public void RemoveEntity(Entity mEntity)
        {
            Debug.Assert(mEntity != null);
            Debug.Assert(Entities.Contains(mEntity));
            Debug.Assert(EntitiesToUpdate.Contains(mEntity));
            Debug.Assert(EntitiesToDrawSorted.Contains(mEntity));

            Entities.Remove(mEntity);
            EntitiesToUpdate.Remove(mEntity);
            EntitiesToDrawSorted.Remove(mEntity);

            foreach (var group in mEntity.Groups)
            {
                Debug.Assert(EntityDictionary[group].Contains(mEntity));
                EntityDictionary[group].Remove(mEntity);
            }
        }