--[[------------------------------------------------------------------------------------------------
База данных живых онлайновых объектов, зон и рестрикторов, актёра
Чугай Александр
--------------------------------------------------------------------------------------------------]]

zone_by_name        = {}
sl_by_name          = {}
storage             = {}
sound               = {}
actor               = nil
FlagRunPsy = 0
Flag1 = 0
Flag2 = 0
Flag3 = 0
Flag4 = 0
Flag5 = 0
Time_Vibros = 0
Time_Vibros2 = 0
Time_Vibros3 = 0
Time_Vibros4 = 0
TV = 45000
Flag_R1 = 0
time = math.random(12,24)
xray = 0.001
db.Flag_Test = 0
prev_time = 0
dt = 0
prev_time1 = 0
dt1 = 0
actor_proxy         = actor_proxy.actor_proxy()
heli                = {}
camp_storage        = {}
story_by_id	        = {}
smart_terrain_by_id = {}
trader				= nil
info_restr          = {}
strn_by_respawn     = {}

function add_obj( obj )
end

function del_obj( obj )
	storage   [obj:id()] = nil
end


function add_zone( zone )
	zone_by_name[zone:name()] = zone
	add_obj( zone )
end

function del_zone( zone )
	zone_by_name[zone:name()] = nil
	del_obj( zone )
end


function add_sl( sl )
	sl_by_name[sl:name()] = sl
	add_obj( sl )
end

function del_sl( sl )
	sl_by_name[sl:name()] = nil
	del_obj( sl )
end


function add_actor( obj )
	actor = obj
	actor_proxy:net_spawn( obj )
	add_obj( obj )

	--' Разбудим Кочергу. Дурацкое место для это кода, конечно. Куда бы его переместить?
	if has_alife_info("val_actor_has_borov_key") and not has_alife_info("val_borov_dead") then
		dbglog("waking up kocherga")
		actor:give_info_portion("val_borov_dead")
	end
end

function del_actor()
	del_obj( actor )
	actor_proxy:net_destroy()
	actor = nil
end


function add_heli(obj)	
	heli[obj:id()] = obj
end	
function del_heli(obj)
	heli[obj:id()] = nil
end	


function add_smart_terrain( obj )
	smart_terrain_by_id[obj.id] = obj
end

function del_smart_terrain( obj )
	smart_terrain_by_id[obj.id] = nil
end
