Files
Bubberstation/code/datums/elements/shuttle_construction_turf.dm
Y0SH1M4S73R 709df7adf5 Multiple custom shuttle fixes (+one qol tweak) (#90898)
## About The Pull Request

This PR adds four small fixes:
- Custom shuttle docking consoles no longer runtime at the world border
- Custom shuttle docking consoles are no longer blocked by where the
linked shuttle currently is
- Shuttle blueprints don't runtime and bluescreen while on whiteships
- Custom shuttles don't cause a divide-by-zero runtime when installing
engines for the first time (and are calculated correctly)

And one major QOL tweak:
- Shuttle frames are now datums which can track their own size, as well
as track which custom shuttles are adjacent to them. This allows shuttle
blueprints to display the size of the shuttle that will be built or
expanded, as well as much more performantly report issues that would
prevent shuttle construction or expansion.

## Why It's Good For The Game

I've been informed of several issues and nice-to-haves regarding custom
shuttles, and caught several other issues in the process of implementing
the requested changes.

## Changelog

🆑
fix: Shuttle blueprints don't error out when opening them while on
non-custom shuttles.
fix: Custom shuttles calculate their engine count correctly, no longer
lagging behind by one engine (un)installation.
fix: Custom shuttle docking consoles are no longer blocked by where the
linked shuttle currently is.
qol: Shuttle blueprints now show you how large a shuttle frame is, along
with any issues preventing you from building or expanding a shuttle
using said frame.
/🆑
2025-05-07 13:06:27 +12:00

54 lines
2.8 KiB
Plaintext

/// Element used to track the conditions for a turf being part of an incomplete shuttle frame
/datum/element/shuttle_construction_turf
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
/datum/element/shuttle_construction_turf/Attach(turf/target)
. = ..()
if(!istype(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_TURF_CHANGE, PROC_REF(pre_turf_changed))
RegisterSignal(target, COMSIG_TURF_ATTEMPT_LATTICE_REPLACEMENT, PROC_REF(pre_lattice_replacement))
RegisterSignal(target, COMSIG_TURF_ADDED_TO_SHUTTLE, PROC_REF(on_turf_added_to_shuttle))
ADD_TRAIT((get_area(target)), TRAIT_HAS_SHUTTLE_CONSTRUCTION_TURF, REF(target))
if(!GLOB.shuttle_frames_by_turf[target])
assign_shuttle_construction_turf_to_frame(target)
/datum/element/shuttle_construction_turf/Detach(turf/source, ...)
. = ..()
UnregisterSignal(source, list(COMSIG_TURF_CHANGE, COMSIG_TURF_ATTEMPT_LATTICE_REPLACEMENT, COMSIG_TURF_ADDED_TO_SHUTTLE, SIGNAL_REMOVETRAIT(TRAIT_SHUTTLE_CONSTRUCTION_TURF)))
REMOVE_TRAIT((get_area(source)), TRAIT_HAS_SHUTTLE_CONSTRUCTION_TURF, REF(source))
var/datum/shuttle_frame/frame = GLOB.shuttle_frames_by_turf[source]
frame.remove_turf(source)
///Changing or destroying the turf detaches the element, also we need to reapply the traits since they don't get passed down.
/datum/element/shuttle_construction_turf/proc/pre_turf_changed(turf/source, path, list/new_baseturfs, flags, list/post_change_callbacks)
SIGNAL_HANDLER
var/list/old_trait_sources = GET_TRAIT_SOURCES(source, TRAIT_SHUTTLE_CONSTRUCTION_TURF)
old_trait_sources = old_trait_sources.Copy()
post_change_callbacks += CALLBACK(src, PROC_REF(post_turf_changed), old_trait_sources)
var/datum/shuttle_frame/frame = GLOB.shuttle_frames_by_turf[source]
frame.possibly_valid_changing_turfs[source] = TRUE
/datum/element/shuttle_construction_turf/proc/pre_lattice_replacement(turf/source, list/post_successful_replacement_callbacks)
SIGNAL_HANDLER
post_successful_replacement_callbacks += CALLBACK(src, PROC_REF(register_lattice))
/datum/element/shuttle_construction_turf/proc/post_turf_changed(list/trait_sources, turf/new_turf)
var/datum/shuttle_frame/frame = GLOB.shuttle_frames_by_turf[new_turf]
frame.possibly_valid_changing_turfs -= new_turf
if(isfloorturf(new_turf) || iswallturf(new_turf))
trait_sources |= ELEMENT_TRAIT(type)
else
trait_sources -= ELEMENT_TRAIT(type)
if(length(trait_sources))
for(var/source in trait_sources)
new_turf.AddElementTrait(TRAIT_SHUTTLE_CONSTRUCTION_TURF, source, type)
else
frame.remove_turf(new_turf)
/datum/element/shuttle_construction_turf/proc/register_lattice(obj/structure/lattice/new_lattice)
new_lattice.AddElement(/datum/element/shuttle_construction_lattice)
/datum/element/shuttle_construction_turf/proc/on_turf_added_to_shuttle(turf/source)
REMOVE_TRAIT(source, TRAIT_SHUTTLE_CONSTRUCTION_TURF, ELEMENT_TRAIT(type))