Ejemplo n.º 1
0
/**
 * Build a path at a tile, and claim the voxels above it as well.
 * @param voxel_pos Coordinate of the voxel.
 * @param path_type The type of path to build.
 * @param path_spr Imploded sprite number.
 * @see RemovePathAtTile
 */
static void BuildPathAtTile(const XYZPoint16 &voxel_pos, PathType path_type, uint8 path_spr)
{
	VoxelStack *avs = _additions.GetModifyStack(voxel_pos.x, voxel_pos.y);

	Voxel *av = avs->GetCreate(voxel_pos.z, true);
	av->SetInstance(SRI_PATH);
	uint8 slope = AddRemovePathEdges(voxel_pos, path_spr, EDGE_ALL, true, _sprite_manager.GetPathStatus(path_type));
	av->SetInstanceData(MakePathInstanceData(slope, path_type));

	av = avs->GetCreate(voxel_pos.z + 1, true);
	av->ClearVoxel();
	av->SetInstance(SRI_PATH);
	av->SetInstanceData(PATH_INVALID);

	if (path_spr >= PATH_FLAT_COUNT) { // For non-flat sprites, add another voxel.
		av = avs->GetCreate(voxel_pos.z + 2, true);
		av->ClearVoxel();
		av->SetInstance(SRI_PATH);
		av->SetInstanceData(PATH_INVALID);
	}

	MarkVoxelDirty(voxel_pos);
}