[MIRROR] Overlay lighting component (#469)

* Overlay lighting component (#52413)

Sparks no longer lag, projectile beams move super smoothly, same with mobs and whatnot. This also allows for easy expansion into directional lights, field-of-view, wee-woo rotating lights or whatever.

It does have a downside: things right-clicked or checked through the alt+click tab will show the light overlay:


This is a BYOND limitation, very well worth it IMO.

🆑
add: Smooth movable lighting system implemented. Projectiles, sparks, thrown flashlights or moving mobs with lights should be much smoother and less laggy.
balance: Light sources no longer stack in range, though they still do in intensity.
/🆑

* Overlay lighting component

Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
SkyratBot
2020-08-23 20:17:12 +02:00
committed by GitHub
co-authored by Rohesie
parent 4a51355a9e
commit 0b65cc596b
85 changed files with 1082 additions and 395 deletions
+8 -4
View File
@@ -17,6 +17,10 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
invisibility = INVISIBILITY_OBSERVER
hud_type = /datum/hud/ghost
movement_type = GROUND | FLYING
light_system = MOVABLE_LIGHT
light_range = 1
light_power = 2
light_on = FALSE
var/can_reenter_corpse
var/datum/hud/living/carbon/hud = null // hud
var/bootime = 0
@@ -144,6 +148,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
show_data_huds()
data_huds_on = 1
/mob/dead/observer/get_photo_description(obj/item/camera/camera)
if(!invisibility || camera.see_ghosts)
return "You can also see a g-g-g-g-ghooooost!"
@@ -901,12 +906,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
. = list("<span class='notice'><i>You examine [src] closer, and note the following...</i></span>")
. += list("\t><span class='admin'>[ADMIN_FULLMONTY(src)]</span>")
/mob/dead/observer/proc/set_invisibility(value)
invisibility = value
if(!value)
set_light(1, 2)
else
set_light(0, 0)
set_light_on(!value ? TRUE : FALSE)
// Ghosts have no momentum, being massless ectoplasm
/mob/dead/observer/Process_Spacemove(movement_dir)
@@ -39,24 +39,36 @@
var/static/b2 = 149
//this is shit but how do i fix it? no clue.
var/drain_time = 0 //used to keep ethereals from spam draining power sources
var/obj/effect/dummy/lighting_obj/ethereal_light
/datum/species/ethereal/Destroy(force)
if(ethereal_light)
QDEL_NULL(ethereal_light)
return ..()
/datum/species/ethereal/on_species_gain(mob/living/carbon/C, datum/species/old_species, pref_load)
.=..()
if(ishuman(C))
var/mob/living/carbon/human/H = C
default_color = "#" + H.dna.features["ethcolor"]
r1 = GETREDPART(default_color)
g1 = GETGREENPART(default_color)
b1 = GETBLUEPART(default_color)
spec_updatehealth(H)
RegisterSignal(C, COMSIG_ATOM_EMAG_ACT, .proc/on_emag_act)
RegisterSignal(C, COMSIG_ATOM_EMP_ACT, .proc/on_emp_act)
. = ..()
if(!ishuman(C))
return
var/mob/living/carbon/human/ethereal = C
default_color = "#[ethereal.dna.features["ethcolor"]]"
r1 = GETREDPART(default_color)
g1 = GETGREENPART(default_color)
b1 = GETBLUEPART(default_color)
RegisterSignal(ethereal, COMSIG_ATOM_EMAG_ACT, .proc/on_emag_act)
RegisterSignal(ethereal, COMSIG_ATOM_EMP_ACT, .proc/on_emp_act)
ethereal_light = ethereal.mob_light()
spec_updatehealth(ethereal)
/datum/species/ethereal/on_species_loss(mob/living/carbon/human/C, datum/species/new_species, pref_load)
.=..()
C.set_light(0)
UnregisterSignal(C, COMSIG_ATOM_EMAG_ACT)
UnregisterSignal(C, COMSIG_ATOM_EMP_ACT)
QDEL_NULL(ethereal_light)
return ..()
/datum/species/ethereal/random_name(gender,unique,lastname)
if(unique)
@@ -66,16 +78,18 @@
return randname
/datum/species/ethereal/spec_updatehealth(mob/living/carbon/human/H)
.=..()
. = ..()
if(H.stat != DEAD && !EMPeffect)
var/healthpercent = max(H.health, 0) / 100
if(!emageffect)
current_color = rgb(r2 + ((r1-r2)*healthpercent), g2 + ((g1-g2)*healthpercent), b2 + ((b1-b2)*healthpercent))
H.set_light(1 + (2 * healthpercent), 1 + (1 * healthpercent), current_color)
ethereal_light.set_light_range_power_color(1 + (2 * healthpercent), 1 + (1 * healthpercent), current_color)
ethereal_light.set_light_on(TRUE)
fixed_mut_color = copytext_char(current_color, 2)
else
H.set_light(0)
ethereal_light.set_light_on(FALSE)
fixed_mut_color = rgb(128,128,128)
H.update_body()
@@ -449,7 +449,9 @@
name = "luminescent glow"
desc = "Tell a coder if you're seeing this."
icon_state = "nothing"
light_system = MOVABLE_LIGHT
light_range = LUMINESCENT_DEFAULT_GLOW
light_power = 2.5
light_color = COLOR_WHITE
/obj/effect/dummy/luminescent_glow/Initialize()
@@ -457,6 +459,7 @@
if(!isliving(loc))
return INITIALIZE_HINT_QDEL
/datum/action/innate/integrate_extract
name = "Integrate Extract"
desc = "Eat a slime extract to use its properties."
@@ -238,8 +238,8 @@
if(istype(O, /obj/item/pda))
var/obj/item/pda/PDA = O
PDA.set_light(0)
PDA.fon = FALSE
PDA.f_lum = 0
PDA.set_light_on(FALSE)
PDA.set_light_range(0) //It won't be turning on again.
PDA.update_icon()
A.visible_message("<span class='danger'>The light in [PDA] shorts out!</span>")
else
+20 -11
View File
@@ -13,6 +13,8 @@
radio = /obj/item/radio/borg
blocks_emissive = EMISSIVE_BLOCK_UNIQUE
light_system = MOVABLE_LIGHT
light_on = FALSE
var/custom_name = ""
var/braintype = "Cyborg"
@@ -105,7 +107,6 @@
wires = new /datum/wires/robot(src)
AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES)
RegisterSignal(src, COMSIG_PROCESS_BORGCHARGER_OCCUPANT, .proc/charge)
robot_modules_background = new()
@@ -537,31 +538,39 @@
return //won't work if dead
set_autosay()
/mob/living/silicon/robot/proc/control_headlamp()
if(stat || lamp_cooldown > world.time || low_power_mode)
to_chat(src, "<span class='danger'>This function is currently offline.</span>")
return
//Some sort of magical "modulo" thing which somehow increments lamp power by 2, until it hits the max and resets to 0.
lamp_intensity = (lamp_intensity+2) % (lamp_max+2)
to_chat(src, "<span class='notice'>[lamp_intensity ? "Headlamp power set to Level [lamp_intensity/2]" : "Headlamp disabled"].</span>")
if(lamp_intensity == 0) //We'll skip intensity of 2, since every mob already has such a see-darkness range, so no much need for it.
lamp_intensity = 4
else //Some sort of magical "modulo" thing which somehow increments lamp power by 2, until it hits the max and resets to 0.
lamp_intensity = (lamp_intensity + 2) % (lamp_max + 2)
to_chat(src, "<span class='notice'>[lamp_intensity > 2 ? "Headlamp power set to Level [lamp_intensity * 0.5]" : "Headlamp disabled"].</span>")
update_headlamp()
/mob/living/silicon/robot/proc/update_headlamp(turn_off = 0, cooldown = 100)
set_light(0)
if(lamp_intensity && (turn_off || stat || low_power_mode))
to_chat(src, "<span class='danger'>Your headlamp has been deactivated.</span>")
lamp_intensity = 0
lamp_cooldown = cooldown == BORG_LAMP_CD_RESET ? 0 : max(world.time + cooldown, lamp_cooldown)
/mob/living/silicon/robot/proc/update_headlamp(turn_off = FALSE, cooldown = 10 SECONDS)
if(lamp_intensity > 2)
if(turn_off || stat || low_power_mode)
to_chat(src, "<span class='danger'>Your headlamp has been deactivated.</span>")
lamp_intensity = 0
lamp_cooldown = cooldown == BORG_LAMP_CD_RESET ? 0 : max(world.time + cooldown, lamp_cooldown)
set_light_on(FALSE)
else
set_light_range(lamp_intensity * 0.5)
set_light_on(TRUE)
else
set_light(lamp_intensity)
set_light_on(FALSE)
if(lamp_button)
lamp_button.icon_state = "lamp[lamp_intensity]"
update_icons()
/mob/living/silicon/robot/proc/deconstruct()
SEND_SIGNAL(src, COMSIG_BORG_SAFE_DECONSTRUCT)
var/turf/T = get_turf(src)
@@ -4,7 +4,6 @@
layer = MOB_LAYER
gender = NEUTER
mob_biotypes = MOB_ROBOTIC
light_range = 3
stop_automated_movement = 1
wander = 0
healable = 0
@@ -23,6 +22,9 @@
bubble_icon = "machine"
speech_span = SPAN_ROBOT
faction = list("neutral", "silicon" , "turret")
light_system = MOVABLE_LIGHT
light_range = 3
light_power = 0.9
var/obj/machinery/bot_core/bot_core = null
var/bot_core_type = /obj/machinery/bot_core
@@ -128,7 +130,7 @@
return FALSE
on = TRUE
update_mobility()
set_light(initial(light_range))
set_light_on(on)
update_icon()
to_chat(src, "<span class='boldnotice'>You turned on!</span>")
diag_hud_set_botstat()
@@ -137,7 +139,7 @@
/mob/living/simple_animal/bot/proc/turn_off()
on = FALSE
update_mobility()
set_light(0)
set_light_on(on)
bot_reset() //Resets an AI's call, should it exist.
to_chat(src, "<span class='userdanger'>You turned off!</span>")
update_icon()
@@ -17,11 +17,11 @@
window_name = "Discomatic Vibe Bot v1.05"
data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC // show jobs
path_image_color = "#2cac12"
var/current_color
var/range = 7
var/power = 3
auto_patrol = TRUE
light_system = MOVABLE_LIGHT
light_range = 7
light_power = 3
/mob/living/simple_animal/bot/vibebot/Initialize()
. = ..()
@@ -48,9 +48,8 @@
/mob/living/simple_animal/bot/vibebot/proc/Vibe()
remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
current_color = random_color()
set_light(range, power, current_color)
add_atom_colour("#[current_color]", TEMPORARY_COLOUR_PRIORITY)
add_atom_colour("#[random_color()]", TEMPORARY_COLOUR_PRIORITY)
set_light_color(color)
update_icon()
/mob/living/simple_animal/bot/vibebot/proc/retaliate(mob/living/carbon/human/H)
@@ -42,6 +42,9 @@ GLOBAL_LIST_EMPTY(parasites) //all currently existing/living guardians
melee_damage_upper = 15
butcher_results = list(/obj/item/ectoplasm = 1)
AIStatus = AI_OFF
light_system = MOVABLE_LIGHT
light_range = 3
light_on = FALSE
hud_type = /datum/hud/guardian
dextrous_hud_type = /datum/hud/dextrous/guardian //if we're set to dextrous, account for it.
var/mutable_appearance/cooloverlay
@@ -370,13 +373,15 @@ GLOBAL_LIST_EMPTY(parasites) //all currently existing/living guardians
/mob/living/simple_animal/hostile/guardian/proc/ToggleMode()
to_chat(src, "<span class='danger'><B>You don't have another mode!</span></B>")
/mob/living/simple_animal/hostile/guardian/proc/ToggleLight()
if(light_range<3)
if(!light_on)
to_chat(src, "<span class='notice'>You activate your light.</span>")
set_light(3)
set_light_on(TRUE)
else
to_chat(src, "<span class='notice'>You deactivate your light.</span>")
set_light(0)
set_light_on(FALSE)
/mob/living/simple_animal/hostile/guardian/verb/ShowType()
set name = "Check Guardian Type"
@@ -60,10 +60,10 @@
QDEL_NULL(alert_light)
if(a_intent != INTENT_HELP)
icon_state = "[initial(icon_state)]_attack"
alert_light = mob_light(COLOR_RED_LIGHT, 6, 0.4)
alert_light = mob_light(6, 0.4, COLOR_RED_LIGHT)
else
icon_state = initial(icon_state)
/mob/living/simple_animal/hostile/hivebot/death(gibbed)
do_sparks(3, TRUE, src)
..(TRUE)
@@ -96,7 +96,7 @@
health = 80
maxHealth = 80
ranged = TRUE
/mob/living/simple_animal/hostile/hivebot/mechanic
name = "hivebot mechanic"
icon_state = "strong"
@@ -109,12 +109,12 @@
rapid = 3
gold_core_spawnable = HOSTILE_SPAWN
var/datum/action/innate/hivebot/foamwall/foam
/mob/living/simple_animal/hostile/hivebot/mechanic/Initialize()
. = ..()
foam = new
foam.Grant(src)
/mob/living/simple_animal/hostile/hivebot/mechanic/AttackingTarget()
if(istype(target, /obj/machinery))
var/obj/machinery/fixable = target
@@ -139,14 +139,14 @@
to_chat(src, "<span class='warning'>Repairs complete.</span>")
return
return ..()
/datum/action/innate/hivebot
background_icon_state = "bg_default"
/datum/action/innate/hivebot/foamwall
name = "Foam Wall"
desc = "Creates a foam wall that resists against the vacuum of space."
/datum/action/innate/hivebot/foamwall/Activate()
var/mob/living/simple_animal/hostile/hivebot/H = owner
var/turf/T = get_turf(H)
@@ -232,6 +232,7 @@ Difficulty: Very Hard
icon = 'icons/effects/effects.dmi'
icon_state = "at_shield2"
layer = FLY_LAYER
light_system = MOVABLE_LIGHT
light_range = 2
duration = 8
var/target
@@ -160,6 +160,7 @@
icon_dead = "watcher_magmawing_dead"
maxHealth = 215 //Compensate for the lack of slowdown on projectiles with a bit of extra health
health = 215
light_system = MOVABLE_LIGHT
light_range = 3
light_power = 2.5
light_color = LIGHT_COLOR_LAVA
@@ -31,6 +31,9 @@
movement_type = FLYING
pressure_resistance = 300
gold_core_spawnable = NO_SPAWN //too spooky for science
light_system = MOVABLE_LIGHT
light_range = 1 // same glowing as visible player ghosts
light_power = 2
var/ghost_hairstyle
var/ghost_hair_color
var/mutable_appearance/ghost_hair
@@ -42,7 +45,6 @@
/mob/living/simple_animal/hostile/retaliate/ghost/Initialize()
. = ..()
give_hair()
set_light(1, 2) // same glowing as visible player ghosts
if(random)
switch(rand(0,1))
if(0)