Example #1
0
/**
 * Verify that all voxels of this track piece are within world boundaries.
 * @return The positioned track piece is entirely within the world boundaries.
 * @pre Positioned track piece must have a piece.
 */
bool PositionedTrackPiece::IsOnWorld() const
{
	assert(this->piece != nullptr);
	if (!IsVoxelInsideWorld(this->base_voxel)) return false;
	if (!IsVoxelInsideWorld(this->GetEndXYZ())) return false;
	XYZPoint16 base = this->base_voxel;
	return std::all_of(this->piece->track_voxels.begin(), this->piece->track_voxels.end(),
	                   [base](TrackVoxel * tv){ return IsVoxelInsideWorld(base + tv->dxyz); });
}
Example #2
0
/**
 * Compute the voxel to display the arrow cursor.
 * @return Computed position of the voxel that should contain the arrow cursor.
 */
XYZPoint16 PathBuildManager::ComputeArrowCursorPosition()
{
	assert(this->state > PBS_WAIT_ARROW && this->state <= PBS_WAIT_BUY);
	assert(this->selected_arrow != INVALID_EDGE);

	Point16 dxy = _tile_dxy[this->selected_arrow];
	XYZPoint16 arr_pos = this->pos + XYZPoint16(dxy.x, dxy.y, 0);

	uint8 bit = 1 << this->selected_arrow;
	if ((bit & this->allowed_arrows) == 0) { // Build direction is not at the bottom of the voxel.
		assert(((bit << 4) &  this->allowed_arrows) != 0); // Should be available at the top of the voxel.
		arr_pos.z++;
	}

	/* Do some paranoia checking. */
	assert(IsVoxelInsideWorld(arr_pos));
	return arr_pos;
}