Files
Bubberstation/code/datums/shuttles/_shuttle.dm
Thunder12345 346297b090 Modular Shuttle Madness (#90412)
## About The Pull Request

Modularises the scrapheap challenge shuttle. Adds support to allow
shuttles to load modularly.

TODO:
- [x] Make it work why does this not load any more I fixed this before
- [x] After above, check if weird airflow issues still persist
~Find a less unusual solution for holding the shuttle back until it
loads?~ Not unless I want to rewrite the entirety of shuttle loading or
something

## Why It's Good For The Game

Modular generation makes the scrapheap challenge feel more "scrappy",
with it being put together of different parts each time you see it.
Added modularisation support allows for more modular shuttle trickery in
future.

## Changelog
🆑
add: Added support for modularly loaded shuttles.
add: The Scrapheap Challenge emergency shuttle now comes in randomly
generated variants.
/🆑
2025-04-17 17:37:11 -07:00

99 lines
3.3 KiB
Plaintext

/datum/map_template/shuttle
name = "Base Shuttle Template"
var/prefix = "_maps/shuttles/"
var/suffix
/**
* Port ID is the place this template should be docking at, set on '/obj/docking_port/stationary'
* Because getShuttle() compares port_id to shuttle_id to find an already existing shuttle,
* you should set shuttle_id to be the same as port_id if you want them to be replacable.
*/
var/port_id
/// ID of the shuttle, make sure it matches port_id if necessary.
var/shuttle_id
/// Information to display on communication console about the shuttle
var/description
/// The recommended occupancy limit for the shuttle (count chairs, beds, and benches then round to 5)
var/occupancy_limit
/// Description of the prerequisite that has to be achieved for the shuttle to be purchased
var/prerequisites
/// Shuttle warnings and hazards to the admin who spawns the shuttle
var/admin_notes
/// How much does this shuttle cost the cargo budget to purchase? Put in terms of CARGO_CRATE_VALUE to properly scale the cost with the current balance of cargo's income.
var/credit_cost = INFINITY
/// What job accesses can buy this shuttle? If null, this shuttle cannot be bought.
var/list/who_can_purchase = list(ACCESS_CAPTAIN)
/// Whether or not this shuttle is locked to emags only.
var/emag_only = FALSE
/// If set, overrides default movement_force on shuttle
var/list/movement_force
var/port_x_offset
var/port_y_offset
var/extra_desc = ""
/datum/map_template/shuttle/proc/prerequisites_met()
return TRUE
/datum/map_template/shuttle/New()
shuttle_id = "[port_id]_[suffix]"
mappath = "[prefix][shuttle_id].dmm"
. = ..()
/datum/map_template/shuttle/preload_size(path, cache)
. = ..(path, TRUE) // Done this way because we still want to know if someone actually wanted to cache the map
if(!cached_map)
return
var/offset = discover_offset(/obj/docking_port/mobile)
port_x_offset = offset[1]
port_y_offset = offset[2]
if(!cache)
cached_map = null
/datum/map_template/shuttle/load(turf/T, centered, register=TRUE)
. = ..()
if(!.)
return
var/list/turfs = block(.[MAP_MINX], .[MAP_MINY], .[MAP_MINZ], \
.[MAP_MAXX], .[MAP_MAXY], .[MAP_MAXZ])
dispatch(turfs, register)
/datum/map_template/shuttle/proc/dispatch(list/turfs, register=TRUE)
while(TRUE)
var/found = FALSE
for(var/turf/current_turf in turfs)
if(is_type_on_turf(current_turf, /obj/modular_map_root))
found = TRUE
if(found)
sleep(5 DECISECONDS)
else
break
for(var/i in 1 to turfs.len)
var/turf/place = turfs[i]
if(isspaceturf(place)) // This assumes all shuttles are loaded in a single spot then moved to their real destination.
continue
if (place.count_baseturfs() < 2) // Some snowflake shuttle shit
continue
place.insert_baseturf(3, /turf/baseturf_skipover/shuttle)
for(var/obj/docking_port/mobile/port in place)
port.calculate_docking_port_information(src)
// initTemplateBounds explicitly ignores the shuttle's docking port, to ensure that it calculates the bounds of the shuttle correctly
// so we need to manually initialize it here
SSatoms.InitializeAtoms(list(port))
if(register)
port.register()
//Whatever special stuff you want
/datum/map_template/shuttle/post_load(obj/docking_port/mobile/M)
if(movement_force)
M.movement_force = movement_force.Copy()
M.linkup()