mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-24 13:56:34 +01:00
- moves stuff to more sane places so modules folder isn't so messy - adds a world system that is the start of being able to data-define world locations and having the game act differently based on which location a map is in there's no ability to separate 'pre-load map' (and a way for persistence to inject this so we can have moving maps yet) but we can add it in later since things are decently abstracted.
76 lines
2.7 KiB
Plaintext
76 lines
2.7 KiB
Plaintext
#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/simulated/wall/durasteel)
|
|
|
|
SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL)
|
|
TEST_ASSERT_EQUAL(watcher.times_called, 2, "After changing turf, connect_loc didn't reconnect it")
|
|
|
|
current_turf.ChangeTurf(/turf/simulated/floor/carpet/arcadecarpet)
|
|
SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL)
|
|
TEST_ASSERT_EQUAL(watcher.times_called, 3, "After changing turf a second time, connect_loc didn't reconnect it")
|
|
|
|
/datum/unit_test/connect_loc_change_turf/Destroy()
|
|
run_loc_floor_bottom_left.ChangeTurf(old_turf_type)
|
|
return ..()
|
|
|
|
/// Tests that multiple objects can have connect_loc on the same turf without runtimes.
|
|
/datum/unit_test/connect_loc_multiple_on_turf
|
|
|
|
/datum/unit_test/connect_loc_multiple_on_turf/Run()
|
|
var/obj/item/watches_mock_calls/watcher_one = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left)
|
|
qdel(watcher_one)
|
|
|
|
var/obj/item/watches_mock_calls/watcher_two = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left)
|
|
qdel(watcher_two)
|
|
|
|
/obj/item/watches_mock_calls
|
|
var/times_called
|
|
|
|
/obj/item/watches_mock_calls/Initialize(mapload)
|
|
. = ..()
|
|
|
|
var/static/list/connections = list(
|
|
COMSIG_MOCK_SIGNAL = PROC_REF(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
|