Beispiel #1
0
        internal static void Start()
        {
            var t = Resources.Load <TextAsset>("SettingsFramework");

            if (t != null)
            {
                JsonUtility.FromJsonOverwrite(t.text, settings);
            }


            lengthTotal = settings.SizeEntities;
            generations = new int[settings.SizeEntities, settings.SizeGenerations];
            transforms  = new Transform[settings.SizeEntities];

            components = (BufferComponents *)UnmanagedMemory.Alloc(sizeBufferComponents * settings.SizeEntities);
            tags       = (BufferTags *)UnmanagedMemory.Alloc(sizeBufferTags * settings.SizeEntities);
            cache      = (Utils *)UnmanagedMemory.Alloc(sizeUtils * settings.SizeEntities);

            for (int i = 0; i < settings.SizeEntities; i++)
            {
                tags[i]       = new BufferTags();
                cache[i]      = new Utils();
                components[i] = new BufferComponents(6);
            }

                        #if UNITY_EDITOR
            Toolbox.OnDestroyAction += Dispose;
                        #endif
        }
Beispiel #2
0
        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++;
        }