mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-23 13:18:09 +01:00
[MIRROR] Up ports the dynamic light system (#10149)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
co-authored by
Kashargul
parent
fe69ddd909
commit
7e2fd538ac
@@ -5,7 +5,7 @@
|
||||
/datum/lighting_corner
|
||||
var/list/datum/light_source/affecting // Light sources affecting us.
|
||||
|
||||
var/sunlight = SUNLIGHT_NONE // CHOMPEdit
|
||||
var/sunlight = SUNLIGHT_NONE
|
||||
var/x = 0
|
||||
var/y = 0
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
///whether we are to be added to SSlighting's corners_queue list for an update
|
||||
var/needs_update = FALSE
|
||||
|
||||
/datum/lighting_corner/New(x, y, z, dynamic) // CHOMPEdit
|
||||
/datum/lighting_corner/New(x, y, z, dynamic)
|
||||
. = ..()
|
||||
|
||||
src.x = x + 0.5
|
||||
@@ -72,7 +72,7 @@
|
||||
master_SE = process_next
|
||||
process_next.lighting_corner_NW = src
|
||||
|
||||
if(((SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) || SSlighting.get_pshandler_z(z)) && dynamic) sunlight = SUNLIGHT_POSSIBLE //CHOMPEdit
|
||||
if(((SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) || SSlighting.get_pshandler_z(z)) && dynamic) sunlight = SUNLIGHT_POSSIBLE
|
||||
|
||||
/datum/lighting_corner/proc/save_master(turf/master, dir)
|
||||
switch (dir)
|
||||
@@ -90,7 +90,7 @@
|
||||
master.lighting_corner_SE = src
|
||||
|
||||
/datum/lighting_corner/proc/self_destruct_if_idle()
|
||||
if (!LAZYLEN(affecting) && !sunlight) //CHOMPEdit
|
||||
if (!LAZYLEN(affecting) && !sunlight)
|
||||
qdel(src, force = TRUE)
|
||||
|
||||
/datum/lighting_corner/proc/vis_update()
|
||||
@@ -102,27 +102,23 @@
|
||||
light_source.recalc_corner(src)
|
||||
|
||||
// God that was a mess, now to do the rest of the corner code! Hooray!
|
||||
/datum/lighting_corner/proc/update_lumcount(delta_r, delta_g, delta_b, var/from_sholder = FALSE) //CHOMPEdit
|
||||
/datum/lighting_corner/proc/update_lumcount(delta_r, delta_g, delta_b, var/from_sholder = FALSE)
|
||||
if (!(delta_r || delta_g || delta_b)) // 0 is falsey ok
|
||||
return
|
||||
|
||||
//CHOMPEdit Begin
|
||||
if((sunlight == SUNLIGHT_ONLY || sunlight == SUNLIGHT_ONLY_SHADE) && LAZYLEN(affecting))
|
||||
change_sun()
|
||||
if(sunlight == SUNLIGHT_ONLY || sunlight == SUNLIGHT_ONLY_SHADE)
|
||||
//Okay fuck. If we're here some doodoo kaka bullshit happened (probably thanks to in-round map loading) and now the sunlight handler that owned us previously is fucking gone (real cool dude) so like try to get a new one ig
|
||||
//Is this optimal? No. Is there a better way? Maybe. God knows I tried, but whatever fucking black magic is going on behind the scenes seems to defy all attempts at logic. So, if this works, it stays.
|
||||
sunlight = SUNLIGHT_POSSIBLE
|
||||
//CHOMPEdit End
|
||||
lum_r += delta_r
|
||||
lum_g += delta_g
|
||||
lum_b += delta_b
|
||||
|
||||
//CHOMPEdit Begin
|
||||
if(sunlight == SUNLIGHT_CURRENT && !LAZYLEN(affecting) && !from_sholder)
|
||||
update_sunlight_handlers()
|
||||
update_sunlight_handlers()
|
||||
//CHOMPEdit End
|
||||
|
||||
if (!needs_update)
|
||||
needs_update = TRUE
|
||||
@@ -204,7 +200,6 @@
|
||||
|
||||
return ..()
|
||||
|
||||
//CHOMPEdit Begin
|
||||
/datum/lighting_corner/proc/update_sun(var/datum/planet_sunlight_handler/pshandler)
|
||||
if(!pshandler)
|
||||
return
|
||||
@@ -311,5 +306,3 @@
|
||||
master_SW_sim.shandler.sunlight_update()
|
||||
if(istype(master_NW_sim) && master_NW_sim.shandler && master_NW_sim.shandler.sleeping)
|
||||
master_NW_sim.shandler.sunlight_update()
|
||||
|
||||
//CHOMPEdit End
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
///whether we are already in the SSlighting.objects_queue list
|
||||
var/needs_update = FALSE
|
||||
|
||||
var/sunlight_only = FALSE //CHOMPEdit
|
||||
var/sunlight_only = FALSE
|
||||
|
||||
///the turf that our light is applied to
|
||||
var/turf/affected_turf
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
/datum/lighting_object/proc/update()
|
||||
|
||||
if(sunlight_only) return //CHOMPEdit
|
||||
if(sunlight_only) return
|
||||
// To the future coder who sees this and thinks
|
||||
// "Why didn't he just use a loop?"
|
||||
// Well my man, it's because the loop performed like shit.
|
||||
@@ -90,7 +90,7 @@
|
||||
current_underlay.color = null
|
||||
else
|
||||
current_underlay.icon_state = "gradient"
|
||||
current_underlay.color = null //CHOMPEdit
|
||||
current_underlay.color = null
|
||||
current_underlay.color = list(
|
||||
red_corner.cache_r, red_corner.cache_g, red_corner.cache_b, 00,
|
||||
green_corner.cache_r, green_corner.cache_g, green_corner.cache_b, 00,
|
||||
@@ -110,7 +110,6 @@
|
||||
/datum/lighting_object/proc/addtoturf()
|
||||
affected_turf.underlays |= current_underlay
|
||||
|
||||
//CHOMPEdit Begin
|
||||
/datum/lighting_object/proc/update_sun()
|
||||
if(QDELETED(src))
|
||||
return
|
||||
@@ -137,6 +136,3 @@
|
||||
affected_turf.vis_contents += pshandler.vis_shade
|
||||
if(FALSE)
|
||||
affected_turf.underlays |= current_underlay
|
||||
|
||||
|
||||
//CHOMPEdit End
|
||||
|
||||
@@ -145,7 +145,6 @@
|
||||
(. * _lum_b) - (OLD * _applied_lum_b) \
|
||||
); \
|
||||
|
||||
//CHOMPEdit Begin
|
||||
#define APPLY_CORNER_NEW(C) \
|
||||
. = LUM_FALLOFF(C); \
|
||||
. *= _light_power; \
|
||||
@@ -160,7 +159,7 @@
|
||||
(. * _lum_g) - (OLD * _applied_lum_g), \
|
||||
(. * _lum_b) - (OLD * _applied_lum_b) \
|
||||
); \
|
||||
//CHOMPEdit End
|
||||
|
||||
#define REMOVE_CORNER(C) \
|
||||
. = -effect_str[C]; \
|
||||
C.update_lumcount \
|
||||
@@ -174,8 +173,8 @@
|
||||
SETUP_CORNERS_REMOVAL_CACHE(src)
|
||||
applied = FALSE
|
||||
for (var/datum/lighting_corner/corner as anything in effect_str)
|
||||
LAZYREMOVE(corner.affecting, src) //CHOMPEdit
|
||||
REMOVE_CORNER(corner) //CHOMPEdit
|
||||
LAZYREMOVE(corner.affecting, src)
|
||||
REMOVE_CORNER(corner)
|
||||
|
||||
effect_str = null
|
||||
|
||||
@@ -192,24 +191,6 @@
|
||||
/datum/light_source/proc/get_turfs_in_range()
|
||||
return view(CEILING(light_range, 1), source_turf)
|
||||
|
||||
// Keep in mind. Lighting corners accept the bottom left (northwest) set of cords to them as input
|
||||
/* CHOMPRemove Start, we use our own in _defines
|
||||
# define GENERATE_MISSING_CORNERS(gen_for) \
|
||||
if (!gen_for.lighting_corner_NE) { \
|
||||
gen_for.lighting_corner_NE = new /datum/lighting_corner(gen_for.x, gen_for.y, gen_for.z); \
|
||||
} \
|
||||
if (!gen_for.lighting_corner_SE) { \
|
||||
gen_for.lighting_corner_SE = new /datum/lighting_corner(gen_for.x, gen_for.y - 1, gen_for.z); \
|
||||
} \
|
||||
if (!gen_for.lighting_corner_SW) { \
|
||||
gen_for.lighting_corner_SW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y - 1, gen_for.z); \
|
||||
} \
|
||||
if (!gen_for.lighting_corner_NW) { \
|
||||
gen_for.lighting_corner_NW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y, gen_for.z); \
|
||||
} \
|
||||
gen_for.lighting_corners_initialised = TRUE;
|
||||
*/// CHOMPRemove End
|
||||
|
||||
/datum/light_source/proc/update_corners()
|
||||
var/update = FALSE
|
||||
var/atom/source_atom = src.source_atom
|
||||
@@ -294,18 +275,13 @@
|
||||
LAZYINITLIST(src.effect_str)
|
||||
var/list/effect_str = src.effect_str
|
||||
if (needs_update == LIGHTING_VIS_UPDATE)
|
||||
for (var/datum/lighting_corner/corner in new_corners) //CHOMPEdit
|
||||
//CHOMPEdit Begin
|
||||
for (var/datum/lighting_corner/corner in new_corners)
|
||||
APPLY_CORNER_NEW(corner)
|
||||
//CHOMPEdit End
|
||||
else
|
||||
for (var/datum/lighting_corner/corner in new_corners) //CHOMPEdit
|
||||
//CHOMPEdit Begin
|
||||
for (var/datum/lighting_corner/corner in new_corners)
|
||||
APPLY_CORNER_NEW(corner)
|
||||
//CHOMPEdit End
|
||||
|
||||
for (var/datum/lighting_corner/corner in corners - new_corners) // Existing corners //CHOMPEdit
|
||||
//CHOMPEdit Begin
|
||||
for (var/datum/lighting_corner/corner in corners - new_corners) // Existing corners
|
||||
. = LUM_FALLOFF(corner);
|
||||
. *= _light_power;
|
||||
var/OLD = effect_str[corner];
|
||||
@@ -321,12 +297,11 @@
|
||||
(. * _lum_b) - (OLD * _applied_lum_b) \
|
||||
);
|
||||
#undef APPLY_CORNER_NEW
|
||||
//CHOMPEdit End
|
||||
|
||||
var/list/datum/lighting_corner/gone_corners = effect_str - corners
|
||||
for (var/datum/lighting_corner/corner as anything in gone_corners)
|
||||
LAZYREMOVE(corner.affecting, src) //CHOMPEdit
|
||||
REMOVE_CORNER(corner) //CHOMPEdit
|
||||
LAZYREMOVE(corner.affecting, src)
|
||||
REMOVE_CORNER(corner)
|
||||
effect_str -= gone_corners
|
||||
|
||||
applied_lum_r = lum_r
|
||||
|
||||
@@ -96,11 +96,6 @@
|
||||
|
||||
///Setter for the byond luminosity var
|
||||
/turf/proc/set_luminosity(new_luminosity, force)
|
||||
/*CHOMP Removal Begin
|
||||
if((is_outdoors() && !force) || outdoors_adjacent)
|
||||
if(check_for_sun()) //If another system handles our lighting, don't interfere
|
||||
return
|
||||
*/ //CHOMP Removal End
|
||||
if(((is_outdoors() && !force) || outdoors_adjacent) && (z in fake_sunlight_zs)) //Special exception for fakesun lit tiles
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user