mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
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:
co-authored by
Emmett Gaines
parent
a7defcd22d
commit
0d24cdea3c
@@ -48,6 +48,7 @@
|
||||
#include "chain_pull_through_space.dm"
|
||||
#include "combat.dm"
|
||||
#include "component_tests.dm"
|
||||
#include "connect_loc.dm"
|
||||
#include "confusion.dm"
|
||||
#include "crayons.dm"
|
||||
#include "designs.dm"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#define COMSIG_MOCK_SIGNAL "mock_signal"
|
||||
|
||||
/// Test that the connect_loc element handles basic movement cases
|
||||
/datum/unit_test/connect_loc_basic
|
||||
|
||||
/datum/unit_test/connect_loc_basic/Run()
|
||||
var/obj/item/watches_mock_calls/watcher = allocate(/obj/item/watches_mock_calls)
|
||||
|
||||
var/turf/current_turf = get_turf(watcher)
|
||||
|
||||
SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL)
|
||||
TEST_ASSERT_EQUAL(watcher.times_called, 1, "After firing mock signal, connect_loc didn't send it")
|
||||
|
||||
watcher.forceMove(run_loc_floor_top_right)
|
||||
|
||||
SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL)
|
||||
TEST_ASSERT_EQUAL(watcher.times_called, 1, "Mock signal was fired on old turf, but connect_loc still picked it up")
|
||||
|
||||
current_turf = get_turf(watcher)
|
||||
SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL)
|
||||
TEST_ASSERT_EQUAL(watcher.times_called, 2, "Mock signal was fired after turf move, but it wasn't picked up")
|
||||
|
||||
/// Test that the connect_loc element handles turf changes
|
||||
/datum/unit_test/connect_loc_change_turf
|
||||
var/old_turf_type
|
||||
|
||||
/datum/unit_test/connect_loc_change_turf/Run()
|
||||
var/obj/item/watches_mock_calls/watcher = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left)
|
||||
|
||||
var/turf/current_turf = get_turf(watcher)
|
||||
old_turf_type = current_turf.type
|
||||
|
||||
SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL)
|
||||
TEST_ASSERT_EQUAL(watcher.times_called, 1, "After firing mock signal, connect_loc didn't send it")
|
||||
|
||||
current_turf.ChangeTurf(/turf/closed/wall)
|
||||
|
||||
current_turf = get_turf(watcher)
|
||||
SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL)
|
||||
TEST_ASSERT_EQUAL(watcher.times_called, 2, "After changing turf, connect_loc didn't reconnect it")
|
||||
|
||||
/datum/unit_test/connect_loc_change_turf/Destroy()
|
||||
run_loc_floor_bottom_left.ChangeTurf(old_turf_type)
|
||||
return ..()
|
||||
|
||||
/obj/item/watches_mock_calls
|
||||
var/times_called
|
||||
|
||||
/obj/item/watches_mock_calls/Initialize()
|
||||
. = ..()
|
||||
|
||||
var/static/list/connections = list(
|
||||
COMSIG_MOCK_SIGNAL = .proc/on_receive_mock_signal,
|
||||
)
|
||||
|
||||
AddElement(/datum/element/connect_loc, connections)
|
||||
|
||||
/obj/item/watches_mock_calls/proc/on_receive_mock_signal(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
times_called += 1
|
||||
|
||||
#undef COMSIG_MOCK_SIGNAL
|
||||
Reference in New Issue
Block a user