mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
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:
@@ -267,7 +267,7 @@
|
|||||||
|
|
||||||
if("cellremove")
|
if("cellremove")
|
||||||
if(open && cell && !usr.get_active_hand())
|
if(open && cell && !usr.get_active_hand())
|
||||||
cell.updateicon()
|
cell.update_icon()
|
||||||
usr.put_in_active_hand(cell)
|
usr.put_in_active_hand(cell)
|
||||||
cell.add_fingerprint(usr)
|
cell.add_fingerprint(usr)
|
||||||
cell = null
|
cell = null
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
if(charging)
|
if(charging)
|
||||||
usr.put_in_hands(charging)
|
usr.put_in_hands(charging)
|
||||||
charging.add_fingerprint(user)
|
charging.add_fingerprint(user)
|
||||||
charging.updateicon()
|
charging.update_icon()
|
||||||
|
|
||||||
src.charging = null
|
src.charging = null
|
||||||
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
|
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
charging.loc = src.loc
|
charging.loc = src.loc
|
||||||
charging.updateicon()
|
charging.update_icon()
|
||||||
charging = null
|
charging = null
|
||||||
update_icon()
|
update_icon()
|
||||||
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
|
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
|
||||||
|
|||||||
@@ -7,28 +7,60 @@
|
|||||||
density = 1
|
density = 1
|
||||||
var/on = 0
|
var/on = 0
|
||||||
var/obj/item/weapon/cell/high/cell = null
|
var/obj/item/weapon/cell/high/cell = null
|
||||||
var/use = 5
|
var/use = 200 // 200W light
|
||||||
var/unlocked = 0
|
var/unlocked = 0
|
||||||
var/open = 0
|
var/open = 0
|
||||||
var/brightness_on = 8 //can't remember what the maxed out value is
|
var/brightness_on = 8 //can't remember what the maxed out value is
|
||||||
|
|
||||||
/obj/machinery/floodlight/New()
|
/obj/machinery/floodlight/New()
|
||||||
src.cell = new(src)
|
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]"
|
icon_state = "flood[open ? "o" : ""][open && cell ? "b" : ""]0[on]"
|
||||||
|
|
||||||
/obj/machinery/floodlight/process()
|
/obj/machinery/floodlight/process()
|
||||||
if(on)
|
if(!on)
|
||||||
if(cell.charge >= use)
|
return
|
||||||
cell.use(use)
|
|
||||||
else
|
if(!cell || (cell.charge < (use * CELLRATE)))
|
||||||
on = 0
|
turn_off(1)
|
||||||
updateicon()
|
return
|
||||||
set_light(0)
|
|
||||||
src.visible_message("<span class='warning'>[src] shuts down due to lack of power!</span>")
|
// If the cell is almost empty rarely "flicker" the light. Aesthetic only.
|
||||||
return
|
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)
|
/obj/machinery/floodlight/attack_hand(mob/user as mob)
|
||||||
if(open && cell)
|
if(open && cell)
|
||||||
@@ -40,27 +72,20 @@
|
|||||||
cell.loc = loc
|
cell.loc = loc
|
||||||
|
|
||||||
cell.add_fingerprint(user)
|
cell.add_fingerprint(user)
|
||||||
cell.updateicon()
|
cell.update_icon()
|
||||||
|
|
||||||
src.cell = null
|
src.cell = null
|
||||||
user << "You remove the power cell"
|
user << "You remove the power cell"
|
||||||
updateicon()
|
update_icon()
|
||||||
return
|
return
|
||||||
|
|
||||||
if(on)
|
if(on)
|
||||||
on = 0
|
turn_off(1)
|
||||||
user << "\blue You turn off the light"
|
|
||||||
set_light(0)
|
|
||||||
else
|
else
|
||||||
if(!cell)
|
if(!turn_on(1))
|
||||||
return
|
user << "You try to turn on \the [src] but it does not work."
|
||||||
if(cell.charge <= 0)
|
|
||||||
return
|
|
||||||
on = 1
|
|
||||||
user << "\blue You turn on the light"
|
|
||||||
set_light(brightness_on)
|
|
||||||
|
|
||||||
updateicon()
|
update_icon()
|
||||||
|
|
||||||
|
|
||||||
/obj/machinery/floodlight/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
/obj/machinery/floodlight/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||||
@@ -93,4 +118,4 @@
|
|||||||
W.loc = src
|
W.loc = src
|
||||||
cell = W
|
cell = W
|
||||||
user << "You insert the power cell."
|
user << "You insert the power cell."
|
||||||
updateicon()
|
update_icon()
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
if("cellremove")
|
if("cellremove")
|
||||||
if(panel_open && cell && !usr.get_active_hand())
|
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].")
|
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)
|
usr.put_in_hands(cell)
|
||||||
cell.add_fingerprint(usr)
|
cell.add_fingerprint(usr)
|
||||||
cell = null
|
cell = null
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
cell.loc = get_turf(loc)
|
cell.loc = get_turf(loc)
|
||||||
|
|
||||||
cell.add_fingerprint(user)
|
cell.add_fingerprint(user)
|
||||||
cell.updateicon()
|
cell.update_icon()
|
||||||
|
|
||||||
user << "You remove the [src.cell]."
|
user << "You remove the [src.cell]."
|
||||||
src.cell = null
|
src.cell = null
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
else if(istype(W, /obj/item/weapon/screwdriver))
|
else if(istype(W, /obj/item/weapon/screwdriver))
|
||||||
if(bcell)
|
if(bcell)
|
||||||
bcell.updateicon()
|
bcell.update_icon()
|
||||||
bcell.loc = get_turf(src.loc)
|
bcell.loc = get_turf(src.loc)
|
||||||
bcell = null
|
bcell = null
|
||||||
user << "<span class='notice'>You remove the cell from the [src].</span>"
|
user << "<span class='notice'>You remove the cell from the [src].</span>"
|
||||||
|
|||||||
@@ -194,7 +194,7 @@
|
|||||||
wrapped = A.cell
|
wrapped = A.cell
|
||||||
|
|
||||||
A.cell.add_fingerprint(user)
|
A.cell.add_fingerprint(user)
|
||||||
A.cell.updateicon()
|
A.cell.update_icon()
|
||||||
A.cell.loc = src
|
A.cell.loc = src
|
||||||
A.cell = null
|
A.cell = null
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@
|
|||||||
wrapped = A.cell
|
wrapped = A.cell
|
||||||
|
|
||||||
A.cell.add_fingerprint(user)
|
A.cell.add_fingerprint(user)
|
||||||
A.cell.updateicon()
|
A.cell.update_icon()
|
||||||
A.updateicon()
|
A.updateicon()
|
||||||
A.cell.loc = src
|
A.cell.loc = src
|
||||||
A.cell = null
|
A.cell = null
|
||||||
|
|||||||
@@ -746,7 +746,7 @@
|
|||||||
if(opened && !wiresexposed && (!istype(user, /mob/living/silicon)))
|
if(opened && !wiresexposed && (!istype(user, /mob/living/silicon)))
|
||||||
var/datum/robot_component/cell_component = components["power cell"]
|
var/datum/robot_component/cell_component = components["power cell"]
|
||||||
if(cell)
|
if(cell)
|
||||||
cell.updateicon()
|
cell.update_icon()
|
||||||
cell.add_fingerprint(user)
|
cell.add_fingerprint(user)
|
||||||
user.put_in_active_hand(cell)
|
user.put_in_active_hand(cell)
|
||||||
user << "You remove \the [cell]."
|
user << "You remove \the [cell]."
|
||||||
|
|||||||
@@ -714,7 +714,7 @@
|
|||||||
if(cell)
|
if(cell)
|
||||||
user.put_in_hands(cell)
|
user.put_in_hands(cell)
|
||||||
cell.add_fingerprint(user)
|
cell.add_fingerprint(user)
|
||||||
cell.updateicon()
|
cell.update_icon()
|
||||||
|
|
||||||
src.cell = null
|
src.cell = null
|
||||||
user.visible_message("<span class='warning'>[user.name] removes the power cell from [src.name]!</span>",\
|
user.visible_message("<span class='warning'>[user.name] removes the power cell from [src.name]!</span>",\
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/obj/item/weapon/cell/initialize()
|
/obj/item/weapon/cell/initialize()
|
||||||
..()
|
..()
|
||||||
updateicon()
|
update_icon()
|
||||||
|
|
||||||
/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/power = 0)
|
/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/power = 0)
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
return use(cell_amt) / CELLRATE
|
return use(cell_amt) / CELLRATE
|
||||||
|
|
||||||
/obj/item/weapon/cell/proc/updateicon()
|
/obj/item/weapon/cell/update_icon()
|
||||||
overlays.Cut()
|
overlays.Cut()
|
||||||
|
|
||||||
if(charge < 0.01)
|
if(charge < 0.01)
|
||||||
|
|||||||
@@ -159,7 +159,7 @@
|
|||||||
else if(cell)
|
else if(cell)
|
||||||
cell.loc = loc
|
cell.loc = loc
|
||||||
cell.add_fingerprint(user)
|
cell.add_fingerprint(user)
|
||||||
cell.updateicon()
|
cell.update_icon()
|
||||||
|
|
||||||
icon_state = "suspension0"
|
icon_state = "suspension0"
|
||||||
cell = null
|
cell = null
|
||||||
|
|||||||
Reference in New Issue
Block a user