Files
Aurora.3/code/datums/local_network.dm
Batrachophreno 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
Repaths obj/machinery to obj/structure/machinery. **Note for
reviewers:** the only meaningful changed code exists within
**code/game/objects/structures.dm** and
**code/game/objects/structures/_machinery.dm**, largely concerning
damage procs. With the exception of moving airlock defines to their own
file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES.

Objects, _categorically_, are largely divided between those you can hold
in your hand/inventory and those you can't. Machinery objects are
already subtypes of Structures behaviorally, this PR just makes their
pathing reflect that, and allows for future work (tool actions, more
health/destruction functionality) to be developed without unnecessary
code duplication.

I have tested this PR by loading up the Horizon and dismantling various
machines and structures with tools, shooting guns of various types
throughout the ship, and detonating a bunch of explosions throughout the
ship.
2026-05-26 19:35:48 +00:00

78 lines
2.0 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/structure/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/structure/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/structure/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