local filter = GLOBAL.terrain.filter
local GROUND = GLOBAL.GROUND
local cacao_rarity = (GetModConfigData("cacao_rarity"))
local multiplier = cacao_rarity
--GLOBAL.terrain.rooms.Forest.contents.distributeprefabs.cacao_tree = 0.25

local function PreInitVeryRare(room)
	if not room.contents.distributeprefabs then
		room.contents.distributeprefabs = {}
	end
	room.contents.distributeprefabs.cacao_tree = 0.0004 * multiplier
	--room.contents.distributepercent = 0.004 * multiplier

	filter.cacao_tree = {GROUND.ROAD, GROUND.WOODFLOOR, GROUND.CARPET, GROUND.CHECKER}
end

local function PreInitRare(room)
	if not room.contents.distributeprefabs then
		room.contents.distributeprefabs = {}
	end
	room.contents.distributeprefabs.cacao_tree = 0.005 * multiplier
	--room.contents.distributepercent = 0.05 * multiplier

	filter.cacao_tree = {GROUND.ROAD, GROUND.WOODFLOOR, GROUND.CARPET, GROUND.CHECKER}
end

local function PreInitFew(room)
	if not room.contents.distributeprefabs then
		room.contents.distributeprefabs = {}
	end
	room.contents.distributeprefabs.cacao_tree = 0.05 * multiplier
	--room.contents.distributepercent = 0.5 * multiplier

	filter.cacao_tree = {GROUND.ROAD, GROUND.WOODFLOOR, GROUND.CARPET, GROUND.CHECKER}
end

local function PreInitNormal(room)
	if not room.contents.distributeprefabs then
		room.contents.distributeprefabs = {}
	end
	room.contents.distributeprefabs.cacao_tree = 0.5 * multiplier
	--room.contents.distributepercent = 1 * multiplier

	filter.cacao_tree = {GROUND.ROAD, GROUND.WOODFLOOR, GROUND.CARPET, GROUND.CHECKER}
end

local function PreInitDouble(room)
	if not room.contents.distributeprefabs then
		room.contents.distributeprefabs = {}
	end
	room.contents.distributeprefabs.cacao_tree = 1 * multiplier
	--room.contents.distributepercent = 2 * multiplier

	filter.cacao_tree = {GROUND.ROAD, GROUND.WOODFLOOR, GROUND.CARPET, GROUND.CHECKER}
end

	--As golden rocks (rock2)
AddRoomPreInit("BGGrass",PreInitFew)
AddRoomPreInit("BGSavanna",PreInitFew)
AddRoomPreInit("Plain",PreInitRare)
AddRoomPreInit("BarePlain",PreInitFew)
AddRoomPreInit("Deerclopsfield", PreInitVeryRare)
AddRoomPreInit("Moundfield", PreInitRare)


AddRoomPreInit("ChessForest", PreInitFew)
AddRoomPreInit("ChessBarrens", PreInitFew)

AddRoomPreInit("BGDirt", PreInitNormal)

AddRoomPreInit("BGCrappyForest", PreInitFew)
AddRoomPreInit("Forest", PreInitDouble)
AddRoomPreInit("DeepForest", PreInitDouble)
AddRoomPreInit("BGForest", PreInitNormal)
AddRoomPreInit("BGDeepForest", PreInitNormal)

AddRoomPreInit("BGGrassBurnt", PreInitFew)

AddRoomPreInit("BGNoise", PreInitNormal)

AddRoomPreInit("BatCave",PreInitDouble)
AddRoomPreInit("BGBatCave",PreInitDouble)
AddRoomPreInit("Wormhole_Plains", PreInitRare)
AddRoomPreInit("NoisyCave", PreInitNormal)
AddRoomPreInit("CaveRoom", PreInitDouble)
AddRoomPreInit("RockLobsterPlains", PreInitFew)
AddRoomPreInit("NoisyCave", PreInitFew)
--coffee
GLOBAL.require("map/terrain")
if GLOBAL.terrain.rooms.BGBadlands then
	GLOBAL.terrain.rooms.BGBadlands.contents.distributeprefabs.coffeebush = 0.35
end
if GLOBAL.terrain.rooms.Lightning then
	GLOBAL.terrain.rooms.Lightning.contents.distributeprefabs.coffeebush = 0.2
end
if GLOBAL.terrain.rooms.Badlands then
	GLOBAL.terrain.rooms.Badlands.contents.distributeprefabs.coffeebush = 0.4
end
if GLOBAL.terrain.rooms.HoundyBadlands then
	GLOBAL.terrain.rooms.HoundyBadlands.contents.distributeprefabs.coffeebush = 0.2
end
if GLOBAL.terrain.rooms.BuzzardyBadlands then
	GLOBAL.terrain.rooms.BuzzardyBadlands.contents.distributeprefabs.coffeebush = 0.2
end

GLOBAL.terrain.filter.coffeebush = {GLOBAL.GROUND.ROAD, GLOBAL.GROUND.WOODFLOOR, GLOBAL.GROUND.CARPET, GLOBAL.GROUND.CHECKER}
