Пример #1
0
        /// <summary>
        /// Groups the specified component types.
        /// </summary>
        /// <param name="componentTypes">The component types.</param>
        /// <returns></returns>
        public EntityGroup Group(Type[] componentTypes)
        {
            if (_groups.TryGetValue(EntityGroup.GetHashCode(componentTypes), out EntityGroup entityGroup))
            {
                return(entityGroup);
            }

            entityGroup = new EntityGroup(componentTypes);
            foreach (Entity entity in _entities.Values)
            {
                entityGroup.TryAdd(entity);
            }

            _groups.Add(EntityGroup.GetHashCode(componentTypes), entityGroup);

            return(entityGroup);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalEntityManager"/> class.
 /// </summary>
 public LocalEntityManager()
 {
     All = new EntityGroup();
     _groups.Add(All.GetHashCode(), All);
 }