dofile( "data/scripts/lib/utilities.lua" )

local entity_id = GetUpdatedEntityID()
local pos_x, pos_y, current_rotation, size_x, size_y = EntityGetTransform( entity_id )

EntitySetTransform(entity_id, pos_x, pos_y, current_rotation, size_x * 2.5, size_y * 2.5)

local AreaEffect = EntityGetFirstComponent(entity_id, "GameAreaEffectComponent")

if(AreaEffect == nil)then
    EntityAddComponent(entity_id, "GameAreaEffectComponent", {
        radius="12",
        frame_length="70",
    })
    local particle = EntityAddComponent(entity_id, "GameAreaEffectComponent", {
        emitted_material_name="spark_white",
		lifetime_min="0.5",
		lifetime_max="1.5",
		count_min="4",
		count_max="4",
		render_on_grid="1",
		fade_based_on_lifetime="1",
		cosmetic_force_create="0",
		airflow_force="0.3",
		airflow_time="0.01",
		airflow_scale="0.05",
		emission_interval_min_frames="1",
		emission_interval_max_frames="1",
		emit_cosmetic_particles="1",
		is_emitting="1",
    })
    ComponentSetValue2(particle, "area_circle_radius.min", "min", 12)
else
    local radius = ComponentGetValue2(AreaEffect, "radius")
    
    local particle = EntityAddComponent(entity_id, "GameAreaEffectComponent", {
        emitted_material_name="spark_white",
		lifetime_min="0.5",
		lifetime_max="1.5",
		count_min="4",
		count_max="4",
		render_on_grid="1",
		fade_based_on_lifetime="1",
		cosmetic_force_create="0",
		airflow_force="0.3",
		airflow_time="0.01",
		airflow_scale="0.05",
		emission_interval_min_frames="1",
		emission_interval_max_frames="1",
		emit_cosmetic_particles="1",
		is_emitting="1",
    })
    ComponentSetValue2(particle, "area_circle_radius.min", "min", radius)

    ComponentSetValue2(AreaEffect, "radius", radius * 2.5)
end
