mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 08:36:00 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
137 lines
5.0 KiB
Plaintext
137 lines
5.0 KiB
Plaintext
/**
|
|
* Component that manages a list of plane masters that are dependent on weather
|
|
* Force hides/shows them depending on the weather activity of their z stack
|
|
* Transparency is achieved by manipulating the alpha of the planes that are visible
|
|
* Applied to the plane master group that owns them
|
|
*/
|
|
/datum/component/hide_weather_planes
|
|
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
|
|
var/list/datum/weather/active_weather = list()
|
|
var/list/atom/movable/screen/plane_master/plane_masters = list()
|
|
|
|
/datum/component/hide_weather_planes/Initialize(atom/movable/screen/plane_master/care_about)
|
|
if(!istype(parent, /datum/plane_master_group))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/datum/plane_master_group/home = parent
|
|
plane_masters += care_about
|
|
RegisterSignal(care_about, COMSIG_QDELETING, PROC_REF(plane_master_deleted))
|
|
|
|
var/list/starting_signals = list()
|
|
var/list/ending_signals = list()
|
|
for(var/datum/weather/weather_type as anything in typesof(/datum/weather))
|
|
starting_signals += COMSIG_WEATHER_TELEGRAPH(weather_type)
|
|
ending_signals += COMSIG_WEATHER_END(weather_type)
|
|
|
|
RegisterSignals(SSdcs, starting_signals, PROC_REF(weather_started))
|
|
RegisterSignals(SSdcs, ending_signals, PROC_REF(weather_finished))
|
|
|
|
if(home.our_hud)
|
|
attach_hud(home.our_hud)
|
|
else
|
|
RegisterSignal(home, COMSIG_GROUP_HUD_CHANGED, PROC_REF(new_hud_attached))
|
|
|
|
/datum/component/hide_weather_planes/Destroy(force)
|
|
hide_planes()
|
|
active_weather = null
|
|
plane_masters = null
|
|
return ..()
|
|
|
|
/datum/component/hide_weather_planes/InheritComponent(datum/component/new_comp, i_am_original, atom/movable/screen/plane_master/care_about)
|
|
if(!i_am_original)
|
|
return
|
|
var/datum/plane_master_group/home = parent
|
|
var/mob/our_lad = home.our_hud?.mymob
|
|
var/our_offset = GET_TURF_PLANE_OFFSET(our_lad)
|
|
plane_masters += care_about
|
|
RegisterSignal(care_about, COMSIG_QDELETING, PROC_REF(plane_master_deleted))
|
|
if(length(active_weather))
|
|
//If there's weather to care about we unhide our new plane and adjust its alpha
|
|
care_about.unhide_plane(our_lad)
|
|
|
|
if(care_about.offset >= our_offset)
|
|
care_about.enable_alpha()
|
|
else
|
|
care_about.disable_alpha()
|
|
else
|
|
care_about.hide_plane(our_lad)
|
|
|
|
/datum/component/hide_weather_planes/proc/new_hud_attached(datum/source, datum/hud/old_hud, datum/hud/new_hud)
|
|
SIGNAL_HANDLER
|
|
attach_hud(new_hud)
|
|
|
|
/datum/component/hide_weather_planes/proc/attach_hud(datum/hud/new_hud)
|
|
RegisterSignal(new_hud, COMSIG_HUD_Z_CHANGED, PROC_REF(z_changed))
|
|
var/mob/eye = new_hud?.mymob?.client?.eye
|
|
var/turf/eye_location = get_turf(eye)
|
|
z_changed(new_hud, eye_location?.z)
|
|
|
|
/datum/component/hide_weather_planes/proc/plane_master_deleted(atom/movable/screen/plane_master/source)
|
|
SIGNAL_HANDLER
|
|
plane_masters -= source
|
|
|
|
/**
|
|
* Unhides the relevant planes for the weather to be visible and manipulated.
|
|
* Also updates the alpha of the planes so enabled planes are either fully opaque or fully transparent
|
|
*/
|
|
/datum/component/hide_weather_planes/proc/display_planes()
|
|
var/datum/plane_master_group/home = parent
|
|
var/mob/our_lad = home.our_hud?.mymob
|
|
var/our_offset = GET_TURF_PLANE_OFFSET(our_lad)
|
|
for(var/atom/movable/screen/plane_master/weather_conscious as anything in plane_masters)
|
|
//If the plane is hidden, unhide it
|
|
if(weather_conscious.force_hidden)
|
|
weather_conscious.unhide_plane(our_lad)
|
|
|
|
//Now we update the alpha of the plane based on our offset. Weather above us (lower offset) are transparent, weather at or below us (higher offset) are opaque.
|
|
if(weather_conscious.offset >= our_offset)
|
|
weather_conscious.enable_alpha()
|
|
else
|
|
weather_conscious.disable_alpha()
|
|
|
|
///Hides the planes from the mob when no weather is occuring
|
|
/datum/component/hide_weather_planes/proc/hide_planes()
|
|
var/datum/plane_master_group/home = parent
|
|
var/mob/our_lad = home.our_hud?.mymob
|
|
for(var/atom/movable/screen/plane_master/weather_conscious as anything in plane_masters)
|
|
weather_conscious.hide_plane(our_lad)
|
|
|
|
/datum/component/hide_weather_planes/proc/z_changed(datum/source, new_z)
|
|
SIGNAL_HANDLER
|
|
active_weather = list()
|
|
if(!SSmapping.initialized)
|
|
return
|
|
|
|
var/list/connected_levels = SSmapping.get_connected_levels(new_z)
|
|
for(var/datum/weather/active as anything in SSweather.processing)
|
|
if(length(connected_levels & active.impacted_z_levels))
|
|
active_weather += WEAKREF(active)
|
|
|
|
if(length(active_weather))
|
|
display_planes()
|
|
else
|
|
hide_planes()
|
|
|
|
/datum/component/hide_weather_planes/proc/weather_started(datum/source, datum/weather/starting)
|
|
SIGNAL_HANDLER
|
|
var/datum/plane_master_group/home = parent
|
|
var/mob/eye = home.our_hud?.mymob?.client?.eye
|
|
var/turf/viewing_from = get_turf(eye)
|
|
if(!viewing_from)
|
|
return
|
|
|
|
var/list/connected_levels = SSmapping.get_connected_levels(viewing_from)
|
|
if(length(connected_levels & starting.impacted_z_levels))
|
|
active_weather += WEAKREF(starting)
|
|
|
|
if(!length(active_weather))
|
|
return
|
|
display_planes()
|
|
|
|
/datum/component/hide_weather_planes/proc/weather_finished(datum/source, datum/weather/stopping)
|
|
SIGNAL_HANDLER
|
|
active_weather -= WEAKREF(stopping)
|
|
|
|
if(length(active_weather))
|
|
return
|
|
hide_planes()
|