new object-based lighting system

Signed-off-by: Mloc <colmohici@gmail.com>
This commit is contained in:
Mloc
2015-05-10 20:54:25 +01:00
parent 733c6a4fb5
commit 16d50c645d
90 changed files with 790 additions and 1004 deletions
+1 -1
View File
@@ -164,7 +164,7 @@
name = "purple sac"
desc = "Weird purple octopus-like thing."
layer = 3
luminosity = NODERANGE
light_range = NODERANGE
var/node_range = NODERANGE
/obj/effect/alien/weeds/node/New()
@@ -58,7 +58,7 @@
density = 0
anchored = 1
layer = 2
luminosity = 1
light_range = 1
icon = 'icons/effects/effects.dmi'
icon_state = "greenglow"
@@ -142,4 +142,4 @@
layer = 2
icon = 'icons/effects/blood.dmi'
icon_state = "mfloor1"
random_icon_states = list("mfloor1", "mfloor2", "mfloor3", "mfloor4", "mfloor5", "mfloor6", "mfloor7")
random_icon_states = list("mfloor1", "mfloor2", "mfloor3", "mfloor4", "mfloor5", "mfloor6", "mfloor7")
+1 -1
View File
@@ -244,7 +244,7 @@ steam.start() -- spawns the effect
/obj/effect/effect/smoke/illumination/New(var/newloc, var/brightness=15, var/lifetime=10)
time_to_live=lifetime
..()
SetLuminosity(brightness)
set_light(brightness)
/////////////////////////////////////////////
// Bad smoke
+1 -1
View File
@@ -37,4 +37,4 @@
name = "Bluespace"
icon = 'icons/turf/space.dmi'
icon_state = "bluespacify"
layer = LIGHTING_LAYER
layer = 10
+6 -6
View File
@@ -68,8 +68,8 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ([epicenter.x],[epicenter.y],[epicenter.z]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[epicenter.x];Y=[epicenter.y];Z=[epicenter.z]'>JMP</a>)")
log_game("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ")
var/lighting_controller_was_processing = lighting_controller.processing //Pause the lighting updates for a bit
lighting_controller.processing = 0
// var/lighting_controller_was_processing = lighting_controller.processing //Pause the lighting updates for a bit
// lighting_controller.processing = 0
var/approximate_intensity = (devastation_range * 3) + (heavy_impact_range * 2) + light_impact_range
@@ -87,8 +87,8 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
var/y0 = epicenter.y
var/z0 = epicenter.z
for(var/turf/T in range(epicenter, max_range))
var/dist = cheap_pythag(T.x - x0,T.y - y0)
for(var/turf/T in trange(max_range, epicenter))
var/dist = sqrt((T.x - x0)**2 + (T.y - y0)**2)
if(dist < devastation_range) dist = 1
else if(dist < heavy_impact_range) dist = 2
@@ -99,7 +99,7 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
if(T)
for(var/atom_movable in T.contents) //bypass type checking since only atom/movable can be contained by turfs anyway
var/atom/movable/AM = atom_movable
if(AM) AM.ex_act(dist)
if(AM && AM.simulated) AM.ex_act(dist)
var/took = (world.timeofday-start)/10
//You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare
@@ -113,7 +113,7 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
sleep(8)
if(!lighting_controller.processing) lighting_controller.processing = lighting_controller_was_processing
// if(!lighting_controller.processing) lighting_controller.processing = lighting_controller_was_processing
if(!powernet_rebuild_was_deferred_already && defer_powernet_rebuild)
makepowernets()
defer_powernet_rebuild = 0
-4
View File
@@ -121,7 +121,6 @@ move an amendment</a> to the drawing.</p>
return
var/area/A = new
A.name = str
A.tagbase = "[A.type]_[md5(str)]" // without this dynamic light system ruin everithing
//var/ma
//ma = A.master ? "[A.master]" : "(null)"
//world << "DEBUG: create_area: <br>A.name=[A.name]<br>A.tag=[A.tag]<br>A.master=[ma]"
@@ -132,9 +131,6 @@ move an amendment</a> to the drawing.</p>
move_turfs_to_area(turfs, A)
A.always_unpowered = 0
for(var/turf/T in A.contents)
T.lighting_changed = 1
lighting_controller.changed_turfs += T
spawn(5)
//ma = A.master ? "[A.master]" : "(null)"
+2 -13
View File
@@ -308,15 +308,6 @@ var/global/list/obj/item/device/pda/PDAs = list()
/*
* The Actual PDA
*/
/obj/item/device/pda/pickup(mob/user)
if(fon)
SetLuminosity(0)
user.SetLuminosity(user.luminosity + f_lum)
/obj/item/device/pda/dropped(mob/user)
if(fon)
user.SetLuminosity(user.luminosity - f_lum)
SetLuminosity(f_lum)
/obj/item/device/pda/New()
..()
@@ -644,12 +635,10 @@ var/global/list/obj/item/device/pda/PDAs = list()
if("Light")
if(fon)
fon = 0
if(src in U.contents) U.SetLuminosity(U.luminosity - f_lum)
else SetLuminosity(0)
set_light(0)
else
fon = 1
if(src in U.contents) U.SetLuminosity(U.luminosity + f_lum)
else SetLuminosity(f_lum)
set_light(f_lum)
if("Medical Scan")
if(scanmode == 1)
scanmode = 0
+5 -25
View File
@@ -18,24 +18,17 @@
..()
if(on)
icon_state = "[initial(icon_state)]-on"
SetLuminosity(brightness_on)
set_light(brightness_on)
else
icon_state = initial(icon_state)
SetLuminosity(0)
set_light(0)
/obj/item/device/flashlight/proc/update_brightness(var/mob/user = null)
if(on)
icon_state = "[initial(icon_state)]-on"
if(loc == user)
user.SetLuminosity(user.luminosity + brightness_on)
else if(isturf(loc))
SetLuminosity(brightness_on)
set_light(brightness_on)
else
icon_state = initial(icon_state)
if(loc == user)
user.SetLuminosity(user.luminosity - brightness_on)
else if(isturf(loc))
SetLuminosity(0)
set_light(0)
/obj/item/device/flashlight/attack_self(mob/user)
if(!isturf(user.loc))
@@ -88,19 +81,6 @@
else
return ..()
/obj/item/device/flashlight/pickup(mob/user)
if(on)
user.SetLuminosity(user.luminosity + brightness_on)
SetLuminosity(0)
/obj/item/device/flashlight/dropped(mob/user)
if(on)
user.SetLuminosity(user.luminosity - brightness_on)
SetLuminosity(brightness_on)
/obj/item/device/flashlight/pen
name = "penlight"
desc = "A pen-sized light, used by medical staff."
@@ -217,7 +197,7 @@
on = 1 //Bio-luminesence has one setting, on.
/obj/item/device/flashlight/slime/New()
SetLuminosity(brightness_on)
set_light(brightness_on)
spawn(1) //Might be sloppy, but seems to be necessary to prevent further runtimes and make these work as intended... don't judge me!
update_brightness()
icon_state = initial(icon_state)
@@ -140,7 +140,9 @@
var/obj/item/weapon/light/L1 = new target.light_type(target.loc)
L1.status = target.status
L1.rigged = target.rigged
L1.brightness = target.brightness
L1.brightness_range = target.brightness_range
L1.brightness_power = target.brightness_power
L1.brightness_color = target.brightness_color
L1.switchcount = target.switchcount
target.switchcount = 0
L1.update()
@@ -153,7 +155,9 @@
target.status = L2.status
target.switchcount = L2.switchcount
target.rigged = emagged
target.brightness = L2.brightness
target.brightness_range = L2.brightness_range
target.brightness_power = L2.brightness_power
target.brightness_color = L2.brightness_color
target.on = target.has_power()
target.update()
qdel(L2)
+4 -4
View File
@@ -52,7 +52,7 @@
anchored = 0
mode = 0
src.visible_message("<span class='notice'>[user] detaches [src] from the cable!</span>")
SetLuminosity(0)
set_light(0)
icon_state = "powersink0"
return
@@ -74,7 +74,7 @@
if(2) //This switch option wasn't originally included. It exists now. --NeoFite
src.visible_message("<span class='notice'>[user] deactivates [src]!</span>")
mode = 1
SetLuminosity(0)
set_light(0)
icon_state = "powersink0"
processing_objects.Remove(src)
@@ -91,7 +91,7 @@
if(!PN)
return
SetLuminosity(12)
set_light(12)
PN.trigger_warning()
// found a powernet, so drain up to max power from it
drained = PN.draw_power(drain_rate)
@@ -124,4 +124,4 @@
if(attached && attached.powernet)
PN = attached.powernet
else
PN = null
PN = null
+2 -16
View File
@@ -48,7 +48,7 @@
//src.damtype = "fire"
for(var/mob/O in viewers(usr, null))
O.show_message(flavor_text, 1)
SetLuminosity(CANDLE_LUM)
set_light(CANDLE_LUM)
processing_objects.Add(src)
@@ -66,22 +66,8 @@
var/turf/T = loc
T.hotspot_expose(700, 5)
/obj/item/weapon/flame/candle/attack_self(mob/user as mob)
if(lit)
lit = 0
update_icon()
SetLuminosity(0)
user.SetLuminosity(user.luminosity - CANDLE_LUM)
/obj/item/weapon/flame/candle/pickup(mob/user)
if(lit)
SetLuminosity(0)
user.SetLuminosity(user.luminosity + CANDLE_LUM)
/obj/item/weapon/flame/candle/dropped(mob/user)
if(lit)
user.SetLuminosity(user.luminosity - CANDLE_LUM)
SetLuminosity(CANDLE_LUM)
set_light(0)
@@ -176,7 +176,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
M.update_inv_l_hand(0)
M.update_inv_r_hand(1)
processing_objects.Remove(src)
/obj/item/clothing/mask/smokable/attackby(obj/item/weapon/W as obj, mob/user as mob)
..()
if(isflamesource(W))
@@ -221,7 +221,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
if(istype(W, /obj/item/weapon/melee/energy/sword))
var/obj/item/weapon/melee/energy/sword/S = W
if(S.active)
light("<span class='warning'>[user] swings their [W], barely missing their nose. They light their [name] in the process.</span>")
light("<span class='warning'>[user] swings their [W], barely missing their nose. They light their [name] in the process.</span>")
return
@@ -456,7 +456,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
user.apply_damage(2,BURN,"r_hand")
user.visible_message("<span class='notice'>After a few attempts, [user] manages to light the [src], they however burn their finger in the process.</span>")
user.SetLuminosity(user.luminosity + 2)
set_light(2)
processing_objects.Add(src)
else
lit = 0
@@ -467,7 +467,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
else
user.visible_message("<span class='notice'>[user] quietly shuts off the [src].")
user.SetLuminosity(user.luminosity - 2)
set_light(0)
processing_objects.Remove(src)
else
return ..()
@@ -496,17 +496,3 @@ CIGARETTE PACKETS ARE IN FANCY.DM
if(location)
location.hotspot_expose(700, 5)
return
/obj/item/weapon/flame/lighter/pickup(mob/user)
if(lit)
SetLuminosity(0)
user.SetLuminosity(user.luminosity+2)
return
/obj/item/weapon/flame/lighter/dropped(mob/user)
if(lit)
user.SetLuminosity(user.luminosity-2)
SetLuminosity(2)
return
-2
View File
@@ -7,8 +7,6 @@
var/list/climbers = list()
/obj/structure/Destroy()
if(opacity)
UpdateAffectingLights()
if(parts)
new parts(loc)
..()
+4 -4
View File
@@ -62,7 +62,7 @@
flick("[mineral]fwall_opening", src)
sleep(15)
src.density = 0
SetOpacity(0)
set_opacity(0)
opening = 0
else
opening = 1
@@ -70,7 +70,7 @@
icon_state = "[mineral]0"
density = 1
sleep(15)
SetOpacity(1)
set_opacity(1)
src.relativewall()
opening = 0
@@ -186,7 +186,7 @@
flick("frwall_opening", src)
sleep(15)
density = 0
SetOpacity(0)
set_opacity(0)
opening = 0
else
opening = 1
@@ -194,7 +194,7 @@
flick("frwall_closing", src)
density = 1
sleep(15)
SetOpacity(1)
set_opacity(1)
relativewall()
opening = 0
@@ -168,7 +168,7 @@
/obj/structure/mineral_door/uranium
mineralType = "uranium"
hardness = 3
luminosity = 2
light_range = 2
/obj/structure/mineral_door/sandstone
mineralType = "sandstone"
+2 -2
View File
@@ -479,10 +479,10 @@
/obj/structure/window/reinforced/polarized/proc/toggle()
if(opacity)
animate(src, color="#FFFFFF", time=5)
SetOpacity(0)
set_opacity(0)
else
animate(src, color="#222222", time=5)
SetOpacity(1)
set_opacity(1)