function ImportCiv6Map(MapToConvert, g_iW, g_iH, bDoTerrains, bImportRivers, bImportFeatures, bImportResources, bImportContinents, bIgnoreCliffs)
print("Importing Civ6 Map ( Terrain = "..tostring(bDoTerrains)..", Rivers = "..tostring(bImportRivers)..", Features = "..tostring(bImportFeatures)..", Resources = "..tostring(bImportResources)..", Continents = "..tostring(bImportContinents)..")")
local count = 0
bOutput = false
for i = 0, (g_iW * g_iH) - 1, 1 do
plot = Map.GetPlotByIndex(i)
if bOutput then
print("----------")
print("Convert plot at "..plot:GetX()..","..plot:GetY())
end
-- Map Data
-- MapToConvert[x][y] = {civ6TerrainType, civ6FeatureType, civ6ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ6ResourceType, num} }
local civ6TerrainType = MapToConvert[plot:GetX()][plot:GetY()][1]
local civ6FeatureType = MapToConvert[plot:GetX()][plot:GetY()][2]
local civ6ContinentType = MapToConvert[plot:GetX()][plot:GetY()][3]
local Rivers = MapToConvert[plot:GetX()][plot:GetY()][4] -- = {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}
local resource = MapToConvert[plot:GetX()][plot:GetY()][5] -- = {Civ6ResourceType, num}
local Cliffs = MapToConvert[plot:GetX()][plot:GetY()][6] -- {IsNEOfCliff,IsWOfCliff,IsNWOfCliff}
-- Set terrain type
if bDoTerrains then
if bOutput then print(" - Set Terrain Type = "..tostring(GameInfo.Terrains[civ6TerrainType].TerrainType)) end
count = count + 1
TerrainBuilder.SetTerrainType(plot, civ6TerrainType)
end
-- Set Rivers
if bImportRivers then
if Rivers[1][1] == 1 then -- IsNEOfRiver
TerrainBuilder.SetNEOfRiver(plot, true, Rivers[1][2])
if bOutput then print(" - Set is NE of River, flow = "..tostring(Rivers[1][2])) end
end
if Rivers[2][1] == 1 then -- IsWOfRiver
TerrainBuilder.SetWOfRiver(plot, true, Rivers[2][2])
if bOutput then print(" - Set is W of River, flow = "..tostring(Rivers[2][2])) end
end
if Rivers[3][1] == 1 then -- IsNWOfRiver
TerrainBuilder.SetNWOfRiver(plot, true, Rivers[3][2])
if bOutput then print(" - Set is NW of River, flow = "..tostring(Rivers[3][2])) end
end
end
-- Set Features
if bImportFeatures then
if civ6FeatureType ~= -1 and civ6FeatureType < GameInfo.Features["FEATURE_BARRIER_REEF"].Index then -- Do not import Natural Wonder here !
if bOutput then print(" - Set Feature Type = "..tostring(GameInfo.Features[civ6FeatureType].FeatureType)) end
TerrainBuilder.SetFeatureType(plot, civ6FeatureType)
end
end
-- Set Continent
if bImportContinents then
if civ6ContinentType ~= -1 then
if bOutput then print(" - Set Continent Type = "..tostring(GameInfo.Continents[civ6ContinentType].ContinentType)) end
TerrainBuilder.SetContinentType(plot, civ6ContinentType)
end
end
-- Set Resources
if bImportResources and not plot:IsNaturalWonder() then
if resource[1] ~= -1 then
if bOutput then print(" - Set Resource Type = "..tostring(GameInfo.Resources[resource[1]].ResourceType)) end
--ResourceBuilder.SetResourceType(plot, ResourceCiv5toCiv6[resource[1]], resource[2]) -- maybe an option to import number of resources on one plot even if civ6 use 1 ?
ResourceBuilder.SetResourceType(plot, resource[1], 1)
end
end
-- Set Cliffs
if Cliffs and not bIgnoreCliffs then
if Cliffs[1] == 1 then -- IsNEOfCliff
TerrainBuilder.SetNEOfCliff(plot, true)
if bOutput then print(" - Set is NE of Cliff") end
end
if Cliffs[2] == 1 then -- IsWOfCliff
TerrainBuilder.SetWOfCliff(plot, true)
if bOutput then print(" - Set is W of Cliff") end
end
if Cliffs[3] == 1 then -- IsNWOfCliff
TerrainBuilder.SetNWOfCliff(plot, true)
if bOutput then print(" - Set is NW of Cliff") end
end
end
end
print("Placed terrain on "..tostring(count) .. " tiles")
end