Adds a stationloving component to replace a couple of flags and SSinbounds with (#37436)

* station lovin' happened so fast

* Update stationloving.dm

* less qdel memes

* imbue soul signal

* rename imbue soul signal

* dupemode

* henk

* Update atoms_movable.dm

* Update nuclearbomb.dm

* Update nuclearbomb.dm
This commit is contained in:
vuonojenmustaturska
2018-04-27 15:35:53 +03:00
committed by CitadelStationBot
parent 4702d0232e
commit d6b48869d8
12 changed files with 100 additions and 148 deletions

View File

@@ -251,24 +251,6 @@
return 1
/atom/movable/Destroy(force)
var/inform_admins = (flags_2 & INFORM_ADMINS_ON_RELOCATE_2)
var/stationloving = (flags_2 & STATIONLOVING_2)
if(inform_admins && force)
var/turf/T = get_turf(src)
message_admins("[src] has been !!force deleted!! in [ADMIN_COORDJMP(T)].")
log_game("[src] has been !!force deleted!! in [COORD(T)].")
if(stationloving && !force)
var/turf/currentturf = get_turf(src)
var/turf/targetturf = relocate()
log_game("[src] has been destroyed in [COORD(currentturf)]. Moving it to [COORD(targetturf)].")
if(inform_admins)
message_admins("[src] has been destroyed in [ADMIN_COORDJMP(currentturf)]. Moving it to [ADMIN_COORDJMP(targetturf)].")
return QDEL_HINT_LETMELIVE
if(stationloving && force)
STOP_PROCESSING(SSinbounds, src)
QDEL_NULL(proximity_monitor)
QDEL_NULL(language_holder)
@@ -365,6 +347,7 @@
loc = null
/atom/movable/proc/onTransitZ(old_z,new_z)
SendSignal(COMSIG_MOVABLE_Z_CHANGED, old_z, new_z)
for (var/item in src) // Notify contents of Z-transition. This can be overridden IF we know the items contents do not care.
var/atom/movable/AM = item
AM.onTransitZ(old_z,new_z)
@@ -632,88 +615,6 @@
animate(src, pixel_y = initial(pixel_y), time = 10)
floating = FALSE
/* Stationloving
*
* A stationloving atom will always teleport back to the station
* if it ever leaves the station z-levels or CentCom. It will also,
* when Destroy() is called, will teleport to a random turf on the
* station.
*
* The turf is guaranteed to be "safe" for normal humans, probably.
* If the station is SUPER SMASHED UP, it might not work.
*
* Here are some important procs:
* relocate()
* moves the atom to a safe turf on the station
*
* check_in_bounds()
* regularly called and checks if `in_bounds()` returns true. If false, it
* triggers a `relocate()`.
*
* in_bounds()
* By default, checks that the atom's z is the station z or centcom.
*/
/atom/movable/proc/set_stationloving(state, inform_admins=FALSE)
var/currently = (flags_2 & STATIONLOVING_2)
if(inform_admins)
flags_2 |= INFORM_ADMINS_ON_RELOCATE_2
else
flags_2 &= ~INFORM_ADMINS_ON_RELOCATE_2
if(state == currently)
return
else if(!state)
STOP_PROCESSING(SSinbounds, src)
flags_2 &= ~STATIONLOVING_2
else
START_PROCESSING(SSinbounds, src)
flags_2 |= STATIONLOVING_2
/atom/movable/proc/relocate()
var/targetturf = find_safe_turf()
if(!targetturf)
if(GLOB.blobstart.len > 0)
targetturf = get_turf(pick(GLOB.blobstart))
else
throw EXCEPTION("Unable to find a blobstart landmark")
if(ismob(loc))
var/mob/M = loc
M.transferItemToLoc(src, targetturf, TRUE) //nodrops disks when?
else if(loc.SendSignal(COMSIG_CONTAINS_STORAGE))
loc.SendSignal(COMSIG_TRY_STORAGE_TAKE, src, targetturf, TRUE)
else
forceMove(targetturf)
// move the disc, so ghosts remain orbiting it even if it's "destroyed"
return targetturf
/atom/movable/proc/check_in_bounds()
if(in_bounds())
return
else
var/turf/currentturf = get_turf(src)
to_chat(get(src, /mob), "<span class='danger'>You can't help but feel that you just lost something back there...</span>")
var/turf/targetturf = relocate()
log_game("[src] has been moved out of bounds in [COORD(currentturf)]. Moving it to [COORD(targetturf)].")
if(flags_2 & INFORM_ADMINS_ON_RELOCATE_2)
message_admins("[src] has been moved out of bounds in [ADMIN_COORDJMP(currentturf)]. Moving it to [ADMIN_COORDJMP(targetturf)].")
/atom/movable/proc/in_bounds()
var/static/list/allowed_shuttles = typecacheof(list(/area/shuttle/syndicate, /area/shuttle/escape, /area/shuttle/pod_1, /area/shuttle/pod_2, /area/shuttle/pod_3, /area/shuttle/pod_4))
var/turf/T = get_turf(src)
if (!T)
return FALSE
if (is_station_level(T.z) || is_centcom_level(T.z))
return TRUE
if (is_transit_level(T.z))
var/area/A = T.loc
if (is_type_in_typecache(A, allowed_shuttles))
return TRUE
return FALSE
/* Language procs */
/atom/movable/proc/get_language_holder(shadow=TRUE)
if(language_holder)