--——————————————————预设————————————————————
local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local Recipe = GLOBAL.Recipe
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH
local State = GLOBAL.State
local SpawnPrefab = GLOBAL.SpawnPrefab
local TimeEvent = GLOBAL.TimeEvent
local FRAMES = GLOBAL.FRAMES
local TheInput = GLOBAL.TheInput
local Vector3 = GLOBAL.Vector3
local FindEntity =GLOBAL.FindEntity
local TUNING = GLOBAL.TUNING
local GetPlayer = GLOBAL.GetPlayer
local GetWorld = GLOBAL.GetWorld
local GetClock = GLOBAL.GetClock
local ACTIONS = GLOBAL.ACTIONS
local Action = GLOBAL.Action
local GROUND = GLOBAL.GROUND
local EventHandler = GLOBAL.EventHandler
local ActionHandler = GLOBAL.ActionHandler
--植物
--local GROUND = GLOBAL.GROUND
local GetGroundTypeAtPosition = GLOBAL.GetGroundTypeAtPosition
local distsq = GLOBAL.distsq
-------
local Armor = require "components/armor"
local Health = require "components/health"
local Combat = require "components/combat"
local SGWilson=require "stategraphs/SGwilson"
local ModsScreen = require "screens/modsscreen"

require "actions"
require "bufferedaction"
local PlayerController = require "components/playercontroller"
--local SGToso=require "stategraphs/SGtoso"


local Lang = GetModConfigData("Lang")---
local LanguageFile = "STRINGS_Chinese.lua"
if Lang == 1 then
	LanguageFile = "STRINGS_English.lua"
end
modimport(LanguageFile)

PrefabFiles = {
	"toso",
	"fenji",
	"eye",
    "jiandai",
	--"bcape",
	--"redlantern",
	"san",
	"light1",
	--brain
	--"axiang",
    --"axiang_egg",
	--"qiuqiu",
	--"yiyu_apple",
	"sword_1",
	"sword_2",
	--"sword_3",
	"sword_4",
	"sword_5",
	"sword_6",
	"sword_7",
	"shouzhang",
	"toso_fx",
    "langhua",
	"chongjibo",
    "jianqiao",
	--"jianqiaoxiu",
	"jianqiao2",
    "toso_sheath",
	"futou",
	"jianzhong",
	--"liandanlu",
	--"gate",
	--"water_platform",
	"flower_1",
	--"flower_cave",
	"flower_seed",
	"flower_hua",
	--"hat_eyeshade",
	"hulu",
	--"musha_small", 
    --"musha_egg",
	--"toso_dog",
    "zhaohunfan",
	"assasin_wilson",
	--"assasin_xjj",
    --"assasin_kikyou",
    --"toso_boat",
	--"toso_xuanfeng",
	"sword_77",
	--"assasin_ganhuo",
	"shadowcane",


	"tososword_boat",

	"yiyuwaxwell_boat",
	"toso_xiang",
	"linglibuchong",

	

}


Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/toso.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/toso.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/toso.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/toso.xml" ),
	
    Asset( "IMAGE", "images/selectscreen_portraits/toso_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/toso_silho.xml" ),

    Asset( "IMAGE", "bigportraits/toso.tex" ),
    Asset( "ATLAS", "bigportraits/toso.xml" ),
	
	Asset( "IMAGE", "images/map_icons/toso.tex" ),
	Asset( "ATLAS", "images/map_icons/toso.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_toso.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_toso.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_ghost_toso.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_toso.xml" ),
	--Asset( "ATLAS", "images/hud/toso_tab.xml" ),
	--
	Asset( "IMAGE", "images/inventoryimages/yiyu_apple.tex" ),
    Asset( "ATLAS", "images/inventoryimages/yiyu_apple.xml" ),
	
		--这个是给制作栏图标用的
	Asset( "ATLAS", "images/tabs/toso_tab.xml" ),
	Asset( "IMAGE", "images/tabs/toso_tab.tex" ),
	
	--加给widgets用
	Asset("ANIM", "anim/lingli.zip"),
	Asset("ANIM", "anim/shaqi.zip"),
	--Asset("ANIM", "anim/ultimate_cd.zip"),
	--Asset("ANIM", "anim/passive_cd.zip"),
	--Asset("ANIM", "anim/normal_cd.zip"),
	
	--Asset( "IMAGE", "images/skillpoint_button.tex" ),
    --Asset( "ATLAS", "images/skillpoint_button.xml" ),
	
	
	Asset("ATLAS", "images/inventoryimages/zhaohunfan_item.xml"),
	Asset("IMAGE", "images/inventoryimages/zhaohunfan_item.tex"),
	
}
--制作
function tosoPostInit(toso)



end

--——————————————————全局数值TUNING————————————————————————————
--————————————————————为了能够方便地切换中英文，应该注意集中有关字符串的使用————————————

TUNING.TOSO_HUNGERRATE = GetModConfigData("toso_Hunger")
TUNING.TOSO_STARTHP = GetModConfigData("Initial attribute")
TUNING.TOSO_NEEDEXP = GetModConfigData("toso_expneed")
TUNING.TOSO_KEY1 = GetModConfigData("toso_R")
TUNING.TOSO_KEY2 = GetModConfigData("upchangeskiils")
TUNING.TOSO_KEY3 = GetModConfigData("downchangeskiils")
TUNING.TOSO_KEY4 = GetModConfigData("upyujian")
TUNING.TOSO_KEY5 = GetModConfigData("commandaxiang")
TUNING.TOSO_KEY6 = GetModConfigData("axiangcollect")

--阿翔
--local YAMCHO = GetModConfigData("commandyamche")
--local Collect = GetModConfigData("yamchecollect")
--local Sacrifice = GetModConfigData("Yamresurrect")

--——————————————————添加物品交易组件————————————————————————————
function Addtradableprefab(inst)
	if not inst.components.tradable then
		inst:AddComponent("tradable")
end end
AddPrefabPostInit("nightmarefuel", Addtradableprefab)
--AddPrefabPostInit("dragon_scales", Addtradableprefab)
--AddPrefabPostInit("houndstooth", Addtradableprefab)
--AddPrefabPostInit("nightmarefuel", Addtradableprefab)


--——————————————————关于小阿翔的————————————————————————————
-----------collect stuffs
-------右键命令跟随参考精灵公主凤凰--------------
--命令代码
ACTIONS.STAYORDER = GLOBAL.Action(2, true, true)
ACTIONS.STAYORDER.fn = function(act)
local targ = act.target
	if targ and targ.components.staycommand then
		act.doer.components.locomotor:Stop()
		targ.components.locomotor:Stop()
		act.doer.components.talker:Say(GLOBAL.GetString(act.doer.prefab, "ANNOUNCE_STAYORDER"))
		targ.components.combat:GiveUp()
		if targ:HasTag("yamche") then 
		targ.stay = true
		if targ.components.container then 
		targ.components.container.canbeopened = false
		end
		if targ.yamche_leader then
			act.doer.yamche_leader = false
			targ.yamche_leader = false
			targ:RemoveTag("yamche_leader")
		end
		end	
			if targ:HasTag("yamche") then
				targ.sg:GoToState("command")
	        end
		targ.components.staycommand:SetStaying(true)
		targ.components.staycommand:RememberStayPos("stayspot", GLOBAL.Point(targ.Transform:GetWorldPosition())) 
	return true
	end
end

ACTIONS.STAYORDER.str = STRINGS.ACTIONS.STAYORDER
ACTIONS.STAYORDER.id = "STAYORDER"
ACTIONS.STAYORDER_CANCEL = GLOBAL.Action(2, true, true)
ACTIONS.STAYORDER_CANCEL.fn = function(act)
	local targ = act.target
	if targ and targ.components.staycommand then
	act.doer.components.locomotor:Stop()
		targ.components.locomotor:Stop()
		
	if targ:HasTag("yamche") and GLOBAL.GetWorld():IsCave() then
	--	targ.components.talker:Say("[Cave Debuff]\nSacrifice-(OFF)")
	elseif targ:HasTag("yamche") and not GLOBAL.GetWorld():IsCave() then
	--	targ.components.talker:Say("[Sacrifice]\n(ON)")
			end
			if targ:HasTag("yamche") then
				targ.sg:GoToState("command")
				targ.stay = false
				if targ.components.container then 
				targ.components.container.canbeopened = true
				end
					targ.sg:GoToState("command") 
			end 
		act.doer.components.talker:Say(GLOBAL.GetString(act.doer.prefab, "ANNOUNCE_STAYORDER_CANCEL"))
		targ.components.staycommand:SetStaying(false)

		return true
	end
end

if Hide == "enable" then
ACTIONS.BLINK.str = STRINGS.ACTIONS.BLINK 
ACTIONS.BLINK.id = "BLINK"
ACTIONS.CASTSPELL.str = STRINGS.ACTIONS.CASTSPELL
ACTIONS.CASTSPELL.id = "CASTSPELL"

STRINGS.ACTIONS.BLINK = ""
STRINGS.ACTIONS.CASTSPELL = ""
end

ACTIONS.STAYORDER_CANCEL.str = STRINGS.ACTIONS.STAYORDER_CANCEL
ACTIONS.STAYORDER_CANCEL.id = "STAYORDER_CANCEL"

STRINGS.ACTIONS.STAYORDER = "待在这儿"
STRINGS.ACTIONS.STAYORDER_CANCEL = "跟我走"
STRINGS.CHARACTERS.GENERIC.ANNOUNCE_STAYORDER = "待在这儿."
STRINGS.CHARACTERS.GENERIC.ANNOUNCE_STAYORDER_CANCEL = "跟我走."
---命令代码结束----

yamche2 = function() 
local inst = GLOBAL.GetPlayer()
inst.components.talker.colour = GLOBAL.Vector3(0.7, 0.85, 1, 1)
local x,y,z = inst.Transform:GetWorldPosition()
local ents = TheSim:FindEntities(x,y,z, 25, {"yamche"})
for k,v in pairs(ents) do
if not v.sg:HasStateTag("open") and not v.stop_working and not v.grow_up_yamchae then
inst.components.locomotor:Stop()

if not v.sleep_on and inst.components.leader:IsFollower(v) and v.components.follower and v.components.follower.leader and not v.yamche_leader and not inst.yamche_leader then
	inst.yamche_leader = true
	v.yamche_leader = true
	v:AddTag("yamche_leader")
end
if not v.sleep_on and inst.components.leader:IsFollower(v) then
	v.yamche = true
end

if v.yamche_leader and not v:HasTag("animals") and v.components.follower and v.components.follower.leader and inst.components.leader:IsFollower(v) and not inst.working --[[and inst.components.leader:CountFollowers("yamche") == 1]] then
if v:HasTag("arongb") then
inst.components.talker:Say("Arong, Gathering stuffs.\n[Gathering]")
elseif not v:HasTag("arongb") then
inst.components.talker:Say("阿翔，收集东西")
end
inst.working = true
if v.yamche_leader and not v.components.inventory then --and not inst.DLC2 and not GLOBAL.SaveGameIndex:IsModeShipwrecked() then
	v:AddComponent("inventory") 
	v:inventoryset()
	if v.DLC2 then	v.components.inventory:IsWaterproof() end
	end

--[[if v.yamche_leader and inst.DLC2 then 
	v:RemoveComponent("inventory")
	if not v.components.inventory then
	v:AddComponent("inventory")
		end
end]]

	v.pick1 = true
	v.working_food = true
	v.drop = false

if v.yamche_leader and not v:HasTag("animals") then
if v:HasTag("arongb") then
v.components.talker:Say("[Gathering Items]")
elseif not v:HasTag("arongb") then
v.components.talker:Say("收集模式")
end
end
elseif v.yamche_leader and not v:HasTag("animals") and v.components.follower and v.components.follower.leader and inst.components.leader:IsFollower(v) and inst.working --[[and inst.components.leader:CountFollowers("yamche") == 1]] --[[and not inst.DLC2]] then
inst.components.talker:Say("Stop to Gathering\n[Stop]")
inst.working = false
v.pick1 = false
v.working_food = false
v.drop = true

if not v:HasTag("animals") and not v:HasTag("level1") and not v:HasTag("baby") then
v.components.talker:Say("关闭收集模式")
elseif not v:HasTag("animals")  and v:HasTag("level1") or v:HasTag("baby") then
if v.components.inventory then	
v.components.inventory:DropEverything(true)	
--换特效
--SpawnPrefab("dr_warm_loop_2").Transform:SetPosition(v:GetPosition():Get())
v.components.talker:Say("东西都交出来")
	v.check_inv = false
	v.item_max_full = false
	v.item_1 = false 
	if v:HasTag("arongb") then
	v.components.locomotor:StopMoving()
	v.sg:GoToState("grow_up_pop")
	end
	end
end 
if v.components.container then
--v.components.container:DropEverything(true) 	
end 	

end 
end
end 
end


GLOBAL.TheInput:AddKeyDownHandler(TUNING.TOSO_KEY6, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("toso") then
		local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
 		yamche2()
	end	end end) 

---------------
local function on_yamcheinfo()
local inst = GLOBAL.GetPlayer()
local x,y,z = inst.Transform:GetWorldPosition()
local ents = TheSim:FindEntities(x,y,z, 12, {"yamche"})
for k,v in pairs(ents) do
if inst.components.leader:IsFollower(v) and v.components.follower.leader then 
v.yamcheinfo = true
--v.yamche = true
end
end end

----active battle command yamche 
follow_yamche = function() 
	local player = GLOBAL.GetPlayer()
	player.components.talker.fontsize = 28
player.components.talker.colour = GLOBAL.Vector3(0.7, 0.85, 1, 1)
local x,y,z = player.Transform:GetWorldPosition()
local ents = TheSim:FindEntities(x,y,z, 20, {"yamcheb"})
for k,v in pairs(ents) do

if not v.sleep_on and player.components.leader:IsFollower(v) and v.components.follower and v.components.follower.leader and not v.yamche_leader and not player.yamche_leader and not v:HasTag("ghosthound") then
	player.yamche_leader = true
	v.yamche_leader = true
	v:AddTag("yamche_leader")
end
if not v.sleep_on and player.components.leader:IsFollower(v) then
	v.yamche = true
	end

-- Leader
if v.yamche_leader and not player:HasTag("berserks") and not player:HasTag("fberserk") and player.components.leader:IsFollower(v) and v.components.follower and v.components.follower.leader then

--Offensive leader
if not v.peace and not v.active_hunt and not v.defense then
 
 if player.components.leader:CountFollowers("Yamche") == 1 then
	if v:HasTag("arongb") then
	player.components.talker:Say("Arong, Lets hunt begin!")
	elseif v:HasTag("yamche") then
	player.components.talker:Say("快点，搞事情了!")
	end
	v.components.talker:Say("战斗模式")
else
	player.components.talker:Say("跟上!")
	v.components.talker:Say("战斗模式")
	end
	
v.peace = false
v.active_hunt = true
v.defense = false


--Avoid leader
elseif not v.peace and v.active_hunt and not v.defense then
 
 if player.components.leader:CountFollowers("Yamche") == 1 then
	if v:HasTag("arongb") then
	player.components.talker:Say("Arong, Be careful!")
	elseif v:HasTag("yamche") then
	player.components.talker:Say("小心!")
	end
	v.components.talker:Say("和平模式")
else
	player.components.talker:Say("停止战斗!")
	v.components.talker:Say("和平模式")
	end

v.peace = true
v.active_hunt = false
v.defense = true


--Defensive leader
elseif v.peace and not v.active_hunt and v.defense then
 
 if player.components.leader:CountFollowers("Yamche") == 1 then
	if v:HasTag("arongb") then
	player.components.talker:Say("Arong, Keep guard my side !")
	elseif v:HasTag("yamche") then
	player.components.talker:Say("阿翔，回来!")
	end
	v.components.talker:Say("战斗")
else
	player.components.talker:Say("阿翔，上!")
	v.components.talker:Say("战斗模式")
	end

v.peace = false
v.active_hunt = false
v.defense = false


--berserker Avoid
elseif (player:HasTag("berserks") or player:HasTag("fberserk")) then
player.components.talker:Say("Back off!, Krrr !")
 
v.components.talker:Say("和平模式")
v.peace = true
v.active_hunt = false
v.defense = true


-- No leader
elseif not v.yamche_leader and not player:HasTag("berserks") and not player:HasTag("fberserk") and player.components.leader:IsFollower(v) and v.components.follower and v.components.follower.leader then

if not v.active_hunt then
v.order = true
player.components.talker:Say("上!")
v.components.talker:Say("战斗模式")
v.peace = false
v.active_hunt = true
v.defense = false


elseif not v.active_hunt then
v.order = true
player.components.talker:Say("一起上!")
v.components.talker:Say("打他们")
v.peace = false
v.active_hunt = false
v.defense = false

end
end 
elseif not player.components.leader:IsFollower(v) and not v.components.follower and v.components.follower.leader and not player.components.leader:CountFollowers("Yamche") == 0 and player.components.leader:CountFollowers("ghosthound") == 0 then
player.components.talker:Say("屠苏我在这儿..")	
end
end
end


--config yamche hotkey 
GLOBAL.TheInput:AddKeyDownHandler(TUNING.TOSO_KEY5, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("toso") then
		local TheInput = GLOBAL.TheInput

	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
   
		follow_yamche()

	end
	end
end)
------------加入cast---------------
local TOSOCAST = GLOBAL.Action(10, false, true, 36)
TOSOCAST.str = "cast"
TOSOCAST.id = "TOSOCAST"
TOSOCAST.fn = function(act)
	--if GetPlayer():HasTag("huoqiang") or GetPlayer():HasTag("baofengxue") then
        --return GetPlayer().components.tosocast:areaskill(GetPlayer())
	--end
end

AddStategraphState("wilson", GLOBAL.State {
        name = "tosocast",
        tags = {"doing", "busy", "canrotate"},
        onenter = function(inst)
        end,
        timeline = 
        {
            GLOBAL.TimeEvent(0*FRAMES, function(inst) 
                if inst and inst.bufferedaction then
                    inst:PerformBufferedAction()
                end
            end),
        },
        events = {
            GLOBAL.EventHandler("animover", function(inst)
                inst.sg:GoToState("idle") 
            end ),
        },
})

------------cast。---------------

--船-------------
AddStategraphState("wilsonboating", GLOBAL.State {
	  name = "tosocast",
	  tags = {"doing", "busy", "canrotate"},
	  onenter = function(inst)
	  end,
	  timeline = 
	  {
		GLOBAL.TimeEvent(0*FRAMES, function(inst) 
		    if inst and inst.prefab=='toso' and inst.bufferedaction then
			  inst:PerformBufferedAction()
		    end
		end),
	  },
	  events = {
		GLOBAL.EventHandler("animover", function(inst)
		    inst.sg:GoToState("idle") 
		end ),
	  },
})

----船。----------------
AddSimPostInit(function(inst)
	local p = GetPlayer()
	tosoPostInit(inst)
	GLOBAL.TheInput:AddControlHandler(GLOBAL.CONTROL_ACTION, function(down)
    local pt = p:GetPosition()
    local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, 30)
	local weapon =  p.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HANDS)
	    for k,v in pairs(ents) do

		if v and v.prefab == "yiyuwaxwell_boat" then
			v:RemoveComponent("drivable")
		end
		end
	end)


end)

local QW = GetModConfigData("quickwork")
if QW == 1 then

------------快速采集-------------
function pick(inst)
	if inst.components.pickable then
	inst.components.pickable.quickpick = true
	end
end

AddPrefabPostInit("sapling", pick)
AddPrefabPostInit("marsh_bush", pick)
AddPrefabPostInit("reeds", pick)
AddPrefabPostInit("grass", pick)
AddPrefabPostInit("berrybush2", pick)
AddPrefabPostInit("berrybush", pick)
AddPrefabPostInit("flower_cave", pick)
AddPrefabPostInit("flower_cave_double", pick)
AddPrefabPostInit("flower_cave_triple", pick)
AddPrefabPostInit("red_mushroom", pick)
AddPrefabPostInit("green_mushroom", pick)
AddPrefabPostInit("blue_mushroom", pick)
AddPrefabPostInit("cactus", pick)
AddPrefabPostInit("lichen", pick)
------------快速采集。-------------
end



--UI煞气
local shaqi = require("widgets/shaqi")
local function Addshaqi(self) 
	if self.owner and self.owner:HasTag("tososhaqi") then
		self.shaqi = self.status:AddChild(shaqi(self.owner))	
		--self.shaqi:SetPosition(-80,-40,0)
		self.shaqi:SetPosition(-120,23,0)
		self.shaqi:SetScale(1,1,1)	
	end
end

AddClassPostConstruct("widgets/controls", Addshaqi)


--UI灵力
local lingli = require("widgets/lingli")
local function Addlingli(self) 
	if self.owner and self.owner:HasTag("toso") then
		self.lingli = self.status:AddChild(lingli(self.owner))	
		--self.lingli:SetPosition(-80,-40,0)
		self.lingli:SetPosition(-120,-75,0)
		self.lingli:SetScale(1,1,1)	
	end
end

AddClassPostConstruct("widgets/controls", Addlingli)


-- Custom speech strings
STRINGS.CHARACTERS.TOSO = require "speech_toso"

STRINGS.TABS.TOSOTAB = "TOSO"
RECIPETABS['TOSOTAB'] = {str = "TOSOTAB", sort=99, icon = "toso_tab.tex", icon_atlas = "images/tabs/toso_tab.xml"}

function RepicPostInit(inst)
   local jianqiao = Ingredient( "jianqiao", 1)
   jianqiao.atlas = "images/inventoryimages/jianqiao.xml"


--Recipe("bundlewrap", {Ingredient("waxpaper", 1), Ingredient("rope", 1)}, RECIPETABS.SURVIVAL, TECH.LOST)
--local suiji_book = GLOBAL.Recipe("suiji_book", {Ingredient("papyrus", 5),Ingredient("silk", 20),Ingredient("purplegem", 1)}, RECIPETABS.YUYITAB, {SCIENCE=2})
--suiji_book.atlas = "images/inventoryimages/suiji_book.xml"

	--轩辕剑
	    local surfboard_item_toso = Recipe("surfboard_item_toso", { Ingredient("goldnugget", 10), Ingredient("thulecite", 2) }, RECIPETABS.TOSOTAB, {SCIENCE=0})
        surfboard_item_toso.atlas = "images/inventoryimages/sword_3.xml"
		surfboard_item_toso.image = "sword_3.tex"
	--饮血剑
	    local sword_5 = Recipe("sword_5", { Ingredient("livinglog", 1), Ingredient("redgem", 2) }, RECIPETABS.TOSOTAB, TECH.NONE)
        sword_5.atlas = "images/inventoryimages/sword_5.xml"
		sword_5.image = "sword_5.tex"
	--工具刀
	    local sword_2 = Recipe("sword_2", { Ingredient("flint", 20), Ingredient("log", 2) }, RECIPETABS.TOSOTAB, TECH.NONE)
        sword_2.atlas = "images/inventoryimages/sword_2.xml"
		sword_2.image = "sword_2.tex"
	--伞
	    local san = Recipe("san", { Ingredient("silk", 6), Ingredient("log", 1), Ingredient("twigs", 6) }, RECIPETABS.TOSOTAB, TECH.NONE)
        san.atlas = "images/inventoryimages/san.xml"
		san.image = "san.tex"
	--护鞘
	    local jianqiao = Recipe("jianqiao", { Ingredient("silk", 5), Ingredient("rope", 2), Ingredient("armorgrass", 1) }, RECIPETABS.TOSOTAB, TECH.NONE)
        jianqiao.atlas = "images/inventoryimages/jianqiao.xml"
		jianqiao.image = "jianqiao.tex"
	--护鞘2
	    local jianqiao2 = Recipe("jianqiao2", { Ingredient("jianqiao", 1), Ingredient("greengem", 1), Ingredient("purplegem", 1) }, RECIPETABS.TOSOTAB, TECH.NONE)
        jianqiao2.atlas = "images/inventoryimages/jianqiao2.xml"
		jianqiao2.image = "jianqiao2.tex"
	--斧头
	    local futou = Recipe("futou", { Ingredient("rocks", 10), Ingredient("log", 1), Ingredient("twigs", 2) }, RECIPETABS.TOSOTAB, TECH.NONE)
        futou.atlas = "images/inventoryimages/futou.xml"
		futou.image = "futou.tex"
	--花
	    local flower_seed = Recipe("flower_seed", { Ingredient("petals_evil", 1), Ingredient("poop", 2) }, RECIPETABS.TOSOTAB, TECH.NONE)
        flower_seed.atlas = "images/inventoryimages/flower_seed.xml"
		flower_seed.image = "flower_seed.tex"
	--招魂幡
	    local zhaohunfan_item = Recipe("zhaohunfan_item", { Ingredient("papyrus", 5), Ingredient("livinglog", 6) }, RECIPETABS.TOSOTAB, TECH.NONE)
        zhaohunfan_item.atlas = "images/inventoryimages/zhaohunfan_item.xml"
		zhaohunfan_item.image = "zhaohunfan_item.tex"
	--盏灯
	    local light1 = Recipe("light1", { Ingredient("charcoal", 10), Ingredient("lantern", 6) }, RECIPETABS.TOSOTAB, TECH.NONE)
        light1.atlas = "images/inventoryimages/light1.xml"
		light1.image = "light1.tex"
		
	--剑冢		
		local jianzhong = GLOBAL.Recipe("jianzhong", {Ingredient("livinglog", 2), Ingredient("charcoal", 2), Ingredient("purplegem", 4)}, GLOBAL.RECIPETABS.TOSOTAB, {SCIENCE = 2}, nil, "jianzhong_placer" )
		jianzhong.atlas = "images/inventoryimages/jianzhong.xml"
		jianzhong.image = "jianzhong.tex"
	--炼丹炉		
		--local liandanlu = Recipe("liandanlu", {Ingredient("livinglog", 2), Ingredient("charcoal", 2), Ingredient("purplegem", 4)}, RECIPETABS.TOSOTAB, {SCIENCE = 2}, nil, "liandanlu_placer" )
		--liandanlu.atlas = "images/inventoryimages/liandanlu.xml"
		--liandanlu.image = "liandanlu.tex"
	--门		
		--local gate = Recipe("gate", {Ingredient("livinglog", 2), Ingredient("charcoal", 2), Ingredient("purplegem", 4)}, RECIPETABS.TOSOTAB, {SCIENCE = 2}, nil, "gate_placer" )
		--gate.atlas = "images/inventoryimages/gate.xml"
		--gate.image = "gate.tex"
	--聚水坛		
		--local water_platform = Recipe("water_platform", {Ingredient("livinglog", 2), Ingredient("charcoal", 2), Ingredient("purplegem", 4)}, RECIPETABS.TOSOTAB, {SCIENCE = 2}, nil, "water_platform_placer" )
		--water_platform.atlas = "images/inventoryimages/water_platform.xml"
		--water_platform.image = "water_platform.tex"
		
--[[
if GLOBAL.SaveGameIndex:IsModeShipwrecked() then
local yuyi_sack2 = GLOBAL.Recipe("yuyi_sack2", {Ingredient("Magic_seal", 1), yuyi_sack11, Ingredient("purplegem", 1)}, RECIPETABS.YUYITAB, {SCIENCE = 0})
yuyi_sack2.atlas = "images/inventoryimages/yuyi_sack2.xml"
local yuyi_sack3 = GLOBAL.Recipe("yuyi_sack3", {Ingredient("Shark_gills", 4), yuyi_sack21, Ingredient("purplegem", 1)}, RECIPETABS.YUYITAB, {SCIENCE = 0})
yuyi_sack3.atlas = "images/inventoryimages/yuyi_sack3.xml"
else
local yuyi_sack2 = GLOBAL.Recipe("yuyi_sack2", {Ingredient("dragon_scales", 1), yuyi_sack11, Ingredient("purplegem", 1)}, RECIPETABS.YUYITAB, {SCIENCE = 0})
yuyi_sack2.atlas = "images/inventoryimages/yuyi_sack2.xml"
local yuyi_sack3 = GLOBAL.Recipe("yuyi_sack3", {Ingredient("bearger_fur", 1), yuyi_sack21, Ingredient("purplegem", 1)}, RECIPETABS.YUYITAB, {SCIENCE = 0})
yuyi_sack3.atlas = "images/inventoryimages/yuyi_sack3.xml"
end
]]
--------------------------------------------------------------

GetPlayer():DoTaskInTime(1, function()
if GLOBAL.IsDLCEnabled(GLOBAL.REIGN_OF_GIANTS) then




elseif not GLOBAL.SaveGameIndex:IsModeShipwrecked() then
--------------------------------------------------------------


--------------------------------------------------------------
elseif GLOBAL.SaveGameIndex:IsModeShipwrecked() then
--------------------------------------------------------------
	--轩辕剑
	    local surfboard_item_toso = Recipe("surfboard_item_toso", { Ingredient("goldnugget", 10), Ingredient("livinglog", 2) }, RECIPETABS.TOSOTAB, {SCIENCE=0})
        surfboard_item_toso.atlas = "images/inventoryimages/sword_3.xml"
		surfboard_item_toso.image = "sword_3.tex"


end
end)

end

function PostInit(inst)
	RepicPostInit(inst)
	if inst.components.keeponland then inst:RemoveComponent("keeponland") end
	if inst.components.yiyu_keeponland then inst:RemoveComponent("yiyu_keeponland") end
	--if inst and not inst.components.yuyi_keeponland then inst:AddComponent("yuyi_keeponland") end
end

----——————————————————————————————————结尾——————————————————————————————————————————————————
AddAction(TOSOCAST)
AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(TOSOCAST, "tosocast"))
AddStategraphActionHandler("wilsonboating", GLOBAL.ActionHandler(TOSOCAST, "tosocast"))

table.insert(GLOBAL.CHARACTER_GENDERS.MALE, "toso")
AddMinimapAtlas("images/map_icons/toso.xml")
AddPrefabPostInit("san", AddMap)
AddMinimapAtlas("images/inventoryimages/san.xml")
AddPrefabPostInit("light1", AddMap)
AddMinimapAtlas("images/inventoryimages/light1.xml")
AddPrefabPostInit("jiandai", AddMap)
AddMinimapAtlas("images/inventoryimages/jiandai.xml")
AddPrefabPostInit("axiang", AddMap)
AddMinimapAtlas("images/inventoryimages/axiang.xml")
AddPrefabPostInit("sword_4", AddMap)
AddMinimapAtlas("images/inventoryimages/sword_4.xml")
AddPrefabPostInit("sword_5", AddMap)
AddMinimapAtlas("images/inventoryimages/sword_5.xml")
AddPrefabPostInit("sword_6", AddMap)
AddMinimapAtlas("images/inventoryimages/sword_6.xml")
AddPrefabPostInit("futou", AddMap)
AddMinimapAtlas("images/inventoryimages/futou.xml")
AddPrefabPostInit("sword_3", AddMap)
AddMinimapAtlas("images/inventoryimages/sword_3.xml")
AddPrefabPostInit("sword_3", AddMap)
AddMinimapAtlas("images/inventoryimages/sword_3.xml")
AddPrefabPostInit("jianqiao", AddMap)
AddMinimapAtlas("images/inventoryimages/jianqiao.xml")
AddPrefabPostInit("jianqiao2", AddMap)
AddMinimapAtlas("images/inventoryimages/jianqiao2.xml")
AddPrefabPostInit("liandanlu", AddMap)
AddMinimapAtlas("images/inventoryimages/liandanlu.xml")
AddPrefabPostInit("jianzhong", AddMap)
AddMinimapAtlas("images/inventoryimages/jianzhong.xml")
AddPrefabPostInit("zhaohunfan_item", AddMap)
AddMinimapAtlas("images/inventoryimages/zhaohunfan_item.xml")

AddModCharacter("toso")
AddSimPostInit(function(inst) PostInit(inst) end)
--地图显示
--AddMinimapAtlas("minimap/zhaohunfan_item.xml")

