mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Replaced "area" shuttles with "landmark" shuttles.
Largely ported from the work done at Baystation in https://github.com/Baystation12/Baystation12/pull/17460 and later commits. - Shuttles no longer require a separate area for each location they jump to. Instead destinations are indicated by landmark objects, which are not necessarily exclusive to that shuttle. This means that more than one shuttle could use the same docking port (not at the same time of course). - Enhanced shuttle control computers to use nanoui if they didn't. - Organizes shuttle datum code a bit better so there is less re-inventing the wheel in subtypes. - Allows the possibility of shuttles (or destinations) that start on late-loaded maps. - Deprecate the "extra" shuttle areas that are no longer needed and update shuttle areas in unit tests This all required a bit of infrastructure improvements. - ChangeArea proc, for changing the area of a turf. - Fixed lighting overlays actually being able to be destroyed. - Added a few utility macros and procs. - Added "turf translation" procs which are like move_contents_to but more flexible.
This commit is contained in:
@@ -308,6 +308,11 @@ proc/listclearnulls(list/list)
|
||||
else
|
||||
L[key] = temp[key]
|
||||
|
||||
// Return a list of the values in an assoc list (including null)
|
||||
/proc/list_values(var/list/L)
|
||||
. = list()
|
||||
for(var/e in L)
|
||||
. += L[e]
|
||||
|
||||
//Mergesort: divides up the list into halves to begin the sort
|
||||
/proc/sortKey(var/list/client/L, var/order = 1)
|
||||
|
||||
@@ -38,4 +38,120 @@
|
||||
var/pressure = environment ? environment.return_pressure() : 0
|
||||
if(pressure < SOUND_MINIMUM_PRESSURE)
|
||||
return TRUE
|
||||
return FALSE
|
||||
return FALSE
|
||||
|
||||
/*
|
||||
Turf manipulation
|
||||
*/
|
||||
|
||||
//Returns an assoc list that describes how turfs would be changed if the
|
||||
//turfs in turfs_src were translated by shifting the src_origin to the dst_origin
|
||||
/proc/get_turf_translation(turf/src_origin, turf/dst_origin, list/turfs_src)
|
||||
var/list/turf_map = list()
|
||||
for(var/turf/source in turfs_src)
|
||||
var/x_pos = (source.x - src_origin.x)
|
||||
var/y_pos = (source.y - src_origin.y)
|
||||
var/z_pos = (source.z - src_origin.z)
|
||||
|
||||
var/turf/target = locate(dst_origin.x + x_pos, dst_origin.y + y_pos, dst_origin.z + z_pos)
|
||||
if(!target)
|
||||
error("Null turf in translation @ ([dst_origin.x + x_pos], [dst_origin.y + y_pos], [dst_origin.z + z_pos])")
|
||||
turf_map[source] = target //if target is null, preserve that information in the turf map
|
||||
|
||||
return turf_map
|
||||
|
||||
/proc/translate_turfs(var/list/translation, var/area/base_area = null, var/turf/base_turf)
|
||||
for(var/turf/source in translation)
|
||||
|
||||
var/turf/target = translation[source]
|
||||
|
||||
if(target)
|
||||
if(base_area) ChangeArea(target, get_area(source))
|
||||
var/leave_turf = base_turf ? base_turf : get_base_turf_by_area(base_area ? base_area : source)
|
||||
translate_turf(source, target, leave_turf)
|
||||
if(base_area) ChangeArea(source, base_area)
|
||||
|
||||
//change the old turfs (Currently done by translate_turf for us)
|
||||
//for(var/turf/source in translation)
|
||||
// source.ChangeTurf(base_turf ? base_turf : get_base_turf_by_area(source), 1, 1)
|
||||
|
||||
// Parmaters for stupid historical reasons are:
|
||||
// T - Origin
|
||||
// B - Destination
|
||||
/proc/translate_turf(var/turf/T, var/turf/B, var/turftoleave = null)
|
||||
|
||||
//You can stay, though.
|
||||
if(istype(T,/turf/space))
|
||||
error("Tried to translate a space turf: src=[log_info_line(T)] dst=[log_info_line(B)]")
|
||||
return FALSE // TODO - Is this really okay to do nothing?
|
||||
|
||||
var/turf/X //New Destination Turf
|
||||
|
||||
//Are we doing shuttlework? Just to save another type check later.
|
||||
var/shuttlework = 0
|
||||
|
||||
//Shuttle turfs handle their own fancy moving.
|
||||
if(istype(T,/turf/simulated/shuttle))
|
||||
shuttlework = 1
|
||||
var/turf/simulated/shuttle/SS = T
|
||||
if(!SS.landed_holder) SS.landed_holder = new(turf = SS)
|
||||
X = SS.landed_holder.land_on(B)
|
||||
|
||||
//Generic non-shuttle turf move.
|
||||
else
|
||||
var/old_dir1 = T.dir
|
||||
var/old_icon_state1 = T.icon_state
|
||||
var/old_icon1 = T.icon
|
||||
var/old_underlays = T.underlays.Copy()
|
||||
var/old_decals = T.decals ? T.decals.Copy() : null
|
||||
|
||||
X = B.ChangeTurf(T.type)
|
||||
X.set_dir(old_dir1)
|
||||
X.icon_state = old_icon_state1
|
||||
X.icon = old_icon1
|
||||
X.copy_overlays(T, TRUE)
|
||||
X.underlays = old_underlays
|
||||
X.decals = old_decals
|
||||
|
||||
//Move the air from source to dest
|
||||
var/turf/simulated/ST = T
|
||||
if(istype(ST) && ST.zone)
|
||||
var/turf/simulated/SX = X
|
||||
if(!SX.air)
|
||||
SX.make_air()
|
||||
SX.air.copy_from(ST.zone.air)
|
||||
ST.zone.remove(ST)
|
||||
|
||||
var/z_level_change = FALSE
|
||||
if(T.z != X.z)
|
||||
z_level_change = TRUE
|
||||
|
||||
//Move the objects. Not forceMove because the object isn't "moving" really, it's supposed to be on the "same" turf.
|
||||
for(var/obj/O in T)
|
||||
if(O.simulated)
|
||||
O.loc = X
|
||||
O.update_light()
|
||||
if(z_level_change) // The objects still need to know if their z-level changed.
|
||||
O.onTransitZ(T.z, X.z)
|
||||
|
||||
//Move the mobs unless it's an AI eye or other eye type.
|
||||
for(var/mob/M in T)
|
||||
if(isEye(M)) continue // If we need to check for more mobs, I'll add a variable
|
||||
M.loc = X
|
||||
|
||||
if(z_level_change) // Same goes for mobs.
|
||||
M.onTransitZ(T.z, X.z)
|
||||
|
||||
if(istype(M, /mob/living))
|
||||
var/mob/living/LM = M
|
||||
LM.check_shadow() // Need to check their Z-shadow, which is normally done in forceMove().
|
||||
|
||||
if(shuttlework)
|
||||
var/turf/simulated/shuttle/SS = T
|
||||
SS.landed_holder.leave_turf(turftoleave)
|
||||
else if(turftoleave)
|
||||
T.ChangeTurf(turftoleave)
|
||||
else
|
||||
T.ChangeTurf(get_base_turf_by_area(T))
|
||||
|
||||
return TRUE
|
||||
|
||||
Reference in New Issue
Block a user