local assets =
{
	Asset("ANIM", "anim/hat_marble.zip"),
--	Asset("ANIM", "anim/hat_marble_swap.zip"),
	
	Asset("ATLAS", "images/inventoryimages/hat_marble.xml"),	
	Asset("IMAGE", "images/inventoryimages/hat_marble.tex"),
}

local function fn(Sim)

	local function onequip(inst, owner)
--		owner.AnimState:OverrideSymbol("swap_hat", "hat_marble_swap", "swap_hat")
		owner.AnimState:OverrideSymbol("swap_hat", "hat_marble", "swap_hat")
		owner.AnimState:Show("HAT")
		owner.AnimState:Show("HAT_HAIR")
		owner.AnimState:Hide("HAIR_NOHAT")
		owner.AnimState:Hide("HAIR")
			
		if owner:HasTag("player") then
			owner.AnimState:Hide("HEAD")
			owner.AnimState:Show("HEAD_HAT")
		end
	end

	local function onunequip(inst, owner)
		owner.AnimState:Hide("HAT")
		owner.AnimState:Hide("HAT_HAIR")
		owner.AnimState:Show("HAIR_NOHAT")
		owner.AnimState:Show("HAIR")
	
        if owner:HasTag("player") then
            owner.AnimState:Show("HEAD")
            owner.AnimState:Hide("HEAD_HAT")
        end
	end

	local inst = CreateEntity()
	
	inst.entity:AddTransform()
	inst.entity:AddAnimState()
	inst.entity:AddNetwork()
	
	MakeInventoryPhysics(inst)

	inst.AnimState:SetBank("hat_marble")
    inst.AnimState:SetBuild("hat_marble")
	inst.AnimState:PlayAnimation("idle") 
	
	inst:AddTag("marble")
	
	inst:AddTag("hat")
	
	inst.entity:SetPristine()
	
	if not TheWorld.ismastersim then
		return inst
	end
	
	inst:AddComponent("inspectable") 
	
	inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/hat_marble.xml"
	inst.components.inventoryitem.imagename = "hat_marble"
	
	inst:AddComponent("tradable")
	
	inst:AddComponent("armor")
	inst.components.armor:InitCondition(TUNING.ARMOR_SLURTLEHAT, .90)

    inst:AddComponent("equippable")
    inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
	inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)
	inst.components.equippable.walkspeedmult = 0.8
	
	inst:AddComponent("waterproofer")
    inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_SMALL)
	
	MakeHauntableLaunch(inst)
	
    return inst
end

STRINGS.NAMES.HAT_MARBLE 								= "Marble Helmet"
STRINGS.RECIPE_DESC.HAT_MARBLE 							= "Keeps your marbles safe."

STRINGS.CHARACTERS.GENERIC.DESCRIBE.HAT_MARBLE 			= "I am not a pawn!"
STRINGS.CHARACTERS.WILLOW.DESCRIBE.HAT_MARBLE 			= "Makes my head feels heavier than usual."
STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.HAT_MARBLE 		= "Is strong head gear for head."
STRINGS.CHARACTERS.WENDY.DESCRIBE.HAT_MARBLE 			= "We are all pawns."
STRINGS.CHARACTERS.WX78.DESCRIBE.HAT_MARBLE 			= "ADDITIONAL PROTECTION FOR MY CRANIUM"
STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.HAT_MARBLE 	= "It looks like the head of a pawn."
STRINGS.CHARACTERS.WOODIE.DESCRIBE.HAT_MARBLE 			= "Now that's one big marble."
STRINGS.CHARACTERS.WAXWELL.DESCRIBE.HAT_MARBLE 			= "How ironic. Now I am the pawn on this board."
STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.HAT_MARBLE 		= "A trophy for my head!"
STRINGS.CHARACTERS.WEBBER.DESCRIBE.HAT_MARBLE 			= "We fancy a game of marbles."

return Prefab( "common/inventory/hat_marble", fn, assets ) 
