--/////////////////////////////////////////////////////////////////////////////////////////////////
--  (c) Galyana's Ultimate Empire at War Modifications
--  
--     ******    ***        *** ************           ***         ***
--    *      *    *          *   *         *            *           *
--   *        *   *          *   *                      *           *
--  *         *   *          *   *                      *           *
--  *             *          *   *    *         **** *  *           *
--  *             *          *   ******        *    *   *           *
--  *      ****   *          *   *    *       *     *   *    ***    *
--  *         *   *          *   *           *      *   *     *     *
--   *        *    *        *    *           *      *    *    *    *
--    *      *      *      *     *         *  *    **     *   *   *
--     ******        ******     ************   **** **     *******
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- C O N F I D E N T I A L   S O U R C E   C O D E -- D O   N O T   D I S T R I B U T E
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
--            File: GUEaW/Data/Scripts/AI/LandMode/AI_Plan_ExpansionGeneric_BuildBunker.LUA
--
-- Original Editor: Giovanni Galyana
--
--   Final Edit By: Giovanni Galyana
--
--            Date: 6 May, 2018
--
--       Revisions: 2
--
--/////////////////////////////////////////////////////////////////////////////////////////////////

require("pgevents")

-- Build a bunker
-- Disabling: | FCU_UC_Empire_Bunker | FCU_UC_Rebel_Bunker | FCU_UC_Underworld_Bunker | FCU_UC_Hutts_Bunker | FCU_UC_Empire_Bunker_Pad | FCU_UC_Rebel_Bunker_Pad | FCU_UC_Underworld_Bunker_Pad | FCU_UC_Hutts_Bunker_Pad

function Definitions()
	
	Category = "Build_Bunker"
	TaskForce = {
	{
		"MainForce"
		,"TaskForceRequired"
		,"UC_Empire_Bunker_Pad | UC_Rebel_Bunker_Pad | UC_Underworld_Bunker_Pad | UC_Hutts_Bunker_Pad | UC_Pirates_Bunker_Pad = 1"
	}
	}

end

function MainForce_Thread()

	-- Make sure we've ended up with a build location that's reasonably close to our original target
	pad_table = MainForce.Get_Reserved_Build_Pads()
	for i,pad in pad_table do
		if pad.Get_Distance(AITarget) > 120 then
			ScriptExit()
		end
	end

	-- Build the task force
	-- Blocking shouldn't be necessary, but we'll use it to ease watching the script
	MainForce.Set_Plan_Result(true)
	BlockOnCommand(MainForce.Build_All())
	ScriptExit()
end