Files
CHOMPStation2/code/ZAS/Atom.dm
Leshana 8c09d39ef1 Convert ZAS "Airflow" into a subsystem plus fixes
* Port of the "Airflow" portions of Yonaguni/EuropaStation#618
* The "airflow" part of ZAS used to be handled by a sleep'd loop.   This has the potential to bunch up and lag.  Switching to a StonedMC managed subsystem improves it.
* Fixed to ensure that zshadow mobs cannot be blown around by the wind no matter how fierce.
* Added a message to mobs informing them when their boots save them from being wind-thwapped.
* Check w_class on non-item objects if they have it defined (might as well since var/w_class is on /obj)
* Tiny optimization of c_airblock
2018-01-30 12:28:45 -05:00

84 lines
2.3 KiB
Plaintext

/atom/var/pressure_resistance = ONE_ATMOSPHERE
/atom/proc/CanPass(atom/movable/mover, turf/target, height=1.5, air_group = 0)
//Purpose: Determines if the object (or airflow) can pass this atom.
//Called by: Movement, airflow.
//Inputs: The moving atom (optional), target turf, "height" and air group
//Outputs: Boolean if can pass.
return (!density || !height || air_group)
/turf/CanPass(atom/movable/mover, turf/target, height=1.5,air_group=0)
if(!target) return 0
if(istype(mover)) // turf/Enter(...) will perform more advanced checks
return !density
else // Now, doing more detailed checks for air movement and air group formation
if(target.blocks_air||blocks_air)
return 0
for(var/obj/obstacle in src)
if(!obstacle.CanPass(mover, target, height, air_group))
return 0
if(target != src)
for(var/obj/obstacle in target)
if(!obstacle.CanPass(mover, src, height, air_group))
return 0
return 1
//Convenience function for atoms to update turfs they occupy
/atom/movable/proc/update_nearby_tiles(need_rebuild)
if(!air_master)
return 0
for(var/turf/simulated/turf in locs)
air_master.mark_for_update(turf)
return 1
//Basically another way of calling CanPass(null, other, 0, 0) and CanPass(null, other, 1.5, 1).
//Returns:
// 0 - Not blocked
// AIR_BLOCKED - Blocked
// ZONE_BLOCKED - Not blocked, but zone boundaries will not cross.
// BLOCKED - Blocked, zone boundaries will not cross even if opened.
atom/proc/c_airblock(turf/other)
#ifdef ZASDBG
ASSERT(isturf(other))
#endif
return (AIR_BLOCKED*!CanPass(null, other, 0, 0))|(ZONE_BLOCKED*!CanPass(null, other, 1.5, 1))
turf/c_airblock(turf/other)
#ifdef ZASDBG
ASSERT(isturf(other))
#endif
if(((blocks_air & AIR_BLOCKED) || (other.blocks_air & AIR_BLOCKED)))
return BLOCKED
//Z-level handling code. Always block if there isn't an open space.
#ifdef MULTIZAS
if(other.z != src.z)
if(other.z < src.z)
if(!istype(src, /turf/simulated/open)) return BLOCKED
else
if(!istype(other, /turf/simulated/open)) return BLOCKED
#endif
if(((blocks_air & ZONE_BLOCKED) || (other.blocks_air & ZONE_BLOCKED)))
if(z == other.z)
return ZONE_BLOCKED
else
return AIR_BLOCKED
var/result = 0
for(var/mm in contents)
var/atom/movable/M = mm
result |= M.c_airblock(other)
if(result == BLOCKED) return BLOCKED
return result