Files
S.P.L.U.R.T-Station-13/code/game/machinery/washing_machine.dm
2021-11-15 01:34:30 -03:00

356 lines
12 KiB
Plaintext

//dye registry, add dye colors and their resulting output here if you want the sprite to change instead of just the color.
GLOBAL_LIST_INIT(dye_registry, list(
DYE_REGISTRY_UNDER = list(
DYE_RED = /obj/item/clothing/under/color/red,
DYE_ORANGE = /obj/item/clothing/under/color/orange,
DYE_YELLOW = /obj/item/clothing/under/color/yellow,
DYE_GREEN = /obj/item/clothing/under/color/green,
DYE_BLUE = /obj/item/clothing/under/color/blue,
DYE_PURPLE = /obj/item/clothing/under/color/lightpurple,
DYE_BLACK = /obj/item/clothing/under/color/black,
DYE_WHITE = /obj/item/clothing/under/color/white,
DYE_RAINBOW = /obj/item/clothing/under/color/rainbow,
DYE_MIME = /obj/item/clothing/under/rank/civilian/mime,
DYE_CLOWN = /obj/item/clothing/under/rank/civilian/clown,
DYE_QM = /obj/item/clothing/under/rank/cargo/qm,
DYE_LAW = /obj/item/clothing/under/suit/black,
DYE_CAPTAIN = /obj/item/clothing/under/rank/captain,
DYE_HOP = /obj/item/clothing/under/rank/civilian/head_of_personnel,
DYE_HOS = /obj/item/clothing/under/rank/security/head_of_security,
DYE_CE = /obj/item/clothing/under/rank/engineering/chief_engineer,
DYE_RD = /obj/item/clothing/under/rank/rnd/research_director,
DYE_CMO = /obj/item/clothing/under/rank/medical/chief_medical_officer,
DYE_REDCOAT = /obj/item/clothing/under/costume/redcoat
),
DYE_REGISTRY_JUMPSKIRT = list(
DYE_RED = /obj/item/clothing/under/color/jumpskirt/red,
DYE_ORANGE = /obj/item/clothing/under/color/jumpskirt/orange,
DYE_YELLOW = /obj/item/clothing/under/color/jumpskirt/yellow,
DYE_GREEN = /obj/item/clothing/under/color/jumpskirt/green,
DYE_BLUE = /obj/item/clothing/under/color/jumpskirt/blue,
DYE_PURPLE = /obj/item/clothing/under/color/jumpskirt/lightpurple,
DYE_BLACK = /obj/item/clothing/under/color/jumpskirt/black,
DYE_WHITE = /obj/item/clothing/under/color/jumpskirt/white,
DYE_RAINBOW = /obj/item/clothing/under/color/jumpskirt/rainbow
),
DYE_REGISTRY_GLOVES = list(
DYE_RED = /obj/item/clothing/gloves/color/red,
DYE_ORANGE = /obj/item/clothing/gloves/color/orange,
DYE_YELLOW = /obj/item/clothing/gloves/color/yellow,
DYE_GREEN = /obj/item/clothing/gloves/color/green,
DYE_BLUE = /obj/item/clothing/gloves/color/blue,
DYE_PURPLE = /obj/item/clothing/gloves/color/purple,
DYE_BLACK = /obj/item/clothing/gloves/color/black,
DYE_WHITE = /obj/item/clothing/gloves/color/white,
DYE_RAINBOW = /obj/item/clothing/gloves/color/rainbow,
DYE_MIME = /obj/item/clothing/gloves/color/white,
DYE_CLOWN = /obj/item/clothing/gloves/color/rainbow,
DYE_QM = /obj/item/clothing/gloves/color/brown,
DYE_CAPTAIN = /obj/item/clothing/gloves/color/captain,
DYE_HOP = /obj/item/clothing/gloves/color/grey,
DYE_HOS = /obj/item/clothing/gloves/color/black,
DYE_CE = /obj/item/clothing/gloves/color/black,
DYE_RD = /obj/item/clothing/gloves/color/grey,
DYE_CMO = /obj/item/clothing/gloves/color/latex/nitrile,
DYE_REDCOAT = /obj/item/clothing/gloves/color/white
),
DYE_REGISTRY_SNEAKERS = list(
DYE_RED = /obj/item/clothing/shoes/sneakers/red,
DYE_ORANGE = /obj/item/clothing/shoes/sneakers/orange,
DYE_YELLOW = /obj/item/clothing/shoes/sneakers/yellow,
DYE_GREEN = /obj/item/clothing/shoes/sneakers/green,
DYE_BLUE = /obj/item/clothing/shoes/sneakers/blue,
DYE_PURPLE = /obj/item/clothing/shoes/sneakers/purple,
DYE_BLACK = /obj/item/clothing/shoes/sneakers/black,
DYE_WHITE = /obj/item/clothing/shoes/sneakers/white,
DYE_RAINBOW = /obj/item/clothing/shoes/sneakers/rainbow,
DYE_MIME = /obj/item/clothing/shoes/sneakers/black,
DYE_QM = /obj/item/clothing/shoes/sneakers/brown,
DYE_CAPTAIN = /obj/item/clothing/shoes/sneakers/brown,
DYE_HOP = /obj/item/clothing/shoes/sneakers/brown,
DYE_CE = /obj/item/clothing/shoes/sneakers/brown,
DYE_RD = /obj/item/clothing/shoes/sneakers/brown,
DYE_CMO = /obj/item/clothing/shoes/sneakers/brown
),
DYE_REGISTRY_FANNYPACK = list(
DYE_RED = /obj/item/storage/belt/fannypack/red,
DYE_ORANGE = /obj/item/storage/belt/fannypack/orange,
DYE_YELLOW = /obj/item/storage/belt/fannypack/yellow,
DYE_GREEN = /obj/item/storage/belt/fannypack/green,
DYE_BLUE = /obj/item/storage/belt/fannypack/blue,
DYE_PURPLE = /obj/item/storage/belt/fannypack/purple,
DYE_BLACK = /obj/item/storage/belt/fannypack/black,
DYE_WHITE = /obj/item/storage/belt/fannypack/white
),
DYE_REGISTRY_BEDSHEET = list(
DYE_RED = /obj/item/bedsheet/red,
DYE_ORANGE = /obj/item/bedsheet/orange,
DYE_YELLOW = /obj/item/bedsheet/yellow,
DYE_GREEN = /obj/item/bedsheet/green,
DYE_BLUE = /obj/item/bedsheet/blue,
DYE_PURPLE = /obj/item/bedsheet/purple,
DYE_BLACK = /obj/item/bedsheet/black,
DYE_WHITE = /obj/item/bedsheet,
DYE_RAINBOW = /obj/item/bedsheet/rainbow,
DYE_MIME = /obj/item/bedsheet/mime,
DYE_CLOWN = /obj/item/bedsheet/clown,
DYE_QM = /obj/item/bedsheet/qm,
DYE_LAW = /obj/item/bedsheet/black,
DYE_CAPTAIN = /obj/item/bedsheet/captain,
DYE_HOP = /obj/item/bedsheet/hop,
DYE_HOS = /obj/item/bedsheet/hos,
DYE_CE = /obj/item/bedsheet/ce,
DYE_RD = /obj/item/bedsheet/rd,
DYE_CMO = /obj/item/bedsheet/cmo,
DYE_COSMIC = /obj/item/bedsheet/cosmos
),
DYE_REGISTRY_DOUBLE_BEDSHEET = list(
DYE_RED = /obj/item/bedsheet/red/double,
DYE_ORANGE = /obj/item/bedsheet/orange/double,
DYE_YELLOW = /obj/item/bedsheet/yellow/double,
DYE_GREEN = /obj/item/bedsheet/green/double,
DYE_BLUE = /obj/item/bedsheet/blue/double,
DYE_PURPLE = /obj/item/bedsheet/purple/double,
DYE_BLACK = /obj/item/bedsheet/black/double,
DYE_WHITE = /obj/item/bedsheet/double,
DYE_RAINBOW = /obj/item/bedsheet/rainbow/double,
DYE_MIME = /obj/item/bedsheet/mime/double,
DYE_CLOWN = /obj/item/bedsheet/clown/double,
DYE_CHAP = /obj/item/bedsheet/chaplain/double,
DYE_QM = /obj/item/bedsheet/qm/double,
DYE_LAW = /obj/item/bedsheet/black/double,
DYE_CAPTAIN = /obj/item/bedsheet/captain/double,
DYE_HOP = /obj/item/bedsheet/hop/double,
DYE_HOS = /obj/item/bedsheet/hos/double,
DYE_CE = /obj/item/bedsheet/ce/double,
DYE_RD = /obj/item/bedsheet/rd/double,
DYE_CMO = /obj/item/bedsheet/cmo/double,
DYE_COSMIC = /obj/item/bedsheet/cosmos/double,
DYE_SYNDICATE = /obj/item/bedsheet/syndie/double,
DYE_CENTCOM = /obj/item/bedsheet/centcom/double
)
))
/obj/machinery/washing_machine
name = "washing machine"
desc = "Gets rid of those pesky bloodstains, or your money back!"
icon = 'icons/obj/machines/washing_machine.dmi'
icon_state = "wm_1_0"
density = TRUE
state_open = TRUE
var/busy = FALSE
var/bloody_mess = 0
var/has_corgi = 0
var/obj/item/color_source
var/max_wash_capacity = 5
/obj/machinery/washing_machine/examine(mob/user)
. = ..()
if(!busy)
. += "<span class='notice'><b>Alt-click</b> it to start a wash cycle.</span>"
/obj/machinery/washing_machine/AltClick(mob/user)
. = ..()
if(!user.canUseTopic(src))
return
if(busy)
return
if(state_open)
to_chat(user, "<span class='notice'>Close the door first</span>")
return TRUE
if(bloody_mess)
to_chat(user, "<span class='warning'>[src] must be cleaned up first.</span>")
return TRUE
busy = TRUE
update_icon()
addtimer(CALLBACK(src, .proc/wash_cycle), 200)
START_PROCESSING(SSfastprocess, src)
return TRUE
/obj/machinery/washing_machine/process()
if (!busy)
animate(src, transform=matrix(), time=2)
return PROCESS_KILL
if (anchored)
if (prob(5))
var/matrix/M = new
M.Translate(rand(-1, 1), rand(0, 1))
animate(src, transform=M, time=1)
animate(transform=matrix(), time=1)
else
if (prob(1))
step(src, pick(GLOB.cardinals))
var/matrix/M = new
M.Translate(rand(-3, 3), rand(-1, 3))
animate(src, transform=M, time=2)
/obj/machinery/washing_machine/clean_blood()
..()
if(!busy)
bloody_mess = FALSE
update_icon()
/obj/machinery/washing_machine/proc/wash_cycle()
for(var/X in contents)
var/atom/movable/AM = X
SEND_SIGNAL(AM, COMSIG_COMPONENT_CLEAN_ACT, CLEAN_WEAK)
AM.clean_blood()
AM.machine_wash(src)
busy = FALSE
if(color_source)
qdel(color_source)
color_source = null
update_icon()
/obj/item/proc/dye_item(dye_color)
if(undyeable)
return FALSE
if(dying_key)
if(!GLOB.dye_registry[dying_key])
log_runtime("Item just tried to be dyed with an invalid registry key: [dying_key]")
return FALSE
var/obj/item/target_type = GLOB.dye_registry[dying_key][dye_color]
if(target_type)
icon = initial(target_type.icon)
icon_state = initial(target_type.icon_state)
lefthand_file = initial(target_type.lefthand_file)
righthand_file = initial(target_type.righthand_file)
item_state = initial(target_type.item_state)
mob_overlay_icon = initial(target_type.mob_overlay_icon)
inhand_x_dimension = initial(target_type.inhand_x_dimension)
inhand_y_dimension = initial(target_type.inhand_y_dimension)
name = initial(target_type.name)
desc = "[initial(target_type.desc)] The colors look a little dodgy."
return target_type //successfully "appearance copy" dyed something; returns the target type as a hacky way of extending
add_atom_colour(dye_color, FIXED_COLOUR_PRIORITY)
return FALSE
//what happens to this object when washed inside a washing machine
/atom/movable/proc/machine_wash(obj/machinery/washing_machine/WM)
return
/obj/item/stack/sheet/hairlesshide/machine_wash(obj/machinery/washing_machine/WM)
new /obj/item/stack/sheet/wetleather(drop_location(), amount)
qdel(src)
/obj/item/clothing/suit/hooded/ian_costume/machine_wash(obj/machinery/washing_machine/WM)
new /obj/item/reagent_containers/food/snacks/meat/slab/corgi(loc)
qdel(src)
/mob/living/simple_animal/pet/dog/corgi/machine_wash(obj/machinery/washing_machine/WM)
gib()
/obj/item/machine_wash(obj/machinery/washing_machine/WM)
if(WM.color_source)
dye_item(WM.color_source.dye_color)
/obj/item/clothing/under/dye_item(dye_color, dye_key)
. = ..()
if(.)
var/obj/item/clothing/under/U = .
can_adjust = initial(U.can_adjust)
if(!can_adjust && adjusted) //we deadjust the uniform if it's now unadjustable
toggle_jumpsuit_adjust()
/obj/item/clothing/shoes/sneakers/machine_wash(obj/machinery/washing_machine/WM)
if(chained)
chained = 0
slowdown = SHOES_SLOWDOWN
new /obj/item/restraints/handcuffs(loc)
..()
/obj/machinery/washing_machine/relaymove(mob/user)
container_resist(user)
/obj/machinery/washing_machine/container_resist(mob/living/user)
if(!busy)
add_fingerprint(user)
open_machine()
/obj/machinery/washing_machine/update_icon_state()
if(busy)
icon_state = "wm_running_[bloody_mess]"
else if(bloody_mess)
icon_state = "wm_[state_open]_blood"
else
var/full = contents.len ? 1 : 0
icon_state = "wm_[state_open]_[full]"
/obj/machinery/washing_machine/update_overlays()
. = ..()
if(panel_open)
. += "wm_panel"
/obj/machinery/washing_machine/attackby(obj/item/W, mob/user, params)
if(panel_open && !busy && default_unfasten_wrench(user, W))
return
if(default_deconstruction_screwdriver(user, null, null, W))
update_icon()
return
if(istype(W, /obj/item/clothing/head/mob_holder))
to_chat(user, "<span class='warning'>It's too unwieldly to put in this way.</span>")
return TRUE
else if(user.a_intent != INTENT_HARM)
if (!state_open)
to_chat(user, "<span class='warning'>Open the door first!</span>")
return TRUE
if(bloody_mess)
to_chat(user, "<span class='warning'>[src] must be cleaned up first.</span>")
return TRUE
if(contents.len >= max_wash_capacity)
to_chat(user, "<span class='warning'>The washing machine is full!</span>")
return TRUE
if(!user.transferItemToLoc(W, src))
to_chat(user, "<span class='warning'>\The [W] is stuck to your hand, you cannot put it in the washing machine!</span>")
return TRUE
if(W.dye_color)
color_source = W
update_icon()
else
return ..()
/obj/machinery/washing_machine/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags)
if(busy)
to_chat(user, "<span class='warning'>[src] is busy.</span>")
return
if(user.pulling && user.a_intent == INTENT_GRAB && isliving(user.pulling))
var/mob/living/L = user.pulling
if(L.buckled || L.has_buckled_mobs())
return
if(state_open)
if(iscorgi(L))
has_corgi = 1
L.forceMove(src)
update_icon()
return
if(!state_open)
open_machine()
else
state_open = FALSE //close the door
update_icon()
/obj/machinery/washing_machine/deconstruct(disassembled = TRUE)
new /obj/item/stack/sheet/metal (loc, 2)
qdel(src)
/obj/machinery/washing_machine/open_machine(drop = 1)
..()
density = TRUE //because machinery/open_machine() sets it to 0
color_source = null
has_corgi = 0