Beispiel #1
0
        public void Set(int x, int y, int z, int state)
        {
            int id = BitsPerEntry <= 8 ? States.IndexOf(state) : state;

            if (id == -1)
            {
                States.Add(state);
                if (States.Count > 1 << BitsPerEntry)
                {
                    BitsPerEntry++;

                    List <int> oldStates = States.ToList();
                    if (BitsPerEntry > 8)
                    {
                        oldStates = new List <int>(States);
                        States.Clear();
                        BitsPerEntry = 13;
                    }

                    FlexibleStorage oldStorage = Storage;
                    Storage = new FlexibleStorage(BitsPerEntry, Storage.GetSize());
                    for (int index = 0; index < Storage.GetSize(); index++)
                    {
                        int value = oldStorage.Get(index);
                        Storage.Set(index, BitsPerEntry <= 8 ? value : oldStates[value]);
                    }
                }

                id = BitsPerEntry <= 8 ? States.IndexOf(state) : state;
            }

            Storage.Set(Index(x, y, z), id);
        }
Beispiel #2
0
        public BlockStorage()
        {
            BitsPerEntry = 4;
            States = new List<int> { 0 };

            Storage = new FlexibleStorage(BitsPerEntry, 4096);
        }
Beispiel #3
0
        public BlockStorage()
        {
            BitsPerEntry = 4;
            States       = new List <int> {
                0
            };

            Storage = new FlexibleStorage(BitsPerEntry, 4096);
        }
Beispiel #4
0
        public void Set(int x, int y, int z, int state)
        {
            int id = BitsPerEntry <= 8 ? States.IndexOf(state) : state;
            if (id == -1)
            {
                States.Add(state);
                if (States.Count > 1 << BitsPerEntry)
                {
                    BitsPerEntry++;

                    List<int> oldStates = States.ToList();
                    if (BitsPerEntry > 8)
                    {
                        oldStates = new List<int>(States);
                        States.Clear();
                        BitsPerEntry = 13;
                    }

                    FlexibleStorage oldStorage = Storage;
                    Storage = new FlexibleStorage(BitsPerEntry, Storage.GetSize());
                    for (int index = 0; index < Storage.GetSize(); index++)
                    {
                        int value = oldStorage.Get(index);
                        Storage.Set(index, BitsPerEntry <= 8 ? value : oldStates[value]);
                    }
                }

                id = BitsPerEntry <= 8 ? States.IndexOf(state) : state;
            }

            Storage.Set(Index(x, y, z), id);
        }