public void readFromNbt(NbtCompound tag) { byte[] array = tag.getByteArray("fog"); for (int i = 0; i < Mathf.Min(this.fogMap.Length, array.Length); i++) { this.fogMap[i] = array[i] == 1; } }
public void readFromNbt(NbtCompound tag) { // Read Plot costs: int[] costArray = tag.getIntArray("costs"); for (int i = 0; i < Mathf.Min(this.plots.Length, costArray.Length); i++) { this.plots[i].cost = costArray[i]; } // Read Plot isOwned state: byte[] isOwnedArray = tag.getByteArray("isOwned"); for (int i = 0; i < Mathf.Min(this.plots.Length, isOwnedArray.Length); i++) { this.plots[i].isOwned = isOwnedArray[i] == 1; } }
public void readFromNbt(NbtCompound tag) { this.aboveGroundMap = tag.getByteArray("aboveGroundMap"); this.workerSpawnPoint = tag.getPosition("workerSpawnPoint"); // Read Layers: NbtList layers = tag.getList("layers"); for (int i = 0; i < layers.Count; i++) { Layer layer = new Layer(this.world, i); NbtCompound layerCompound = layers.Get <NbtCompound>(i); layer.readFromNbt(layerCompound); this.layers[layer.depth] = layer; // Call onCreate method for all the behaviors, now that all Cell's // have been loaded. for (int x = 0; x < this.world.mapSize; x++) { for (int y = 0; y < this.world.mapSize; y++) { CellState state = layer.getCellState(x, y); if (state.behavior != null) { state.behavior.onCreate(this.world, state, new Position(x, y, layer.depth)); } } } // After onCreate is called for all of the behaviors, let them read their // state from NBT. NbtList listBehaviorTags = layerCompound.getList("meta"); foreach (NbtCompound behaviorTag in listBehaviorTags) { CellBehavior meta = layer.getCellState(behaviorTag.getInt("xPos"), behaviorTag.getInt("yPos")).behavior; if (meta != null && meta is IHasData) { ((IHasData)meta).readFromNbt(behaviorTag); } } } }