public bool Set(int x, int y, int z, IBiomeData value) { lock (this) { if (_allocSize == 0) { this.Create(0xFF); } var index = HashInt(x, y, z) & _allocSize; var entry = _data[index]; while (entry != null) { var pos = entry.position; if (pos.x == x && pos.y == y && pos.z == z) { _data[index].value = value; return(true); } index = (index + 1) & _allocSize; entry = _data[index]; } if (value != null) { _data[index] = new BiomeDataNode <Vector3 <int>, IBiomeData>(new Vector3 <int>(x, y, z), value); _count++; if (_count >= _allocSize) { this.Grow(); } return(true); } return(false); } }
private bool Grow(BiomeDataNode <Vector3 <int>, IBiomeData> data) { var pos = data.position; var index = HashInt(pos.x, pos.y, pos.z) & _allocSize; var entry = _data[index]; while (entry != null) { index = (index + 1) & _allocSize; entry = _data[index]; } if (data.value != null) { _data[index] = data; _count++; return(true); } return(false); }