-- @ Version: SCREEN SPACE SHADERS - UPDATE 19
-- @ Description: Wind script
-- @ Author: https://www.moddb.com/members/ascii1457
-- @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders

-- Flora settings
local ssfx_wind_min_speed = 0

local ssfx_wind_grass_speed = 0
local ssfx_wind_grass_turbulence = 0
local ssfx_wind_grass_push = 0
local ssfx_wind_grass_wave = 0

local ssfx_wind_trees_anim = 0
local ssfx_wind_trees_trunk = 0
local ssfx_wind_trees_bend = 0

function apply_florafixes_settings()

	get_console():execute("ssfx_wind_grass (" .. ssfx_wind_grass_speed .. "," .. ssfx_wind_grass_turbulence .. "," .. ssfx_wind_grass_push .. "," .. ssfx_wind_grass_wave .. ")")
	get_console():execute("ssfx_wind_trees (" .. ssfx_wind_trees_anim .. "," .. ssfx_wind_trees_trunk .. "," .. ssfx_wind_trees_bend .. "," .. ssfx_wind_min_speed .. ")")
	
end

function on_option_change()
	
	-- Get settings
	local module_id = "wind"

	ssfx_wind_min_speed = ssfx_001_mcm.ssfx_get_setting(module_id, "min_speed", ssfx_wind_settings)

	ssfx_wind_grass_speed = ssfx_001_mcm.ssfx_get_setting(module_id, "grass_speed", ssfx_wind_settings)
	ssfx_wind_grass_turbulence = ssfx_001_mcm.ssfx_get_setting(module_id, "grass_turbulence", ssfx_wind_settings)
	ssfx_wind_grass_push = ssfx_001_mcm.ssfx_get_setting(module_id, "grass_push", ssfx_wind_settings)
	ssfx_wind_grass_wave = ssfx_001_mcm.ssfx_get_setting(module_id, "grass_wave", ssfx_wind_settings)

	ssfx_wind_trees_anim = ssfx_001_mcm.ssfx_get_setting(module_id, "trees_speed", ssfx_wind_settings)
	ssfx_wind_trees_trunk = ssfx_001_mcm.ssfx_get_setting(module_id, "trees_trunk", ssfx_wind_settings)
	ssfx_wind_trees_bend = ssfx_001_mcm.ssfx_get_setting(module_id, "trees_bend", ssfx_wind_settings)

	-- Apply settings
	apply_florafixes_settings()

end

function on_game_start()

	-- General Functions
	RegisterScriptCallback("on_option_change", on_option_change)
	
	-- Read and apply settigns
	on_option_change()
end