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

	

}

local prefabs =
{
    "explode_small",
}

local function OnIgniteFn(inst)
  inst._fx = SpawnPrefab("torchfire")
    inst._fx.entity:SetParent(inst.entity)
            inst._fx.entity:AddFollower()
            inst._fx.Follower:FollowSymbol(inst.GUID, "smallbomb", 0, 0, 0)
    inst.SoundEmitter:PlaySound("dontstarve/common/blackpowder_fuse_LP", "hiss")
end

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


local function OnExplodeFn(inst)
local x, y, z = inst.Transform:GetWorldPosition()
local ents = TheSim:FindEntities(x, y, z, 3)
		 for i, v in ipairs(ents) do
		 
		   if v.components.health ~= nil then
				 if v:HasTag("player") then				         
				 else
v.components.health:DoDelta(-25)	end
		 end
end
    inst.SoundEmitter:KillSound("hiss")
    SpawnPrefab("explode_small").Transform:SetPosition(inst.Transform:GetWorldPosition())
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("smallbombactive")
    anim:SetBuild("smallbombactive")
    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.lightonexplode = false
	
  inst._light = nil

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



	


	 




    
    return inst
end

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