Files
Bubberstation/code/game/objects/items/candle.dm
MrPerson e22560a346 update_icon() improvements (#48669)
* update_icon() improvements

Fixes some update_icon() calls to properly call parent and use update_overlays() and update_icon_state().

The rest of obj/item fuck it

* Suggested fixes, also passes the linter

* I always forget . = ..() is faster than return ..() FOR SOME FUCKING REASON

* Actually this is better

* Signilzes datum/action to update its icon when its connected item does.
2020-01-11 23:46:43 -05:00

81 lines
1.7 KiB
Plaintext

#define CANDLE_LUMINOSITY 2
/obj/item/candle
name = "red candle"
desc = "In Greek myth, Prometheus stole fire from the Gods and gave it to \
humankind. The jewelry he kept for himself."
icon = 'icons/obj/candle.dmi'
icon_state = "candle1"
item_state = "candle1"
w_class = WEIGHT_CLASS_TINY
light_color = LIGHT_COLOR_FIRE
heat = 1000
var/wax = 1000
var/lit = FALSE
var/infinite = FALSE
var/start_lit = FALSE
/obj/item/candle/Initialize()
. = ..()
if(start_lit)
light()
/obj/item/candle/update_icon_state()
icon_state = "candle[(wax > 400) ? ((wax > 750) ? 1 : 2) : 3][lit ? "_lit" : ""]"
/obj/item/candle/attackby(obj/item/W, mob/user, params)
var/msg = W.ignition_effect(src, user)
if(msg)
light(msg)
else
return ..()
/obj/item/candle/fire_act(exposed_temperature, exposed_volume)
if(!lit)
light() //honk
return ..()
/obj/item/candle/get_temperature()
return lit * heat
/obj/item/candle/proc/light(show_message)
if(!lit)
lit = TRUE
if(show_message)
usr.visible_message(show_message)
set_light(CANDLE_LUMINOSITY)
START_PROCESSING(SSobj, src)
update_icon()
/obj/item/candle/proc/put_out_candle()
if(!lit)
return
lit = FALSE
update_icon()
set_light(0)
return TRUE
/obj/item/candle/extinguish()
put_out_candle()
return ..()
/obj/item/candle/process()
if(!lit)
return PROCESS_KILL
if(!infinite)
wax--
if(!wax)
new /obj/item/trash/candle(loc)
qdel(src)
update_icon()
open_flame()
/obj/item/candle/attack_self(mob/user)
if(put_out_candle())
user.visible_message("<span class='notice'>[user] snuffs [src].</span>")
/obj/item/candle/infinite
infinite = TRUE
start_lit = TRUE
#undef CANDLE_LUMINOSITY