Skip to content

Commit

Permalink
Movement cross/uncross implementation. (#26762)
Browse files Browse the repository at this point in the history
* 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 9814f98.

* 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 <[email protected]>
Signed-off-by: warriorstar-orion <[email protected]>

* lewc review

* Apply suggestions from code review

Co-authored-by: Burzah <[email protected]>
Signed-off-by: warriorstar-orion <[email protected]>

* burza review

* fix bad args for grenade assemblies

* Update code/__DEFINES/is_helpers.dm

Co-authored-by: Luc <[email protected]>
Signed-off-by: warriorstar-orion <[email protected]>

---------

Signed-off-by: warriorstar-orion <[email protected]>
Co-authored-by: DGamerL <[email protected]>
Co-authored-by: Luc <[email protected]>
Co-authored-by: Burzah <[email protected]>
  • Loading branch information
4 people authored Dec 21, 2024
1 parent 3a3bdc8 commit 79bad42
Show file tree
Hide file tree
Showing 175 changed files with 2,494 additions and 1,325 deletions.
6 changes: 4 additions & 2 deletions code/__DEFINES/dcs/atom_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

// /atom

//from SSatoms InitAtom - Only if the atom was not deleted or failed initialization and has a loc
#define COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON "atom_init_success_on"
// from SSatoms InitAtom - Only if the atom was not deleted or failed initialization
#define COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZE "atom_init_success"
///from base of atom/attack_hulk(): (/mob/living/carbon/human)
Expand Down Expand Up @@ -38,12 +40,12 @@
#define COMSIG_ATOM_UPDATE_OVERLAYS "atom_update_overlays"
///from base of [/atom/proc/update_icon]: (signalOut, did_anything)
#define COMSIG_ATOM_UPDATED_ICON "atom_updated_icon"
///from base of atom/Entered(): (atom/movable/entering, /atom)
///from base of atom/Entered(): (atom/movable/entered, /atom)
#define COMSIG_ATOM_ENTERED "atom_entered"
///from base of atom/Exit(): (/atom/movable/exiting, /atom/newloc)
#define COMSIG_ATOM_EXIT "atom_exit"
#define COMPONENT_ATOM_BLOCK_EXIT (1<<0)
///from base of atom/Exited(): (atom/movable/exiting, atom/newloc)
///from base of atom/Exited(): (atom/movable/exiting, direction)
#define COMSIG_ATOM_EXITED "atom_exited"
///from base of atom/ex_act(): (severity, target)
#define COMSIG_ATOM_EX_ACT "atom_ex_act"
Expand Down
17 changes: 9 additions & 8 deletions code/__DEFINES/dcs/movable_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
* All signals send the source datum of the signal as the first argument
*/

///from base of atom/movable/Moved(): (/atom)
#define COMSIG_MOVABLE_PRE_MOVE "movable_pre_move"
#define COMPONENT_MOVABLE_BLOCK_PRE_MOVE (1<<0)
///from base of atom/movable/Moved(): (/atom, dir)
#define COMSIG_MOVABLE_MOVED "movable_moved"
///from base of atom/movable/Cross(): (/atom/movable)
#define COMSIG_MOVABLE_CROSS "movable_cross"
///from base of atom/movable/Crossed(): (/atom/movable)
#define COMSIG_MOVABLE_CROSSED "movable_crossed"
///when we cross over something (calling Crossed() on that atom)
#define COMSIG_CROSSED_MOVABLE "crossed_movable"
#define COMSIG_MOVABLE_CHECK_CROSS "movable_cross"
#define COMPONENT_BLOCK_CROSS (1<<0)
///from base of atom/movable/Move(): (/atom/movable)
#define COMSIG_MOVABLE_CHECK_CROSS_OVER "movable_cross_over"
///from base of atom/movable/Uncross(): (/atom/movable)
#define COMSIG_MOVABLE_UNCROSS "movable_uncross"
#define COMPONENT_MOVABLE_BLOCK_UNCROSS (1<<0)
///from base of atom/movable/Uncrossed(): (/atom/movable)
#define COMSIG_MOVABLE_UNCROSSED "movable_uncrossed"
///from base of atom/movable/Bump(): (/atom)
#define COMSIG_MOVABLE_BUMP "movable_bump"
#define COMPONENT_INTERCEPT_BUMPED (1<<0)
///from base of atom/movable/throw_impact(): (/atom/hit_atom, /datum/thrownthing/throwingdatum)
#define COMSIG_MOVABLE_IMPACT "movable_impact"
#define COMPONENT_MOVABLE_IMPACT_FLIP_HITPUSH (1<<0) //if true, flip if the impact will push what it hits
Expand All @@ -41,7 +42,7 @@
#define COMSIG_MOVABLE_THROW_LANDED "movable_throw_landed"
///from base of atom/movable/shove_impact(): (mob/living/target, mob/living/attacker)
#define COMSIG_MOVABLE_SHOVE_IMPACT "movable_shove_impact"
///from base of atom/movable/onTransitZ(): (old_z, new_z)
///from base of atom/movable/on_changed_z_level(): (turf/old_turf, turf/new_turf)
#define COMSIG_MOVABLE_Z_CHANGED "movable_ztransit"

/// Called just before something gets untilted
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,5 @@ GLOBAL_LIST_INIT(turfs_pass_meteor, typecacheof(list(
#define ispassmeteorturf(A) (is_type_in_typecache(A, GLOB.turfs_pass_meteor))

#define is_screen_atom(A) istype(A, /atom/movable/screen)

#define is_multi_tile_object(atom) (atom?.bound_width > world.icon_size || atom?.bound_height > world.icon_size)
16 changes: 16 additions & 0 deletions code/__DEFINES/movement_info.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// The arguments of this macro correspond directly to the argument order of /atom/movable/proc/Moved
#define SET_ACTIVE_MOVEMENT(_old_loc, _direction, _forced, _oldlocs) \
active_movement = list( \
_old_loc, \
_direction, \
_forced, \
_oldlocs, \
)

/// Finish any active movements
#define RESOLVE_ACTIVE_MOVEMENT \
if(active_movement) { \
var/__move_args = active_movement; \
active_movement = null; \
Moved(arglist(__move_args)); \
}
10 changes: 10 additions & 0 deletions code/__HELPERS/atom_helpers.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// Returns a list of all locations (except the area) the movable is within.
/proc/get_nested_locs(atom/movable/atom_on_location, include_turf = FALSE)
. = list()
var/atom/location = atom_on_location.loc
var/turf/our_turf = get_turf(atom_on_location)
while(location && location != our_turf)
. += location
location = location.loc
if(our_turf && include_turf) // At this point, only the turf is left, provided it exists.
. += our_turf
3 changes: 3 additions & 0 deletions code/controllers/subsystem/non_firing/SSatoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ SUBSYSTEM_DEF(atoms)
BadInitializeCalls[the_type] |= BAD_INIT_DIDNT_INIT
else
SEND_SIGNAL(A, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZE)
var/atom/location = A.loc
if(location)
SEND_SIGNAL(location, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON, A, arguments[1])

return qdeleted || QDELING(A)

Expand Down
23 changes: 16 additions & 7 deletions code/datums/beam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@
anchored = TRUE
var/datum/beam/owner

/obj/effect/ebeam/Initialize(mapload)
. = ..()
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_atom_entered),
)
AddElement(/datum/element/connect_loc, loc_connections)

/obj/effect/ebeam/proc/on_atom_entered(datum/source, atom/movable/entered)
SIGNAL_HANDLER // ON_ATOM_ENTERED
return

/obj/effect/ebeam/ex_act(severity)
return

Expand All @@ -131,9 +142,8 @@
/obj/effect/ebeam/singularity_act()
return

/obj/effect/ebeam/deadly/Crossed(atom/A, oldloc)
..()
A.ex_act(EXPLODE_DEVASTATE)
/obj/effect/ebeam/deadly/on_atom_entered(datum/source, atom/movable/entered)
entered.ex_act(EXPLODE_DEVASTATE)

/obj/effect/ebeam/vetus/Destroy()
for(var/mob/living/M in get_turf(src))
Expand All @@ -147,11 +157,10 @@
/obj/effect/ebeam/disintegration
layer = ON_EDGED_TURF_LAYER

/obj/effect/ebeam/disintegration/Crossed(atom/A, oldloc)
..()
if(!isliving(A))
/obj/effect/ebeam/disintegration/on_atom_entered(datum/source, atom/movable/entered)
if(!isliving(entered))
return
var/mob/living/L = A
var/mob/living/L = entered
var/damage = 50
if(L.stat == DEAD)
visible_message("<span class='danger'>[L] is disintegrated by the beam!</span>")
Expand Down
145 changes: 145 additions & 0 deletions code/datums/card_deck_table_tracker.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#define COMSIG_CARD_DECK_FIELD_CLEAR "card_deck_field_clear"

/datum/card_deck_table_tracker
/// How far away you can be (in terms of table squares).
var/max_table_distance
/// How far away you can be (euclidean distance).
var/max_total_distance
/// The UID of the deck
var/deck_uid
/// Indicate field activity with colors on the field's turfs.
var/debug = FALSE
/// The deck we're tracking.
var/atom/host

/// The list of floors from which a player can access the card field.
var/list/floors = list()
/// The list of tables that the card deck's location is contiguous with.
var/list/tables = list()

/datum/card_deck_table_tracker/New(atom/host_, max_table_distance_ = 5)
max_table_distance = max_table_distance_
max_total_distance = max_table_distance_
if(istype(host_, /obj/item/deck))
// this is important for tracking traits and attacking multiple cards. so it's not a true UID, sue me
var/obj/item/deck/D = host_
deck_uid = D.main_deck_id
else
deck_uid = host_.UID()

host = host_
RegisterSignal(host, COMSIG_MOVABLE_MOVED, PROC_REF(on_movable_moved))
lay_out_field()

/datum/card_deck_table_tracker/proc/on_movable_moved(datum/source, atom/old_loc, direction, forced)
SIGNAL_HANDLER // COMSIG_MOVABLE_MOVED
lay_out_field()

/datum/card_deck_table_tracker/proc/lay_out_field()
for(var/turf/floor in floors)
SEND_SIGNAL(floor, COMSIG_CARD_DECK_FIELD_CLEAR)

if(!isturf(host.loc))
return

floors.Cut()
tables.Cut()

crawl_along(host.loc, 0)

for(var/obj/structure/table in tables)
if(istype(table))
RegisterSignal(table, COMSIG_PARENT_QDELETING, PROC_REF(on_table_qdel), override = TRUE)

for(var/turf/turf in floors)
if(!istype(turf))
continue

if(debug)
turf.color = "#ffaaff"

RegisterSignal(turf, COMSIG_ATOM_ENTERED, PROC_REF(on_atom_entered))
RegisterSignal(turf, COMSIG_ATOM_EXITED, PROC_REF(on_atom_exited))
RegisterSignal(turf, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON, PROC_REF(on_new_atom_at_loc))
RegisterSignal(turf, COMSIG_CARD_DECK_FIELD_CLEAR, PROC_REF(on_card_deck_field_clear))

for(var/mob/living/L in turf)
on_atom_entered(turf, L)

/datum/card_deck_table_tracker/Destroy(force, ...)
host = null
for(var/turf/floor in floors)
SEND_SIGNAL(floor, COMSIG_CARD_DECK_FIELD_CLEAR)
for(var/mob/living/L in floor)
REMOVE_TRAIT(L, TRAIT_PLAYING_CARDS, "deck_[deck_uid]")

floors.Cut()
tables.Cut()

return ..()

/datum/card_deck_table_tracker/proc/on_atom_entered(turf/source, atom/movable/entered, old_loc)
SIGNAL_HANDLER // COMSIG_ATOM_ENTERED

var/mob/living/L = entered
if(istype(L))
ADD_TRAIT(L, TRAIT_PLAYING_CARDS, "deck_[deck_uid]")
if(debug)
source.color = "#ff0000"

/datum/card_deck_table_tracker/proc/on_atom_exited(turf/source, atom/movable/exited, direction)
SIGNAL_HANDLER // COMSIG_ATOM_EXITED

var/mob/living/L = exited
if(istype(L))
REMOVE_TRAIT(L, TRAIT_PLAYING_CARDS, "deck_[deck_uid]")
if(debug)
source.color = "#ffaaff"

/datum/card_deck_table_tracker/proc/on_table_qdel(datum/source)
SIGNAL_HANDLER // COMSIG_PARENT_QDELETING
lay_out_field()

/datum/card_deck_table_tracker/proc/on_new_atom_at_loc(turf/location, atom/created, init_flags)
SIGNAL_HANDLER // COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON
if(istable(created))
lay_out_field()

/datum/card_deck_table_tracker/proc/on_card_deck_field_clear(atom/target)
SIGNAL_HANDLER // COMSIG_CARD_DECK_FIELD_CLEAR
if(debug)
target.color = initial(target.color)

UnregisterSignal(target, list(
COMSIG_ATOM_ENTERED,
COMSIG_ATOM_EXITED,
COMSIG_CARD_DECK_FIELD_CLEAR,
COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON,
))

/datum/card_deck_table_tracker/proc/crawl_along(turf/current_turf, distance_from_start)
var/obj/structure/current_table = locate(/obj/structure/table) in current_turf

if(QDELETED(current_table))
// if there's no table here, we're still adjacent to a table, so this is a spot you could play from
floors |= current_turf
return

if(current_table in tables)
return

tables |= current_table
floors |= current_turf

if(distance_from_start + 1 > max_table_distance)
return

for(var/direction in GLOB.alldirs)
var/turf/next_turf = get_step(current_table, direction)
if(!istype(next_turf))
continue
if(get_dist_euclidian(get_turf(host), next_turf) > max_total_distance)
continue
.(next_turf, distance_from_start + 1)

#undef COMSIG_CARD_DECK_FIELD_CLEAR
21 changes: 16 additions & 5 deletions code/datums/components/caltrop.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
///Shoebypassing, walking interaction, silence
var/flags

///given to connect_loc to listen for something moving over target
var/static/list/crossed_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_entered),
)

var/cooldown = 0

/datum/component/caltrop/Initialize(_min_damage = 0, _max_damage = 0, _probability = 100, _weaken_duration = 6 SECONDS, _flags = NONE)
Expand All @@ -23,21 +28,23 @@
src.weaken_duration = _weaken_duration
src.flags = _flags

/datum/component/caltrop/RegisterWithParent()
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, PROC_REF(Crossed))
if(ismovable(parent))
AddComponent(/datum/component/connect_loc_behalf, parent, crossed_connections)
else
RegisterSignal(get_turf(parent), COMSIG_ATOM_ENTERED, PROC_REF(on_entered))

/datum/component/caltrop/proc/Crossed(datum/source, atom/movable/AM)
/datum/component/caltrop/proc/on_entered(atom/source, atom/movable/entered, turf/old_loc)
var/atom/A = parent
if(!has_gravity(A))
return

if(!prob(probability))
return

if(!ishuman(AM))
if(!ishuman(entered))
return

var/mob/living/carbon/human/H = AM
var/mob/living/carbon/human/H = entered

if(HAS_TRAIT(H, TRAIT_PIERCEIMMUNE))
return
Expand Down Expand Up @@ -82,3 +89,7 @@

cooldown = world.time
H.Weaken(weaken_duration)

/datum/component/caltrop/UnregisterFromParent()
if(ismovable(parent))
qdel(GetComponent(/datum/component/connect_loc_behalf))
Loading

0 comments on commit 79bad42

Please sign in to comment.