----------------------------------------------------------------------------------------------------
-- Подсвечивает себя при входе актёра
----------------------------------------------------------------------------------------------------

class "action_mapspot"

function action_mapspot:__init(obj, storage)
	self.object = obj
	self.st = storage
end

function action_mapspot:reset_scheme()
	--printf("_bp: sr_mapspot: action_mapspot:reset_scheme: self.object:name()='%s'", self.object:name())
	self.st.mapspots_sended = false
end

function action_mapspot:update(delta)
	--printf("_br: sr_mapspot: action_mapspot:update()")

	local actor = db.actor
	if not actor then
		return
	end
-- alterei
	if db.vanish ~= nil then
		if db.vanish:id() ~= npc:id() then

	if level.map_has_object_spot(self.object:id(), self.st.location) == 0 and self.object:inside(actor:position()) then
		level.map_add_object_spot(self.object:id(), self.st.location, self.st.hint)
	end

	if xr_logic.try_switch_to_another_section(self.object, self.st, actor) then
		return
	end	

-- fim
		end
	end

end

---------------------------------------------------------------------------------------------------------------------
function add_to_binder(npc, ini, scheme, section, storage)
	printf("DEBUG: add_to_binder: scheme='%s', section='%s'", scheme, section)

	local new_action = action_mapspot(npc, storage)

	-- Зарегистрировать все actions, в которых должен быть вызван метод reset_scheme при изменении настроек схемы:
	-- alterei
	if db.vanish ~= nil then
		if db.vanish:id() ~= npc:id() then xr_logic.subscribe_action_for_events(npc, storage, new_action) end
	end
end

function set_scheme(obj, ini, scheme, section, gulag_name)
	local st = xr_logic.assign_storage_and_bind(obj, ini, scheme, section)
	st.logic = xr_logic.cfg_get_switch_conditions(ini, section, obj)

	st.hint     = utils.cfg_get_string(ini, section, "hint",     obj, true,  "", "")
	st.location = utils.cfg_get_string(ini, section, "location", obj, false, "", "crlc_small")
end
