--***********************************************************
--**                    ROBERT JOHNSON                     **
--***********************************************************

ISRainCollectorMenu = {};

-- context is our context menu
-- world objects are the list of objects where you clicked
-- player is the id of the played who asked for the context
ISRainCollectorMenu.doRainCollectorMenu = function(player, context, worldobjects)
	local barrel = nil;
--~ 	ISContextMenu:printtest(context);
	-- we fetch all the item we clicked on to see if there's a barrel
	for i,v in ipairs(worldobjects) do
		square = v:getSquare();
		if instanceof(v, "IsoThumpable") and v:getModData()["isBarrel"] == "true" then
			barrel = v;
		end
    end
	-- do we have a water container with some water in it ?
--~ 	local waterCont = ISWorldObjectContextMenu.haveWaterContainer(player);
	-- if we got a barrel, we can empty it, or fill it
--~ 	if barrel and waterCont then
--~ 		context:addOption("Pour " .. waterCont:getName() .. " into barrel", worldobjects, ISRainCollectorMenu.onPourIntoBarrel, player, waterCont);
--~ 	end
	-- construct the barrel :
	-- we check if the player have enough experience in carpentry (min lvl 2 needed)
	-- then, he need 4 planks and 4 nails
	-- first we get the number of wood item we got, i did a function in ISBuildMenu to check the material in the inventory and on the ground
--	haveSomethingtoBuildWood(player);
--	if getSpecificPlayer(player):getPerkLevel(Perks.Woodwork) >= 2 and ISBuildMenu.planks >= 4 and ISBuildMenu.nails >= 4 or ISBuildMenu.cheat then
		-- now we can add our option to the context menu
		-- parameters : name in the context menu, world objects (sometimes needed for more test), function to call, and other parameters you want to give (if you clicked on a bed, you can give the bed, etc..) up to 4 objects
--~ 		context:addOption("Create a Barrel", worldobjects, ISRainCollectorMenu.onCreateBarrel, player);
--	end
end

-- create a new barrel to drag a ghost render of the barrel under the mouse
ISRainCollectorMenu.onCreateBarrel = function(worldobjects, player)
	local barrel = RainCollectorBarrel:new(player);
	-- we now set his the mod data the needed material
	-- by doing this, all will be automatically consummed, drop on the ground if destoryed etc.
	barrel.modData["need:Base.Plank"] = "4";
	barrel.modData["need:Base.Nails"] = "4";
	-- and now allow the item to be dragged by mouse
	getCell():setDrag(barrel);
end


--~ Events.OnFillWorldObjectContextMenu.Add(ISRainCollectorMenu.doRainCollectorMenu);
