--------------------------------------------------------------------------------
-- Level changer binding -------------------------------------------------------
-- Made by Peacemaker ----------------------------------------------------------
-- 25.12.07 --------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Standart function for object binding
function bind(obj)
--    local new_binder = crow_binder(obj)
    obj:bind_object(lchanger_binder(obj))
end
--------------------------------------------------------------------------------
-- Class "crow_binder"
--------------------------------------------------------------------------------
class "lchanger_binder" (object_binder)
-- Class constructor
function lchanger_binder:__init(obj) super(obj)
end
-- Class update
function lchanger_binder:update(delta)
-- standart update
    god.main() -- Повелитель Зоны -- 
    object_binder.update(self, delta)
end
-- Reload object
function lchanger_binder:reload(section)
    object_binder.reload(self, section)
end
-- Reinitialize object
function lchanger_binder:reinit()
    object_binder.reinit(self)
    db.storage[self.object:id()] = {}
    self.st = db.storage[self.object:id()]
end
-- Net spawn
function lchanger_binder:net_spawn(sobject)
    if not(object_binder.net_spawn(self, sobject)) then
        return false
    end
    if string.find(command_line(), "-designer") then
		return true
	end

	local obj = self.object
    db.add_obj(obj)

    self.st.s_obj = alife():object(obj:id())
    obj:enable_level_changer(self.st.s_obj.enabled)
    obj:set_level_changer_invitation(self.st.s_obj.hint)
    return true
end
-- Net destroy
function lchanger_binder:net_destroy()
    db.del_obj(self.object)
    object_binder.net_destroy(self)
end
-- Standart function for save
function lchanger_binder:net_save_relevant()
	return true
end
-- Saving level changer
function lchanger_binder:save(package)
	set_save_marker(package, "save", false, "lchanger_binder")
	object_binder.save(self, package)
	xr_logic.save_obj(self.object, package)
	set_save_marker(package, "save", true, "lchanger_binder")
end
-- Loading level changer
function lchanger_binder:load(reader)
	set_save_marker(reader, "load", false, "lchanger_binder")
	object_binder.load(self, reader)
	xr_logic.load_obj(self.object, reader)
	set_save_marker(reader, "load", true, "lchanger_binder")
end
