コード例 #1
0
ファイル: Entity.cs プロジェクト: bmjoy/ecs
        internal static void Initialize(int id, byte age, bool pooled = false)
        {
            if (id >= lengthTotal)
            {
                var l = id << 1;
                HelperArray.ResizeInt(ref generations, l, settings.SizeGenerations);
                Array.Resize(ref transforms, l);

                components = (BufferComponents *)UnmanagedMemory.ReAlloc(components, sizeBufferComponents * l);
                tags       = (BufferTags *)UnmanagedMemory.ReAlloc(tags, sizeBufferTags * l);
                cache      = (Utils *)UnmanagedMemory.ReAlloc(cache, sizeUtils * l);

                for (int i = lengthTotal; i < l; i++)
                {
                    tags[i]       = new BufferTags();
                    cache[i]      = new Utils();
                    components[i] = new BufferComponents(5);
                }

                lengthTotal = l;
            }

            components[id].amount = 0;

            var ptrCache = &cache[id];

            ptrCache->id       = id;
            ptrCache->age      = age;
            ptrCache->isAlive  = true;
            ptrCache->isPooled = pooled;

            Count++;
        }
コード例 #2
0
ファイル: DictionaryGroup.cs プロジェクト: bmjoy/ecs
 internal int TryGetValue(int tagID)
 {
     return(len == 0 ? -1 : HelperArray.BinarySearch(ref tagsID, tagID, 0, len));
 }