#include "../../script/common/utils.lua"

local velocityOffset = {Vec(0, 0, -0.25), Vec(0, 0, 0.25), Vec(0.25, 0, 0), Vec(-0.25, 0, 0)}
local additionalParticlePos = {}

function init()
	firecampLocationTransform = GetLocationTransform(FindLocation("firecamp"))

	for index, offset in pairs(velocityOffset) do
		additionalParticlePos[index] = VecAdd(firecampLocationTransform.pos, offset)
	end

	light = FindLight("bonfirelight")
end

function tick(dt)
	local particleVelocity = {}

	ParticleReset()
	ParticleType("smoke")
	ParticleColor(1.0, 0.75, 0.5, 0.85, 0.23, 0.0)
	ParticleRadius(0.17, 0.08, "easein")
	ParticleCollide(1)
	ParticleGravity(2, 0.5, "smooth")
	ParticleAlpha(0.5, 0.1)
	ParticleEmissive(0.8, 0,7, "easein")
	ParticleRotation(1, 0, "linear")
	ParticleStretch(8)
	ParticleTile(5)

	particleVelocity = Vec(rnd(-0.05, 0.05), rnd(0.02, 0.2), rnd(-0.05, 0.05))
	SpawnParticle(firecampLocationTransform.pos, particleVelocity, rnd(0.02, 0.4))

	ParticleRadius(0.1, 0.08, "easein")

	for _, pos in pairs(additionalParticlePos) do
		particleVelocity = Vec(rnd(-0.05, 0.05), 0.05, rnd(-0.05, 0.05))
		SpawnParticle(pos, particleVelocity, rnd(0.01, 0.3))
	end

	ParticleReset()
	ParticleType("smoke")
	ParticleColor(1, 1, 1)
	ParticleRadius(0.16, 0.5, "easein")
	ParticleCollide(1)
	ParticleGravity(1, 0.1, "smooth")
	ParticleAlpha(0.06, 0,04, "fadeout")
	ParticleRotation(1, 0, "linear")
	ParticleStretch(5)
	ParticleTile(3)

	SpawnParticle(firecampLocationTransform.pos, Vec(0.5, 3, 1), 10)

	SetLightColor(light, 0.72, 0.51, 0.2)
	SetLightIntensity(light, rnd(0.7, 1.5))
end