* Openturf icon fixes and improvements

* more things

* Remove some pointless/bad layering/planing

* yeah well I didn't need this anyways

* Refactor Z mimickry to be at /turf

* more refactoring

* Cleanup, use turf/flags instead of z_mimic_flags

* Fix turf/Entered()

* misc optimizations

* fixes

* Major icon smoothing optimizations

* Speed up boot some more

* Fix AO

* Remove some redundant code

* Tie Z-lights to Z-mimic instead of openturfs

* Fix an opacity issue with no_mutate turfs

* Fix some issues with Z-mimic AO not properly clearing

* Fix some OT->OT changetuf bugs

* Add helpers for changing Z-mimic operational state on turfs

* Fix some merge issues, change how F_CUT smoothhint works a bit.

* indentation

* SSopenturf -> SSzcopy
This commit is contained in:
Lohikar
2017-12-30 04:42:18 +02:00
committed by Erki
parent 6debd29cb7
commit 06514840f7
19 changed files with 301 additions and 264 deletions
@@ -1,27 +1,3 @@
/**
* Used to check wether or not an atom can pass through a turf.
*
* @param A The atom that's moving either up or down from this turf or to it.
* @param direction The direction of the atom's movement in relation to its
* current position.
*
* @return TRUE if A can pass in the movement direction, FALSE if not.
*/
/turf/proc/CanZPass(atom/A, direction)
if(z == A.z) //moving FROM this turf
return direction == UP //can't go below
else
if(direction == UP) //on a turf below, trying to enter
return FALSE
if(direction == DOWN) //on a turf above, trying to enter
return !density
/turf/simulated/open/CanZPass(atom, direction)
return TRUE
/turf/space/CanZPass(atom, direction)
return TRUE
/**
* Open turf class.
*
@@ -35,19 +11,14 @@
density = 0
pathweight = 100000 //Seriously, don't try and path over this one numbnuts
is_hole = TRUE
flags = MIMIC_BELOW | MIMIC_OVERWRITE | MIMIC_NO_AO
roof_type = null
var/tmp/turf/below
var/tmp/atom/movable/openspace/multiplier/shadower // Overlay used to multiply color of all OO overlays at once.
var/tmp/updating = FALSE // If this turf is queued for openturf update.
// A lazy list to contain a list of mobs who are currently scaling
// up this turf. Used in human/can_fall.
var/tmp/depth
var/tmp/list/climbers // A lazy list to contain a list of mobs who are currently scaling
// up this turf. Used in human/can_fall.
var/no_mutate = FALSE // If TRUE, SSopenturf will not modify the appearance of this turf.
var/tmp/list/climbers
// An override of turf/Enter() to make it so that magboots allow you to stop
// falling off the damned rock.
@@ -85,38 +56,10 @@
LAZYREMOVE(climbers, mover)
/turf/simulated/open/Destroy()
SSopenturf.openspace_turfs -= src
SSopenturf.queued_turfs -= src
QDEL_NULL(shadower)
for (var/atom/movable/openspace/overlay/OwO in src) // wats this~?
OwO.owning_turf_changed()
if (istype(above))
addtimer(CALLBACK(above, /turf/simulated/open/.proc/update), 0)
above = null
if (below)
below.above = null
below = null
LAZYCLEARLIST(climbers)
UNSETEMPTY(climbers)
return ..()
/**
* Used to check whether or not the specific open turf eventually leads into spess.
*
* @return TRUE if the turfs/holes eventually lead into space. FALSE otherwise.
*/
/turf/simulated/open/proc/is_above_space()
var/turf/T = GetBelow(src)
while (isopenturf(T))
T = GetBelow(T)
return istype(T, /turf/space)
/**
* Used to add a climber to the climbers list. Climbers do not fall down this specific tile.
*
@@ -163,7 +106,8 @@
icon = 'icons/turf/smooth/chasms_seethrough.dmi'
icon_state = "debug"
smooth = SMOOTH_TRUE | SMOOTH_BORDER | SMOOTH_NO_CLEAR_ICON
no_mutate = TRUE
smoothing_hints = SMOOTHHINT_CUT_F | SMOOTHHINT_ONLY_MATCH_TURF | SMOOTHHINT_TARGETS_NOT_UNIQUE
flags = MIMIC_BELOW
name = "hole"
/turf/simulated/open/chasm/airless
@@ -172,7 +116,7 @@
temperature = TCMB
icon_state = "debug_airless"
/turf/simulated/open/chasm/airless/Initialize()
/turf/simulated/open/chasm/Initialize()
. = ..()
icon_state = "Fill"
@@ -190,9 +134,9 @@
/turf/simulated/open/Initialize(mapload)
. = ..()
icon_state = "" // Clear out the debug icon.
SSopenturf.openspace_turfs += src
SSzcopy.openspace_turfs += src
shadower = new(src)
if (no_mutate && plane == PLANE_SPACE_BACKGROUND)
if (!(flags & MIMIC_OVERWRITE) && plane == PLANE_SPACE_BACKGROUND)
// If the plane is default and we're a no_mutate turf, force it to 0 so the icon works properly.
plane = 0
update(mapload)
@@ -219,8 +163,6 @@
if (is_hole && O.simulated)
ADD_FALLING_ATOM(O)
update_icon(mapload)
/turf/simulated/open/update_dirt()
return 0
@@ -230,13 +172,7 @@
O.hide(0)
/turf/simulated/open/update_icon(mapload)
if(!updating && below)
updating = TRUE
SSopenturf.queued_turfs += src
if (!mapload && above) // Even if we're already updating, the turf above us might not be.
// Cascade updates until we hit the top openturf.
above.update_icon()
update_mimic(!mapload)
/turf/simulated/open/attackby(obj/item/C as obj, mob/user as mob)
if (istype(C, /obj/item/stack/rods))
@@ -0,0 +1,39 @@
// Updates whatever openspace components may be mimicing us. On turfs this queues an openturf update on the above openturf, on movables this updates their bound movable (if present). Meaningless on any type other than `/turf` or `/atom/movable` (incl. children).
/atom/proc/update_above()
return
/**
* Used to check wether or not an atom can pass through a turf.
*
* @param A The atom that's moving either up or down from this turf or to it.
* @param direction The direction of the atom's movement in relation to its
* current position.
*
* @return TRUE if A can pass in the movement direction, FALSE if not.
*/
/turf/proc/CanZPass(atom/A, direction)
if(z == A.z) //moving FROM this turf
return direction == UP //can't go below
else
if(direction == UP) //on a turf below, trying to enter
return FALSE
if(direction == DOWN) //on a turf above, trying to enter
return !density
/**
* Used to check whether or not the specific open turf eventually leads into spess.
*
* @return TRUE if the turf eventually leads into space. FALSE otherwise.
*/
/turf/proc/is_above_space()
var/turf/T = GetBelow(src)
while (T && (T.flags & MIMIC_BELOW))
T = GetBelow(T)
return istype(T, /turf/space)
/turf/simulated/open/CanZPass(atom, direction)
return TRUE
/turf/space/CanZPass(atom, direction)
return TRUE
@@ -1,36 +1,3 @@
/*
== Openspace ==
This file contains the openspace movable types, including interactrion code and openspace helpers.
Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
*/
// Updates whatever openspace components may be mimicing us. On turfs this queues an openturf update on the above openturf, on movables this updates their bound movable (if present). Meaningless on any type other than `/turf` or `/atom/movable` (incl. children).
/atom/proc/update_above()
return
/turf
// Reference to any open turf that might be above us to speed up atom Entered() updates.
var/tmp/turf/simulated/open/above
var/tmp/atom/movable/openspace/turf_overlay/bound_overlay
/turf/Entered(atom/movable/thing, atom/oldLoc)
. = ..()
if (above && !thing.no_z_overlay && !thing.bound_overlay && !isopenturf(oldLoc))
above.update_icon()
/turf/Destroy()
above = null
if (bound_overlay)
QDEL_NULL(bound_overlay)
return ..()
/turf/update_above()
if (istype(above))
above.update_icon()
/atom/movable
var/tmp/atom/movable/openspace/overlay/bound_overlay // The overlay that is directly mirroring us that we proxy movement to.
var/no_z_overlay // If TRUE, this atom will not be drawn on open turfs.
@@ -59,9 +26,9 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
if (!bound_overlay)
return
if (isopenturf(bound_overlay.loc))
if (TURF_IS_MIMICING(loc))
if (!bound_overlay.queued)
SSopenturf.queued_overlays += bound_overlay
SSzcopy.queued_overlays += bound_overlay
bound_overlay.queued = TRUE
else
qdel(bound_overlay)
@@ -117,7 +84,7 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
)
/atom/movable/openspace/multiplier/Destroy()
var/turf/simulated/open/myturf = loc
var/turf/myturf = loc
if (istype(myturf))
myturf.shadower = null
@@ -168,10 +135,10 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
/atom/movable/openspace/overlay/New()
initialized = TRUE
SSopenturf.openspace_overlays += src
SSzcopy.openspace_overlays += src
/atom/movable/openspace/overlay/Destroy()
SSopenturf.openspace_overlays -= src
SSzcopy.openspace_overlays -= src
if (associated_atom)
associated_atom.bound_overlay = null
@@ -194,9 +161,9 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
/atom/movable/openspace/overlay/examine(mob/examiner)
associated_atom.examine(examiner)
/atom/movable/openspace/overlay/forceMove(atom/dest)
/atom/movable/openspace/overlay/forceMove(turf/dest)
. = ..()
if (isopenturf(dest))
if (TURF_IS_MIMICING(dest))
if (destruction_timer)
deltimer(destruction_timer)
destruction_timer = null
+91
View File
@@ -0,0 +1,91 @@
/turf
// Reference to any open turf that might be above us to speed up atom Entered() updates.
var/tmp/turf/above
var/tmp/turf/below
var/tmp/atom/movable/openspace/turf_overlay/bound_overlay
var/tmp/atom/movable/openspace/multiplier/shadower // Overlay used to multiply color of all OO overlays at once.
/turf/Entered(atom/movable/thing, turf/oldLoc)
. = ..()
if (thing.bound_overlay || !thing.no_z_overlay || !above || !(above.flags & MIMIC_BELOW) || (isturf(oldLoc) && oldLoc.above && (oldLoc.above.flags & MIMIC_BELOW)))
return
above.update_mimic()
/turf/update_above()
if (TURF_IS_MIMICING(above))
above.update_mimic()
/turf/proc/update_mimic(recurse = TRUE)
if (!(flags & MIMIC_BELOW))
return
if (below && !(flags & MIMIC_QUEUED))
flags |= MIMIC_QUEUED
SSzcopy.queued_turfs += src
if (recurse)
update_above() // Even if we're already updating, the turf above us might not be.
// Enables Z-mimic for a turf that didn't already have it enabled.
/turf/proc/enable_zmimic(additional_flags = 0)
if (flags & MIMIC_BELOW)
return FALSE
flags |= MIMIC_BELOW | additional_flags
setup_zmimic(FALSE)
return TRUE
// Disables Z-mimic for a turf.
/turf/proc/disable_zmimic()
if (!(flags & MIMIC_BELOW))
return FALSE
flags &= ~MIMIC_BELOW
cleanup_zmimic()
// Sets up Z-mimic for this turf. You shouldn't call this directly 99% of the time.
/turf/proc/setup_zmimic(mapload)
if (shadower)
CRASH("Attempt to enable Z-mimic on already-enabled turf!")
shadower = new(src)
SSzcopy.openspace_turfs += src
var/turf/under = GetBelow(src)
if (under)
below = under
below.above = src
update_mimic(!mapload) // Only recursively update if the map isn't loading.
// Cleans up Z-mimic objects for this turf. You shouldn't call this directly 99% of the time.
/turf/proc/cleanup_zmimic()
SSzcopy.openspace_turfs -= src
if (flags & MIMIC_QUEUED)
SSzcopy.queued_turfs -= src
QDEL_NULL(shadower)
for (var/atom/movable/openspace/overlay/OwO in src) // wats this~?
OwO.owning_turf_changed()
if (above)
above.update_mimic()
if (below)
below.above = null
below = null
// Movable for mimicing turfs that don't allow appearance mutation.
/atom/movable/openspace/turf_overlay
plane = OPENTURF_MAX_PLANE
/atom/movable/openspace/turf_overlay/attackby(obj/item/W, mob/user)
loc.attackby(W, user)
/atom/movable/openspace/turf_overlay/attack_hand(mob/user as mob)
loc.attack_hand(user)
/atom/movable/openspace/turf_overlay/attack_generic(mob/user as mob)
loc.attack_generic(user)
/atom/movable/openspace/turf_overlay/examine(mob/examiner)
loc.examine(examiner)