Files
Bubberstation/code/modules/power/pipecleaners.dm
TemporalOroboros 976c1fcb8c [READY] Bespoke Datum Mats (#55296)
* Bespoke Material Backend

- Adds support for bespoke materials:
  - Reimplements [/datum/material/var/id]
  - Ports GetIdFromArguments from SSdcs
  - Adds a wrapper define for GetMaterialRef
  - Adds [MATERIAL_INIT_BESPOKE]
  - Adds [/datum/material/proc/Initialize]
- Does not actually add any bespoke materials

- [ ] TODO: Code docs
- [ ] TODO: Actually adding bespoke materials

* Some has_material procs and cleaning up some spaghetti

- Adds a pair of has_material procs for use in checking whether a given atom has a given material

* Adds meat

- Adds bespoke meat variants
  - Does not make them accessible
- Shuts up the linter

* Implements bespoke meat

- Makes the material container preserve bespoke materials
- Makes the sheetifier accept bespoke materials
- Makes the autolathe accept bespoke materials
- Makes the gibber produce bespoke meats

* Makes butchering produce bespoke meats

This is jank and really needs to be folded into a unified butchering and gibbing system

* Material documentation

- Adds, fixes, and touches up some documentation

* Material container insertion callback

- Changes the proc used to expand the material container's material list ot a proc used to check whether a material fits into a material container
- Instantiating new materials is no longer O(n) relative to the number of autolathes in existence.

* Makes processing meat conserve materials

- Makes bespoke meat carry over into meatballs

* Makes preserving custom materials an option

- Implements the ability to turn preserving custom materials _off_ for processor recipes

* Fixes all bespoke materials of the same type using the same singleton

- We use ids now, not just types.

* Makes the fat sucker produce bespoke meats

- Because consistency is good.

* Fixes autolathes merging bespoke stacks into normal stacks.

* Makes the callback to test materials for holdibility optional

- @Floyd

* GetMaterialRef -> GET_MATERIAL_REF

- We capitalize macros.

* Removes an extraneous callback

- Makes the sheetifier use functionality I didn't notice I implemented a few commits ago.

* Makes mob and species meat null compatible

* Fixes the ore silo

- The ore silo had really snowflake material handling that has been brought in line with the rest.
- The materials should show up in the correct order.

* Fixes minor lathe bugs

- Fixes stack_traces caused when lathes tried to fetch materials using reagent typepaths
- Fixed the selective reagent disposal topic. I have no idea how long this has been broken.

* Various documentation fixes

- Clarified a couple comments
- Removes an extraneous ?. operator
- Fixed mat floor tiles having bugged reagent temperatures

* More fixes

-/datum/material/meat/mob -> /datum/material/meat/mob_meat
- Adds atom typecheck to material containers.

* Fixes old typepaths
2021-01-15 23:39:58 -08:00

491 lines
14 KiB
Plaintext

GLOBAL_LIST_INIT(pipe_cleaner_colors, list(
"blue" = COLOR_STRONG_BLUE,
"cyan" = COLOR_CYAN,
"green" = COLOR_DARK_LIME,
"orange" = COLOR_MOSTLY_PURE_ORANGE,
"pink" = COLOR_LIGHT_PINK,
"red" = COLOR_RED,
"white" = COLOR_WHITE,
"yellow" = COLOR_YELLOW
))
//This is the old cable code, but minus any actual powernet logic
//Wireart is fun
///////////////////////////////
//CABLE STRUCTURE
///////////////////////////////
////////////////////////////////
// Definitions
////////////////////////////////
/* Cable directions (d1 and d2)
* 9 1 5
* \ | /
* 8 - 0 - 4
* / | \
* 10 2 6
If d1 = 0 and d2 = 0, there's no pipe_cleaner
If d1 = 0 and d2 = dir, it's a O-X pipe_cleaner, getting from the center of the tile to dir (knot pipe_cleaner)
If d1 = dir1 and d2 = dir2, it's a full X-X pipe_cleaner, getting from dir1 to dir2
By design, d1 is the smallest direction and d2 is the highest
*/
/obj/structure/pipe_cleaner
name = "pipe cleaner"
desc = "A bendable piece of wire covered in fuzz. Fun for arts and crafts!"
icon = 'icons/obj/power_cond/pipe_cleaner.dmi'
icon_state = "0-1"
layer = WIRE_LAYER //Above hidden pipes, GAS_PIPE_HIDDEN_LAYER
anchored = TRUE
obj_flags = CAN_BE_HIT | ON_BLUEPRINTS
color = COLOR_RED
/// Pipe_cleaner direction 1 (see above)
var/d1 = 0
/// pipe_cleaner direction 2 (see above)
var/d2 = 1
/// Internal cable stack
var/obj/item/stack/pipe_cleaner_coil/stored
/obj/structure/pipe_cleaner/yellow
color = COLOR_YELLOW
/obj/structure/pipe_cleaner/green
color = COLOR_DARK_LIME
/obj/structure/pipe_cleaner/blue
color = COLOR_STRONG_BLUE
/obj/structure/pipe_cleaner/pink
color = COLOR_LIGHT_PINK
/obj/structure/pipe_cleaner/orange
color = COLOR_MOSTLY_PURE_ORANGE
/obj/structure/pipe_cleaner/cyan
color = COLOR_CYAN
/obj/structure/pipe_cleaner/white
color = COLOR_WHITE
// the power pipe_cleaner object
/obj/structure/pipe_cleaner/Initialize(mapload, param_color)
. = ..()
// ensure d1 & d2 reflect the icon_state for entering and exiting pipe_cleaner
var/dash = findtext(icon_state, "-")
d1 = text2num(copytext(icon_state, 1, dash))
d2 = text2num(copytext(icon_state, dash + length(icon_state[dash])))
if(d1)
stored = new/obj/item/stack/pipe_cleaner_coil(null, 2, null, null, null, color)
else
stored = new/obj/item/stack/pipe_cleaner_coil(null, 1, null, null, null, color)
color = param_color || color
if(!color)
var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors
var/random_color = pick(pipe_cleaner_colors)
color = pipe_cleaner_colors[random_color]
update_icon()
/obj/structure/pipe_cleaner/Destroy() // called when a pipe_cleaner is deleted
//If we have a stored item at this point, lets just delete it, since that should be
//handled by deconstruction
if(stored)
QDEL_NULL(stored)
return ..() // then go ahead and delete the pipe_cleaner
/obj/structure/pipe_cleaner/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
var/turf/T = get_turf(loc)
if(T)
stored.forceMove(T)
stored = null
else
qdel(stored)
qdel(src)
///////////////////////////////////
// General procedures
///////////////////////////////////
/obj/structure/pipe_cleaner/update_icon()
icon_state = "[d1]-[d2]"
add_atom_colour(color, FIXED_COLOUR_PRIORITY)
// Items usable on a pipe_cleaner :
// - Wirecutters : cut it duh !
// - pipe cleaner coil : merge pipe cleaners
//
/obj/structure/pipe_cleaner/proc/handlecable(obj/item/W, mob/user, params)
if(W.tool_behaviour == TOOL_WIRECUTTER)
cut_pipe_cleaner(user)
return
else if(istype(W, /obj/item/stack/pipe_cleaner_coil))
var/obj/item/stack/pipe_cleaner_coil/coil = W
if (coil.get_amount() < 1)
to_chat(user, "<span class='warning'>Not enough pipe cleaner!</span>")
return
coil.pipe_cleaner_join(src, user)
add_fingerprint(user)
/obj/structure/pipe_cleaner/proc/cut_pipe_cleaner(mob/user)
user.visible_message("<span class='notice'>[user] pulls up the pipe cleaner.</span>", "<span class='notice'>You pull up the pipe cleaner.</span>")
stored.add_fingerprint(user)
investigate_log("was pulled up by [key_name(usr)] in [AREACOORD(src)]", INVESTIGATE_WIRES)
deconstruct()
/obj/structure/pipe_cleaner/attackby(obj/item/W, mob/user, params)
handlecable(W, user, params)
/obj/structure/pipe_cleaner/singularity_pull(S, current_size)
..()
if(current_size >= STAGE_FIVE)
deconstruct()
/obj/structure/pipe_cleaner/proc/update_stored(length = 1, colorC = COLOR_RED)
stored.amount = length
stored.color = colorC
stored.update_icon()
/obj/structure/pipe_cleaner/AltClick(mob/living/user)
if(!user.canUseTopic(src, BE_CLOSE))
return
cut_pipe_cleaner(user)
///////////////////////////////////////////////
// The pipe cleaner coil object, used for laying pipe cleaner
///////////////////////////////////////////////
////////////////////////////////
// Definitions
////////////////////////////////
/obj/item/stack/pipe_cleaner_coil
name = "pipe cleaner coil"
desc = "A coil of pipe cleaners. Good for arts and crafts, not to build with."
custom_price = PAYCHECK_ASSISTANT * 0.5
gender = NEUTER //That's a pipe_cleaner coil sounds better than that's some pipe_cleaner coils
icon = 'icons/obj/power.dmi'
icon_state = "pipecleaner"
inhand_icon_state = "pipecleaner"
worn_icon_state = "coil"
lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi'
max_amount = MAXCOIL
amount = MAXCOIL
merge_type = /obj/item/stack/pipe_cleaner_coil // This is here to let its children merge between themselves
throwforce = 0
w_class = WEIGHT_CLASS_SMALL
throw_speed = 3
throw_range = 5
mats_per_unit = list(/datum/material/iron=10, /datum/material/glass=5)
flags_1 = CONDUCT_1
slot_flags = ITEM_SLOT_BELT
attack_verb_continuous = list("whips", "lashes", "disciplines", "flogs")
attack_verb_simple = list("whip", "lash", "discipline", "flog")
singular_name = "pipe cleaner piece"
full_w_class = WEIGHT_CLASS_SMALL
grind_results = list("copper" = 2) //2 copper per pipe_cleaner in the coil
usesound = 'sound/items/deconstruct.ogg'
cost = 1
source = /datum/robot_energy_storage/pipe_cleaner
color = COLOR_RED
/obj/item/stack/pipe_cleaner_coil/cyborg/attack_self(mob/user)
var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors
var/list/possible_colors = list()
for(var/color in pipe_cleaner_colors)
var/image/pipe_icon = image(icon = src.icon, icon_state = src.icon_state)
pipe_icon.color = pipe_cleaner_colors[color]
possible_colors += list("[color]" = pipe_icon)
var/selected_color = show_radial_menu(user, src, possible_colors, custom_check = CALLBACK(src, .proc/check_menu, user), radius = 40, require_near = TRUE)
if(!selected_color)
return
color = pipe_cleaner_colors[selected_color]
update_icon()
/**
* Checks if we are allowed to interact with a radial menu
*
* Arguments:
* * user The mob interacting with the menu
*/
/obj/item/stack/pipe_cleaner_coil/cyborg/proc/check_menu(mob/user)
if(!istype(user))
return FALSE
if(!user.is_holding(src))
return FALSE
if(user.incapacitated())
return FALSE
return TRUE
/obj/item/stack/pipe_cleaner_coil/suicide_act(mob/user)
if(locate(/obj/structure/chair/stool) in get_turf(user))
user.visible_message("<span class='suicide'>[user] is making a noose with [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
else
user.visible_message("<span class='suicide'>[user] is strangling [user.p_them()]self with [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
return(OXYLOSS)
/obj/item/stack/pipe_cleaner_coil/Initialize(mapload, new_amount = null, list/mat_override=null, mat_amt=1, param_color = null)
. = ..()
if(param_color)
color = param_color
if(!color)
var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors
var/random_color = pick(pipe_cleaner_colors)
color = pipe_cleaner_colors[random_color]
pixel_x = base_pixel_x + rand(-2, 2)
pixel_y = base_pixel_y + rand(-2, 2)
update_icon()
///////////////////////////////////
// General procedures
///////////////////////////////////
/obj/item/stack/pipe_cleaner_coil/update_icon()
icon_state = "[initial(inhand_icon_state)][amount < 3 ? amount : ""]"
name = "pipe cleaner [amount < 3 ? "piece" : "coil"]"
add_atom_colour(color, FIXED_COLOUR_PRIORITY)
/obj/item/stack/pipe_cleaner_coil/attack_hand(mob/user)
. = ..()
if(.)
return
var/obj/item/stack/pipe_cleaner_coil/new_pipe_cleaner = ..()
if(istype(new_pipe_cleaner))
new_pipe_cleaner.color = color
new_pipe_cleaner.update_icon()
//add pipe_cleaners to the stack
/obj/item/stack/pipe_cleaner_coil/proc/give(extra)
if(amount + extra > max_amount)
amount = max_amount
else
amount += extra
update_icon()
///////////////////////////////////////////////
// Cable laying procedures
//////////////////////////////////////////////
/obj/item/stack/pipe_cleaner_coil/proc/get_new_pipe_cleaner(location)
var/path = /obj/structure/pipe_cleaner
return new path(location, color)
// called when pipe_cleaner_coil is clicked on a turf
/obj/item/stack/pipe_cleaner_coil/proc/place_turf(turf/T, mob/user, dirnew)
if(!isturf(user.loc))
return
if(!isturf(T) || !T.can_have_cabling())
to_chat(user, "<span class='warning'>You can only lay pipe cleaners on a solid floor!</span>")
return
if(get_amount() < 1) // Out of pipe_cleaner
to_chat(user, "<span class='warning'>There is no pipe cleaner left!</span>")
return
if(get_dist(T,user) > 1) // Too far
to_chat(user, "<span class='warning'>You can't lay pipe cleaner at a place that far away!</span>")
return
var/dirn
if(!dirnew) //If we weren't given a direction, come up with one! (Called as null from catwalk.dm and floor.dm)
if(user.loc == T)
dirn = user.dir //If laying on the tile we're on, lay in the direction we're facing
else
dirn = get_dir(T, user)
else
dirn = dirnew
for(var/obj/structure/pipe_cleaner/LC in T)
if(LC.d2 == dirn && LC.d1 == 0)
to_chat(user, "<span class='warning'>There's already a pipe leaner at that position!</span>")
return
var/obj/structure/pipe_cleaner/C = get_new_pipe_cleaner(T)
//set up the new pipe_cleaner
C.d1 = 0 //it's a O-X node pipe_cleaner
C.d2 = dirn
C.add_fingerprint(user)
C.update_icon()
use(1)
return C
// called when pipe_cleaner_coil is click on an installed obj/pipe_cleaner
// or click on a turf that already contains a "node" pipe_cleaner
/obj/item/stack/pipe_cleaner_coil/proc/pipe_cleaner_join(obj/structure/pipe_cleaner/C, mob/user, showerror = TRUE, forceddir)
var/turf/U = user.loc
if(!isturf(U))
return
var/turf/T = C.loc
if(!isturf(T)) // sanity check
return
if(get_dist(C, user) > 1) // make sure it's close enough
to_chat(user, "<span class='warning'>You can't lay pipe cleaner at a place that far away!</span>")
return
if(U == T && !forceddir) //if clicked on the turf we're standing on and a direction wasn't supplied, try to put a pipe_cleaner in the direction we're facing
place_turf(T,user)
return
var/dirn = get_dir(C, user)
if(forceddir)
dirn = forceddir
// one end of the clicked pipe_cleaner is pointing towards us and no direction was supplied
if((C.d1 == dirn || C.d2 == dirn) && !forceddir)
if(!U.can_have_cabling()) //checking if it's a plating or catwalk
if (showerror)
to_chat(user, "<span class='warning'>You can only lay pipe cleaners on catwalks and plating!</span>")
return
else
// pipe_cleaner is pointing at us, we're standing on an open tile
// so create a stub pointing at the clicked pipe_cleaner on our tile
var/fdirn = turn(dirn, 180) // the opposite direction
for(var/obj/structure/pipe_cleaner/LC in U) // check to make sure there's not a pipe_cleaner there already
if(LC.d1 == fdirn || LC.d2 == fdirn)
if (showerror)
to_chat(user, "<span class='warning'>There's already a pipe cleaner at that position!</span>")
return
var/obj/structure/pipe_cleaner/NC = get_new_pipe_cleaner(U)
NC.d1 = 0
NC.d2 = fdirn
NC.add_fingerprint(user)
NC.update_icon()
use(1)
return
// exisiting pipe_cleaner doesn't point at our position or we have a supplied direction, so see if it's a stub
else if(C.d1 == 0)
// if so, make it a full pipe_cleaner pointing from it's old direction to our dirn
var/nd1 = C.d2 // these will be the new directions
var/nd2 = dirn
if(nd1 > nd2) // swap directions to match icons/states
nd1 = dirn
nd2 = C.d2
for(var/obj/structure/pipe_cleaner/LC in T) // check to make sure there's no matching pipe_cleaner
if(LC == C) // skip the pipe_cleaner we're interacting with
continue
if((LC.d1 == nd1 && LC.d2 == nd2) || (LC.d1 == nd2 && LC.d2 == nd1) ) // make sure no pipe_cleaner matches either direction
if (showerror)
to_chat(user, "<span class='warning'>There's already a pipe cleaner at that position!</span>")
return
C.update_icon()
C.d1 = nd1
C.d2 = nd2
//updates the stored pipe_cleaner coil
C.update_stored(2, color)
C.add_fingerprint(user)
C.update_icon()
use(1)
return
//////////////////////////////
// Misc.
/////////////////////////////
/obj/item/stack/pipe_cleaner_coil/red
color = COLOR_RED
/obj/item/stack/pipe_cleaner_coil/yellow
color = COLOR_YELLOW
/obj/item/stack/pipe_cleaner_coil/blue
color = COLOR_STRONG_BLUE
/obj/item/stack/pipe_cleaner_coil/green
color = COLOR_DARK_LIME
/obj/item/stack/pipe_cleaner_coil/pink
color = COLOR_LIGHT_PINK
/obj/item/stack/pipe_cleaner_coil/orange
color = COLOR_MOSTLY_PURE_ORANGE
/obj/item/stack/pipe_cleaner_coil/cyan
color = COLOR_CYAN
/obj/item/stack/pipe_cleaner_coil/white
color = COLOR_WHITE
/obj/item/stack/pipe_cleaner_coil/random
color = null
/obj/item/stack/pipe_cleaner_coil/random/five
amount = 5
/obj/item/stack/pipe_cleaner_coil/cut
amount = null
icon_state = "pipecleaner2"
/obj/item/stack/pipe_cleaner_coil/cut/Initialize(mapload)
if(!amount)
amount = rand(1,2)
. = ..()
pixel_x = base_pixel_x + rand(-2, 2)
pixel_y = base_pixel_y + rand(-2, 2)
update_icon()
/obj/item/stack/pipe_cleaner_coil/cut/red
color = COLOR_RED
/obj/item/stack/pipe_cleaner_coil/cut/yellow
color = COLOR_YELLOW
/obj/item/stack/pipe_cleaner_coil/cut/blue
color = COLOR_STRONG_BLUE
/obj/item/stack/pipe_cleaner_coil/cut/green
color = COLOR_DARK_LIME
/obj/item/stack/pipe_cleaner_coil/cut/pink
color = COLOR_LIGHT_PINK
/obj/item/stack/pipe_cleaner_coil/cut/orange
color = COLOR_MOSTLY_PURE_ORANGE
/obj/item/stack/pipe_cleaner_coil/cut/cyan
color = COLOR_CYAN
/obj/item/stack/pipe_cleaner_coil/cut/white
color = COLOR_WHITE
/obj/item/stack/pipe_cleaner_coil/cut/random
color = null