コード例 #1
0
ファイル: Entity.cs プロジェクト: Allexeee/actors
        internal static void Initialize(int id, bool isPooled = false, bool isNested = false)
        {
            if (id >= lengthTotal)
            {
                var l = id << 1;
                HelperArray.ResizeInt(ref Generations, l, Framework.Settings.SizeGenerations);
                // Array.Resize(ref Transforms, l);

                entities = (CacheEntity *)UnmanagedMemory.ReAlloc(entities, sizeEntityCache * l);

                for (int i = lengthTotal; i < l; i++)
                {
                    entities[i] = new CacheEntity(5);
                }

                lengthTotal = l;
            }

            entities[id].componentsAmount = 0;

            var ptrCache = &entities[id];

            // ptrCache->age      = age;
            ptrCache->isNested = isNested;
            ptrCache->isPooled = isPooled;
            // todo: need to refactor in future
            // ptrCache->isDirty  = true;
            // ptrCache->isAlive  = true;

            ent e = new ent();

            e.id = id;
            // e.age = age;
            // alive.Add(e);
        }
コード例 #2
0
        internal static void Initialize(int id, byte age, bool isPooled = false, bool isNested = false)
        {
            if (id >= lengthTotal)
            {
                var l = id << 1;
                HelperArray.ResizeInt(ref Generations, l, Framework.Settings.SizeGenerations);
                HelperArray.ResizeInt(ref GenerationsInstant, l, Framework.Settings.SizeGenerations);
                Array.Resize(ref Transforms, l);

                entities = (CacheEntity *)UnmanagedMemory.ReAlloc(entities, sizeEntityCache * l);
        #if !ACTORS_TAGS_0
                Tags = (CacheTags *)UnmanagedMemory.ReAlloc(Tags, sizeBufferTags * l);
        #endif

                for (int i = lengthTotal; i < l; i++)
                {
          #if !ACTORS_TAGS_0
                    Tags[i] = new CacheTags();
          #endif
                    entities[i] = new CacheEntity(5);
                }

                lengthTotal = l;
            }

            entities[id].componentsAmount = 0;

            var ptrCache = &entities[id];
            ptrCache->age      = age;
            ptrCache->isNested = isNested;
            ptrCache->isPooled = isPooled;
            // todo: need to refactor in future
            ptrCache->isDirty = true;
            ptrCache->isAlive = true;

            ent e;
            e.id  = id;
            e.age = age;
            alive.Add(e);
        }
コード例 #3
0
 internal int TryGetValue(int tagID)
 {
     return(len == 0 ? -1 : HelperArray.BinarySearch(ref tagsID, tagID, 0, len - 1));
 }