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

}

local prefabs =
{
	
}







local function onhammered(inst, worker)
	inst.components.lootdropper:DropLoot()
    SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition())
	inst.SoundEmitter:PlaySound("dontstarve/wilson/rock_break")
	inst:Remove()
end

local function onhit(inst, worker)
	inst.AnimState:PlayAnimation("hit_idle")
	
end

local function onbuilt(inst)
	inst.AnimState:PlayAnimation("place")
end

local function fn()
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
	inst.entity:AddSoundEmitter()
    

	MakeObstaclePhysics(inst, 0.5)

	inst:AddComponent("lootdropper")
	

	anim:SetBank("dxxn")
	anim:SetBuild("dxxn")
	
	anim:PlayAnimation("idle")


	inst.entity:AddMiniMapEntity()
	inst.MiniMapEntity:SetIcon( "dxxn.tex" )

local light = inst.entity:AddLight()

    inst.Light:SetRadius(1)
    inst.Light:SetFalloff(1)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(255/255,0/0,0/0)    


   inst.Light:Enable(true)

	inst:AddComponent("inspectable")
   inst:AddComponent("lootdropper")
	inst:AddComponent("workable")
       inst.components.workable:SetWorkAction(ACTIONS.HAMMER)
        inst.components.workable:SetWorkLeft(6)
	  inst.components.workable:SetOnFinishCallback(onhammered)
        inst.components.workable:SetOnWorkCallback(onhit) 

inst:ListenForEvent("onbuilt", onbuilt)
    

	return inst
end


return Prefab( "common/objects/dxxn", fn, assets),
		MakePlacer( "common/dxxn_placer", "dxxn", "dxxn", "idle" ) 