Example #1
0
        static GroupTag()
        {
            if (Interlocked.CompareExchange(ref isInitializing, 1, 0) == 0)
            {
                var group = new ExclusiveGroup();
                _Groups.Add(group);

#if DEBUG
                var typeInfo = typeof(T);
                var name     = $"Compound: {typeInfo.Name} ID {(uint) group.id}";

                var typeInfoBaseType = typeInfo.BaseType;
                if (typeInfoBaseType.GenericTypeArguments[0] != typeInfo) //todo: this should shield from using a pattern different than public class GROUP_NAME : GroupTag<GROUP_NAME> {} however I am not sure it's working
                {
                    throw new ECSException("Invalid Group Tag declared");
                }

                GroupNamesMap.idToName[group] = name;
#endif
                //The hashname is independent from the actual group ID. this is fundamental because it is want
                //guarantees the hash to be the same across different machines
                GroupHashMap.RegisterGroup(group, typeof(GroupTag <T>).FullName);

                _GroupsHashSet = new HashSet <ExclusiveGroupStruct>(_Groups.ToArrayFast(out _));
            }
        }
Example #2
0
        static GroupTag()
        {
            if (Interlocked.CompareExchange(ref isInitializing, 1, 0) == 0)
            {
                var group = new ExclusiveGroup();
                _Groups.Add(group);


                var typeInfo = typeof(T);

                var name = $"Compound: {typeInfo.Name} ID {(uint) @group}";
#if DEBUG
                var typeInfoBaseType = typeInfo.BaseType;
                if (typeInfoBaseType.GenericTypeArguments[0] != typeInfo)
                {
                    throw new ECSException("Invalid Group Tag declared");
                }

                GroupNamesMap.idToName[(uint)group] = name;
#endif
                GroupHashMap.RegisterGroup(group, name);

                _GroupsHashSet = new HashSet <ExclusiveGroupStruct>(_Groups.ToArrayFast(out _));
            }
        }
        public Consumer <T> GenerateConsumer(ExclusiveGroup @group, string name, int capacity)
        {
            var consumer = new Consumer <T>(group, name, capacity, this);

            _consumers.Add(consumer);

            return(consumer);
        }
Example #4
0
        internal Consumer <T> GenerateConsumer(ExclusiveGroup group, string name, uint capacity)
        {
            var consumer = new Consumer <T>(group, name, capacity);

            _consumers.Add(consumer);

            return(consumer);
        }
Example #5
0
        public bool TryDequeue(ExclusiveGroup group, out T entity)
        {
            if (_ringBuffer.TryDequeue(out entity) == true)
            {
                return(entity.ID.groupID == @group);
            }

            return(false);
        }
        public Consumer <T> GenerateConsumer <T>(ExclusiveGroup @group, string name, int capacity) where T : unmanaged, IEntityStruct
        {
            if (_streams.ContainsKey(typeof(T)) == false)
            {
                _streams[typeof(T)] = new EntityStream <T>();
            }

            return((_streams[typeof(T)] as EntityStream <T>).GenerateConsumer(@group, name, capacity));
        }
Example #7
0
        public Consumer <T> GenerateConsumer <T>(ExclusiveGroup group, string name, uint capacity)
            where T : unmanaged, IEntityStruct
        {
            if (_streams.ContainsKey(TypeRefWrapper <T> .wrapper) == false)
            {
                _streams[TypeRefWrapper <T> .wrapper] = new EntityStream <T>();
            }

            return((_streams[TypeRefWrapper <T> .wrapper] as EntityStream <T>).GenerateConsumer(group, name, capacity));
        }
Example #8
0
        static GroupTag()
        {
            var group = new ExclusiveGroup();

            _Groups.Add(group);

#if DEBUG
            GroupMap.idToName[(uint)group] = $"Compound: {typeof(T).Name} ID {(uint)group}";
#endif
        }
Example #9
0
        static GroupTag()
        {
            var group = new ExclusiveGroup();

            _Groups.Add(group);
            _GroupsHashSet = new HashSet <ExclusiveGroupStruct>(_Groups.ToArrayFast(out _));

#if DEBUG
            GroupMap.idToName[(uint)group] = $"Compound: {typeof(T).Name} ID {(uint) group}";
#endif
        }
Example #10
0
        public Consumer <T> GenerateConsumer <T>(ExclusiveGroup group, string name, uint capacity)
            where T : unmanaged, IEntityComponent
        {
            if (_streams.ContainsKey(TypeRefWrapper <T> .wrapper) == false)
            {
                _streams[TypeRefWrapper <T> .wrapper] = new EntityStream <T>();
            }

            EntityStream <T> typeSafeStream = (EntityStream <T>)_streams[TypeRefWrapper <T> .wrapper];

            return(typeSafeStream.GenerateConsumer(group, name, capacity));
        }
Example #11
0
        public static void Add(ExclusiveGroup @group)
        {
            var       type       = typeof(GroupCompound <T>);
            var       fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Static);
            FieldInfo field      = fieldInfos[0];

            var _array = (ExclusiveGroup[])field.GetValue(null);

            Array.Resize(ref _array, _array.Length + 1);

            _array[_array.Length - 1] = group;

            field.SetValue(null, _array);
        }
        //Each time a new combination of group tags is found a new group is added.
        internal static void Add(ExclusiveGroup @group)
        {
            for (int i = 0; i < Groups.count; ++i)
            {
                if (Groups[i] == group)
                {
                    throw new Exception("temporary must be transformed in unit test");
                }
            }

            Groups.Add(group);

            Console.LogDebug(typeof(T).ToString().FastConcat("- Add ", group.ToString()));
        }
Example #13
0
        /// <summary>
        /// this can be better, I probably would need to get the group regardless if it supports EGID or not
        /// </summary>
        /// <param name="group"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool TryDequeue(ExclusiveGroup group, out T entity)
        {
            if (_ringBuffer.TryDequeue(out entity, _name) == true)
            {
                if (EntityBuilder <T> .HAS_EGID)
                {
                    return((entity as INeedEGID).ID.groupID == @group);
                }

                return(true);
            }

            return(false);
        }
        //Each time a new combination of group tags is found a new group is added.
        internal static void Add(ExclusiveGroup @group)
        {
            for (int i = 0; i < _Groups.count; ++i)
            {
                if (_Groups[i] == group)
                {
                    throw new Exception("temporary must be transformed in unit test");
                }
            }

            _Groups.Add(group);
#if DEBUG
            GroupMap.idToName[(uint)group] = $"Compound: {typeof(T).Name}";
#endif
        }
        static GroupCompound()
        {
            if ((Groups = GroupCompound <G3, G1, G2> .Groups) == null)
            {
                if ((Groups = GroupCompound <G2, G3, G1> .Groups) == null)
                {
                    if ((Groups = GroupCompound <G3, G2, G1> .Groups) == null)
                    {
                        if ((Groups = GroupCompound <G1, G3, G2> .Groups) == null)
                        {
                            if ((Groups = GroupCompound <G2, G1, G3> .Groups) == null)
                            {
                                Groups = new FasterList <ExclusiveGroupStruct>(1);

                                var Group = new ExclusiveGroup();
                                Groups.Add(Group);

                                Console.LogDebug("<color=orange>".FastConcat(typeof(G1).ToString().FastConcat("-", typeof(G2).ToString(), "-").FastConcat(typeof(G3).ToString(), "- Initialized ", Groups[0].ToString()), "</color>"));

                                GroupCompound <G1, G2> .Add(Group); //<G1/G2> and <G2/G1> must share the same array

                                GroupCompound <G1, G3> .Add(Group);

                                GroupCompound <G2, G3> .Add(Group);

                                GroupTag <G1> .Add(Group);

                                GroupTag <G2> .Add(Group);

                                GroupTag <G3> .Add(Group);
                            }
                            else
                            {
                                Console.LogDebug(typeof(G1).ToString().FastConcat("-", typeof(G2).ToString(), "-").FastConcat(typeof(G3).ToString(), "-", Groups[0].ToString()));
                            }
                        }
                    }
                }
            }
        }
        static GroupCompound()
        {
            if ((_Groups = GroupCompound <G3, G1, G2> ._Groups) == null)
            {
                if ((_Groups = GroupCompound <G2, G3, G1> ._Groups) == null)
                {
                    if ((_Groups = GroupCompound <G3, G2, G1> ._Groups) == null)
                    {
                        if ((_Groups = GroupCompound <G1, G3, G2> ._Groups) == null)
                        {
                            if ((_Groups = GroupCompound <G2, G1, G3> ._Groups) == null)
                            {
                                _Groups = new FasterList <ExclusiveGroupStruct>(1);

                                var Group = new ExclusiveGroup();
                                _Groups.Add(Group);

                                GroupCompound <G1, G2> .Add(Group); //<G1/G2> and <G2/G1> must share the same array

                                GroupCompound <G1, G3> .Add(Group);

                                GroupCompound <G2, G3> .Add(Group);

                                //This is done here to be sure that the group is added once per group tag
                                //(if done inside the previous group compound it would be added multiple times)
                                GroupTag <G1> .Add(Group);

                                GroupTag <G2> .Add(Group);

                                GroupTag <G3> .Add(Group);

#if DEBUG
                                GroupMap.idToName[(uint)Group] = $"Compound: {typeof(G1).Name}-{typeof(G2).Name}-{typeof(G3).Name}";
#endif
                            }
                        }
                    }
                }
            }
        }
        static GroupCompound()
        {
            if ((_Groups = GroupCompound <G3, G1, G2> ._Groups) == null)
            {
                if ((_Groups = GroupCompound <G2, G3, G1> ._Groups) == null)
                {
                    if ((_Groups = GroupCompound <G3, G2, G1> ._Groups) == null)
                    {
                        if ((_Groups = GroupCompound <G1, G3, G2> ._Groups) == null)
                        {
                            if ((_Groups = GroupCompound <G2, G1, G3> ._Groups) == null)
                            {
                                _Groups = new FasterList <ExclusiveGroupStruct>(1);

                                var Group = new ExclusiveGroup();
                                _Groups.Add(Group);

                                GroupCompound <G1, G2> .Add(Group); //<G1/G2> and <G2/G1> must share the same array

                                GroupCompound <G1, G3> .Add(Group);

                                GroupCompound <G2, G3> .Add(Group);

                                GroupTag <G1> .Add(Group);

                                GroupTag <G2> .Add(Group);

                                GroupTag <G3> .Add(Group);

#if DEBUG
                                GroupMap.idToName[(uint)Group] = $"Compound: {typeof(G1).Name}-{typeof(G2).Name}-{typeof(G3).Name}";
#endif
                            }
                        }
                    }
                }
            }
        }
Example #18
0
        static GroupCompound()
        {
            //avoid race conditions if compounds are using on multiple thread
            if (Interlocked.CompareExchange(ref isInitializing, 1, 0) == 0 &&
                GroupCompoundInitializer.skipStaticCompoundConstructorsWith4Tags.Value == false)
            {
                _Groups = new FasterList <ExclusiveGroupStruct>(1);

                var group = new ExclusiveGroup();
                _Groups.Add(group);

                var name =
                    $"Compound: {typeof(G1).Name}-{typeof(G2).Name}-{typeof(G3).Name}-{typeof(G4).Name} ID {(uint) group}";
#if DEBUG
                GroupNamesMap.idToName[(uint)group] = name;
#endif
                GroupHashMap.RegisterGroup(group, name);

                _GroupsHashSet = new HashSet <ExclusiveGroupStruct>(_Groups.ToArrayFast(out _));

                GroupCompoundInitializer.skipStaticCompoundConstructorsWith4Tags.Value = true;

                //all the permutations must share the same group and group hashset. Warm them up, avoid call the
                //constructors again, set the desired value
                GroupCompound <G1, G2, G4, G3> ._Groups = _Groups;
                GroupCompound <G1, G3, G2, G4> ._Groups = _Groups;
                GroupCompound <G1, G3, G4, G2> ._Groups = _Groups;
                GroupCompound <G1, G4, G2, G3> ._Groups = _Groups;
                GroupCompound <G2, G1, G3, G4> ._Groups = _Groups;
                GroupCompound <G2, G3, G4, G1> ._Groups = _Groups;
                GroupCompound <G3, G1, G2, G4> ._Groups = _Groups;
                GroupCompound <G4, G1, G2, G3> ._Groups = _Groups;
                GroupCompound <G1, G4, G3, G2> ._Groups = _Groups;
                GroupCompound <G2, G1, G4, G3> ._Groups = _Groups;
                GroupCompound <G2, G4, G3, G1> ._Groups = _Groups;
                GroupCompound <G3, G1, G4, G2> ._Groups = _Groups;
                GroupCompound <G4, G1, G3, G2> ._Groups = _Groups;
                GroupCompound <G2, G3, G1, G4> ._Groups = _Groups;
                GroupCompound <G3, G4, G1, G2> ._Groups = _Groups;
                GroupCompound <G2, G4, G1, G3> ._Groups = _Groups;
                GroupCompound <G3, G2, G1, G4> ._Groups = _Groups;
                GroupCompound <G3, G2, G4, G1> ._Groups = _Groups;
                GroupCompound <G3, G4, G2, G1> ._Groups = _Groups;
                GroupCompound <G4, G2, G1, G3> ._Groups = _Groups;
                GroupCompound <G4, G2, G3, G1> ._Groups = _Groups;
                GroupCompound <G4, G3, G1, G2> ._Groups = _Groups;
                GroupCompound <G4, G3, G2, G1> ._Groups = _Groups;

                //all the permutations are warmed up now
                GroupCompoundInitializer.skipStaticCompoundConstructorsWith4Tags.Value = false;

                GroupCompound <G1, G2, G4, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G3, G2, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G3, G4, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G4, G2, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G1, G3, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G3, G4, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G1, G2, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G1, G2, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G4, G3, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G1, G4, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G4, G3, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G1, G4, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G1, G3, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G3, G1, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G4, G1, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G4, G1, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G2, G1, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G2, G4, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G4, G2, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G2, G1, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G2, G3, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G3, G1, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G3, G2, G1> ._GroupsHashSet = _GroupsHashSet;

                GroupCompound <G1, G2, G3> .Add(group);

                GroupCompound <G1, G2, G4> .Add(group);

                GroupCompound <G1, G3, G4> .Add(group);

                GroupCompound <G2, G3, G4> .Add(group);

                GroupCompound <G1, G2> .Add(group); //<G1/G2> and <G2/G1> must share the same array

                GroupCompound <G1, G3> .Add(group);

                GroupCompound <G1, G4> .Add(group);

                GroupCompound <G2, G3> .Add(group);

                GroupCompound <G2, G4> .Add(group);

                GroupCompound <G3, G4> .Add(group);

                //This is done here to be sure that the group is added once per group tag
                //(if done inside the previous group compound it would be added multiple times)
                GroupTag <G1> .Add(group);

                GroupTag <G2> .Add(group);

                GroupTag <G3> .Add(group);

                GroupTag <G4> .Add(group);
            }
        }
Example #19
0
        static GroupCompound()
        {
            if (GroupCompoundInitializer.isInitializing4.Value == false)
            {
                _Groups = new FasterList <ExclusiveGroupStruct>(1);

                var Group = new ExclusiveGroup();
                _Groups.Add(Group);
                _GroupsHashSet = new HashSet <ExclusiveGroupStruct>(_Groups.ToArrayFast(out _));

                GroupCompound <G1, G2, G3> .Add(Group);

                GroupCompound <G1, G2, G4> .Add(Group);

                GroupCompound <G1, G3, G4> .Add(Group);

                GroupCompound <G2, G3, G4> .Add(Group);

                GroupCompound <G1, G2> .Add(Group); //<G1/G2> and <G2/G1> must share the same array

                GroupCompound <G1, G3> .Add(Group);

                GroupCompound <G1, G4> .Add(Group);

                GroupCompound <G2, G3> .Add(Group);

                GroupCompound <G2, G4> .Add(Group);

                GroupCompound <G3, G4> .Add(Group);

                //This is done here to be sure that the group is added once per group tag
                //(if done inside the previous group compound it would be added multiple times)
                GroupTag <G1> .Add(Group);

                GroupTag <G2> .Add(Group);

                GroupTag <G3> .Add(Group);

                GroupTag <G4> .Add(Group);

#if DEBUG
                GroupMap.idToName[(uint)Group] =
                    $"Compound: {typeof(G1).Name}-{typeof(G2).Name}-{typeof(G3).Name}-{typeof(G4).Name} ID {(uint) Group}";
#endif
                GroupCompoundInitializer.isInitializing4.Value = true;

                //all the combinations must share the same group and group hashset
                GroupCompound <G1, G2, G4, G3> ._Groups = _Groups;
                GroupCompound <G1, G3, G2, G4> ._Groups = _Groups;
                GroupCompound <G1, G3, G4, G2> ._Groups = _Groups;
                GroupCompound <G1, G4, G2, G3> ._Groups = _Groups;
                GroupCompound <G2, G1, G3, G4> ._Groups = _Groups;
                GroupCompound <G2, G3, G4, G1> ._Groups = _Groups;
                GroupCompound <G3, G1, G2, G4> ._Groups = _Groups;
                GroupCompound <G4, G1, G2, G3> ._Groups = _Groups;
                GroupCompound <G1, G4, G3, G2> ._Groups = _Groups;
                GroupCompound <G2, G1, G4, G3> ._Groups = _Groups;
                GroupCompound <G2, G4, G3, G1> ._Groups = _Groups;
                GroupCompound <G3, G1, G4, G2> ._Groups = _Groups;
                GroupCompound <G4, G1, G3, G2> ._Groups = _Groups;
                GroupCompound <G2, G3, G1, G4> ._Groups = _Groups;
                GroupCompound <G3, G4, G1, G2> ._Groups = _Groups;
                GroupCompound <G2, G4, G1, G3> ._Groups = _Groups;
                GroupCompound <G3, G2, G1, G4> ._Groups = _Groups;
                GroupCompound <G3, G2, G4, G1> ._Groups = _Groups;
                GroupCompound <G3, G4, G2, G1> ._Groups = _Groups;
                GroupCompound <G4, G2, G1, G3> ._Groups = _Groups;
                GroupCompound <G4, G2, G3, G1> ._Groups = _Groups;
                GroupCompound <G4, G3, G1, G2> ._Groups = _Groups;
                GroupCompound <G4, G3, G2, G1> ._Groups = _Groups;

                GroupCompound <G1, G2, G4, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G3, G2, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G3, G4, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G4, G2, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G1, G3, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G3, G4, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G1, G2, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G1, G2, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G4, G3, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G1, G4, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G4, G3, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G1, G4, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G1, G3, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G3, G1, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G4, G1, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G4, G1, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G2, G1, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G2, G4, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G4, G2, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G2, G1, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G2, G3, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G3, G1, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G3, G2, G1> ._GroupsHashSet = _GroupsHashSet;

                GroupCompoundInitializer.isInitializing4.Value = false;
            }
        }
Example #20
0
 public EGID(int entityID, ExclusiveGroup groupID) : this()
 {
     _GID = MAKE_GLOBAL_ID(entityID, (int)groupID);
 }
Example #21
0
 public EntityStructInitializer BuildEntity(int entityID, ExclusiveGroup groupID, IEntityBuilder[] entityToBuild, object[] implementors)
 {
     return(_weakEngine.Target.BuildEntity(new EGID(entityID, (int)groupID), entityToBuild, implementors));
 }
Example #22
0
 public void RemoveEntity <T>(int entityID, ExclusiveGroup groupID) where T : IEntityDescriptor, new()
 {
     _weakReference.Target.QueueEntitySubmitOperation(
         new EntitySubmitOperation(EntitySubmitOperationType.Remove, entityID, (int)groupID, -1, EntityDescriptorTemplate <T> .descriptor.entitiesToBuild));
 }
Example #23
0
 public void RemoveGroupAndEntities(ExclusiveGroup groupID)
 {
     _weakReference.Target.QueueEntitySubmitOperation(
         new EntitySubmitOperation(EntitySubmitOperationType.RemoveGroup, -1, (int)groupID, -1, null));
 }
 internal Consumer(ExclusiveGroup @group, string name, int capacity, EntityStream <T> stream) : this(name, capacity, stream)
 {
     _group    = group;
     _hasGroup = true;
 }
Example #25
0
 public void SwapEntityGroup <T>(EGID id, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new()
 {
     _weakReference.Target.QueueEntitySubmitOperation(
         new EntitySubmitOperation(EntitySubmitOperationType.Swap, id.entityID, id.groupID, (int)toGroupID, EntityDescriptorTemplate <T> .descriptor.entitiesToBuild));
 }
Example #26
0
        static GroupCompound()
        {
            //avoid race conditions if compounds are using on multiple thread
            if (Interlocked.CompareExchange(ref isInitializing, 1, 0) == 0 &&
                GroupCompoundInitializer.skipStaticCompoundConstructorsWith4Tags.Value == false)
            {
                var group = new ExclusiveGroup(); //todo: it's a bit of a waste to create a class here even if this is a static constructor

                _Groups = new FasterList <ExclusiveGroupStruct>(1);
                _Groups.Add(group);

#if DEBUG
                var name =
                    $"Compound: {typeof(G1).Name}-{typeof(G2).Name}-{typeof(G3).Name}-{typeof(G4).Name} ID {(uint) group.id}";
                GroupNamesMap.idToName[group] = name;
#endif
                //The hashname is independent from the actual group ID. this is fundamental because it is want
                //guarantees the hash to be the same across different machines
                GroupHashMap.RegisterGroup(group, typeof(GroupCompound <G1, G2, G3, G4>).FullName);

                _GroupsHashSet = new HashSet <ExclusiveGroupStruct>(_Groups.ToArrayFast(out _));

                GroupCompoundInitializer.skipStaticCompoundConstructorsWith4Tags.Value = true;

                //all the permutations must share the same group and group hashset. Warm them up, avoid call the
                //constructors again, set the desired value
                GroupCompound <G1, G2, G4, G3> ._Groups = _Groups;
                GroupCompound <G1, G3, G2, G4> ._Groups = _Groups;
                GroupCompound <G1, G3, G4, G2> ._Groups = _Groups;
                GroupCompound <G1, G4, G2, G3> ._Groups = _Groups;
                GroupCompound <G2, G1, G3, G4> ._Groups = _Groups;
                GroupCompound <G2, G3, G4, G1> ._Groups = _Groups;
                GroupCompound <G3, G1, G2, G4> ._Groups = _Groups;
                GroupCompound <G4, G1, G2, G3> ._Groups = _Groups;
                GroupCompound <G1, G4, G3, G2> ._Groups = _Groups;
                GroupCompound <G2, G1, G4, G3> ._Groups = _Groups;
                GroupCompound <G2, G4, G3, G1> ._Groups = _Groups;
                GroupCompound <G3, G1, G4, G2> ._Groups = _Groups;
                GroupCompound <G4, G1, G3, G2> ._Groups = _Groups;
                GroupCompound <G2, G3, G1, G4> ._Groups = _Groups;
                GroupCompound <G3, G4, G1, G2> ._Groups = _Groups;
                GroupCompound <G2, G4, G1, G3> ._Groups = _Groups;
                GroupCompound <G3, G2, G1, G4> ._Groups = _Groups;
                GroupCompound <G3, G2, G4, G1> ._Groups = _Groups;
                GroupCompound <G3, G4, G2, G1> ._Groups = _Groups;
                GroupCompound <G4, G2, G1, G3> ._Groups = _Groups;
                GroupCompound <G4, G2, G3, G1> ._Groups = _Groups;
                GroupCompound <G4, G3, G1, G2> ._Groups = _Groups;
                GroupCompound <G4, G3, G2, G1> ._Groups = _Groups;

                //all the permutations are warmed up now
                GroupCompoundInitializer.skipStaticCompoundConstructorsWith4Tags.Value = false;

                GroupCompound <G1, G2, G4, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G3, G2, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G3, G4, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G4, G2, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G1, G3, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G3, G4, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G1, G2, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G1, G2, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G1, G4, G3, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G1, G4, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G4, G3, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G1, G4, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G1, G3, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G3, G1, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G4, G1, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G2, G4, G1, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G2, G1, G4> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G2, G4, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G3, G4, G2, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G2, G1, G3> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G2, G3, G1> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G3, G1, G2> ._GroupsHashSet = _GroupsHashSet;
                GroupCompound <G4, G3, G2, G1> ._GroupsHashSet = _GroupsHashSet;

                GroupCompound <G1, G2, G3> .Add(group);

                GroupCompound <G1, G2, G4> .Add(group);

                GroupCompound <G1, G3, G4> .Add(group);

                GroupCompound <G2, G3, G4> .Add(group);

                GroupCompound <G1, G2> .Add(group); //<G1/G2> and <G2/G1> must share the same array

                GroupCompound <G1, G3> .Add(group);

                GroupCompound <G1, G4> .Add(group);

                GroupCompound <G2, G3> .Add(group);

                GroupCompound <G2, G4> .Add(group);

                GroupCompound <G3, G4> .Add(group);

                //This is done here to be sure that the group is added once per group tag
                //(if done inside the previous group compound it would be added multiple times)
                GroupTag <G1> .Add(group);

                GroupTag <G2> .Add(group);

                GroupTag <G3> .Add(group);

                GroupTag <G4> .Add(group);
            }
        }
 public void PreallocateEntitySpace<T>(ExclusiveGroup groupID, int size) where T : IEntityDescriptor, new()
 {
     _weakEngine.Target.Preallocate<T>((int)groupID, size);
 }
 public EntityStructInitializer BuildEntity(int entityID, ExclusiveGroup groupID, IEntityDescriptor descriptorEntity, object[] implementors)
 {
     return _weakEngine.Target.BuildEntity(new EGID(entityID, (int)groupID), descriptorEntity, implementors);
 }
 public EntityStructInitializer BuildEntity<T>(int entityID, ExclusiveGroup groupID, object[] implementors) where T : IEntityDescriptor, new()
 {
     return _weakEngine.Target.BuildEntity<T>(new EGID(entityID, (int)groupID), implementors);
 }
 public Consumer <T> GenerateConsumer <T>(ExclusiveGroup group, string name, uint capacity) where T : unmanaged, IEntityStruct
 {
     return(_enginesRoot.Target.GenerateConsumer <T>(group, name, capacity));
 }