示例#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);
        }
示例#2
0
        public BlockStorage()
        {
            BitsPerEntry = 4;
            States = new List<int> { 0 };

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

            Storage = new FlexibleStorage(BitsPerEntry, 4096);
        }
示例#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);
        }