local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local Recipe = GLOBAL.Recipe
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH
local State = GLOBAL.State
local TimeEvent = GLOBAL.TimeEvent
local EventHandler = GLOBAL.EventHandler
local FRAMES = GLOBAL.FRAMES
local Action = GLOBAL.Action
local ActionHandler = GLOBAL.ActionHandler
local EQUIPSLOTS = GLOBAL.EQUIPSLOTS
local TheInput = GLOBAL.TheInput
local IsPaused = GLOBAL.IsPaused
local Vector3 = GLOBAL.Vector3
local ACTIONS = GLOBAL.ACTIONS
local GetPlayer = GLOBAL.GetPlayer
local GetString = GLOBAL.GetString
local Prefabs = GLOBAL.Prefabs
local package =GLOBAL.package
local kleifileexists =GLOBAL.kleifileexists
local select = GLOBAL.select
local RECIPE_GAME_TYPE = GLOBAL.RECIPE_GAME_TYPE

function exists(filepath)
	local filepath = string.gsub(filepath, "^/", "")
	local searchpaths = package.path
    for path in string.gmatch(searchpaths, "([^;]+)") do
        local filename = string.gsub(path, "scripts\\%?%.lua", filepath)
        filename = string.gsub(filename, "\\", "/")
		if not kleifileexists or kleifileexists(filename) then
            return true
        end
    end
	if not kleifileexists or kleifileexists(filepath) then
		return true
	end
	return false
end

function Recipe2(...)
	local b = select(1, ...)
	if b and exists('images/inventoryimages/'..b..'.xml') then
		return Recipe(...)
	elseif b and string.find(b, '_') and exists('images/inventoryimages/'..string.sub(b,0,string.find(b, '_')-1)..'.xml') 
	and b~='saricatsword_cat'
	then
		return Recipe(...)
	else
		return {}
	end
end


function sariPostInit()

	if GLOBAL.IsDLCEnabled(GLOBAL.REIGN_OF_GIANTS) then
			----地毯1
			local turf_saria1 = Recipe2( "turf_saria1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_saria1.atlas = "images/inventoryimages/turf_saria1.xml"
			----地毯2
			local turf_sarib1 = Recipe2( "turf_sarib1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarib1.atlas = "images/inventoryimages/turf_sarib1.xml"
			----地毯3
			local turf_saric1 = Recipe2( "turf_saric1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_saric1.atlas = "images/inventoryimages/turf_saric1.xml"
			----地毯4
			local turf_sarid1 = Recipe2( "turf_sarid1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarid1.atlas = "images/inventoryimages/turf_sarid1.xml"
			----地毯5
			local turf_sarie1 = Recipe2( "turf_sarie1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarie1.atlas = "images/inventoryimages/turf_sarie1.xml"
			----地毯6
			local turf_sarif1 = Recipe2( "turf_sarif1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarif1.atlas = "images/inventoryimages/turf_sarif1.xml"
			----地毯7
			local turf_sarig1 = Recipe2( "turf_sarig1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarig1.atlas = "images/inventoryimages/turf_sarig1.xml"
			----地毯8
			local turf_sarih1 = Recipe2( "turf_sarih1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarih1.atlas = "images/inventoryimages/turf_sarih1.xml"
			----地毯9
			local turf_sarii1 = Recipe2( "turf_sarii1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarii1.atlas = "images/inventoryimages/turf_sarii1.xml"
			----猫尾巴
			local coontail = Recipe2( "coontail", { Ingredient("rope", 1), Ingredient("petals", 1) }, RECIPETABS.SARITAB, {SCIENCE = 0}, nil, nil, nil, 1 )
			----中空树屋
			local catcoonden = Recipe2("catcoonden",
				    {
				            Ingredient("coontail", 2), 
				            Ingredient("log", 4), 
				    },
				    RECIPETABS.SARITAB, {SCIENCE = 1}, "catcoonden_placer" , 2)
			        catcoonden.atlas = "images/inventoryimages/catcoonden.xml"
			        catcoonden.image = "catcoonden.tex"
			----鸟笼
			local saribirdcage = Recipe2("saribirdcage",
				    {
				            Ingredient("coontail", 2), 
				            Ingredient("charcoal", 6), 
				            Ingredient("papyrus", 2),
				    },
				    RECIPETABS.SARITAB, {SCIENCE = 1}, "saribirdcage_placer" , 2.5)
			        saribirdcage.atlas = "images/inventoryimages/saribirdcage.xml"
			        saribirdcage.image = "saribirdcage.tex" 
			----粉色箱子
			local saritreasurechest = Recipe2("saritreasurechest",
				    {
				            Ingredient("boards", 3), 
				            Ingredient("petals", 1), 
				    },
				    RECIPETABS.SARITAB, {SCIENCE = 1}, "saritreasurechest_placer", 1)
			        saritreasurechest.atlas = "images/inventoryimages/saritreasurechest.xml"
			        saritreasurechest.image = "saritreasurechest.tex" 
			----粉色帽子
			local sarihattop = Recipe2("sarihattop", 
				     {
				            Ingredient("coontail", 2), 
				            Ingredient("spidergland", 3), 
				            Ingredient("silk", 3)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        sarihattop.atlas = "images/inventoryimages/sarihattop.xml"
			----猫包
			local saribackpack = Recipe2("saribackpack",
			         {
			                Ingredient("coontail", 8), 
			                Ingredient("livinglog",8), 
			                Ingredient("purplegem", 2)}, 
			        RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        saribackpack.atlas = "images/inventoryimages/saribackpack.xml"         
			----猫长剑       
			local saricatsword_cat = Recipe2("saricatsword_cat", 
				     {
				            Ingredient("coontail", 9), 
				            Ingredient("nitre", 9), 
				            Ingredient("transistor", 9)},
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        saricatsword_cat.atlas = "images/inventoryimages/saricatsword_cat.xml"  
			----小花伞
			local sariftumbrella = Recipe2("sariftumbrella", 
				     {
				            Ingredient("twigs", 2), 
				            Ingredient("silk", 4), 
				            Ingredient("coontail", 2)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        sariftumbrella.atlas = "images/inventoryimages/sariftumbrella.xml"        
			----巨锤
			local saricth = Recipe2("saricth", 
				     {
				            Ingredient("hammer", 1),
				            Ingredient("goldnugget", 1), 
				            Ingredient("cutstone", 2)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
					saricth.atlas = "images/inventoryimages/saricth.xml"
			---------------------------------------------------------------------------------------
			elseif not GLOBAL.SaveGameIndex:IsModeShipwrecked() then----包含海难的巨人国
			----地毯1
			local turf_saria1 = Recipe2( "turf_saria1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_saria1.atlas = "images/inventoryimages/turf_saria1.xml"
			----地毯2
			local turf_sarib1 = Recipe2( "turf_sarib1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarib1.atlas = "images/inventoryimages/turf_sarib1.xml"
			----地毯3
			local turf_saric1 = Recipe2( "turf_saric1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_saric1.atlas = "images/inventoryimages/turf_saric1.xml"
			----地毯4
			local turf_sarid1 = Recipe2( "turf_sarid1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarid1.atlas = "images/inventoryimages/turf_sarid1.xml"
			----地毯5
			local turf_sarie1 = Recipe2( "turf_sarie1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarie1.atlas = "images/inventoryimages/turf_sarie1.xml"
			----地毯6
			local turf_sarif1 = Recipe2( "turf_sarif1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarif1.atlas = "images/inventoryimages/turf_sarif1.xml"
			----地毯7
			local turf_sarig1 = Recipe2( "turf_sarig1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarig1.atlas = "images/inventoryimages/turf_sarig1.xml"
			----地毯8
			local turf_sarih1 = Recipe2( "turf_sarih1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarih1.atlas = "images/inventoryimages/turf_sarih1.xml"
			----地毯9
			local turf_sarii1 = Recipe2( "turf_sarii1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarii1.atlas = "images/inventoryimages/turf_sarii1.xml"
			----猫尾巴
			local coontail = Recipe2( "coontail", { Ingredient("rope", 1), Ingredient("petals", 1) }, RECIPETABS.SARITAB, {SCIENCE = 0}, nil, nil, nil, 1 )
			----中空树屋
			local catcoonden = Recipe2("catcoonden",
					{
							Ingredient("coontail", 2), 
							Ingredient("log", 4), 
					},  
					RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE,RECIPE_GAME_TYPE.COMMON, "catcoonden_placer" , 2)
					catcoonden.atlas = "images/inventoryimages/catcoonden.xml"
					catcoonden.image = "catcoonden.tex"
			----鸟笼
			local saribirdcage = Recipe2("saribirdcage",
					{
							Ingredient("coontail", 2), 
							Ingredient("charcoal", 6), 
							Ingredient("papyrus", 2),
					},  
					RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE,RECIPE_GAME_TYPE.COMMON, "saribirdcage_placer" , 2.5)
					saribirdcage.atlas = "images/inventoryimages/saribirdcage.xml"
					saribirdcage.image = "saribirdcage.tex" 
			----粉色箱子
			local saritreasurechest = Recipe2("saritreasurechest",
					 {
							Ingredient("boards", 3), 
							Ingredient("petals", 1), 
					},
					RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE,RECIPE_GAME_TYPE.COMMON, "saritreasurechest_placer", 1)
					saritreasurechest.atlas = "images/inventoryimages/saritreasurechest.xml"
					saritreasurechest.image = "saritreasurechest.tex" 
			----粉色帽子
			local sarihattop = Recipe2("sarihattop", 
				     {
				            Ingredient("coontail", 2), 
				            Ingredient("spidergland", 3), 
				            Ingredient("silk", 3)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        sarihattop.atlas = "images/inventoryimages/sarihattop.xml"
			----猫包
			local saribackpack = Recipe2("saribackpack",
			         {
			                Ingredient("coontail", 8), 
			                Ingredient("livinglog",8), 
			                Ingredient("purplegem", 2)}, 
			        RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        saribackpack.atlas = "images/inventoryimages/saribackpack.xml"        
			----猫长剑       
			local saricatsword_cat = Recipe2("saricatsword_cat", 
				     {
				            Ingredient("coontail", 9), 
				            Ingredient("nitre", 9), 
				            Ingredient("transistor", 9)},
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        saricatsword_cat.atlas = "images/inventoryimages/saricatsword_cat.xml" 
			----小花伞
			local sariftumbrella = Recipe2("sariftumbrella", 
				     {
				            Ingredient("twigs", 2), 
				            Ingredient("silk", 4), 
				            Ingredient("coontail", 2)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        sariftumbrella.atlas = "images/inventoryimages/sariftumbrella.xml"        
			----巨锤
			local saricth = Recipe2("saricth", 
				     {
				            Ingredient("hammer", 1),
				            Ingredient("goldnugget", 1), 
				            Ingredient("cutstone", 2)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
					saricth.atlas = "images/inventoryimages/saricth.xml"
			---------------------------------------------------------------------------------------
			elseif GLOBAL.SaveGameIndex:IsModeShipwrecked() then----海难
			----地毯1
			local turf_saria1 = Recipe2( "turf_saria1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_saria1.atlas = "images/inventoryimages/turf_saria1.xml"
			----地毯2
			local turf_sarib1 = Recipe2( "turf_sarib1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarib1.atlas = "images/inventoryimages/turf_sarib1.xml"
			----地毯3
			local turf_saric1 = Recipe2( "turf_saric1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_saric1.atlas = "images/inventoryimages/turf_saric1.xml"
			----地毯4
			local turf_sarid1 = Recipe2( "turf_sarid1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarid1.atlas = "images/inventoryimages/turf_sarid1.xml"
			----地毯5
			local turf_sarie1 = Recipe2( "turf_sarie1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarie1.atlas = "images/inventoryimages/turf_sarie1.xml"
			----地毯6
			local turf_sarif1 = Recipe2( "turf_sarif1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarif1.atlas = "images/inventoryimages/turf_sarif1.xml"
			----地毯7
			local turf_sarig1 = Recipe2( "turf_sarig1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarig1.atlas = "images/inventoryimages/turf_sarig1.xml"
			----地毯8
			local turf_sarih1 = Recipe2( "turf_sarih1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarih1.atlas = "images/inventoryimages/turf_sarih1.xml"
			----地毯9
			local turf_sarii1 = Recipe2( "turf_sarii1", {crystal2, Ingredient("beefalowool", 2), Ingredient("goldnugget", 1) }, RECIPETABS.SARITAB, {SCIENCE = 2}, nil, nil, nil, 1 )
			turf_sarii1.atlas = "images/inventoryimages/turf_sarii1.xml"
			----猫尾巴
			local coontail = Recipe2( "coontail", { Ingredient("rope", 1), Ingredient("petals", 1) }, RECIPETABS.SARITAB, {SCIENCE = 0}, nil, nil, nil, 1 )
			----中空树屋
			local catcoonden = Recipe2("catcoonden",
					{
							Ingredient("coontail", 2), 
							Ingredient("log", 4), 
					},  
					RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE,RECIPE_GAME_TYPE.COMMON, "catcoonden_placer" , 2)
					catcoonden.atlas = "images/inventoryimages/catcoonden.xml"
					catcoonden.image = "catcoonden.tex"
			----鸟笼
			local saribirdcage = Recipe2("saribirdcage",
					{
							Ingredient("coontail", 2), 
							Ingredient("charcoal", 6), 
							Ingredient("papyrus", 2),
					},  
					RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE,RECIPE_GAME_TYPE.COMMON, "saribirdcage_placer" , 2.5)
					saribirdcage.atlas = "images/inventoryimages/saribirdcage.xml"
					saribirdcage.image = "saribirdcage.tex" 
			----粉色箱子
			local saritreasurechest = Recipe2("saritreasurechest",
					 {
							Ingredient("boards", 3), 
							Ingredient("petals", 1), 
					},
					RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE,RECIPE_GAME_TYPE.COMMON, "saritreasurechest_placer", 1)
					saritreasurechest.atlas = "images/inventoryimages/saritreasurechest.xml"
					saritreasurechest.image = "saritreasurechest.tex" 
			----粉色帽子
			local sarihattop = Recipe2("sarihattop", 
				     {
				            Ingredient("coontail", 2), 
				            Ingredient("fabric", 1), 
				            Ingredient("silk", 3)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        sarihattop.atlas = "images/inventoryimages/sarihattop.xml"
			----猫包
			local saribackpack = Recipe2("saribackpack",
			         {
			                Ingredient("coontail", 8), 
			                Ingredient("fabric",6), 
			                Ingredient("purplegem", 2)}, 
			        RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        saribackpack.atlas = "images/inventoryimages/saribackpack.xml"  
			----猫长剑       
			local saricatsword_cat = Recipe2("saricatsword_cat", 
				     {
				            Ingredient("coontail", 9), 
				            Ingredient("boneshard", 9), 
				            Ingredient("limestone", 9)},
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        saricatsword_cat.atlas = "images/inventoryimages/saricatsword_cat.xml" 
			----小花伞
			local sariftumbrella = Recipe2("sariftumbrella", 
				     {
				            Ingredient("twigs", 2), 
				            Ingredient("fabric", 2), 
				            Ingredient("coontail", 2)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
			        sariftumbrella.atlas = "images/inventoryimages/sariftumbrella.xml"        
			----巨锤
			local saricth = Recipe2("saricth", 
				     {
				            Ingredient("hammer", 1),
				            Ingredient("goldnugget", 1), 
				            Ingredient("cutstone", 2)}, 
				    RECIPETABS.SARITAB, GLOBAL.TECH.SCIENCE_ONE)
					saricth.atlas = "images/inventoryimages/saricth.xml"
	end    
end 