Remove Uncross() and CheckExit(), add connect_loc element to cover the cases we used it for (#58188)

* Remove Uncross(), add create_loc element

* Update on ChangeTurf

* Explicit return

* Hold onto elements and remove TEST_FOCUS

* Remove UNIT_TESTS compile flag

* Follow my own advice.

* Comment about Uncross + CRASH

* Remove /atom/Exit ..()

* Apply suggestions from code review

Co-authored-by: Emmett Gaines <ninjanomnom@gmail.com>

* Use keyed locs

* Re-add Bump()

* Superfluous check

* Correct change turf signal, remove old continue check

* Fix compile failure

* Fix tests

* Don't create element for fulltile windows

* Correctly unregister old location

Co-authored-by: Emmett Gaines <ninjanomnom@gmail.com>
This commit is contained in:
Mothblocks
2021-04-08 15:52:00 -04:00
committed by GitHub
co-authored by Emmett Gaines
parent a7defcd22d
commit 0d24cdea3c
19 changed files with 301 additions and 101 deletions
+33 -13
View File
@@ -15,17 +15,15 @@
density = FALSE
climbable = FALSE
/obj/structure/railing/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS ,null,CALLBACK(src, .proc/can_be_rotated),CALLBACK(src,.proc/after_rotation))
/obj/structure/railing/Initialize()
. = ..()
ini_dir = dir
if(climbable)
AddElement(/datum/element/climbable)
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS ,null,CALLBACK(src, .proc/can_be_rotated),CALLBACK(src,.proc/after_rotation))
init_connect_loc_element()
/obj/structure/railing/attackby(obj/item/I, mob/living/user, params)
..()
add_fingerprint(user)
@@ -81,15 +79,37 @@
..()
return TRUE
/obj/structure/railing/CheckExit(atom/movable/mover, turf/target)
..()
if(get_dir(loc, target) & dir)
var/checking = PHASING | FLYING | FLOATING
return !density || mover.throwing || mover.movement_type & checking || mover.move_force >= MOVE_FORCE_EXTREMELY_STRONG
return TRUE
/obj/structure/railing/proc/init_connect_loc_element()
var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = .proc/on_exit,
)
/obj/structure/railing/corner/CheckExit()
return TRUE
AddElement(/datum/element/connect_loc, loc_connections)
/obj/structure/railing/proc/on_exit(datum/source, atom/movable/leaving, atom/new_location)
SIGNAL_HANDLER
if(!(get_dir(leaving.loc, new_location) & dir))
return
if (!density)
return
if (leaving.throwing)
return
if (leaving.movement_type & (PHASING | FLYING | FLOATING))
return
if (leaving.move_force >= MOVE_FORCE_EXTREMELY_STRONG)
return
leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT
// Corner railings don't block anything, so they don't create the element.
/obj/structure/railing/corner/init_connect_loc_element()
return
/obj/structure/railing/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
+14 -7
View File
@@ -33,6 +33,13 @@
force_open_above()
build_signal_listener()
update_surrounding()
var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = .proc/on_exit,
)
AddElement(/datum/element/connect_loc, loc_connections)
return ..()
/obj/structure/stairs/Destroy()
@@ -53,13 +60,13 @@
if(S)
S.update_appearance()
/obj/structure/stairs/Uncross(atom/movable/AM, atom/newloc)
if(!newloc || !AM)
return ..()
if(!isobserver(AM) && isTerminator() && (get_dir(src, newloc) == dir))
stair_ascend(AM)
return FALSE
return ..()
/obj/structure/stairs/proc/on_exit(datum/source, atom/movable/leaving, atom/new_location)
SIGNAL_HANDLER
if(!isobserver(leaving) && isTerminator() && (get_dir(src, new_location) == dir))
INVOKE_ASYNC(src, .proc/stair_ascend, leaving)
leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT
/obj/structure/stairs/Cross(atom/movable/AM)
if(isTerminator() && (get_dir(src, AM) == dir))
@@ -29,12 +29,18 @@
var/state = "01" //How far the door assembly has progressed
CanAtmosPass = ATMOS_PASS_PROC
/obj/structure/windoor_assembly/New(loc, set_dir)
..()
/obj/structure/windoor_assembly/Initialize(loc, set_dir)
. = ..()
if(set_dir)
setDir(set_dir)
air_update_turf(TRUE, TRUE)
var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = .proc/on_exit,
)
AddElement(/datum/element/connect_loc, loc_connections)
/obj/structure/windoor_assembly/Destroy()
density = FALSE
air_update_turf(TRUE, FALSE)
@@ -68,13 +74,15 @@
else
return 1
/obj/structure/windoor_assembly/CheckExit(atom/movable/mover, turf/target)
if(mover.pass_flags & pass_flags_self)
return TRUE
if(get_dir(loc, target) == dir)
return !density
else
return TRUE
/obj/structure/windoor_assembly/proc/on_exit(datum/source, atom/movable/leaving, atom/new_location)
SIGNAL_HANDLER
if (leaving.pass_flags & pass_flags_self)
return
if (get_dir(loc, new_location) == dir && density)
leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT
/obj/structure/windoor_assembly/attackby(obj/item/W, mob/user, params)
//I really should have spread this out across more states but thin little windoors are hard to sprite.
+18 -6
View File
@@ -68,6 +68,13 @@
flags_1 |= ALLOW_DARK_PAINTS_1
RegisterSignal(src, COMSIG_OBJ_PAINTED, .proc/on_painted)
var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = .proc/on_exit,
)
if (flags_1 & ON_BORDER_1)
AddElement(/datum/element/connect_loc, loc_connections)
/obj/structure/window/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS ,null,CALLBACK(src, .proc/can_be_rotated),CALLBACK(src,.proc/after_rotation))
@@ -117,13 +124,18 @@
return TRUE
/obj/structure/window/CheckExit(atom/movable/O, turf/target)
if(istype(O) && (O.pass_flags & pass_flags_self))
return TRUE
if(!fulltile && get_dir(O.loc, target) == dir)
return !density
return TRUE
/obj/structure/window/proc/on_exit(datum/source, atom/movable/leaving, atom/new_location)
SIGNAL_HANDLER
if (istype(leaving) && (leaving.pass_flags & pass_flags_self))
return
if (fulltile)
return
if(get_dir(leaving.loc, new_location) == dir && density)
leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT
/obj/structure/window/attack_tk(mob/user)
user.changeNext_move(CLICK_CD_MELEE)