Files
Aurora.3/code/modules/cargo/delivery/_helpers.dm
Fluffy 7265630dde Turn more unmanaged global vars into GLOB (#20446)
Turned a ton of unmanaged globals into managed globals.
Refactored some UT output.
Removed some unused things, including vars.
Added a test to ensure people don't keep adding new unmanaged vars.
2025-02-17 23:34:02 +00:00

24 lines
951 B
Plaintext

/proc/get_cargo_package_delivery_point(var/atom/atom, var/horizon_only = FALSE)
var/obj/effect/overmap/visitable/ship/horizon
if(SSatlas.current_map.overmap_visitable_type)
horizon = SSshuttle.ship_by_type(SSatlas.current_map.overmap_visitable_type)
var/turf/current_turf = get_turf(atom)
var/list/eligible_delivery_points = list()
for(var/obj/structure/cargo_receptacle/delivery_point in GLOB.all_cargo_receptacles)
var/obj/effect/overmap/visitable/my_sector = GLOB.map_sectors["[current_turf.z]"]
var/obj/effect/overmap/visitable/delivery_point_sector = GLOB.map_sectors["[delivery_point.z]"]
// no delivering to ourselves
if(my_sector == delivery_point_sector)
continue
// guaranteed horizon, has to go to horizon
if(horizon_only && horizon && delivery_point_sector != horizon)
continue
eligible_delivery_points += delivery_point
if(!length(eligible_delivery_points))
return
return pick(eligible_delivery_points)