Starlight colors with parallax, small parallax code clean-up (#77020)

The space gas parallax now colors starlight in the color of the gas: 


![image](https://github.com/tgstation/tgstation/assets/7501474/18b5554f-6357-473e-8f43-64aad1517be0)

<details>
  <summary>Others</summary>
  

![image](https://github.com/tgstation/tgstation/assets/7501474/1599795f-f76d-479d-a1c3-aa19390ad403)

![image](https://github.com/tgstation/tgstation/assets/7501474/fb992df0-ee85-4afc-a546-f28e739ea923)

![image](https://github.com/tgstation/tgstation/assets/7501474/ed64a01c-c104-4177-bf63-b82288251aa9)

</details>

I also cleaned up parallax random code a bit, making it easier to add
new parallaxes and add minor effects to them

The radioactive nebula parallax thing has also been moved to SSparallax
to make it easier and a bit more sane to change

🆑
add: Starlight will color with space gas parallax
code: Cleans up random parallax code / radioactive nebula parallax code
/🆑

## Why it's good for the game

We can change the starlight color now (mostly thanks to @LemonInTheDark
making light code easier to work with), so I thought it'd be fun to
actually do! If people hate it, I'll turn it off and we can just call
this a code clean-up PR
This commit is contained in:
Time-Green
2023-07-29 13:21:33 +01:00
committed by GitHub
parent b220dc3010
commit 8f053721a6
6 changed files with 105 additions and 39 deletions
@@ -17,7 +17,7 @@
C.parallax_layers_cached += new /atom/movable/screen/parallax_layer/layer_2(null, src)
C.parallax_layers_cached += new /atom/movable/screen/parallax_layer/planet(null, src)
if(SSparallax.random_layer)
C.parallax_layers_cached += new SSparallax.random_layer(null, src)
C.parallax_layers_cached += new SSparallax.random_layer.type(null, src, SSparallax.random_layer)
C.parallax_layers_cached += new /atom/movable/screen/parallax_layer/layer_3(null, src)
C.parallax_layers = C.parallax_layers_cached.Copy()
@@ -271,9 +271,14 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_layer)
screen_loc = "CENTER-7,CENTER-7"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/parallax_layer/Initialize(mapload, datum/hud/hud_owner)
/atom/movable/screen/parallax_layer/Initialize(mapload, datum/hud/hud_owner, template = FALSE)
. = ..()
if(template)
return
var/client/boss = hud_owner?.mymob?.canon_client
if(!boss) // If this typepath all starts to harddel your culprit is likely this
return INITIALIZE_HINT_QDEL
@@ -322,22 +327,6 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_layer)
speed = 1.4
layer = 3
/atom/movable/screen/parallax_layer/random
blend_mode = BLEND_OVERLAY
speed = 3
layer = 3
/atom/movable/screen/parallax_layer/random/space_gas
icon_state = "space_gas"
/atom/movable/screen/parallax_layer/random/space_gas/Initialize(mapload, datum/hud/hud_owner)
. = ..()
add_atom_colour(SSparallax.random_parallax_color, ADMIN_COLOUR_PRIORITY)
/atom/movable/screen/parallax_layer/random/asteroids
icon_state = "asteroids"
layer = 4
/atom/movable/screen/parallax_layer/planet
icon_state = "planet"
blend_mode = BLEND_OVERLAY
@@ -0,0 +1,51 @@
/// Parallax layers that vary between rounds. Has come code to make sure we all have the same one
/atom/movable/screen/parallax_layer/random
blend_mode = BLEND_OVERLAY
speed = 3
layer = 3
/atom/movable/screen/parallax_layer/random/Initialize(mapload, datum/hud/hud_owner, template, atom/movable/screen/parallax_layer/random/twin)
. = ..()
if(twin)
copy_parallax(twin)
/// Make this layer unique, with color or position or something
/atom/movable/screen/parallax_layer/random/proc/get_random_look()
/// Copy a parallax instance to ensure parity between everyones parallax
/atom/movable/screen/parallax_layer/random/proc/copy_parallax(atom/movable/screen/parallax_layer/random/twin)
/// For applying minor effects related to parallax. If you want big stuff, put it in a station trait or something
/atom/movable/screen/parallax_layer/random/proc/apply_global_effects()
/// Gassy background with a few random colors, also tints starlight!
/atom/movable/screen/parallax_layer/random/space_gas
icon_state = "space_gas"
/// The colors we can be
var/possible_colors = list(COLOR_TEAL, COLOR_GREEN, COLOR_SILVER, COLOR_YELLOW, COLOR_CYAN, COLOR_ORANGE, COLOR_PURPLE)
/// The color we are. If starlight_color is not set, we also become the starlight color
var/parallax_color
/// The color we give to starlight
var/starlight_color
/atom/movable/screen/parallax_layer/random/space_gas/get_random_look()
parallax_color = parallax_color || pick(possible_colors)
/atom/movable/screen/parallax_layer/random/space_gas/copy_parallax(atom/movable/screen/parallax_layer/random/space_gas/twin)
parallax_color = twin.parallax_color
add_atom_colour(parallax_color, ADMIN_COLOUR_PRIORITY)
/atom/movable/screen/parallax_layer/random/space_gas/apply_global_effects()
GLOB.starlight_color = starlight_color || parallax_color
/// Space gas but green for the radioactive nebula station trait
/atom/movable/screen/parallax_layer/random/space_gas/radioactive
parallax_color = list(0,0,0,0, 0,2,0,0, 0,0,0,0, 0,0,0,1, 0,0,0,0) //very vibrant green
starlight_color = COLOR_VIBRANT_LIME
/// Big asteroid rocks appear in the background
/atom/movable/screen/parallax_layer/random/asteroids
icon_state = "asteroids"
layer = 4
+42 -5
View File
@@ -1,3 +1,6 @@
/// Define for the pickweight value where you get no parallax
#define PARALLAX_NONE "parallax_none"
SUBSYSTEM_DEF(parallax)
name = "Parallax"
wait = 2
@@ -7,16 +10,21 @@ SUBSYSTEM_DEF(parallax)
var/list/currentrun
var/planet_x_offset = 128
var/planet_y_offset = 128
var/random_layer
var/random_parallax_color
/// A random parallax layer that we sent to every player
var/atom/movable/screen/parallax_layer/random/random_layer
/// Weighted list with the parallax layers we could spawn
var/random_parallax_weights = list(
/atom/movable/screen/parallax_layer/random/space_gas = 35,
/atom/movable/screen/parallax_layer/random/asteroids = 35,
PARALLAX_NONE = 30,
)
//These are cached per client so needs to be done asap so people joining at roundstart do not miss these.
/datum/controller/subsystem/parallax/PreInit()
. = ..()
if(prob(70)) //70% chance to pick a special extra layer
random_layer = pick(/atom/movable/screen/parallax_layer/random/space_gas, /atom/movable/screen/parallax_layer/random/asteroids)
random_parallax_color = pick(COLOR_TEAL, COLOR_GREEN, COLOR_SILVER, COLOR_YELLOW, COLOR_CYAN, COLOR_ORANGE, COLOR_PURPLE)//Special color for random_layer1. Has to be done here so everyone sees the same color.
set_random_parallax_layer(pick_weight(random_parallax_weights))
planet_y_offset = rand(100, 160)
planet_x_offset = rand(100, 160)
@@ -57,3 +65,32 @@ SUBSYSTEM_DEF(parallax)
if (MC_TICK_CHECK)
return
currentrun = null
/// Generate a random layer for parallax
/datum/controller/subsystem/parallax/proc/set_random_parallax_layer(picked_parallax)
if(picked_parallax == PARALLAX_NONE)
return
random_layer = new picked_parallax(null, /* hud_owner = */ null, /* template = */ TRUE)
RegisterSignal(random_layer, COMSIG_QDELETING, PROC_REF(clear_references))
random_layer.get_random_look()
/// Change the random parallax layer after it's already been set. update_player_huds = TRUE will also replace them in the players client images, if it was set
/datum/controller/subsystem/parallax/proc/swap_out_random_parallax_layer(atom/movable/screen/parallax_layer/new_type, update_player_huds = TRUE)
set_random_parallax_layer(new_type)
if(!update_player_huds)
return
//Parallax is one of the first things to be set (during client join), so rarely is anything fast enough to swap it out
//That's why we need to swap the layers out for fast joining clients :/
for(var/client/client as anything in GLOB.clients)
client.parallax_layers_cached?.Cut()
client.mob?.hud_used?.update_parallax_pref(client.mob)
/datum/controller/subsystem/parallax/proc/clear_references()
SIGNAL_HANDLER
random_layer = null
#undef PARALLAX_NONE
@@ -21,6 +21,7 @@ PROCESSING_SUBSYSTEM_DEF(station)
#endif
announcer = new announcer() //Initialize the station's announcer datum
SSparallax.random_layer.apply_global_effects() //Apply station effects that parallax might have
return SS_INIT_SUCCESS
+2 -15
View File
@@ -429,27 +429,15 @@
show_in_report = TRUE
///The color of the "nebula" we send to the players client
var/nebula_color
///The parallax layer of the nebula
var/nebula_layer = /atom/movable/screen/parallax_layer/random/space_gas
///The color space 'glows'
var/space_light_color = COLOR_STARLIGHT
///If set, gives the basic carp different colors
var/carp_color_override
/datum/station_trait/nebula/New()
. = ..()
///We set the parallax layer to give a visual effect
SSparallax.random_layer = nebula_layer
SSparallax.random_parallax_color = nebula_color //give a unique color to tell the player somethings up
GLOB.starlight_color = space_light_color //color starlight in our nebula color
//parallax is generated for quick-joiners before we can change it, so reset it for them :/
for(var/client/client as anything in GLOB.clients)
client.parallax_layers_cached?.Cut()
client.mob?.hud_used?.update_parallax_pref(client.mob)
SSparallax.swap_out_random_parallax_layer(nebula_layer)
//Color the carp in unique colors to better blend with the nebula
if(carp_color_override)
@@ -541,8 +529,7 @@
intensity_increment_time = 5 MINUTES
maximum_nebula_intensity = 1 HOURS + 40 MINUTES
nebula_color = list(0,0,0,0, 0,2,0,0, 0,0,0,0, 0,0,0,1, 0,0,0,0) //very vibrant green
space_light_color = COLOR_VIBRANT_LIME
nebula_layer = /atom/movable/screen/parallax_layer/random/space_gas/radioactive
carp_color_override = list(
COLOR_CARP_GREEN = 1,
COLOR_CARP_TEAL = 1,
+2 -1
View File
@@ -520,7 +520,6 @@
#include "code\_onclick\hud\movable_screen_objects.dm"
#include "code\_onclick\hud\new_player.dm"
#include "code\_onclick\hud\ooze.dm"
#include "code\_onclick\hud\parallax.dm"
#include "code\_onclick\hud\picture_in_picture.dm"
#include "code\_onclick\hud\radial.dm"
#include "code\_onclick\hud\radial_persistent.dm"
@@ -529,6 +528,8 @@
#include "code\_onclick\hud\screen_object_holder.dm"
#include "code\_onclick\hud\screen_objects.dm"
#include "code\_onclick\hud\screentip.dm"
#include "code\_onclick\hud\parallax\parallax.dm"
#include "code\_onclick\hud\parallax\random_layer.dm"
#include "code\_onclick\hud\rendering\plane_master.dm"
#include "code\_onclick\hud\rendering\plane_master_controller.dm"
#include "code\_onclick\hud\rendering\plane_master_group.dm"