mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Optimize flashlight processing
This commit is contained in:
@@ -20,23 +20,19 @@
|
|||||||
|
|
||||||
/obj/item/device/flashlight/Initialize()
|
/obj/item/device/flashlight/Initialize()
|
||||||
. = ..()
|
. = ..()
|
||||||
update_icon()
|
|
||||||
|
|
||||||
/obj/item/device/flashlight/New()
|
|
||||||
if(power_use)
|
|
||||||
START_PROCESSING(SSobj, src)
|
|
||||||
if(cell_type)
|
|
||||||
cell = new cell_type(src)
|
|
||||||
brightness_levels = list("low" = 0.25, "medium" = 0.5, "high" = 1)
|
|
||||||
power_usage = brightness_levels[brightness_level]
|
|
||||||
|
|
||||||
|
if(power_use && cell_type)
|
||||||
|
cell = new cell_type(src)
|
||||||
|
brightness_levels = list("low" = 0.25, "medium" = 0.5, "high" = 1)
|
||||||
|
power_usage = brightness_levels[brightness_level]
|
||||||
else
|
else
|
||||||
verbs -= /obj/item/device/flashlight/verb/toggle
|
verbs -= /obj/item/device/flashlight/verb/toggle
|
||||||
..()
|
|
||||||
|
update_icon()
|
||||||
|
|
||||||
/obj/item/device/flashlight/Destroy()
|
/obj/item/device/flashlight/Destroy()
|
||||||
if(power_use)
|
STOP_PROCESSING(SSobj, src)
|
||||||
STOP_PROCESSING(SSobj, src)
|
qdel_null(cell)
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/obj/item/device/flashlight/get_cell()
|
/obj/item/device/flashlight/get_cell()
|
||||||
@@ -57,18 +53,17 @@
|
|||||||
update_icon()
|
update_icon()
|
||||||
|
|
||||||
/obj/item/device/flashlight/process()
|
/obj/item/device/flashlight/process()
|
||||||
if(on)
|
if(!on || !cell)
|
||||||
if(cell)
|
return PROCESS_KILL
|
||||||
if(brightness_level && power_usage)
|
|
||||||
if(power_usage < cell.charge)
|
if(brightness_level && power_usage)
|
||||||
cell.charge -= power_usage
|
if(cell.use(power_usage) != power_usage) // we weren't able to use our full power_usage amount!
|
||||||
else
|
visible_message("<span class='warning'>\The [src] flickers before going dull.</span>")
|
||||||
cell.charge = 0
|
set_light(0)
|
||||||
visible_message("<span class='warning'>\The [src] flickers before going dull.</span>")
|
playsound(src.loc, 'sound/effects/sparks3.ogg', 10, 1, -3) //Small cue that your light went dull in your pocket.
|
||||||
set_light(0)
|
on = 0
|
||||||
playsound(src.loc, 'sound/effects/sparks3.ogg', 10, 1, -3) //Small cue that your light went dull in your pocket.
|
update_icon()
|
||||||
on = 0
|
return PROCESS_KILL
|
||||||
update_icon()
|
|
||||||
|
|
||||||
/obj/item/device/flashlight/update_icon()
|
/obj/item/device/flashlight/update_icon()
|
||||||
if(on)
|
if(on)
|
||||||
@@ -110,6 +105,10 @@
|
|||||||
to_chat(user, "You flick the switch on [src], but nothing happens.")
|
to_chat(user, "You flick the switch on [src], but nothing happens.")
|
||||||
return 0
|
return 0
|
||||||
on = !on
|
on = !on
|
||||||
|
if(on && power_use)
|
||||||
|
START_PROCESSING(SSobj, src)
|
||||||
|
else if(power_use)
|
||||||
|
STOP_PROCESSING(SSobj, src)
|
||||||
playsound(src.loc, 'sound/weapons/empty.ogg', 15, 1, -3)
|
playsound(src.loc, 'sound/weapons/empty.ogg', 15, 1, -3)
|
||||||
update_icon()
|
update_icon()
|
||||||
user.update_action_buttons()
|
user.update_action_buttons()
|
||||||
|
|||||||
Reference in New Issue
Block a user