public Vector3Int getRandomPosition(Vector3Int center, int xRange, int zRange) { IntBounds3 bounds = new IntBounds3(center, xRange, xRange, zRange); normalizeBounds(bounds); List <Vector3Int> positions = new List <Vector3Int>(); bounds.iterate((x, y, z) => { int blockType = map.blockType.get(x, y, z); if (blockType != BlockTypeEnum.SPACE.CODE && blockType != BlockTypeEnum.WALL.CODE && blockType != BlockTypeEnum.FARM.CODE) // passable position { positions.Add(new Vector3Int(x, y, z)); } }); return(positions[Random.Range(0, positions.Count - 1)]); }
private void _handleSelection(IntBounds3 bounds) { if (currentTool == NONE) { return; // TODO add unit/building/item/plant/block selection for NONE tool } bounds.iterate((x, y, z) => { if (currentTool.designation != null) // tool applies designation { if (currentTool.designation.VALIDATOR.validate(x, y, z)) { GameModel.get().designationContainer.createDesignation(new Vector3Int(x, y, z), currentTool.designation); } } else if (currentTool == CLEAR) { GameModel.get().designationContainer.cancelDesignation(new Vector3Int(x, y, z)); } }); }