--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆
--◆◆[[Author: JinYering]]
--◆◆[[E-Mail: jin_yering@naver.com]]
--◆◆[[WhaRang The Millennium Fox]]
--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆--◆◆

local Assets =
{
	 Asset("ANIM",			"anim/fox_campfire_fire.zip"),
	 Asset("ANIM",			"anim/fox_campfire_fire_build.zip"),
	 Asset("SOUND",			"sound/common.fsb"),
}

local function GetHeatFn(inst)
if IsDLCEnabled(REIGN_OF_GIANTS) or IsDLCEnabled(CAPY_DLC) then
local heats = { 75, 90, 105, 120 }
return heats[inst.components.firefx.level] or 20
else
local heats = { 75, 125, 185, 225 }
return heats[inst.components.firefx.level] or 20
end
end

local function fn(Sim)

	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
	local sound = inst.entity:AddSoundEmitter()
	local light = inst.entity:AddLight()

    anim:SetBank("fox_campfire_fire")
    anim:SetBuild("fox_campfire_fire_build")
	anim:SetBloomEffectHandle("shaders/anim.ksh")

    inst:AddTag("fx")

    inst:AddComponent("heater")
    inst.components.heater.heatfn = GetHeatFn

    inst:AddComponent("firefx")
    inst.components.firefx.levels =
    {
        {anim="level1", sound="dontstarve/common/campfire", radius=3, intensity=.8, falloff=.33, colour = {192/255,255/255,192/255}, soundintensity=.1},
        {anim="level2", sound="dontstarve/common/campfire", radius=4, intensity=.8, falloff=.33, colour = {192/255,255/255,192/255}, soundintensity=.3},
        {anim="level3", sound="dontstarve/common/campfire", radius=5, intensity=.8, falloff=.33, colour = {192/255,255/255,192/255}, soundintensity=.6},
        {anim="level4", sound="dontstarve/common/campfire", radius=6, intensity=.8, falloff=.33, colour = {192/255,255/255,192/255}, soundintensity=1},
    }
    
    anim:SetFinalOffset(-1)
    inst.components.firefx:SetLevel(1)
    inst.components.firefx.usedayparamforsound = true
    return inst
end

return Prefab( "common/fx/firepit_ghost_fire", fn, Assets) 
