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
+42 -25
View File
@@ -199,7 +199,9 @@
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
var/on = 0 // 1 if on, 0 if off
var/on_gs = 0
var/brightness = 8 // luminosity when on, also used in power calculation
var/brightness_range = 8 // luminosity when on, also used in power calculation
var/brightness_power = 3
var/brightness_color = null
var/status = LIGHT_OK // LIGHT_OK, _EMPTY, _BURNED or _BROKEN
var/flickering = 0
var/light_type = /obj/item/weapon/light/tube // the type of light item
@@ -215,7 +217,9 @@
icon_state = "bulb1"
base_state = "bulb"
fitting = "bulb"
brightness = 4
brightness_range = 4
brightness_power = 2
brightness_color = "#a0a080"
desc = "A small lighting fixture."
light_type = /obj/item/weapon/light/bulb
@@ -224,7 +228,8 @@
name = "spotlight"
fitting = "large tube"
light_type = /obj/item/weapon/light/tube/large
brightness = 12
brightness_range = 12
brightness_power = 4
/obj/machinery/light/built/New()
status = LIGHT_EMPTY
@@ -247,11 +252,14 @@
switch(fitting)
if("tube")
brightness = 8
brightness_range = 8
brightness_power = 3
if(prob(2))
broken(1)
if("bulb")
brightness = 4
brightness_range = 4
brightness_power = 2
brightness_color = "#a0a080"
if(prob(5))
broken(1)
spawn(1)
@@ -285,7 +293,7 @@
update_icon()
if(on)
if(luminosity != brightness)
if(light_range != brightness_range || light_power != brightness_power || light_color != brightness_color)
switchcount++
if(rigged)
if(status == LIGHT_OK && trigger)
@@ -299,15 +307,15 @@
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
on = 0
SetLuminosity(0)
set_light(0)
else
use_power = 2
SetLuminosity(brightness)
set_light(brightness_range, brightness_power, brightness_color)
else
use_power = 1
SetLuminosity(0)
set_light(0)
active_power_usage = (luminosity * 10)
active_power_usage = ((light_range + light_power) * 10)
if(on != on_gs)
on_gs = on
@@ -368,8 +376,9 @@
user << "You insert the [L.name]."
switchcount = L.switchcount
rigged = L.rigged
brightness = L.brightness
l_color = L.color
brightness_range = L.brightness_range
brightness_power = L.brightness_power
brightness_color = L.brightness_color
on = has_power()
update()
@@ -515,8 +524,9 @@
var/obj/item/weapon/light/L = new light_type()
L.status = status
L.rigged = rigged
L.brightness = src.brightness
L.color = l_color
L.brightness_range = brightness_range
L.brightness_power = brightness_power
L.brightness_color = brightness_color
// light item inherits the switchcount, then zero it
L.switchcount = switchcount
@@ -541,8 +551,9 @@
var/obj/item/weapon/light/L = new light_type()
L.status = status
L.rigged = rigged
L.brightness = brightness
L.color = l_color
L.brightness_range = brightness_range
L.brightness_power = brightness_power
L.brightness_color = brightness_color
// light item inherits the switchcount, then zero it
L.switchcount = switchcount
@@ -575,7 +586,6 @@
if(status == LIGHT_OK)
return
status = LIGHT_OK
brightness = initial(brightness)
on = 1
update()
@@ -610,7 +620,7 @@
/obj/machinery/light/process()
if(on)
use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT)
use_power(light_range * LIGHTING_POWER_FACTOR, LIGHT)
// called when area power state changes
@@ -650,7 +660,9 @@
var/switchcount = 0 // number of times switched
matter = list("metal" = 60)
var/rigged = 0 // true if rigged to explode
var/brightness = 2 //how much light it gives off
var/brightness_range = 2 //how much light it gives off
var/brightness_power = 1
var/brightness_color = null
/obj/item/weapon/light/tube
name = "light tube"
@@ -659,12 +671,14 @@
base_state = "ltube"
item_state = "c_tube"
matter = list("glass" = 100)
brightness = 8
brightness_range = 8
brightness_power = 3
/obj/item/weapon/light/tube/large
w_class = 2
name = "large light tube"
brightness = 15
brightness_range = 15
brightness_power = 4
/obj/item/weapon/light/bulb
name = "light bulb"
@@ -673,7 +687,9 @@
base_state = "lbulb"
item_state = "contvapour"
matter = list("glass" = 100)
brightness = 5
brightness_range = 5
brightness_power = 2
brightness_color = "#a0a080"
/obj/item/weapon/light/throw_impact(atom/hit_atom)
..()
@@ -686,7 +702,8 @@
base_state = "fbulb"
item_state = "egg4"
matter = list("glass" = 100)
brightness = 5
brightness_range = 5
brightness_power = 2
// update the icon state and description of the light
@@ -707,9 +724,9 @@
..()
switch(name)
if("light tube")
brightness = rand(6,9)
brightness_range = rand(6,9)
if("light bulb")
brightness = rand(4,6)
brightness_range = rand(4,6)
update()
@@ -9,7 +9,7 @@
density = 0
unacidable = 1
use_power = 0
luminosity = 4
light_range = 4
var/obj/machinery/field_generator/FG1 = null
var/obj/machinery/field_generator/FG2 = null
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
+4 -4
View File
@@ -31,8 +31,8 @@ var/global/list/narsie_list = list()
// Pixel stuff centers Narsie.
pixel_x = -236
pixel_y = -256
luminosity = 1
l_color = "#3e0000"
light_range = 1
light_color = "#3e0000"
current_size = 12
consume_range = 12 // How many tiles out do we eat.
@@ -144,7 +144,7 @@ var/global/list/narsie_list = list()
if(T.icon_state != "cult-narsie")
T.desc = "something that goes beyond your understanding went this way"
T.icon_state = "cult-narsie"
T.luminosity = 1
T.set_light(1)
/obj/singularity/narsie/proc/narsiewall(var/turf/T)
T.desc = "An opening has been made on that wall, but who can say if what you seek truly lies on the other side?"
@@ -152,7 +152,7 @@ var/global/list/narsie_list = list()
T.icon_state = "cult-narsie"
T.opacity = 0
T.density = 0
luminosity = 1
set_light(1)
/obj/singularity/narsie/large/consume(const/atom/A) //Has its own consume proc because it doesn't need energy and I don't want BoHs to explode it. --NEO
//NEW BEHAVIOUR
@@ -8,7 +8,7 @@
anchored = 1
density = 1
layer = 6
luminosity = 6
light_range = 6
unacidable = 1 //Don't comment this out.
var/current_size = 1