[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
+24 -11
View File
@@ -16,7 +16,11 @@
usesound = list('sound/items/welder.ogg', 'sound/items/welder2.ogg')
drop_sound = 'sound/items/handling/weldingtool_drop.ogg'
pickup_sound = 'sound/items/handling/weldingtool_pickup.ogg'
light_system = MOVABLE_LIGHT
light_range = 2
light_power = 0.75
light_color = LIGHT_COLOR_FIRE
light_on = FALSE
throw_speed = 3
throw_range = 5
w_class = WEIGHT_CLASS_SMALL
@@ -28,12 +32,12 @@
wound_bonus = 10
bare_wound_bonus = 15
custom_materials = list(/datum/material/iron=70, /datum/material/glass=30)
var/welding = 0 //Whether or not the welding tool is off(0), on(1) or currently welding(2)
///Whether the welding tool is on or off.
var/welding = FALSE
var/status = TRUE //Whether the welder is secured or unsecured (able to attach rods to it to make a flamethrower)
var/max_fuel = 20 //The max amount of fuel the welder can hold
var/change_icons = 1
var/can_off_process = 0
var/light_intensity = 2 //how powerful the emitted light is when used.
var/burned_fuel_for = 0 //when fuel was last removed
var/acti_sound = 'sound/items/welderactivate.ogg'
var/deac_sound = 'sound/items/welderdeactivate.ogg'
@@ -47,7 +51,7 @@
/obj/item/weldingtool/ComponentInitialize()
. = ..()
AddElement(/datum/element/update_icon_updates_onmob)
AddElement(/datum/element/tool_flash, light_intensity)
AddElement(/datum/element/tool_flash, light_range)
/obj/item/weldingtool/update_icon_state()
if(welding)
@@ -158,16 +162,16 @@
message_admins("[ADMIN_LOOKUPFLW(user)] set [key_name_admin(L)] on fire with [src] at [AREACOORD(user)]")
log_game("[key_name(user)] set [key_name(L)] on fire with [src] at [AREACOORD(user)]")
/obj/item/weldingtool/attack_self(mob/user)
if(src.reagents.has_reagent(/datum/reagent/toxin/plasma))
message_admins("[ADMIN_LOOKUPFLW(user)] activated a rigged welder at [AREACOORD(user)].")
explode()
switched_on(user)
if(welding)
set_light(light_intensity)
update_icon()
// Ah fuck, I can't believe you've done this
/obj/item/weldingtool/proc/handle_fuel_and_temps(used = 0, mob/living/user)
use(used)
@@ -194,10 +198,19 @@
return FALSE
//Toggles the welding value.
/obj/item/weldingtool/proc/set_welding(new_value)
if(welding == new_value)
return
. = welding
welding = new_value
set_light_on(welding)
//Turns off the welder if there is no more fuel (does this really need to be its own proc?)
/obj/item/weldingtool/proc/check_fuel(mob/user)
if(get_fuel() <= 0 && welding)
set_light(0)
set_light_on(FALSE)
switched_on(user)
update_icon()
return 0
@@ -208,7 +221,7 @@
if(!status)
to_chat(user, "<span class='warning'>[src] can't be turned on while unsecured!</span>")
return
welding = !welding
set_welding(!welding)
if(welding)
if(get_fuel() >= 1)
to_chat(user, "<span class='notice'>You switch [src] on.</span>")
@@ -228,8 +241,7 @@
//Switches the welder off
/obj/item/weldingtool/proc/switched_off(mob/user)
welding = 0
set_light(0)
set_welding(FALSE)
force = 3
damtype = "brute"
@@ -335,7 +347,8 @@
icon = 'icons/obj/abductor.dmi'
icon_state = "welder"
toolspeed = 0.1
light_intensity = 0
light_system = NO_LIGHT_SUPPORT
light_range = 0
change_icons = 0
/obj/item/weldingtool/abductor/process()
@@ -360,7 +373,7 @@
custom_materials = list(/datum/material/iron=70, /datum/material/glass=120)
change_icons = 0
can_off_process = 1
light_intensity = 1
light_range = 1
toolspeed = 0.5
var/last_gen = 0
var/nextrefueltick = 0