示例#1
0
 public static void AddTransition <G1, G2, G3, G4>()  where G1 : GroupTag <G1>
     where G2 : GroupTag <G2>
     where G3 : GroupTag <G3>
     where G4 : GroupTag <G4>
 {
     GroupCompound <G1, G2, G4, G3> .Init();
 }
        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);

                                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);

                                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
                            }
                        }
                    }
                }
            }
        }
示例#5
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;
            }
        }
示例#6
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);
            }
        }
示例#7
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);
            }
        }