local assets =
{
	Asset("ANIM", "anim/ast.zip"),
    Asset("ATLAS", "images/inventoryimages/ast.xml"),
	Asset("ANIM", "anim/tujian.zip"),
	
}
local function fn()
    local inst = CreateEntity()
	local probably = 1
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("ast")
    inst.AnimState:SetBuild("ast")
    inst.AnimState:PlayAnimation("idle")

    inst.entity:SetPristine()
---

---
    if not TheWorld.ismastersim then
        return inst
    end
	inst:AddTag("molebait")
    inst:AddComponent("inspectable")
	inst:AddComponent("talker")
	inst.components.talker.fontsize = 28
    inst.components.talker.font = TALKINGFONT
    inst.components.talker.colour = Vector3(.4, .4, .9)
    inst.components.talker.offset = Vector3(0, 0, 0)
    inst.components.talker.symbol = "swap_object"
    inst:AddComponent("inventoryitem")
	--调查

	inst.components.inspectable.getstatus = function(inst,viewer)
	local say = ""
	if probably == 1 then
	local id = math.random(4000,9999)
	inst.components.talker:Say("编号"..id.."，欢迎进入DST世界，接下来将对你进行AST计划的说明（请继续点击）")
probably=2

	elseif probably == 2 then
	inst.components.talker:Say("AST计划即是向异世界进行殖民活动以获得更多的资源来制造对抗精灵的装备的由DEM社提出的计划 \n 不过目前仍然只是实验罢了，希望你可以创造出令人满意的结果") probably = 2.1
	
	elseif probably == 2.1 then
	inst.components.talker:Say("由于DST世界的特殊性，我们将通过starbound世界传送资源，所以部分物品会被像素化，请注意") probably = 3
	
	elseif probably == 3 then
	inst.components.talker:Say("现在将对你进行AST计划的器材培训,根据协议，投放cr式显现装置") probably = 4
	viewer.components.inventory:GiveItem( SpawnPrefab("crunitcr"))
	elseif probably == 4 then
	inst.components.talker:Say("首先，请装备刚才发给你的显现装置cr型，然后使用它，你将得到5个魔力，然后调查本终端以完成任务")
	if viewer.components.inventory:Has("magicpower", 5) and	probably == 4 then probably = 5 end
	elseif probably == 5 then
	inst.components.talker:Say("魔力是显现装置的基本动力，正常的魔力是由生命源转换的 \n 但是cr型显现装置经过改良只需要消耗精神力即可（请继续点击）") 
	probably = 5.1
	elseif probably == 5.1 then
	inst.components.talker:Say("不过我们暂时还用不着魔力，你现在应该先想办法活下去（请继续点击）") probably = 5.2
	elseif probably == 5.2 then
	inst.components.talker:Say("那么，发布第一个正式任务：（请继续点击）") probably = 5.3
	elseif probably == 5.3 then
	inst.components.talker:Say("请制造出研磨器（科学二本），然后将燧石研磨为金属碎片，获得6个金属碎片后提交给终端 \n 你也可以通过手搓燧石获得金属碎片，但是性价比过低，不建议你这样做")
	if viewer.components.inventory:Has("coherer_small", 6) and	probably == 5.3 then probably = 5.4 end
	elseif probably == 5.4 then
	inst.components.talker:Say("金属碎片可以用于合成大块金属以方便我们提取其中的其他金属 \n 也可以将金块研磨以获得更多的大块金属（请继续点击）") probably = 5.5
	elseif probably == 5.5 then
	inst.components.talker:Say("请将5单位的大块金属塞入研磨器中研磨，将得到的产物提交给终端 \n 任务奖励：玻璃x1") 
	if viewer.components.inventory:Has("fe", 5) and viewer.components.inventory:Has("cu", 5) and probably == 5.4 then probably = 5.6 
	viewer.components.inventory:GiveItem( SpawnPrefab("glass")) end
	elseif probably == 5.6 then
	inst.components.talker:Say("大块金属中含有相当量的铁和铜，当然你也可以通过挖掘含有月石的岩石来获得这两种金属（请继续点击）") probably = 5.7
	elseif probably == 5.7 then
	inst.components.talker:Say("请制作1个基础机器外壳和1个显现装置核心 \n 它们是非常重要的材料 任务奖励：指令卡-木板合成") 
	if viewer.components.inventory:Has("bmachineshell", 5) and viewer.components.inventory:Has("unit_center", 5) and probably == 5.7 then probably = 5.8 
	viewer.components.inventory:GiveItem( SpawnPrefab("ast_sr_boards")) end
	elseif probably == 5.8 then
	inst.components.talker:Say("基础机器外壳和显现装置核心是很多机器的必要材料，指令卡可以让你通过消耗研究台的数据以得到物质资源（请继续点击）") probably = 5.9
	elseif probably == 5.9 then
	inst.components.talker:Say("因为今后的很多机器都需要各类矿石的支持，必要时你可以制作出挖矿机以获得矿物资源（请继续点击）") probably = 6
	
	elseif probably == 6 then
	inst.components.talker:Say("接下来，请制作一个压缩机，然后往其中填充40个魔力进行压缩 \n 并将得到的东西带在身上以便终端读取")
	if viewer.components.inventory:Has("magicpower_mk2", 1) then probably = 7 end
	elseif probably == 7 then
	inst.components.talker:Say("纯净魔力是进一步将魔力提纯得到的魔力 \n 具有接近精灵灵力的波动等级 \n 也许会应用在其他机器上（请继续点击）") probably = 8
	
	elseif probably == 8 then
	inst.components.talker:Say("压缩机不仅可以压缩魔力，干草，木头，树枝，金子，矿石都可以以40或20单位一组进行压缩（请继续点击）") probably = 9
	
	elseif probably == 9 then
	inst.components.talker:Say("ok，目前为止你做的很好，我认为我应该给你一些奖励了（请继续点击）") 
	viewer.components.inventory:GiveItem( SpawnPrefab("ast_n_gears")) probably = 10
	elseif probably == 10 then
	inst.components.talker:Say("这是一次性的指令卡，请务必好好使用，制作压缩机想必精神力消耗很大吧 \n 但是请你理解，cr型已经是最新型号，早期的显现装置是要消耗生命力的，CR型是我们技术的极限了（请继续点击）") probably = 11
	
	elseif probably == 11 then
	inst.components.talker:Say("接下来，请你使用纯净魔力还有显现装置核心制作一台分解机（请继续点击）") probably = 12
	
	elseif probably == 12 then
	inst.components.talker:Say("分解机可以用来将被压缩的物品重新还原，以及加工金属制作配件 \n 请不要随意分解奇怪的东西，比如活物（请继续点击）") probably = 13
	
	elseif probably == 13 then
	inst.components.talker:Say("为了告诫你，请你抓一只兔子，要活的，然后塞进分解机里，然后拿出那些血肉模糊的东西提交终端 \n 我相信你会理解这样做的后果") 
	if viewer.components.inventory:Has("soul", 1) then probably = 14 end
	elseif probably == 14 then
	inst.components.talker:Say("这是什么东西。。。居然不是血肉模糊的。。咳咳，我们会报告给DEM社，继续你的工作吧（请继续点击）") probably = 15
	
	elseif probably == 15 then
	inst.components.talker:Say("根据DST世界原住民的情报，在DST世界似乎很容易因为饥饿导致死亡\n 为了防止你因为工作而过于饥饿，请你准备一下食物的补给（请继续点击）") probably = 16
	
	elseif probably == 16 then
	inst.components.talker:Say("请制作一个植物研究台，并提交一个胡萝卜以获取其基因，将该基因提交给终端。 奖励：基因数据库")
	if viewer.components.inventory:Has("gene_nengliang", 1) and viewer.components.inventory:Has("gene_luoxuan", 1) and viewer.components.inventory:Has("gene_dikang", 1) and probably == 16 
	then probably = 17 
	viewer.components.inventory:GiveItem( SpawnPrefab("geneshujuku")) end
	
	elseif probably == 17 then
	inst.components.talker:Say("接下来，请对照基因数据库，提取植物的基因制作出小麦种子，之后向终端提交5个小麦种子。 奖励：指令卡-料理台")
	if viewer.components.inventory:Has("seed_wheat",5) and probably == 17
	then probably = 18
	viewer.components.inventory:GiveItem( SpawnPrefab("ast_sr_foodworktable")) end
	end
	return say
	end
	--
	inst:AddComponent("tradable")
    inst.components.inventoryitem.imagename = "ast"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/ast.xml"
    inst:AddComponent("selfstacker")

	
    
    MakeHauntableLaunchAndSmash(inst)
--保存载入
local function onsave(inst, data)
    data.probably = probably
	end
local function onload (inst, data)
    if data ~= nil
     then
		probably = data.probably
	end 
end
inst.OnSave = onsave
inst.OnLoad = onload
    return inst
end

return Prefab("ast", fn, assets),
MakePlacer("ast_placer", "worktable", "worktable", "idle")