|
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 |
| 1 | +/** |
| 2 | + * Component that manages a list of plane masters that are dependent on weather |
| 3 | + * Force hides/shows them depending on the weather activity of their z stack |
| 4 | + * Transparency is achieved by manipulating the alpha of the planes that are visible |
| 5 | + * Applied to the plane master group that owns them |
| 6 | + */ |
4 | 7 | /datum/component/hide_weather_planes |
5 | 8 | dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS |
6 | 9 | var/list/datum/weather/active_weather = list() |
|
36 | 39 | /datum/component/hide_weather_planes/InheritComponent(datum/component/new_comp, i_am_original, atom/movable/screen/plane_master/care_about) |
37 | 40 | if(!i_am_original) |
38 | 41 | return |
| 42 | + var/datum/plane_master_group/home = parent |
| 43 | + var/mob/our_lad = home.our_hud?.mymob |
| 44 | + var/our_offset = GET_TURF_PLANE_OFFSET(our_lad) |
39 | 45 | plane_masters += care_about |
40 | 46 | RegisterSignal(care_about, COMSIG_QDELETING, PROC_REF(plane_master_deleted)) |
41 | 47 | if(length(active_weather)) |
42 | | - care_about.enable_alpha() |
| 48 | + //If there's weather to care about we unhide our new plane and adjust its alpha |
| 49 | + care_about.unhide_plane(our_lad) |
| 50 | + |
| 51 | + if(care_about.offset >= our_offset) |
| 52 | + care_about.enable_alpha() |
| 53 | + else |
| 54 | + care_about.disable_alpha() |
43 | 55 | else |
44 | | - care_about.disable_alpha() |
| 56 | + care_about.hide_plane(our_lad) |
45 | 57 |
|
46 | 58 | /datum/component/hide_weather_planes/proc/new_hud_attached(datum/source, datum/hud/new_hud) |
47 | 59 | SIGNAL_HANDLER |
48 | | - if(new_hud) |
49 | | - attach_hud(new_hud) |
| 60 | + attach_hud(new_hud) |
50 | 61 |
|
51 | 62 | /datum/component/hide_weather_planes/proc/attach_hud(datum/hud/new_hud) |
52 | 63 | RegisterSignal(new_hud, COMSIG_HUD_Z_CHANGED, PROC_REF(z_changed)) |
|
58 | 69 | SIGNAL_HANDLER |
59 | 70 | plane_masters -= source |
60 | 71 |
|
| 72 | +/** |
| 73 | + * Unhides the relevant planes for the weather to be visible and manipulated. |
| 74 | + * Also updates the alpha of the planes so enabled planes are either fully opaque or fully transparent |
| 75 | + */ |
61 | 76 | /datum/component/hide_weather_planes/proc/display_planes() |
62 | 77 | var/datum/plane_master_group/home = parent |
63 | 78 | var/mob/our_lad = home.our_hud?.mymob |
64 | 79 | var/our_offset = GET_TURF_PLANE_OFFSET(our_lad) |
65 | 80 | 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) |
| 81 | + //If the plane is hidden, unhide it |
| 82 | + if(weather_concious.force_hidden) |
| 83 | + weather_concious.unhide_plane(our_lad) |
| 84 | + |
| 85 | + //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. |
| 86 | + if(weather_concious.offset >= our_offset) |
68 | 87 | weather_concious.enable_alpha() |
| 88 | + else |
| 89 | + weather_concious.disable_alpha() |
69 | 90 |
|
| 91 | +///Hides the planes from the mob when no weather is occuring |
70 | 92 | /datum/component/hide_weather_planes/proc/hide_planes() |
| 93 | + var/datum/plane_master_group/home = parent |
| 94 | + var/mob/our_lad = home.our_hud?.mymob |
71 | 95 | for(var/atom/movable/screen/plane_master/weather_concious as anything in plane_masters) |
72 | | - weather_concious.disable_alpha() |
| 96 | + weather_concious.hide_plane(our_lad) |
73 | 97 |
|
74 | 98 | /datum/component/hide_weather_planes/proc/z_changed(datum/source, new_z) |
75 | 99 | 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 | 100 | active_weather = list() |
83 | 101 | if(!SSmapping.initialized) |
84 | 102 | return |
|
90 | 108 |
|
91 | 109 | if(length(active_weather)) |
92 | 110 | display_planes() |
| 111 | + else |
| 112 | + hide_planes() |
93 | 113 |
|
94 | 114 | /datum/component/hide_weather_planes/proc/weather_started(datum/source, datum/weather/starting) |
95 | 115 | SIGNAL_HANDLER |
|
0 commit comments