Files
Bubberstation/code/modules/unit_tests/teleporters.dm
MrDas a8103bdc5a Turning off teleport beacon actually disables teleporting to it and adds unit tests for teleporter (#78183)
## About The Pull Request
Teleport beacon can be turned on and off. Turning off only removes it
from the list of selectable locations on the teleporter, you can still
teleport to it. In this PR <s>I add weak_ref removal on turning off the
beacon (of which I'm not certain if that's a good solution, but seems to
work)</s> I use signals to handle turning off the teleportation.
## Why It's Good For The Game
You can turn off the beacon to stop someone teleporting to your location
and it doesn't mislead players into thinking disabled teleport beacon
cannot be teleported to anymore.
## Changelog
🆑
fix: You can no longer teleport to disabled beacon if the teleporter was
previously locked-on to it.
/🆑
2023-09-13 21:40:53 +01:00

19 lines
1.2 KiB
Plaintext

/datum/unit_test/teleporter/Run()
// Put down the teleporter machinery
var/obj/machinery/teleport/hub/hub = allocate(/obj/machinery/teleport/hub)
var/obj/machinery/teleport/station/station = allocate(/obj/machinery/teleport/station, locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z))
var/obj/machinery/computer/teleporter/computer = allocate(/obj/machinery/computer/teleporter, locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z))
var/obj/item/beacon/beacon = allocate(/obj/item/beacon)
TEST_ASSERT_EQUAL(hub.power_station, station, "Hub didn't link to the station")
TEST_ASSERT_EQUAL(station.teleporter_console, computer, "Station didn't link to the teleporter console")
TEST_ASSERT_EQUAL(station.teleporter_hub, hub, "Station didn't link to the hub")
TEST_ASSERT_EQUAL(computer.power_station, station, "Teleporter console didn't link to the hub")
computer.set_teleport_target(beacon)
TEST_ASSERT_EQUAL(computer.target_ref, beacon.weak_reference, "Teleporter didn't target beacon correctly")
computer.set_teleport_target(beacon)
beacon.turn_off()
TEST_ASSERT_NULL(computer.target_ref, "Teleporter beacon isn't properly turned off.")