mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Merge pull request #10955 from VOREStation/Arokha/fakesunfix
Fixup fake sun to work like planetary lights
This commit is contained in:
committed by
Chompstation Bot
parent
0f8fefd765
commit
5b15eff22b
@@ -4,7 +4,7 @@
|
|||||||
icon = 'icons/effects/effects_vr.dmi'
|
icon = 'icons/effects/effects_vr.dmi'
|
||||||
icon_state = "fakesun"
|
icon_state = "fakesun"
|
||||||
invisibility = INVISIBILITY_ABSTRACT
|
invisibility = INVISIBILITY_ABSTRACT
|
||||||
var/datum/light_source/sun/fake_sun
|
var/atom/movable/sun_visuals/sun
|
||||||
|
|
||||||
var/list/possible_light_setups = list(
|
var/list/possible_light_setups = list(
|
||||||
list(
|
list(
|
||||||
@@ -88,10 +88,6 @@
|
|||||||
if(choice["brightness"] <= LIGHTING_SOFT_THRESHOLD) // dark!
|
if(choice["brightness"] <= LIGHTING_SOFT_THRESHOLD) // dark!
|
||||||
return
|
return
|
||||||
|
|
||||||
fake_sun = new
|
|
||||||
fake_sun.light_color = choice["color"]
|
|
||||||
fake_sun.light_power = choice["brightness"]
|
|
||||||
|
|
||||||
var/list/zees = GetConnectedZlevels()
|
var/list/zees = GetConnectedZlevels()
|
||||||
var/min = z
|
var/min = z
|
||||||
var/max = z
|
var/max = z
|
||||||
@@ -111,7 +107,15 @@
|
|||||||
warning("Fake sun placed on a level where it can't find any outdoor turfs to color at [x],[y],[z].")
|
warning("Fake sun placed on a level where it can't find any outdoor turfs to color at [x],[y],[z].")
|
||||||
return
|
return
|
||||||
|
|
||||||
fake_sun.update_corners(turfs_to_use)
|
sun = new(null)
|
||||||
|
|
||||||
|
sun.color = choice["color"]
|
||||||
|
sun.alpha = round(CLAMP01(choice["brightness"])*255,1)
|
||||||
|
|
||||||
|
for(var/turf/T as anything in turfs_to_use)
|
||||||
|
T.vis_contents += sun
|
||||||
|
T.dynamic_lumcount = 0.5 // Cheap hack
|
||||||
|
T.set_luminosity(1, TRUE)
|
||||||
|
|
||||||
/obj/effect/fake_sun/warm
|
/obj/effect/fake_sun/warm
|
||||||
name = "warm fake sun"
|
name = "warm fake sun"
|
||||||
|
|||||||
@@ -139,18 +139,6 @@
|
|||||||
. * applied_lum_b \
|
. * applied_lum_b \
|
||||||
);
|
);
|
||||||
|
|
||||||
#define APPLY_CORNER_SIMPLE(C) \
|
|
||||||
. = light_power; \
|
|
||||||
var/OLD = effect_str[C]; \
|
|
||||||
\
|
|
||||||
C.update_lumcount \
|
|
||||||
( \
|
|
||||||
(. * lum_r) - (OLD * applied_lum_r), \
|
|
||||||
(. * lum_g) - (OLD * applied_lum_g), \
|
|
||||||
(. * lum_b) - (OLD * applied_lum_b) \
|
|
||||||
); \
|
|
||||||
|
|
||||||
|
|
||||||
/datum/light_source/proc/remove_lum()
|
/datum/light_source/proc/remove_lum()
|
||||||
applied = FALSE
|
applied = FALSE
|
||||||
for (var/datum/lighting_corner/corner as anything in effect_str)
|
for (var/datum/lighting_corner/corner as anything in effect_str)
|
||||||
@@ -284,91 +272,7 @@
|
|||||||
|
|
||||||
UNSETEMPTY(effect_str)
|
UNSETEMPTY(effect_str)
|
||||||
|
|
||||||
// For planets and fake suns
|
|
||||||
/datum/light_source/sun
|
|
||||||
light_range = 1
|
|
||||||
light_color = "#FFFFFF"
|
|
||||||
light_power = 2
|
|
||||||
var/applied_power = 2
|
|
||||||
|
|
||||||
/datum/light_source/sun/New()
|
|
||||||
return
|
|
||||||
|
|
||||||
/datum/light_source/sun/force_update()
|
|
||||||
return
|
|
||||||
|
|
||||||
/datum/light_source/sun/vis_update()
|
|
||||||
return
|
|
||||||
|
|
||||||
/datum/light_source/sun/update_corners(var/list/turfs_to_update)
|
|
||||||
if(!LAZYLEN(turfs_to_update))
|
|
||||||
stack_trace("Planet sun tried to update with no turfs given")
|
|
||||||
return
|
|
||||||
|
|
||||||
// Update lum_r/g/b from our light_color
|
|
||||||
PARSE_LIGHT_COLOR(src)
|
|
||||||
|
|
||||||
// Noop update
|
|
||||||
if(lum_r == applied_lum_r && lum_g == applied_lum_g && lum_b == applied_lum_b && light_power == applied_power)
|
|
||||||
return
|
|
||||||
|
|
||||||
// No reason to unapply on the first run or if previous run was 0 power
|
|
||||||
if(applied)
|
|
||||||
remove_lum()
|
|
||||||
|
|
||||||
// Entirely dark, just stop now that we've remove_lum()'d
|
|
||||||
if(!light_power)
|
|
||||||
applied = FALSE
|
|
||||||
return
|
|
||||||
|
|
||||||
LAZYINITLIST(effect_str)
|
|
||||||
|
|
||||||
var/list/datum/lighting_corner/corners = list()
|
|
||||||
for(var/turf/T as anything in turfs_to_update)
|
|
||||||
if(!IS_OPAQUE_TURF(T))
|
|
||||||
if(!T.lighting_corners_initialised)
|
|
||||||
T.generate_missing_corners()
|
|
||||||
|
|
||||||
var/datum/lighting_corner/LC = T.lighting_corner_NE
|
|
||||||
if(!corners[LC])
|
|
||||||
corners[LC] = 1
|
|
||||||
APPLY_CORNER_SIMPLE(LC)
|
|
||||||
LAZYADD(LC.affecting, src)
|
|
||||||
effect_str[LC] = .
|
|
||||||
|
|
||||||
LC = T.lighting_corner_SE
|
|
||||||
if(!corners[LC])
|
|
||||||
corners[LC] = 1
|
|
||||||
APPLY_CORNER_SIMPLE(LC)
|
|
||||||
LAZYADD(LC.affecting, src)
|
|
||||||
effect_str[LC] = .
|
|
||||||
|
|
||||||
LC = T.lighting_corner_NW
|
|
||||||
if(!corners[LC])
|
|
||||||
corners[LC] = 1
|
|
||||||
APPLY_CORNER_SIMPLE(LC)
|
|
||||||
LAZYADD(LC.affecting, src)
|
|
||||||
effect_str[LC] = .
|
|
||||||
|
|
||||||
LC = T.lighting_corner_SW
|
|
||||||
if(!corners[LC])
|
|
||||||
corners[LC] = 1
|
|
||||||
APPLY_CORNER_SIMPLE(LC)
|
|
||||||
LAZYADD(LC.affecting, src)
|
|
||||||
effect_str[LC] = .
|
|
||||||
|
|
||||||
CHECK_TICK
|
|
||||||
|
|
||||||
applied_lum_r = lum_r
|
|
||||||
applied_lum_g = lum_g
|
|
||||||
applied_lum_b = lum_b
|
|
||||||
applied_power = light_power
|
|
||||||
applied = TRUE // remove_lum() now necessary in the future
|
|
||||||
|
|
||||||
UNSETEMPTY(effect_str)
|
|
||||||
|
|
||||||
#undef EFFECT_UPDATE
|
#undef EFFECT_UPDATE
|
||||||
#undef LUM_FALLOFF
|
#undef LUM_FALLOFF
|
||||||
#undef REMOVE_CORNER
|
#undef REMOVE_CORNER
|
||||||
#undef APPLY_CORNER
|
#undef APPLY_CORNER
|
||||||
#undef APPLY_CORNER_SIMPLE
|
|
||||||
Reference in New Issue
Block a user