[MIRROR] Multi-Z Support for Lazy Templates | Cleans up some turf flag misuse [MDB IGNORE] (#23794)

* Multi-Z Support for Lazy Templates | Cleans up some turf flag misuse

* Update hilbertshotel.dm

* Modular proc ref

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-09-19 19:26:14 +02:00
committed by GitHub
parent 4fa7c51670
commit d9624bdf97
38 changed files with 1054 additions and 191 deletions
@@ -112,9 +112,10 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
if(!storageTurf) //Blame subsystems for not allowing this to be in Initialize
if(!GLOB.hhStorageTurf)
var/datum/map_template/hilbertshotelstorage/storageTemp = new()
var/datum/turf_reservation/storageReservation = SSmapping.RequestBlockReservation(3, 3)
storageTemp.load(locate(storageReservation.bottom_left_coords[1], storageReservation.bottom_left_coords[2], storageReservation.bottom_left_coords[3]))
GLOB.hhStorageTurf = locate(storageReservation.bottom_left_coords[1]+1, storageReservation.bottom_left_coords[2]+1, storageReservation.bottom_left_coords[3])
var/datum/turf_reservation/storageReservation = SSmapping.request_turf_block_reservation(1, 1, 1)
var/turf/storage_turf = storageReservation.bottom_left_turfs[1]
storageTemp.load(storage_turf)
GLOB.hhStorageTurf = storage_turf
else
storageTurf = GLOB.hhStorageTurf
if(tryActiveRoom(chosenRoomNumber, target))
@@ -127,20 +128,30 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
if(activeRooms["[roomNumber]"])
var/datum/turf_reservation/roomReservation = activeRooms["[roomNumber]"]
do_sparks(3, FALSE, get_turf(user))
user.forceMove(locate(roomReservation.bottom_left_coords[1] + hotelRoomTemp.landingZoneRelativeX, roomReservation.bottom_left_coords[2] + hotelRoomTemp.landingZoneRelativeY, roomReservation.bottom_left_coords[3]))
var/turf/room_bottom_left = roomReservation.bottom_left_turfs[1]
user.forceMove(locate(
room_bottom_left.x + hotelRoomTemp.landingZoneRelativeX,
room_bottom_left.y + hotelRoomTemp.landingZoneRelativeY,
room_bottom_left.z,
))
return TRUE
return FALSE
/obj/item/hilbertshotel/proc/tryStoredRoom(roomNumber, mob/user)
if(storedRooms["[roomNumber]"])
var/datum/turf_reservation/roomReservation = SSmapping.RequestBlockReservation(hotelRoomTemp.width, hotelRoomTemp.height)
hotelRoomTempEmpty.load(locate(roomReservation.bottom_left_coords[1], roomReservation.bottom_left_coords[2], roomReservation.bottom_left_coords[3]))
var/datum/turf_reservation/roomReservation = SSmapping.request_turf_block_reservation(hotelRoomTemp.width, hotelRoomTemp.height, 1)
var/turf/room_turf = roomReservation.bottom_left_turfs[1]
hotelRoomTempEmpty.load(room_turf)
var/turfNumber = 1
for(var/x in 0 to hotelRoomTemp.width-1)
for(var/y in 0 to hotelRoomTemp.height-1)
for(var/atom/movable/A in storedRooms["[roomNumber]"][turfNumber])
if(istype(A.loc, /obj/item/abstracthotelstorage))//Don't want to recall something thats been moved
A.forceMove(locate(roomReservation.bottom_left_coords[1] + x, roomReservation.bottom_left_coords[2] + y, roomReservation.bottom_left_coords[3]))
A.forceMove(locate(
room_turf.x + x,
room_turf.y + y,
room_turf.z,
))
turfNumber++
for(var/obj/item/abstracthotelstorage/S in storageTurf)
if((S.roomNumber == roomNumber) && (S.parentSphere == src))
@@ -149,29 +160,39 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
activeRooms["[roomNumber]"] = roomReservation
linkTurfs(roomReservation, roomNumber)
do_sparks(3, FALSE, get_turf(user))
user.forceMove(locate(roomReservation.bottom_left_coords[1] + hotelRoomTemp.landingZoneRelativeX, roomReservation.bottom_left_coords[2] + hotelRoomTemp.landingZoneRelativeY, roomReservation.bottom_left_coords[3]))
user.forceMove(locate(
room_turf.x + hotelRoomTemp.landingZoneRelativeX,
room_turf.y + hotelRoomTemp.landingZoneRelativeY,
room_turf.z,
))
return TRUE
return FALSE
/obj/item/hilbertshotel/proc/sendToNewRoom(roomNumber, mob/user, chosen_room) //SKYRAT EDIT ADDITION - GHOST HOTEL UPDATE. Was sendToNewRoom(chosenRoomNumber, target)
var/datum/turf_reservation/roomReservation = SSmapping.RequestBlockReservation(hotelRoomTemp.width, hotelRoomTemp.height)
/obj/item/hilbertshotel/proc/sendToNewRoom(roomNumber, mob/user, chosen_room) //SKYRAT EDIT ADDITION - GHOST HOTEL UPDATE. Was sendToNewRoom(roomNumber, mob/user)
var/datum/turf_reservation/roomReservation = SSmapping.request_turf_block_reservation(hotelRoomTemp.width, hotelRoomTemp.height, 1)
var/turf/bottom_left = roomReservation.bottom_left_turfs[1]
var/datum/map_template/load_from = hotelRoomTemp
if(ruinSpawned && roomNumber == GLOB.hhMysteryRoomNumber)
hotelRoomTempLore.load(locate(roomReservation.bottom_left_coords[1], roomReservation.bottom_left_coords[2], roomReservation.bottom_left_coords[3]))
else
//SKYRAT EDIT ADDITION - GHOST HOTEL UPDATE
switch(chosen_room)
if("Apartment")
ghost_cafe_rooms_apartment.load(locate(roomReservation.bottom_left_coords[1], roomReservation.bottom_left_coords[2], roomReservation.bottom_left_coords[3]))
else
//SKYRAT EDIT END
hotelRoomTemp.load(locate(roomReservation.bottom_left_coords[1], roomReservation.bottom_left_coords[2], roomReservation.bottom_left_coords[3]))
load_from = hotelRoomTempLore
//SKYRAT EDIT ADDITION START - GHOST HOTEL UPDATE
else if(chosen_room == "Apartment")
load_from = ghost_cafe_rooms_apartment
//SKYRAT EDIT ADDITION END
load_from.load(bottom_left)
activeRooms["[roomNumber]"] = roomReservation
linkTurfs(roomReservation, roomNumber)
do_sparks(3, FALSE, get_turf(user))
user.forceMove(locate(roomReservation.bottom_left_coords[1] + hotelRoomTemp.landingZoneRelativeX, roomReservation.bottom_left_coords[2] + hotelRoomTemp.landingZoneRelativeY, roomReservation.bottom_left_coords[3]))
user.forceMove(locate(
bottom_left.x + hotelRoomTemp.landingZoneRelativeX,
bottom_left.y + hotelRoomTemp.landingZoneRelativeY,
bottom_left.z,
))
/obj/item/hilbertshotel/proc/linkTurfs(datum/turf_reservation/currentReservation, currentRoomnumber)
var/area/misc/hilbertshotel/currentArea = get_area(locate(currentReservation.bottom_left_coords[1], currentReservation.bottom_left_coords[2], currentReservation.bottom_left_coords[3]))
var/turf/room_bottom_left = currentReservation.bottom_left_turfs[1]
var/area/misc/hilbertshotel/currentArea = get_area(room_bottom_left)
currentArea.name = "Hilbert's Hotel Room [currentRoomnumber]"
currentArea.parentSphere = src
currentArea.storageTurf = storageTurf
@@ -187,9 +208,10 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
if(activeRooms.len)
for(var/x in activeRooms)
var/datum/turf_reservation/room = activeRooms[x]
var/turf/room_bottom_left = room.bottom_left_turfs[1]
for(var/i in 0 to hotelRoomTemp.width-1)
for(var/j in 0 to hotelRoomTemp.height-1)
for(var/atom/movable/A in locate(room.bottom_left_coords[1] + i, room.bottom_left_coords[2] + j, room.bottom_left_coords[3]))
for(var/atom/movable/A in locate(room_bottom_left.x + i, room_bottom_left.y + j, room_bottom_left.z))
if(ismob(A))
var/mob/M = A
if(M.mind)
@@ -271,7 +293,7 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
icon_state = "bluespace"
base_icon_state = "bluespace"
baseturfs = /turf/open/space/bluespace
flags_1 = NOJAUNT
turf_flags = NOJAUNT
explosive_resistance = INFINITY
var/obj/item/hilbertshotel/parentSphere
@@ -437,7 +459,11 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
storeRoom()
/area/misc/hilbertshotel/proc/storeRoom()
var/roomSize = (reservation.top_right_coords[1]-reservation.bottom_left_coords[1]+1)*(reservation.top_right_coords[2]-reservation.bottom_left_coords[2]+1)
var/turf/room_bottom_left = reservation.bottom_left_turfs[1]
var/turf/room_top_right = reservation.top_right_turfs[1]
var/roomSize = \
((room_top_right.x - room_bottom_left.x) + 1) * \
((room_top_right.y - room_bottom_left.y) + 1)
var/storage[roomSize]
var/turfNumber = 1
var/obj/item/abstracthotelstorage/storageObj = new(storageTurf)
@@ -447,7 +473,7 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
for(var/x in 0 to parentSphere.hotelRoomTemp.width-1)
for(var/y in 0 to parentSphere.hotelRoomTemp.height-1)
var/list/turfContents = list()
for(var/atom/movable/A in locate(reservation.bottom_left_coords[1] + x, reservation.bottom_left_coords[2] + y, reservation.bottom_left_coords[3]))
for(var/atom/movable/A in locate(room_bottom_left.x + x, room_bottom_left.y + y, room_bottom_left.z))
if(ismob(A) && !isliving(A))
continue //Don't want to store ghosts
turfContents += A