Skip to content

Commit

Permalink
[MIRROR] device/spaceflare -> shuttle_beacon, add /active type (Sierr…
Browse files Browse the repository at this point in the history
…aBay#1858)

Co-authored-by: Spookerton <[email protected]>
Co-authored-by: LordNest <[email protected]>
  • Loading branch information
3 people authored and dj-34 committed Feb 12, 2024
1 parent cbecaad commit fdf4bb6
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 131 deletions.
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/storage/belt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
/obj/item/folder,
/obj/item/paper,
/obj/item/pen,
/obj/item/device/spaceflare,
/obj/item/shuttle_beacon,
/obj/item/pinpointer/radio,
/obj/item/device/taperecorder,
/obj/item/device/tape,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
/obj/item/pickaxe/xeno/hand,
/obj/item/storage/bag/fossils,
/obj/item/hand_labeler,
/obj/item/device/spaceflare
/obj/item/shuttle_beacon
)

/obj/structure/closet/shipping_wall
Expand Down
193 changes: 105 additions & 88 deletions code/modules/shuttles/landmarks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@
var/shuttle_restricted
var/flags = 0


/obj/shuttle_landmark/Initialize()
. = ..()
if(docking_controller)
. = INITIALIZE_HINT_LATELOAD

if(flags & SLANDMARK_FLAG_AUTOSET)
base_area = get_area(src)
var/turf/T = get_turf(src)
if(T)
base_turf = T.type
else
base_area = locate(base_area || world.area)

SetName(name + " ([x],[y])")
SSshuttle.register_landmark(landmark_tag, src)


/obj/shuttle_landmark/LateInitialize(mapload)
if(!docking_controller)
return
Expand All @@ -51,6 +51,7 @@
if(location && location.docking_codes)
docking_controller.docking_codes = location.docking_codes


/obj/shuttle_landmark/forceMove()
var/obj/overmap/visitable/map_origin = map_sectors["[z]"]
. = ..()
Expand All @@ -61,10 +62,12 @@
if(map_destination)
map_destination.add_landmark(src, shuttle_restricted)


//Called when the landmark is added to an overmap sector.
/obj/shuttle_landmark/proc/sector_set(obj/overmap/visitable/O, shuttle_name)
shuttle_restricted = shuttle_name


/obj/shuttle_landmark/proc/is_valid(datum/shuttle/shuttle)
if(shuttle.current_location == src)
return FALSE
Expand All @@ -78,12 +81,15 @@
return FALSE
return TRUE


/obj/shuttle_landmark/proc/cannot_depart(datum/shuttle/shuttle)
return FALSE


/obj/shuttle_landmark/proc/shuttle_arrived(datum/shuttle/shuttle)
return


/proc/check_collision(area/target_area, list/target_turfs)
for(var/target_turf in target_turfs)
var/turf/target = target_turf
Expand All @@ -95,48 +101,107 @@
return TRUE //dense turf
return FALSE


//Self-naming/numbering ones.
/obj/shuttle_landmark/automatic
name = "Navpoint"
landmark_tag = "navpoint"
flags = SLANDMARK_FLAG_AUTOSET


/obj/shuttle_landmark/automatic/Initialize()
landmark_tag += "-[x]-[y]-[z]-[random_id("landmarks",1,9999)]"
return ..()


/obj/shuttle_landmark/automatic/sector_set(obj/overmap/visitable/O)
..()
SetName("[O.name] - [initial(name)] ([x],[y])")


//Subtype that calls explosion on init to clear space for shuttles
/obj/shuttle_landmark/automatic/clearing
var/radius = LANDING_ZONE_RADIUS


/obj/shuttle_landmark/automatic/clearing/Initialize()
..()
return INITIALIZE_HINT_LATELOAD


/obj/shuttle_landmark/automatic/clearing/LateInitialize(mapload)
..()
for(var/turf/T in range(radius, src))
if(T.density)
T.ChangeTurf(get_base_turf_by_area(T))


/obj/item/device/spaceflare
/obj/shuttle_landmark/automatic/beacon
name = "Bluespace Beacon Signal"
/// The beacon object synced to this landmark. If this is ever null or qdeleted the landmark should delete itself.
var/obj/item/shuttle_beacon/beacon


/obj/shuttle_landmark/automatic/beacon/Initialize(mapload, obj/item/shuttle_beacon/beacon)
. = ..()
if (!istype(beacon))
log_debug(append_admin_tools("\A [src] was initialized with an invalid or nonexistant beacon", location = get_turf(src)))
return INITIALIZE_HINT_QDEL
if (beacon.landmark && beacon.landmark != src)
log_debug(append_admin_tools("\A [src] was initialized with a beacon already has a synced landmark.", location = get_turf(src)))
return INITIALIZE_HINT_QDEL
src.beacon = beacon
GLOB.moved_event.register(beacon, src, /obj/shuttle_landmark/automatic/beacon/proc/update_beacon_moved)


/obj/shuttle_landmark/automatic/beacon/Destroy()
GLOB.moved_event.unregister(beacon, src, /obj/shuttle_landmark/automatic/beacon/proc/update_beacon_moved)
if (beacon?.active)
log_debug(append_admin_tools("\A [src] was destroyed with a still active beacon.", location = get_turf(beacon)))
beacon.deactivate()
beacon = null
return ..()


/// Event handler for when the beacon moves. Theoretically possible with a beacon deployed on a shuttle turf, or with adminbus.
/obj/shuttle_landmark/automatic/beacon/proc/update_beacon_moved(atom/movable/moving_instance, atom/old_loc, atom/new_loc)
if (!isturf(new_loc) || isspaceturf(new_loc) || isopenspace(new_loc))
log_debug(append_admin_tools("\A [src]'s beacon was moved to a non-turf or unacceptable location.", location = get_turf(new_loc)))
beacon.deactivate()
return
forceMove(new_loc)
SetName("[initial(name)] ([x],[y])")
log_debug(append_admin_tools("\A [src]'s beacon was moved to [get_area(new_loc)].", location = get_turf(src)))


/// Desynchronizes the effect from the beacon, rendering it a permanent landmark.
/obj/shuttle_landmark/automatic/beacon/proc/desync_beacon()
GLOB.moved_event.unregister(beacon, src, /obj/shuttle_landmark/automatic/beacon/proc/update_beacon_moved)
if (beacon?.active)
beacon.deactivate(TRUE, TRUE)
beacon = null


/obj/item/shuttle_beacon
name = "shuttle beacon"
desc = "Burst transmitter used to broadcast all needed information for shuttle navigation systems. Has a bright blue light attached for marking the spot where you probably shouldn't be standing."
icon = 'icons/obj/space_flare.dmi'
icon_state = "packaged"
light_color = "#3728ff"
/// Boolean. Whether or not the spaceflare has been activated.

/// Boolean. Whether or not the beacon has been activated.
var/active = FALSE

/// The shuttle landmark synced to this beacon. This is set when the beacon is activated.
var/obj/shuttle_landmark/automatic/spaceflare/landmark
var/obj/shuttle_landmark/automatic/beacon/landmark


/obj/item/shuttle_beacon/Destroy()
deactivate(TRUE)
return ..()


/obj/item/device/spaceflare/attack_self(mob/user)
/obj/item/shuttle_beacon/attack_self(mob/user)
if (activate(user))
user.visible_message(
SPAN_NOTICE("\The [user] plants \the [src] and activates it."),
Expand All @@ -145,6 +210,28 @@
)


/obj/item/shuttle_beacon/on_update_icon()
if (active)
icon_state = "deployed"
var/image/image = image(icon, "active")
image.plane = EFFECTS_ABOVE_LIGHTING_PLANE
image.layer = ABOVE_LIGHTING_LAYER
AddOverlays(image)
pixel_x = rand(-6, 6)
pixel_y = rand(-6, 6)
set_light(7, 0.7, "#85d1ff")
else
icon_state = initial(icon_state)
ClearOverlays()
set_light(0)


/obj/item/shuttle_beacon/shuttle_land_on()
if (active)
landmark.desync_beacon()
..()


/**
* Handles activation of the flare.
*
Expand All @@ -153,26 +240,21 @@
*
* Returns boolean - FALSE if the flare was not activated, TRUE if it was.
*/
/obj/item/device/spaceflare/proc/activate(mob/user)
/obj/item/shuttle_beacon/proc/activate(mob/user)
if (active)
log_debug(append_admin_tools("\A [src] attempted to activate but was already active.", user, get_turf(src)))
return FALSE

var/turf/T = get_turf(src)
if (isspaceturf(T) || isopenspace(T))
if (user)
to_chat(user, SPAN_WARNING("\The [src] needs to be activated on solid ground."))
return FALSE

if (istype(user) && !user.unEquip(src, T))
log_debug(append_admin_tools("\A [src] attempted to activate but could not be unequipped by the mob.", user, get_turf(src)))
return FALSE

// Just in case some other weird things happen that try to call activate on a non-turf location
if (loc != T)
log_debug(append_admin_tools("\A [src] attempted to activate but was not on a valid turf.", user, get_turf(src)))
return FALSE

if (user)
user.visible_message(
SPAN_ITALIC("\The [user] starts setting up \a [src]."),
Expand All @@ -196,94 +278,29 @@
*
* Returns boolean - FALSE if the flare was not deactivated, TRUE if it was.
*/
/obj/item/device/spaceflare/proc/deactivate(silent = FALSE, keep_landmark = FALSE)
/obj/item/shuttle_beacon/proc/deactivate(silent, skip_destroy_landmark)
if (!active)
return FALSE

active = FALSE
anchored = FALSE
if (keep_landmark)
landmark = null
else
if (!skip_destroy_landmark)
QDEL_NULL(landmark)
landmark = null
update_icon()
if (!silent)
visible_message(SPAN_WARNING("\The [src] deactivates, going dark."))
return TRUE


/obj/item/device/spaceflare/on_update_icon()
if (active)
icon_state = "deployed"
var/image/image = image(icon, "active")
image.plane = EFFECTS_ABOVE_LIGHTING_PLANE
image.layer = ABOVE_LIGHTING_LAYER
AddOverlays(image)
pixel_x = rand(-6, 6)
pixel_y = rand(-6, 6)
set_light(7, 0.7, "#85d1ff")
else
icon_state = initial(icon_state)
ClearOverlays()
set_light(0)


/obj/item/device/spaceflare/Destroy()
deactivate(TRUE)
. = ..()


/obj/item/device/spaceflare/shuttle_land_on()
if (active)
// If a shuttle landed here we don't want to destroy the landmark, that breaks things. It becomes a permanent beacon smushed into the ground instead.
landmark.desync_flare()
..()


/obj/shuttle_landmark/automatic/spaceflare
name = "Bluespace Beacon Signal"
/// The beacon object synced to this landmark. If this is ever null or qdeleted the landmark should delete itself.
var/obj/item/device/spaceflare/beacon
/obj/item/shuttle_beacon/active
active = TRUE
anchored = TRUE


/obj/shuttle_landmark/automatic/spaceflare/Initialize(mapload, obj/item/device/spaceflare/beacon)
/obj/item/shuttle_beacon/active/Initialize()
. = ..()

if (!istype(beacon))
log_debug(append_admin_tools("\A [src] was initialized with an invalid or nonexistant beacon", location = get_turf(src)))
return INITIALIZE_HINT_QDEL

if (beacon.landmark && beacon.landmark != src)
log_debug(append_admin_tools("\A [src] was initialized with a beacon already has a synced landmark.", location = get_turf(src)))
var/turf/turf = get_turf(src)
if (!turf)
return INITIALIZE_HINT_QDEL

src.beacon = beacon
GLOB.moved_event.register(beacon, src, TYPE_PROC_REF(/obj/shuttle_landmark/automatic/spaceflare, update_beacon_moved))


/obj/shuttle_landmark/automatic/spaceflare/Destroy()
GLOB.moved_event.unregister(beacon, src, TYPE_PROC_REF(/obj/shuttle_landmark/automatic/spaceflare, update_beacon_moved))
if (beacon?.active)
log_debug(append_admin_tools("\A [src] was destroyed with a still active beacon.", location = get_turf(beacon)))
beacon.deactivate()
beacon = null
. = ..()


/// Event handler for when the beacon moves. Theoretically possible with a beacon deployed on a shuttle turf, or with adminbus.
/obj/shuttle_landmark/automatic/spaceflare/proc/update_beacon_moved(atom/movable/moving_instance, atom/old_loc, atom/new_loc)
if (!isturf(new_loc) || isspaceturf(new_loc) || isopenspace(new_loc))
log_debug(append_admin_tools("\A [src]'s beacon was moved to a non-turf or unacceptable location.", location = get_turf(new_loc)))
beacon.deactivate()
return
forceMove(new_loc)
SetName("[initial(name)] ([x],[y])")
log_debug(append_admin_tools("\A [src]'s beacon was moved to [get_area(new_loc)].", location = get_turf(src)))


/// Desynchronizes the effect from the beacon, rendering it a permanent landmark.
/obj/shuttle_landmark/automatic/spaceflare/proc/desync_flare()
GLOB.moved_event.unregister(beacon, src, TYPE_PROC_REF(/obj/shuttle_landmark/automatic/spaceflare, update_beacon_moved))
if (beacon?.active)
beacon.deactivate(TRUE, TRUE)
beacon = null
landmark = new (turf, src)
update_icon()
6 changes: 3 additions & 3 deletions maps/antag_spawn/mercenary/mercenary_base.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1839,9 +1839,9 @@
/obj/item/storage/briefcase/inflatable,
/obj/item/storage/briefcase/inflatable,
/obj/item/inflatable_dispenser,
/obj/item/device/spaceflare,
/obj/item/device/spaceflare,
/obj/item/device/spaceflare,
/obj/item/shuttle_beacon,
/obj/item/shuttle_beacon,
/obj/item/shuttle_beacon,
/obj/machinery/light{
dir = 4
},
Expand Down
4 changes: 2 additions & 2 deletions maps/antag_spawn/vox/vox_raider.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
/obj/item/device/multitool,
/obj/item/device/multitool,
/obj/item/stack/material/rods/fifty,
/obj/item/device/spaceflare,
/obj/item/device/spaceflare,
/obj/item/shuttle_beacon,
/obj/item/shuttle_beacon,
/obj/item/storage/backpack/weldpack,
/obj/item/storage/backpack/weldpack,
/obj/item/storage/backpack/dufflebag,
Expand Down
2 changes: 1 addition & 1 deletion maps/away/scavver/scavver_gantry-1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
/obj/item/storage/briefcase/inflatable,
/obj/item/storage/briefcase/inflatable,
/obj/item/storage/briefcase/inflatable,
/obj/item/device/spaceflare,
/obj/item/shuttle_beacon,
/turf/simulated/floor,
/area/scavver/gantry/down1)
"iB" = (
Expand Down
4 changes: 2 additions & 2 deletions maps/random_ruins/exoplanet_ruins/playablecolony2/colony2.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1825,8 +1825,8 @@
/obj/floor_decal/industrial/outline/yellow,
/obj/item/wrench,
/obj/item/wrench,
/obj/item/device/spaceflare,
/obj/item/device/spaceflare,
/obj/item/shuttle_beacon,
/obj/item/shuttle_beacon,
/turf/simulated/floor/reinforced{
map_airless = 1
},
Expand Down
Loading

0 comments on commit fdf4bb6

Please sign in to comment.