Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit b77e228

Browse files
alright we're good i think (#22614)
1 parent c1a98a5 commit b77e228

File tree

21 files changed

+357
-90
lines changed

21 files changed

+357
-90
lines changed

code/__DEFINES/dcs/signals/signals_huds.dm renamed to code/__DEFINES/dcs/signals/signals_hud.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/// Sent from /datum/hud/proc/on_eye_change(): (atom/old_eye, atom/new_eye)
22
#define COMSIG_HUD_EYE_CHANGED "hud_eye_changed"
3+
/// Sent from /datum/hud/proc/eye_z_changed() : (new_z)
4+
#define COMSIG_HUD_Z_CHANGED "hud_z_changed"
35
/// Sent from /datum/hud/proc/eye_z_changed() : (old_offset, new_offset)
46
#define COMSIG_HUD_OFFSET_CHANGED "hud_offset_changed"
57
/// Sent from /atom/movable/screen/lobby/button/collapse/proc/collapse_buttons() : ()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// from /datum/plane_master_group/proc/set_hud(): (datum/hud/new_hud)
2+
#define COMSIG_GROUP_HUD_CHANGED "group_hud_changed"

code/__DEFINES/layers.dm

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,31 @@
1313
#define PLANE_SPACE -21
1414
#define PLANE_SPACE_PARALLAX -20
1515

16-
#define GRAVITY_PULSE_PLANE -12
16+
#define GRAVITY_PULSE_PLANE -19
1717
#define GRAVITY_PULSE_RENDER_TARGET "*GRAVPULSE_RENDER_TARGET"
1818

19-
#define RENDER_PLANE_TRANSPARENT -11 //Transparent plane that shows openspace underneath the floor
19+
#define RENDER_PLANE_TRANSPARENT -18 //Transparent plane that shows openspace underneath the floor
20+
#define TRANSPARENT_FLOOR_PLANE -13
2021

21-
#define TRANSPARENT_FLOOR_PLANE -10
22+
#define FLOOR_PLANE -12
23+
#define FLOOR_PLANE_RENDER_TARGET "*FLOOR_PLANE"
24+
#define WALL_PLANE -11
25+
#define GAME_PLANE -10
26+
#define ABOVE_GAME_PLANE -9
2227

23-
#define FLOOR_PLANE -6
24-
25-
#define WALL_PLANE -5
26-
#define GAME_PLANE -4
27-
#define ABOVE_GAME_PLANE -3
2828
///Slightly above the game plane but does not catch mouse clicks. Useful for certain visuals that should be clicked through, like seethrough trees
2929
#define SEETHROUGH_PLANE -2
3030

3131
#define RENDER_PLANE_GAME_WORLD -1
3232

3333
#define DEFAULT_PLANE 0 //Marks out the default plane, even if we don't use it
3434

35+
#define WEATHER_PLANE 1
3536
#define AREA_PLANE 2
36-
#define MASSIVE_OBJ_PLANE 3
37-
#define GHOST_PLANE 4
38-
#define POINT_PLANE 5
37+
38+
#define MASSIVE_OBJ_PLANE 6
39+
#define GHOST_PLANE 7
40+
#define POINT_PLANE 8
3941

4042
//---------- LIGHTING -------------
4143
///Normal 1 per turf dynamic lighting underlays
@@ -64,6 +66,7 @@
6466

6567
///Things that should render ignoring lighting
6668
#define ABOVE_LIGHTING_PLANE 17
69+
#define WEATHER_GLOW_PLANE 18
6770

6871
///---------------- MISC -----------------------
6972

code/__DEFINES/weather.dm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//A reference to this list is passed into area sound managers, and it's modified in a manner that preserves that reference in ash_storm.dm
2+
GLOBAL_LIST_EMPTY(ash_storm_sounds)
3+
4+
#define STARTUP_STAGE 1
5+
#define MAIN_STAGE 2
6+
#define WIND_DOWN_STAGE 3
7+
#define END_STAGE 4

code/_onclick/hud/hud.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
195195
SIGNAL_HANDLER
196196
update_parallax_pref() // If your eye changes z level, so should your parallax prefs
197197
var/turf/eye_turf = get_turf(eye)
198+
SEND_SIGNAL(src, COMSIG_HUD_Z_CHANGED, eye_turf.z)
198199
var/new_offset = GET_TURF_PLANE_OFFSET(eye_turf)
199200
if(current_plane_offset == new_offset)
200201
return

code/_onclick/hud/rendering/plane_master_group.dm

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,34 @@
2424
build_plane_masters(0, SSmapping.max_plane_offset)
2525

2626
/datum/plane_master_group/Destroy()
27-
orphan_hud()
27+
set_hud(null)
2828
QDEL_LIST_ASSOC_VAL(plane_masters)
2929
return ..()
3030

31+
/datum/plane_master_group/proc/set_hud(datum/hud/new_hud)
32+
if(new_hud == our_hud)
33+
return
34+
if(our_hud)
35+
our_hud.master_groups -= key
36+
hide_hud()
37+
our_hud = new_hud
38+
if(new_hud)
39+
our_hud.master_groups[key] = src
40+
show_hud()
41+
transform_lower_turfs(our_hud, active_offset)
42+
SEND_SIGNAL(src, COMSIG_GROUP_HUD_CHANGED, our_hud)
43+
3144
/// Display a plane master group to some viewer, so show all our planes to it
3245
/datum/plane_master_group/proc/attach_to(datum/hud/viewing_hud)
3346
if(viewing_hud.master_groups[key])
3447
stack_trace("Hey brother, our key [key] is already in use by a plane master group on the passed in hud, belonging to [viewing_hud.mymob]. Ya fucked up, why are there dupes")
3548
return
3649

37-
our_hud = viewing_hud
50+
set_hud(viewing_hud)
3851
our_hud.master_groups[key] = src
3952
show_hud()
4053
transform_lower_turfs(our_hud, active_offset)
4154

42-
/// Hide the plane master from its current hud, fully clear it out
43-
/datum/plane_master_group/proc/orphan_hud()
44-
if(our_hud)
45-
our_hud.master_groups -= key
46-
hide_hud()
47-
our_hud = null
48-
4955
/// Well, refresh our group, mostly useful for plane specific updates
5056
/datum/plane_master_group/proc/refresh_hud()
5157
hide_hud()

code/_onclick/hud/rendering/plane_masters/plane_master_subtypes.dm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@
252252
documentation = "Holds the areas themselves, which ends up meaning it holds any overlays/effects we apply to areas. NOT snow or rad storms, those go on above lighting"
253253
plane = AREA_PLANE
254254

255+
/atom/movable/screen/plane_master/weather
256+
name = "Weather"
257+
documentation = "Holds the main tiling 32x32 sprites of weather. We mask against walls that are on the edge of weather effects."
258+
plane = WEATHER_PLANE
259+
260+
/atom/movable/screen/plane_master/weather/set_home(datum/plane_master_group/home)
261+
. = ..()
262+
if(!.)
263+
return
264+
home.AddComponent(/datum/component/hide_weather_planes, src)
265+
255266
/atom/movable/screen/plane_master/massive_obj
256267
name = "Massive object"
257268
documentation = "Huge objects need to render above everything else on the game plane, otherwise they'd well, get clipped and look not that huge. This does that."
@@ -294,6 +305,16 @@
294305
documentation = "Anything on the game plane that needs a space to draw on that will be above the lighting plane.\
295306
<br>Mostly little alerts and effects, also sometimes contains things that are meant to look as if they glow."
296307

308+
/atom/movable/screen/plane_master/weather_glow
309+
name = "Weather Glow"
310+
documentation = "Holds the glowing parts of the main tiling 32x32 sprites of weather."
311+
plane = WEATHER_GLOW_PLANE
312+
313+
/atom/movable/screen/plane_master/weather_glow/set_home(datum/plane_master_group/home)
314+
. = ..()
315+
if(!.)
316+
return
317+
home.AddComponent(/datum/component/hide_weather_planes, src)
297318
/**
298319
* Handles emissive overlays and emissive blockers.
299320
*/

code/_onclick/hud/rendering/render_plate.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
if(!.)
350350
return
351351

352-
RegisterSignal(mymob, COMSIG_MOB_SIGHT_CHANGE, PROC_REF(handle_sight))
352+
RegisterSignal(mymob, COMSIG_MOB_SIGHT_CHANGE, PROC_REF(handle_sight), override = TRUE)
353353
handle_sight(mymob, mymob.sight, NONE)
354354

355355
/atom/movable/screen/plane_master/rendering_plate/light_mask/hide_from(mob/oldmob)

code/controllers/subsystem/weather.dm

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
#define STARTUP_STAGE 1
2-
#define MAIN_STAGE 2
3-
#define WIND_DOWN_STAGE 3
4-
#define END_STAGE 4
5-
6-
//Used for all kinds of weather, ex. lavaland ash storms.
1+
/// Used for all kinds of weather, ex. lavaland ash storms.
72
SUBSYSTEM_DEF(weather)
83
name = "Weather"
94
flags = SS_BACKGROUND
@@ -16,25 +11,23 @@ SUBSYSTEM_DEF(weather)
1611
/datum/controller/subsystem/weather/fire()
1712
// process active weather
1813
for(var/V in processing)
19-
var/datum/weather/W = V
20-
if(W.aesthetic || W.stage != MAIN_STAGE)
14+
var/datum/weather/our_event = V
15+
if(our_event.aesthetic || our_event.stage != MAIN_STAGE)
2116
continue
22-
for(var/i in GLOB.mob_living_list)
23-
var/mob/living/L = i
24-
if(W.can_weather_act(L))
25-
W.weather_act(L)
17+
for(var/mob/act_on as anything in GLOB.mob_living_list)
18+
if(our_event.can_weather_act(act_on))
19+
our_event.weather_act(act_on)
2620

2721
// start random weather on relevant levels
2822
for(var/z in eligible_zlevels)
2923
var/possible_weather = eligible_zlevels[z]
30-
var/datum/weather/W = pickweight(possible_weather)
31-
run_weather(W, list(text2num(z)))
24+
var/datum/weather/our_event = pick_weight(possible_weather)
25+
run_weather(our_event, list(text2num(z)))
3226
eligible_zlevels -= z
33-
var/randTime = rand(W.cooldown_lower, W.cooldown_higher)
34-
addtimer(CALLBACK(src, PROC_REF(make_eligible), z, possible_weather), randTime + initial(W.weather_duration_upper), TIMER_UNIQUE) //Around 5-10 minutes between weathers
35-
next_hit_by_zlevel["[z]"] = world.time + randTime + initial(W.telegraph_duration)
27+
var/randTime = rand(our_event.cooldown_lower, our_event.cooldown_higher)
28+
next_hit_by_zlevel["[z]"] = addtimer(CALLBACK(src, PROC_REF(make_eligible), z, possible_weather), randTime + initial(our_event.weather_duration_upper), TIMER_UNIQUE|TIMER_STOPPABLE) //Around 5-10 minutes between weathers
3629

37-
/datum/controller/subsystem/weather/Initialize(start_timeofday)
30+
/datum/controller/subsystem/weather/Initialize()
3831
for(var/V in subtypesof(/datum/weather))
3932
var/datum/weather/W = V
4033
var/probability = initial(W.probability)
@@ -75,17 +68,28 @@ SUBSYSTEM_DEF(weather)
7568

7669
var/datum/weather/W = new weather_datum_type(z_levels)
7770
W.telegraph()
78-
return W
7971

8072
/datum/controller/subsystem/weather/proc/make_eligible(z, possible_weather)
8173
eligible_zlevels[z] = possible_weather
8274
next_hit_by_zlevel["[z]"] = null
8375

8476
/datum/controller/subsystem/weather/proc/get_weather(z, area/active_area)
85-
var/datum/weather/A
86-
for(var/V in processing)
87-
var/datum/weather/W = V
88-
if((z in W.impacted_z_levels) && istype(active_area, W.area_type))
89-
A = W
90-
break
91-
return A
77+
var/datum/weather/A
78+
for(var/V in processing)
79+
var/datum/weather/W = V
80+
if((z in W.impacted_z_levels) && W.area_type == active_area.type)
81+
A = W
82+
break
83+
return A
84+
85+
///Returns an active storm by its type
86+
/datum/controller/subsystem/weather/proc/get_weather_by_type(type)
87+
return locate(type) in processing
88+
89+
// ADMIN_VERB(stop_weather, R_DEBUG|R_ADMIN, "Stop All Active Weather", "Stop all currently active weather.", ADMIN_CATEGORY_DEBUG)
90+
// log_admin("[key_name(user)] stopped all currently active weather.")
91+
// message_admins("[key_name_admin(user)] stopped all currently active weather.")
92+
// for(var/datum/weather/current_weather as anything in SSweather.processing)
93+
// if(current_weather in SSweather.processing)
94+
// current_weather.end()
95+
// BLACKBOX_LOG_ADMIN_VERB("Stop All Active Weather")
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/// Component that manages a list of plane masters that are dependent on weather
2+
/// Force hides/shows them depending on the weather activity of their z stack
3+
/// Applied to the plane master group that owns them
4+
/datum/component/hide_weather_planes
5+
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
6+
var/list/datum/weather/active_weather = list()
7+
var/list/atom/movable/screen/plane_master/plane_masters = list()
8+
9+
/datum/component/hide_weather_planes/Initialize(atom/movable/screen/plane_master/care_about)
10+
if(!istype(parent, /datum/plane_master_group))
11+
return COMPONENT_INCOMPATIBLE
12+
var/datum/plane_master_group/home = parent
13+
plane_masters += care_about
14+
RegisterSignal(care_about, COMSIG_QDELETING, PROC_REF(plane_master_deleted))
15+
16+
var/list/starting_signals = list()
17+
var/list/ending_signals = list()
18+
for(var/datum/weather/weather_type as anything in typesof(/datum/weather))
19+
starting_signals += COMSIG_WEATHER_TELEGRAPH(weather_type)
20+
ending_signals += COMSIG_WEATHER_END(weather_type)
21+
22+
RegisterSignals(SSdcs, starting_signals, PROC_REF(weather_started))
23+
RegisterSignals(SSdcs, ending_signals, PROC_REF(weather_finished))
24+
25+
if(home.our_hud)
26+
attach_hud(home.our_hud)
27+
else
28+
RegisterSignal(home, COMSIG_GROUP_HUD_CHANGED, PROC_REF(new_hud_attached))
29+
30+
/datum/component/hide_weather_planes/Destroy(force)
31+
hide_planes()
32+
active_weather = null
33+
plane_masters = null
34+
return ..()
35+
36+
/datum/component/hide_weather_planes/InheritComponent(datum/component/new_comp, i_am_original, atom/movable/screen/plane_master/care_about)
37+
if(!i_am_original)
38+
return
39+
plane_masters += care_about
40+
RegisterSignal(care_about, COMSIG_QDELETING, PROC_REF(plane_master_deleted))
41+
if(length(active_weather))
42+
care_about.enable_alpha()
43+
else
44+
care_about.disable_alpha()
45+
46+
/datum/component/hide_weather_planes/proc/new_hud_attached(datum/source, datum/hud/new_hud)
47+
SIGNAL_HANDLER
48+
if(new_hud)
49+
attach_hud(new_hud)
50+
51+
/datum/component/hide_weather_planes/proc/attach_hud(datum/hud/new_hud)
52+
RegisterSignal(new_hud, COMSIG_HUD_Z_CHANGED, PROC_REF(z_changed))
53+
var/mob/eye = new_hud?.mymob?.client?.eye
54+
var/turf/eye_location = get_turf(eye)
55+
z_changed(new_hud, eye_location?.z)
56+
57+
/datum/component/hide_weather_planes/proc/plane_master_deleted(atom/movable/screen/plane_master/source)
58+
SIGNAL_HANDLER
59+
plane_masters -= source
60+
61+
/datum/component/hide_weather_planes/proc/display_planes()
62+
var/datum/plane_master_group/home = parent
63+
var/mob/our_lad = home.our_hud?.mymob
64+
var/our_offset = GET_TURF_PLANE_OFFSET(our_lad)
65+
for(var/atom/movable/screen/plane_master/weather_concious as anything in plane_masters)
66+
//We need to make sure that planes above us are hidden, but below us are visible
67+
if(!weather_concious.alpha_enabled && weather_concious.offset >= our_offset)
68+
weather_concious.enable_alpha()
69+
70+
/datum/component/hide_weather_planes/proc/hide_planes()
71+
for(var/atom/movable/screen/plane_master/weather_concious as anything in plane_masters)
72+
weather_concious.disable_alpha()
73+
74+
/datum/component/hide_weather_planes/proc/z_changed(datum/source, new_z)
75+
SIGNAL_HANDLER
76+
/**
77+
* We hide all impacted planes on z change first because weather planes on lower offsets will show through the game world
78+
* so we can't count on them just not being visible like turfs above you. This is a result of attaching weather effects to areas,
79+
* which aren't beholden to z-levels and planes like atoms we're used to
80+
*/
81+
hide_planes()
82+
active_weather = list()
83+
if(!SSmapping.initialized)
84+
return
85+
86+
var/list/connected_levels = SSmapping.get_connected_levels(new_z)
87+
for(var/datum/weather/active as anything in SSweather.processing)
88+
if(length(connected_levels & active.impacted_z_levels))
89+
active_weather += WEAKREF(active)
90+
91+
if(length(active_weather))
92+
display_planes()
93+
94+
/datum/component/hide_weather_planes/proc/weather_started(datum/source, datum/weather/starting)
95+
SIGNAL_HANDLER
96+
var/datum/plane_master_group/home = parent
97+
var/mob/eye = home.our_hud?.mymob?.client?.eye
98+
var/turf/viewing_from = get_turf(eye)
99+
if(!viewing_from)
100+
return
101+
102+
var/list/connected_levels = SSmapping.get_connected_levels(viewing_from)
103+
if(length(connected_levels & starting.impacted_z_levels))
104+
active_weather += WEAKREF(starting)
105+
106+
if(!length(active_weather))
107+
return
108+
display_planes()
109+
110+
/datum/component/hide_weather_planes/proc/weather_finished(datum/source, datum/weather/stopping)
111+
SIGNAL_HANDLER
112+
active_weather -= WEAKREF(stopping)
113+
114+
if(length(active_weather))
115+
return
116+
hide_planes()

0 commit comments

Comments
 (0)