-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathgriddle.dm
122 lines (107 loc) · 3.77 KB
/
griddle.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/obj/machinery/griddle
name = "griddle"
desc = "Because using pans is for pansies."
icon = 'icons/obj/machines/kitchenmachines.dmi'
icon_state = "griddle1_off"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 5
layer = BELOW_OBJ_LAYER
circuit = /obj/item/circuitboard/machine/griddle
resistance_flags = FIRE_PROOF
///Things that are being griddled right now
var/list/griddled_objects = list()
///Looping sound for the grill
var/datum/looping_sound/grill/grill_loop
///Whether or not the machine is turned on right now
var/on = FALSE
///What variant of griddle is this?
var/variant = 1
///How many shit fits on the griddle?
var/max_items = 8
/obj/machinery/griddle/Initialize(mapload)
. = ..()
end_processing() //doesn't start on
grill_loop = new(list(src), FALSE)
variant = rand(1,3)
/obj/machinery/griddle/attackby(obj/item/I, mob/user, params)
if(default_deconstruction_crowbar(I))
return
if(!on && default_deconstruction_screwdriver(user, icon_state, icon_state, I))
update_appearance(UPDATE_ICON)
return
if(griddled_objects.len >= max_items)
to_chat(user, "<span class='notice'>[src] can't fit more items!</span>")
return
if(user.transferItemToLoc(I, src))
I.pixel_x = pick(-(world.icon_size/4), 0, (world.icon_size/4))
I.pixel_y = pick(-(world.icon_size/8), 0, (world.icon_size/4))
var/list/click_params = params2list(params)
//Attempt to center the icon where the user clicked.
if(click_params && click_params["icon-x"] && click_params["icon-y"])
//Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf)
I.pixel_x = clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/4), world.icon_size/4)
I.pixel_y = clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/8), world.icon_size/4)
to_chat(user, "<span class='notice'>You place [I] on [src].</span>")
AddToGrill(I, user)
update_appearance(UPDATE_ICON)
else
return ..()
/obj/machinery/griddle/attack_hand(mob/user)
. = ..()
if(panel_open)
return
toggle_mode()
/obj/machinery/griddle/attack_robot(mob/user)
. = ..()
if(panel_open)
return
toggle_mode()
/obj/machinery/griddle/proc/toggle_mode()
on = !on
if(on)
begin_processing()
else
end_processing()
update_appearance(UPDATE_ICON)
update_grill_audio()
/obj/machinery/griddle/proc/AddToGrill(obj/item/item_to_grill, mob/user)
vis_contents += item_to_grill
griddled_objects += item_to_grill
//item_to_grill.flags_1 |= IS_ONTOP_1
RegisterSignal(item_to_grill, COMSIG_MOVABLE_MOVED, PROC_REF(ItemMoved),TRUE)
RegisterSignal(item_to_grill, COMSIG_GRILL_COMPLETED, PROC_REF(GrillCompleted))
update_grill_audio()
/obj/machinery/griddle/proc/ItemMoved(obj/item/I, atom/OldLoc, Dir, Forced)
//I.flags_1 &= ~IS_ONTOP_1
griddled_objects -= I
vis_contents -= I
UnregisterSignal(I, COMSIG_GRILL_COMPLETED)
update_grill_audio()
/obj/machinery/griddle/proc/GrillCompleted(obj/item/source, atom/grilled_result)
griddled_objects -= source //Old object
AddToGrill(grilled_result)
/obj/machinery/griddle/proc/update_grill_audio()
if(on && griddled_objects.len)
grill_loop.start()
else
grill_loop.stop()
/obj/machinery/griddle/process(delta_time)
..()
listclearnulls(griddled_objects)
for(var/i in griddled_objects)
var/obj/item/griddled_item = i
if(QDELETED(griddled_item))
griddled_objects -= i
return
if(SEND_SIGNAL(griddled_item, COMSIG_ITEM_GRILLED, src, delta_time) & COMPONENT_HANDLED_GRILLING)
continue
griddled_item.fire_act(1000) //Hot hot hot!
if(prob(10))
visible_message("<span class='danger'>[griddled_item] doesn't seem to be doing too great on the [src]!</span>")
/obj/machinery/griddle/update_icon_state()
. = ..()
if(panel_open)
icon_state = "griddle[variant]_o"
else
icon_state = "griddle[variant]_[on ? "on" : "off"]"