mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 04:30:44 +01:00
[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:
@@ -398,9 +398,7 @@
|
||||
if(!user.transferItemToLoc(I, src))
|
||||
return
|
||||
to_chat(user, "<span class='notice'>You click [S] into place on [src].</span>")
|
||||
if(S.on)
|
||||
set_light(0)
|
||||
gun_light = S
|
||||
set_gun_light(S)
|
||||
update_gunlight()
|
||||
alight = new(src)
|
||||
if(loc == user)
|
||||
@@ -508,12 +506,30 @@
|
||||
if(!gun_light)
|
||||
return
|
||||
var/obj/item/flashlight/seclite/removed_light = gun_light
|
||||
gun_light = null
|
||||
set_gun_light(null)
|
||||
update_gunlight()
|
||||
removed_light.update_brightness()
|
||||
QDEL_NULL(alight)
|
||||
return TRUE
|
||||
|
||||
|
||||
///Called when gun_light value changes.
|
||||
/obj/item/gun/proc/set_gun_light(obj/item/flashlight/seclite/new_light)
|
||||
if(gun_light == new_light)
|
||||
return
|
||||
. = gun_light
|
||||
gun_light = new_light
|
||||
if(gun_light)
|
||||
gun_light.set_light_flags(gun_light.light_flags | LIGHT_ATTACHED)
|
||||
if(gun_light.loc != src)
|
||||
gun_light.forceMove(src)
|
||||
else if(.)
|
||||
var/obj/item/flashlight/seclite/old_gun_light = .
|
||||
old_gun_light.set_light_flags(old_gun_light.light_flags & ~LIGHT_ATTACHED)
|
||||
if(old_gun_light.loc == src)
|
||||
old_gun_light.forceMove(get_turf(src))
|
||||
|
||||
|
||||
/obj/item/gun/ui_action_click(mob/user, actiontype)
|
||||
if(istype(actiontype, alight))
|
||||
toggle_gunlight()
|
||||
@@ -526,19 +542,13 @@
|
||||
|
||||
var/mob/living/carbon/human/user = usr
|
||||
gun_light.on = !gun_light.on
|
||||
gun_light.update_brightness()
|
||||
to_chat(user, "<span class='notice'>You toggle the gunlight [gun_light.on ? "on":"off"].</span>")
|
||||
|
||||
playsound(user, 'sound/weapons/empty.ogg', 100, TRUE)
|
||||
update_gunlight()
|
||||
|
||||
/obj/item/gun/proc/update_gunlight()
|
||||
if(gun_light)
|
||||
if(gun_light.on)
|
||||
set_light(gun_light.brightness_on)
|
||||
else
|
||||
set_light(0)
|
||||
else
|
||||
set_light(0)
|
||||
update_icon()
|
||||
for(var/X in actions)
|
||||
var/datum/action/A = X
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
flight_y_offset = 13
|
||||
|
||||
/obj/item/gun/energy/e_gun/mini/Initialize()
|
||||
gun_light = new /obj/item/flashlight/seclite(src)
|
||||
set_gun_light(new /obj/item/flashlight/seclite(src))
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/energy/e_gun/stun
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
icon_state = "laser"
|
||||
pass_flags = PASSTABLE | PASSGLASS | PASSGRILLE
|
||||
damage = 20
|
||||
light_range = 2
|
||||
damage_type = BURN
|
||||
hitsound = 'sound/weapons/sear.ogg'
|
||||
hitsound_wall = 'sound/weapons/effects/searwall.ogg'
|
||||
flag = "laser"
|
||||
eyeblur = 2
|
||||
impact_effect_type = /obj/effect/temp_visual/impact_effect/red_laser
|
||||
light_system = MOVABLE_LIGHT
|
||||
light_range = 2
|
||||
light_power = 1
|
||||
light_color = COLOR_SOFT_RED
|
||||
ricochets_max = 50 //Honk!
|
||||
ricochet_chance = 80
|
||||
@@ -17,6 +19,7 @@
|
||||
wound_bonus = -20
|
||||
bare_wound_bonus = 10
|
||||
|
||||
|
||||
/obj/projectile/beam/laser
|
||||
tracer_type = /obj/effect/projectile/tracer/laser
|
||||
muzzle_type = /obj/effect/projectile/muzzle/laser
|
||||
|
||||
Reference in New Issue
Block a user