Files
CHOMPStation2/code/modules/multiz/zshadow.dm
Leshana ebaf958179 Upgraded to "see-down" open spaces, inspired by Eris:
* Instead of open spaces simply showing a static image of the turf below, it shows the turf, all objects, and even moving mobs.
  * Controller updates the view to floor below fairly quickly; mobs update in real time.
  * Open space can be examined to see how deep it is.
  * Mobs are examinable even when on floor below, using a special "zshadow" mob.
  * Changes from Eris: Heavily re-written to handle layering, special cases, rewrote controller etc.  Shadow mobs don't break entering turfs, etc.
* Update to properly layer the objects from multiple "below" floors in the case of tripple-stacked or more z levels.
* Added constant defines for the planes in use.
* Added open_space.dmi with blank_open icon state for open space's darkening overlay.
2017-04-18 23:19:41 -04:00

86 lines
1.9 KiB
Plaintext

/mob // TODO: rewrite as obj.
var/mob/zshadow/shadow
/mob/zshadow
plane = OVER_OPENSPACE_PLANE
name = "shadow"
desc = "Z-level shadow"
status_flags = GODMODE
anchored = 1
unacidable = 1
density = 0
opacity = 0 // Don't trigger lighting recalcs gah! TODO - consider multi-z lighting.
auto_init = FALSE // We do not need to be initialize()d
var/mob/owner = null // What we are a shadow of.
/mob/zshadow/can_fall()
return FALSE
/mob/zshadow/New(var/mob/L)
if(!istype(L))
qdel(src)
return
..() // I'm cautious about this, but its the right thing to do.
owner = L
sync_icon(L)
/mob/Destroy()
if(shadow)
qdel(shadow)
shadow = null
. = ..()
/mob/zshadow/examine(mob/user, distance, infix, suffix)
return owner.examine(user, distance, infix, suffix)
// Relay some stuff they hear
/mob/zshadow/hear_say(var/message, var/verb = "says", var/datum/language/language = null, var/alt_name = "", var/italics = 0, var/mob/speaker = null, var/sound/speech_sound, var/sound_vol)
if(isliving(owner))
verb += " from above"
return owner.hear_say(message, verb, language, alt_name, italics, speaker, speech_sound, sound_vol)
/mob/zshadow/proc/sync_icon(var/mob/M)
name = M.name
icon = M.icon
icon_state = M.icon_state
//color = M.color
color = "#848484"
overlays = M.overlays
transform = M.transform
dir = M.dir
if(shadow)
shadow.sync_icon(src)
/mob/living/Move()
. = ..()
check_shadow()
/mob/living/forceMove()
. = ..()
check_shadow()
/mob/living/proc/check_shadow()
var/mob/M = src
if(isturf(M.loc))
var/turf/simulated/open/OS = GetAbove(src)
while(OS && istype(OS))
if(!M.shadow)
M.shadow = PoolOrNew(/mob/zshadow, M)
M.shadow.forceMove(OS)
M = M.shadow
OS = GetAbove(M)
// The topmost level does not need a shadow!
if(M.shadow)
qdel(M.shadow)
M.shadow = null
/mob/living/update_icons()
. = ..()
if(shadow)
shadow.sync_icon(src)
/mob/set_dir(new_dir)
. = ..()
if(shadow)
shadow.set_dir(new_dir)