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

zone_by_name        = {}
sl_by_name          = {}
bridge_by_name		= {}
script_ids			= {}
storage             = {}
sound               = {}
actor               = nil
actor_proxy         = actor_proxy.actor_proxy()
heli                = {}
camp_storage        = {}
story_by_id	        = {}
smart_terrain_by_id = {}
trader				= nil
info_restr          = {}
strn_by_respawn     = {}
heli_enemies        = {}
heli_enemy_count    = 0
anim_obj_by_name	= {}
goodwill 			= {sympathy = {}, relations = {}}

signal_light		= {}

function add_enemy( obj )
    heli_enemies[heli_enemy_count] = obj
    heli_enemy_count = heli_enemy_count + 1
end

function delete_enemy( e_index )
    heli_enemies[e_index] = nil
end

function add_obj( obj )
    printf("adding object %s",obj:name())
    storage[obj:id()].object = obj
end

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


function add_zone( zone )
	zone_by_name[zone:name()] = zone
	--storage[zone:id()].object = obj
end

function del_zone( zone )
	zone_by_name[zone:name()] = nil
	--storage[zone:id()].object = nil
end

function add_bridge( bridge, binder )
	printf("adding bridge %s",bridge:name())
	bridge_by_name[bridge:name()] = binder
	add_obj( bridge )
end

function del_bridge( bridge )
	bridge_by_name[bridge:name()] = nil
	del_obj( bridge )
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 )
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


function add_anim_obj(anim_obj, binder)
	anim_obj_by_name[anim_obj:name()] = binder
	add_obj(anim_obj)
end

function del_anim_obj(anim_obj)
	anim_obj_by_name[anim_obj:name()] = nil
	del_obj(anim_obj)
end
