From 614665210cbbcab8df9c50e6c23ef366b3eac558 Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Fri, 16 May 2025 05:30:40 -0700 Subject: [PATCH] [MIRROR] Subsystem For Overmap Shuttle's Star Movement Effects (#10897) Co-authored-by: Will <7099514+Willburd@users.noreply.github.com> --- code/__defines/subsystems.dm | 2 + code/controllers/subsystems/starmover.dm | 69 ++++++++++++++++++++++++ code/modules/overmap/ships/ship.dm | 4 +- code/modules/overmap/turfs.dm | 17 ------ vorestation.dme | 1 + 5 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 code/controllers/subsystems/starmover.dm diff --git a/code/__defines/subsystems.dm b/code/__defines/subsystems.dm index 5957e867c8..40932c0bbe 100644 --- a/code/__defines/subsystems.dm +++ b/code/__defines/subsystems.dm @@ -143,6 +143,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G #define INIT_ORDER_ATOMS 14 #define INIT_ORDER_POIS 13 #define INIT_ORDER_MACHINES 10 +#define INIT_ORDER_STARMOVER 4 #define INIT_ORDER_SHUTTLES 3 #define INIT_ORDER_TIMER 1 #define INIT_ORDER_DEFAULT 0 @@ -183,6 +184,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G #define FIRE_PRIORITY_PING 10 #define FIRE_PRIORITY_SERVER_MAINT 10 #define FIRE_PRIORITY_AI 10 +#define FIRE_PRIORITY_STARMOVER 11 #define FIRE_PRIORITY_GARBAGE 15 #define FIRE_PRIORITY_ASSETS 20 #define FIRE_PRIORITY_POIS 20 diff --git a/code/controllers/subsystems/starmover.dm b/code/controllers/subsystems/starmover.dm new file mode 100644 index 0000000000..f83059e4fc --- /dev/null +++ b/code/controllers/subsystems/starmover.dm @@ -0,0 +1,69 @@ +// +// Handles the moving star effects behind overmap shuttles during travel. +// +SUBSYSTEM_DEF(starmover) + name = "Shuttle Star Movement" + init_order = INIT_ORDER_STARMOVER + priority = FIRE_PRIORITY_STARMOVER + wait = 1 // This needs to be done pretty quickly + var/list/zqueue = list() + var/list/current_movement = null + //list used to track which zlevels are being 'moved' by the proc below + var/list/moving_levels = list() + var/list/currentrun = null + var/current_direction = 0 + +/datum/controller/subsystem/starmover/Initialize() + return SS_INIT_SUCCESS + +#define CR_ZLEVEL 1 +#define CR_DIRECTION 2 +#define CR_TURFS 3 + +/datum/controller/subsystem/starmover/fire(resumed) + // Get next in queue or dropout + if(!resumed && !current_movement) + if(!zqueue.len) + return + current_movement = zqueue[1] + zqueue[1] = null + zqueue -= null + // Setup data + var/zlevel = current_movement[CR_ZLEVEL] + var/new_dir = current_movement[CR_DIRECTION] + var/list/turf_list = current_movement[CR_TURFS] + if(!turf_list.len || moving_levels["[zlevel]"] == new_dir) + clear_movement_run() + return + moving_levels["[zlevel]"] = new_dir + currentrun = turf_list + + // Has a movement queued, process all turfs + while(currentrun.len) + var/turf/space/T = currentrun[currentrun.len] + currentrun.len-- + if(istype(T)) + T.toggle_transit(current_movement[CR_DIRECTION]) + if(MC_TICK_CHECK) + return + clear_movement_run() + +/datum/controller/subsystem/starmover/proc/clear_movement_run() + current_movement.Cut() + current_movement = null + currentrun = null + +/datum/controller/subsystem/starmover/stat_entry(msg) + msg = "Q:[zqueue.len] C:[currentrun ? currentrun.len : "-"]" + return ..() + +/// Used to 'move' stars in spess. null direction stops movement +/datum/controller/subsystem/starmover/proc/toggle_move_stars(zlevel, direction) + if(!zlevel) + return + var/list/spaceturfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) + zqueue += list(list(zlevel,direction,spaceturfs)) + +#undef CR_ZLEVEL +#undef CR_DIRECTION +#undef CR_TURFS diff --git a/code/modules/overmap/ships/ship.dm b/code/modules/overmap/ships/ship.dm index be5d123c18..f155f4a2d0 100644 --- a/code/modules/overmap/ships/ship.dm +++ b/code/modules/overmap/ships/ship.dm @@ -133,7 +133,7 @@ else if(still) STOP_PROCESSING(SSprocessing, src) for(var/zz in map_z) - toggle_move_stars(zz) + SSstarmover.toggle_move_stars(zz) if(last_sound + sound_cooldown >= world.time) return //VOREStation Add Start @@ -148,7 +148,7 @@ START_PROCESSING(SSprocessing, src) glide_size = WORLD_ICON_SIZE/max(DS2TICKS(SSprocessing.wait), 1) //Down to whatever decimal for(var/zz in map_z) - toggle_move_stars(zz, fore_dir) + SSstarmover.toggle_move_stars(zz, fore_dir) if(last_sound + sound_cooldown >= world.time) return //VOREStation Add Start diff --git a/code/modules/overmap/turfs.dm b/code/modules/overmap/turfs.dm index b935842fcd..9d4f36bc99 100644 --- a/code/modules/overmap/turfs.dm +++ b/code/modules/overmap/turfs.dm @@ -89,20 +89,3 @@ GLOBAL_LIST_EMPTY(map_sectors) ..() if(istype(O, /obj/effect/overmap/visitable/ship)) GLOB.overmap_event_handler.on_turf_exited(src, O, newloc) - -//list used to track which zlevels are being 'moved' by the proc below -var/list/moving_levels = list() -//Proc to 'move' stars in spess -//yes it looks ugly, but it should only fire when state actually change. -//null direction stops movement -/proc/toggle_move_stars(zlevel, direction) - if(!zlevel) - return - - if (moving_levels["[zlevel]"] != direction) - moving_levels["[zlevel]"] = direction - - var/list/spaceturfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) - for(var/turf/space/T in spaceturfs) - T.toggle_transit(direction) - CHECK_TICK diff --git a/vorestation.dme b/vorestation.dme index 79b82cce7d..24f3ca53ef 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -443,6 +443,7 @@ #include "code\controllers\subsystems\speech_controller.dm" #include "code\controllers\subsystems\sqlite.dm" #include "code\controllers\subsystems\SSvote.dm" +#include "code\controllers\subsystems\starmover.dm" #include "code\controllers\subsystems\statpanel.dm" #include "code\controllers\subsystems\sun.dm" #include "code\controllers\subsystems\supply.dm"