Refactor floodlights

- Fixes #9543
- Removes ugly floodlight/proc/updateicon() and replaces it with proper floodlight/update_icon() which is standard on all objects/items. Does the same refactor for power cells and adjusts the proc call in relevant files (hence the amount of 1-line changes in various files)
- Makes floodlights properly use CELLRATE. Their load is 200 watts. Cell adjusted accordingly, it starts with 1k cell, which is enough for ~40 minutes (roughly)
- Floodlights with almost discharged cell (less than 10%) ocassionally "flicker", dimming for few seconds. This serves as indicator that the power cell is running low.
- Floodlight luminosity adjusted. They now shine slightly more, espicially closer to the floodlight.
This commit is contained in:
Atlantis
2015-05-28 21:45:54 +02:00
parent 928722c08a
commit 30e4550e2e
11 changed files with 94 additions and 69 deletions

View File

@@ -267,7 +267,7 @@
if("cellremove")
if(open && cell && !usr.get_active_hand())
cell.updateicon()
cell.update_icon()
usr.put_in_active_hand(cell)
cell.add_fingerprint(usr)
cell = null

View File

@@ -71,7 +71,7 @@
if(charging)
usr.put_in_hands(charging)
charging.add_fingerprint(user)
charging.updateicon()
charging.update_icon()
src.charging = null
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
@@ -84,7 +84,7 @@
return
charging.loc = src.loc
charging.updateicon()
charging.update_icon()
charging = null
update_icon()
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")

View File

@@ -7,29 +7,61 @@
density = 1
var/on = 0
var/obj/item/weapon/cell/high/cell = null
var/use = 5
var/use = 200 // 200W light
var/unlocked = 0
var/open = 0
var/brightness_on = 8 //can't remember what the maxed out value is
/obj/machinery/floodlight/New()
src.cell = new(src)
cell.maxcharge = 1000
cell.charge = 1000 // 41minutes @ 200W
..()
/obj/machinery/floodlight/proc/updateicon()
/obj/machinery/floodlight/update_icon()
overlays.Cut()
icon_state = "flood[open ? "o" : ""][open && cell ? "b" : ""]0[on]"
/obj/machinery/floodlight/process()
if(on)
if(cell.charge >= use)
cell.use(use)
else
on = 0
updateicon()
set_light(0)
src.visible_message("<span class='warning'>[src] shuts down due to lack of power!</span>")
if(!on)
return
if(!cell || (cell.charge < (use * CELLRATE)))
turn_off(1)
return
// If the cell is almost empty rarely "flicker" the light. Aesthetic only.
if((cell.percent() < 10) && prob(5))
set_light(brightness_on/2, brightness_on/4)
spawn(20)
if(on)
set_light(brightness_on, brightness_on/2)
cell.use(use*CELLRATE)
// Returns 0 on failure and 1 on success
/obj/machinery/floodlight/proc/turn_on(var/loud = 0)
if(!cell)
return 0
if(cell.charge < (use * CELLRATE))
return 0
on = 1
set_light(brightness_on, brightness_on / 2)
update_icon()
if(loud)
visible_message("\the [src] turns on.")
return 1
/obj/machinery/floodlight/proc/turn_off(var/loud = 0)
on = 0
set_light(0, 0)
update_icon()
if(loud)
visible_message("\the [src] shuts down.")
/obj/machinery/floodlight/attack_hand(mob/user as mob)
if(open && cell)
if(ishuman(user))
@@ -40,27 +72,20 @@
cell.loc = loc
cell.add_fingerprint(user)
cell.updateicon()
cell.update_icon()
src.cell = null
user << "You remove the power cell"
updateicon()
update_icon()
return
if(on)
on = 0
user << "\blue You turn off the light"
set_light(0)
turn_off(1)
else
if(!cell)
return
if(cell.charge <= 0)
return
on = 1
user << "\blue You turn on the light"
set_light(brightness_on)
if(!turn_on(1))
user << "You try to turn on \the [src] but it does not work."
updateicon()
update_icon()
/obj/machinery/floodlight/attackby(obj/item/weapon/W as obj, mob/user as mob)
@@ -93,4 +118,4 @@
W.loc = src
cell = W
user << "You insert the power cell."
updateicon()
update_icon()

View File

@@ -121,7 +121,7 @@
if("cellremove")
if(panel_open && cell && !usr.get_active_hand())
usr.visible_message("\blue [usr] removes \the [cell] from \the [src].", "\blue You remove \the [cell] from \the [src].")
cell.updateicon()
cell.update_icon()
usr.put_in_hands(cell)
cell.add_fingerprint(usr)
cell = null

View File

@@ -112,7 +112,7 @@
cell.loc = get_turf(loc)
cell.add_fingerprint(user)
cell.updateicon()
cell.update_icon()
user << "You remove the [src.cell]."
src.cell = null

View File

@@ -73,7 +73,7 @@
else if(istype(W, /obj/item/weapon/screwdriver))
if(bcell)
bcell.updateicon()
bcell.update_icon()
bcell.loc = get_turf(src.loc)
bcell = null
user << "<span class='notice'>You remove the cell from the [src].</span>"

View File

@@ -194,7 +194,7 @@
wrapped = A.cell
A.cell.add_fingerprint(user)
A.cell.updateicon()
A.cell.update_icon()
A.cell.loc = src
A.cell = null
@@ -211,7 +211,7 @@
wrapped = A.cell
A.cell.add_fingerprint(user)
A.cell.updateicon()
A.cell.update_icon()
A.updateicon()
A.cell.loc = src
A.cell = null

View File

@@ -746,7 +746,7 @@
if(opened && !wiresexposed && (!istype(user, /mob/living/silicon)))
var/datum/robot_component/cell_component = components["power cell"]
if(cell)
cell.updateicon()
cell.update_icon()
cell.add_fingerprint(user)
user.put_in_active_hand(cell)
user << "You remove \the [cell]."

View File

@@ -714,7 +714,7 @@
if(cell)
user.put_in_hands(cell)
cell.add_fingerprint(user)
cell.updateicon()
cell.update_icon()
src.cell = null
user.visible_message("<span class='warning'>[user.name] removes the power cell from [src.name]!</span>",\

View File

@@ -8,7 +8,7 @@
/obj/item/weapon/cell/initialize()
..()
updateicon()
update_icon()
/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/power = 0)
@@ -22,7 +22,7 @@
return use(cell_amt) / CELLRATE
/obj/item/weapon/cell/proc/updateicon()
/obj/item/weapon/cell/update_icon()
overlays.Cut()
if(charge < 0.01)

View File

@@ -159,7 +159,7 @@
else if(cell)
cell.loc = loc
cell.add_fingerprint(user)
cell.updateicon()
cell.update_icon()
icon_state = "suspension0"
cell = null