local assets=
{
	Asset("ANIM", "anim/voltbombactive.zip"),

	

}

local prefabs =
{
    "explode_small",
}

local function OnIgniteFn(inst)


	   SpawnPrefab("sparks").Transform:SetPosition(inst.Transform:GetWorldPosition())
			

end

local function OnExtinguishFn(inst)
    inst.SoundEmitter:KillSound("hiss")
end


local function OnExplodeFn(inst)

	

   SpawnPrefab("chester_transform_fx").Transform:SetPosition(inst.Transform:GetWorldPosition())
	   SpawnPrefab("moose_nest_fx_idle").Transform:SetPosition(inst.Transform:GetWorldPosition())
	   	   SpawnPrefab("sparks").Transform:SetPosition(inst.Transform:GetWorldPosition())
    inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod")
	    inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/moose/egg_electric")
	   
	   
	local x,y,z = inst.Transform:GetWorldPosition()
		local ents = TheSim:FindEntities(x, y, z, 3)	
            for i,v in pairs(ents) do

 if v:GetIsWet() then 	 
 if v.components.health ~= nil then			
						v.components.health:DoDelta(-125)
						
						
						else

	end
	end
end
end

local function Explode(inst)
    inst.SoundEmitter:KillSound("hiss")
  inst.components.explosive:OnBurnt()
end





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

	inst.entity:AddNetwork()
    MakeInventoryPhysics(inst)
    
    anim:SetBank("voltbombactive")
    anim:SetBuild("voltbombactive")
    anim:PlayAnimation("idle",true)
        inst:AddTag("explosive")
		        inst:AddTag("SCARYTOPREY")
		
      inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

	


        inst:AddComponent("explosive")
    inst.components.explosive:SetOnExplodeFn(OnExplodeFn)
    inst.components.explosive.explosivedamage = 50
			  	      inst.components.explosive.buildingdamage = 2
	  inst.components.explosive.lightonexplode = false
	
  inst._light = nil

		  inst:DoTaskInTime(0, OnIgniteFn)
	  inst:DoTaskInTime(1, Explode)



	


	 




    
    return inst
end

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