コード例 #1
0
ファイル: ProcessorGroups.cs プロジェクト: Allexeee/actors
        internal static GroupCore CreateGroup(CacheGroup cacheGroup, Type groupType, Composition composition)
        {
            var gr = (Activator.CreateInstance(groupType, true) as GroupCore).Initialize(composition);

            gr.id = cacheGroup.length;
            return(gr);
        }
コード例 #2
0
        internal void Add(int tagID, CacheGroup anotherGroupStorage)
        {
            if (len == cache.Length - 1)
            {
                var l = len << 1;
                Array.Resize(ref cache, l);
                Array.Resize(ref tagsID, l);
            }

            var pointer   = len++;
            var indexLast = pointer;
            var index     = pointer - 1;

            if (index >= 0)
            {
                if (tagID < tagsID[index])
                {
                    var startIndex = 0;
                    var endIndex   = indexLast;

                    while (endIndex > startIndex)
                    {
                        var middleIndex = (endIndex + startIndex) / 2;
                        var middleValue = tagsID[middleIndex];

                        if (middleValue == tagID)
                        {
                            pointer = middleIndex;

                            break;
                        }

                        if (middleValue < tagID)
                        {
                            startIndex = middleIndex + 1;
                            pointer    = startIndex;
                        }
                        else
                        {
                            endIndex = middleIndex;
                            pointer  = endIndex;
                        }
                    }
                }
            }

            for (int i = indexLast; i >= pointer; i--)
            {
                tagsID[i + 1] = tagsID[i];
                cache[i + 1]  = cache[i];
            }

            cache[pointer]  = anotherGroupStorage;
            tagsID[pointer] = tagID;
        }
コード例 #3
0
ファイル: CacheGroup.cs プロジェクト: Allexeee/actors
        public static bool Contain(this CacheGroup container, GroupCore groupCore)
        {
            var len = container.length;

            for (int i = 0; i < len; i++)
            {
                var groupAdded = container.Elements[i];
                if (groupAdded.Equals(groupCore))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #4
0
ファイル: CacheGroup.cs プロジェクト: Allexeee/actors
        public static bool TryGetValue(this CacheGroup container, Type t, Composition composition, out GroupCore group)
        {
            var len = container.length;

            for (int i = 0; i < len; i++)
            {
                var instance = container.Elements[i];
                if (t != instance.GetType())
                {
                    continue;
                }

                if (instance.composition.Hash.value == composition.Hash.value)
                {
                    group = instance;
                    return(true);
                }
            }

            group = default;
            return(false);
        }
コード例 #5
0
        internal bool TryGetValue(int tagID, out CacheGroup groupOld)
        {
            var id = -1;

            for (int i = 0; i < len; i++)
            {
                if (tagsID[i] == tagID)
                {
                    id = i;
                    break;
                }

                id = -1;
            }

            if (id > -1)
            {
                groupOld = cache[id];
                return(true);
            }

            groupOld = default;
            return(false);
        }
コード例 #6
0
ファイル: CacheGroup.cs プロジェクト: Allexeee/actors
 public static GroupCore Add(this CacheGroup container, GroupCore group)
 {
     ref var len     = ref container.length;
コード例 #7
0
 internal static void Add(this CacheGroup container, GroupCore group)
 {
     ref var len     = ref container.length;