mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-01-15 03:42:38 +00:00
* SDQL2 update * fix that verb * cl * fix that * toworld * this is pointless * update info * siiiiick.. * vv edit update * fix that * fix editing vars * fix VV * Port the /TG/ globals controller. * part 1 * part 2 * oops * part 3 * Hollow Purple * sadas * bsbsdb * muda na agaki ta * ids 1-15 * 16-31 * 41-75 * bring me back to how things used to be before i lost it all * the strength of mayhem * final touches * cl * protect some vars * update sdql2 to use glob * stuff? * forgot that is not defined there * whoops * observ * but it never gets better * a --------- Co-authored-by: Matt Atlas <liermattia@gmail.com>
78 lines
1.9 KiB
Plaintext
78 lines
1.9 KiB
Plaintext
GLOBAL_LIST_EMPTY(local_networks)
|
|
|
|
/datum/local_network
|
|
var/id_tag
|
|
var/list/network_entities = list()
|
|
var/const/network_size = 25 // Distance in tiles network objects can be from each other.
|
|
|
|
/datum/local_network/New(_id)
|
|
id_tag = _id
|
|
GLOB.local_networks[id_tag] = src
|
|
|
|
/datum/local_network/Destroy()
|
|
network_entities.Cut()
|
|
GLOB.local_networks -= src
|
|
. = ..()
|
|
|
|
/datum/local_network/proc/within_radius(atom/checking)
|
|
for(var/entity_list in network_entities)
|
|
for(var/entity in entity_list)
|
|
if(get_dist(entity, checking) > network_size)
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/datum/local_network/proc/add_device(obj/machinery/device)
|
|
var/list/entities = get_devices(device.type)
|
|
|
|
if(!entities)
|
|
entities = list()
|
|
network_entities[device.type] = entities
|
|
|
|
entities[device] = TRUE
|
|
|
|
return entities[device]
|
|
|
|
/datum/local_network/proc/remove_device(obj/machinery/device)
|
|
var/list/entities = get_devices(device.type)
|
|
if(!entities)
|
|
return TRUE
|
|
|
|
entities -= device
|
|
if(length(entities) <= 0)
|
|
network_entities -= device.type
|
|
if(length(network_entities) <= 0)
|
|
qdel(src)
|
|
return isnull(entities[device])
|
|
|
|
/datum/local_network/proc/is_connected(obj/machinery/device)
|
|
var/list/entities = get_devices(device.type)
|
|
|
|
if(!entities)
|
|
return FALSE
|
|
return !isnull(entities[device])
|
|
|
|
/datum/local_network/proc/get_devices(device_type)
|
|
for(var/entity_type in network_entities)
|
|
if(ispath(entity_type, device_type))
|
|
return network_entities[entity_type]
|
|
|
|
|
|
//Multilevel network
|
|
GLOBAL_LIST_EMPTY(multilevel_local_networks)
|
|
|
|
/datum/local_network/multilevel/New(_id)
|
|
id_tag = _id
|
|
GLOB.multilevel_local_networks[id_tag] = src
|
|
|
|
/datum/local_network/multilevel/Destroy()
|
|
network_entities.Cut()
|
|
GLOB.multilevel_local_networks -= src
|
|
. = ..()
|
|
|
|
/datum/local_network/multilevel/within_radius(atom/checking)
|
|
for(var/entity_list in network_entities)
|
|
for(var/atom/entity in entity_list)
|
|
if(!(GET_Z(entity) in GetConnectedZlevels(GET_Z(checking))))
|
|
return FALSE
|
|
return TRUE
|