mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-19 18:17:52 +01:00
* refactor: Movement cross/uncross implementation.
* wrong var name
* fix unit tests dropping PDAs into nowhere
* Add documentation.
* remove unused constants
* say which procs are off limits
* fix simpleanimal z change runtime
* helps not to leave merge conflicts
* kill me
* fix typecast
* fix projectile/table collision
* treadmills don't cause MC to crash anymore
* connect_loc is appropriate here
* fix windoors and teleporters
* fix bonfires and clarify docs
* fix proximity sensors
Tested with sensors in crates, sensors in modsuits
Tested new proximity component with firing projectiles at singularity
Tested new proximity component with portable flashes
Tested new proximity component with facehuggers
* lint
* fix: polarized access helper false positives
* Revert "fix: polarized access helper false positives"
This reverts commit 9814f98cf6.
* hopefully the right change for mindflayer steam
* Changes following cameras
* fix glass table collision
* appears to fix doorspam
* fix ore bags not picking up ore
* fix signatures of /Exited
* remove debug log
* remove duplicate signal registrar
* fix emptying bags into locations
* I don't trust these nested Move calls
* use connect_loc for upgraded resonator fields
* use moveToNullspace
* fix spiderweb crossing
* fix pass checking for windows from a tile off
* fix bluespace closet/transparency issues
* fix mechs not interacting with doors and probably other things
* fix debug
* fix telepete
* add some docs
* stop trying to shoehorn prox monitor into cards
* I should make sure things build
* kill override signal warning
* undef signal
* not many prox monitors survive going off like this
* small fixes to storage
* make moving wormholes respect signals
* use correct signals for pulse demon
* fix pulse heart too
* fix smoke signals
* may have fucked singulo projectile swerve
* fix singulo projectile arcing
* remove duplicate define
* just look at it
* hopefully last cleanups of incorrect signal usage
* fix squeaking
* may god have mercy on my soul
* Apply suggestions from code review
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
* lewc review
* Apply suggestions from code review
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
* burza review
* fix bad args for grenade assemblies
* Update code/__DEFINES/is_helpers.dm
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
---------
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: DGamerL <daan.lyklema@gmail.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
169 lines
6.4 KiB
Plaintext
169 lines
6.4 KiB
Plaintext
#define FIELD_TURFS_KEY "field_turfs"
|
|
#define EDGE_TURFS_KEY "edge_turfs"
|
|
|
|
/**
|
|
* Movable and easily code-modified fields! Allows for custom AOE effects that affect movement
|
|
* and anything inside of them, and can do custom turf effects!
|
|
* Supports automatic recalculation/reset on movement.
|
|
*
|
|
* "What do I gain from using advanced over standard prox monitors?"
|
|
* - You can set different effects on edge vs field entrance
|
|
* - You can set effects when the proximity monitor starts and stops tracking a turf
|
|
*/
|
|
/datum/proximity_monitor/advanced
|
|
/// If TRUE, edge turfs will be included as "in the field" for effects
|
|
/// Can be used in certain situations where you may have effects that trigger only at the edge,
|
|
/// while also wanting the field effect to trigger at edge turfs as well
|
|
var/edge_is_a_field = FALSE
|
|
/// All turfs on the inside of the proximity monitor - range - 1 turfs
|
|
var/list/turf/field_turfs = list()
|
|
/// All turfs on the very last tile of the proximity monitor's radius
|
|
var/list/turf/edge_turfs = list()
|
|
|
|
/datum/proximity_monitor/advanced/Destroy()
|
|
cleanup_field()
|
|
return ..()
|
|
|
|
/datum/proximity_monitor/advanced/proc/cleanup_field()
|
|
for(var/turf/turf as anything in edge_turfs)
|
|
cleanup_edge_turf(turf)
|
|
edge_turfs = list()
|
|
for(var/turf/turf as anything in field_turfs)
|
|
cleanup_field_turf(turf)
|
|
field_turfs = list()
|
|
|
|
//Call every time the field moves (done automatically if you use update_center) or a setup specification is changed.
|
|
/datum/proximity_monitor/advanced/proc/recalculate_field(full_recalc = FALSE)
|
|
var/list/new_turfs = update_new_turfs()
|
|
|
|
var/list/old_field_turfs = field_turfs
|
|
var/list/old_edge_turfs = edge_turfs
|
|
field_turfs = new_turfs[FIELD_TURFS_KEY]
|
|
edge_turfs = new_turfs[EDGE_TURFS_KEY]
|
|
if(full_recalc)
|
|
field_turfs = list()
|
|
edge_turfs = list()
|
|
|
|
for(var/turf/old_turf as anything in old_field_turfs - field_turfs)
|
|
if(QDELETED(src))
|
|
return
|
|
cleanup_field_turf(old_turf)
|
|
for(var/turf/old_turf as anything in old_edge_turfs - edge_turfs)
|
|
if(QDELETED(src))
|
|
return
|
|
cleanup_edge_turf(old_turf)
|
|
|
|
if(full_recalc)
|
|
old_field_turfs = list()
|
|
old_edge_turfs = list()
|
|
field_turfs = new_turfs[FIELD_TURFS_KEY]
|
|
edge_turfs = new_turfs[EDGE_TURFS_KEY]
|
|
|
|
for(var/turf/new_turf as anything in field_turfs - old_field_turfs)
|
|
if(QDELETED(src))
|
|
return
|
|
setup_field_turf(new_turf)
|
|
|
|
for(var/turf/new_turf as anything in edge_turfs - old_edge_turfs)
|
|
if(QDELETED(src))
|
|
return
|
|
setup_edge_turf(new_turf)
|
|
|
|
/datum/proximity_monitor/advanced/on_initialized(turf/location, atom/created, init_flags)
|
|
. = ..()
|
|
on_entered(location, created, null)
|
|
|
|
/datum/proximity_monitor/advanced/on_entered(turf/source, atom/movable/entered, turf/old_loc)
|
|
. = ..()
|
|
if(get_dist(source, host) == current_range)
|
|
field_edge_crossed(entered, old_loc, source)
|
|
else
|
|
field_turf_crossed(entered, old_loc, source)
|
|
|
|
/datum/proximity_monitor/advanced/on_moved(atom/movable/movable, atom/old_loc)
|
|
. = ..()
|
|
if(ignore_if_not_on_turf)
|
|
//Early return if it's not the host that has moved.
|
|
if(movable != host)
|
|
return
|
|
//Cleanup the field if the host was on a turf but isn't anymore.
|
|
if(!isturf(host.loc))
|
|
if(isturf(old_loc))
|
|
cleanup_field()
|
|
return
|
|
recalculate_field(full_recalc = FALSE)
|
|
|
|
/datum/proximity_monitor/advanced/on_uncrossed(turf/source, atom/movable/gone, direction)
|
|
if(get_dist(source, host) == current_range)
|
|
field_edge_uncrossed(gone, source, get_turf(gone))
|
|
else
|
|
field_turf_uncrossed(gone, source, get_turf(gone))
|
|
|
|
/// Called when a turf in the field of the monitor is linked
|
|
/datum/proximity_monitor/advanced/proc/setup_field_turf(turf/target)
|
|
return
|
|
|
|
/// Called when a turf in the field of the monitor is unlinked
|
|
/// Do NOT call this manually, requires management of the field_turfs list
|
|
/datum/proximity_monitor/advanced/proc/cleanup_field_turf(turf/target)
|
|
PRIVATE_PROC(TRUE)
|
|
return
|
|
|
|
/// Called when a turf in the edge of the monitor is linked
|
|
/datum/proximity_monitor/advanced/proc/setup_edge_turf(turf/target)
|
|
if(edge_is_a_field) // If the edge is considered a field, set it up like one
|
|
setup_field_turf(target)
|
|
|
|
/// Called when a turf in the edge of the monitor is unlinked
|
|
/// Do NOT call this manually, requires management of the edge_turfs list
|
|
/datum/proximity_monitor/advanced/proc/cleanup_edge_turf(turf/target)
|
|
if(edge_is_a_field) // If the edge is considered a field, clean it up like one
|
|
cleanup_field_turf(target)
|
|
|
|
/datum/proximity_monitor/advanced/proc/update_new_turfs()
|
|
if(ignore_if_not_on_turf && !isturf(host.loc))
|
|
return list(FIELD_TURFS_KEY = list(), EDGE_TURFS_KEY = list())
|
|
var/list/local_field_turfs = list()
|
|
var/list/local_edge_turfs = list()
|
|
var/turf/center = get_turf(host)
|
|
if(current_range > 0)
|
|
local_field_turfs += RANGE_TURFS(current_range - 1, center)
|
|
if(current_range > 1)
|
|
local_edge_turfs = RANGE_TURFS(current_range, center) - local_field_turfs
|
|
return list(FIELD_TURFS_KEY = local_field_turfs, EDGE_TURFS_KEY = local_edge_turfs)
|
|
|
|
//Gets edge direction/corner, only works with square radius/WDH fields!
|
|
/datum/proximity_monitor/advanced/proc/get_edgeturf_direction(turf/T, turf/center_override = null)
|
|
var/turf/checking_from = get_turf(host)
|
|
if(istype(center_override))
|
|
checking_from = center_override
|
|
if(!(T in edge_turfs))
|
|
return
|
|
if(((T.x == (checking_from.x + current_range)) || (T.x == (checking_from.x - current_range))) && ((T.y == (checking_from.y + current_range)) || (T.y == (checking_from.y - current_range))))
|
|
return get_dir(checking_from, T)
|
|
if(T.x == (checking_from.x + current_range))
|
|
return EAST
|
|
if(T.x == (checking_from.x - current_range))
|
|
return WEST
|
|
if(T.y == (checking_from.y - current_range))
|
|
return SOUTH
|
|
if(T.y == (checking_from.y + current_range))
|
|
return NORTH
|
|
|
|
/datum/proximity_monitor/advanced/proc/field_turf_crossed(atom/movable/movable, turf/old_location, turf/new_location)
|
|
return
|
|
|
|
/datum/proximity_monitor/advanced/proc/field_turf_uncrossed(atom/movable/movable, turf/old_location, turf/new_location)
|
|
return
|
|
|
|
/datum/proximity_monitor/advanced/proc/field_edge_crossed(atom/movable/movable, turf/old_location, turf/new_location)
|
|
if(edge_is_a_field) // If the edge is considered a field, pass crossed to that
|
|
field_turf_crossed(movable, old_location, new_location)
|
|
|
|
/datum/proximity_monitor/advanced/proc/field_edge_uncrossed(atom/movable/movable, turf/old_location, turf/new_location)
|
|
if(edge_is_a_field) // If the edge is considered a field, pass uncrossed to that
|
|
field_turf_uncrossed(movable, old_location, new_location)
|
|
|
|
#undef FIELD_TURFS_KEY
|
|
#undef EDGE_TURFS_KEY
|