Skip to content

Commit 38ffa81

Browse files
authored
Makes advanced factories possible -- Bunch of changes to mech component and the assembler (#5121)
## About The Pull Request - Adds examine text telling you that you that using a multitool on mech components is how you interact with them - Makes it so right-clicking with a multitool on a component automatically sets your multitool buffer to the link - Makes interaction components capable of only choosing a specific type of item instead of all items on a tile (AKA, a filter) - Makes assemblers actually have ALL the recipes in the crafting book by taking it from `GLOB.crafting_recipes` (except restricted ones) - Removes the 10x longer coffin crafting recipe that bloodsuckers added for no reason ## Why It's Good For The Game > Adds examine text telling you that you that using a multitool on mech components is how you interact with them - Somehow we didnt have that, was also needed for the next point > Makes it so right-clicking with a multitool on a component automatically sets your multitool buffer to the link - Speeds up the repetiveness a bit > Makes interaction components capable of only choosing a specific type of item instead of all items on a tile (AKA, a filter) - Ever wanted to make a conveyorbelt with items and only interact with the items? Now is your chance to do so! > Makes assemblers actually have ALL the recipes in the crafting book by taking it from `GLOB.crafting_recipes` (except restricted ones) - They didnt have the recipes from sheets of items, now they do, so a lot more is possible combined with the interaction comp filter. - ((This does mean cargo can make coffins 10 times faster now, since that recipe is also taken into account. Can be slowed on request)) > Removes the 10x longer coffin crafting recipe that bloodsuckers added for no reason - Bug :3 ## Changelog :cl: add: Interaction components can now have a filter that only interacts with specific items. qol: Mech components can now have themselfes quickly put into the multitool buffer as a device to link if you right-click them. balance: automatic assemblers can now make any* crafting recipe thats made using sheets in your hand fix: There is no longer a coffin recipe that takes 10 times as long to craft in the crafting menu. /:cl:
1 parent 73ec32b commit 38ffa81

File tree

4 files changed

+67
-22
lines changed

4 files changed

+67
-22
lines changed

monkestation/code/modules/bloodsuckers/structures/bloodsucker_recipes.dm

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,3 @@
112112
time = 8 SECONDS
113113
category = CAT_WEAPON_MELEE
114114
always_available = FALSE
115-
116-
/datum/crafting_recipe/coffin
117-
name = "Coffin"
118-
result = /obj/structure/closet/crate/coffin
119-
reqs = list(
120-
/obj/item/stack/sheet/mineral/wood = 5,
121-
)
122-
time = 15 SECONDS
123-
category = CAT_STRUCTURE

monkestation/code/modules/factory_type_beat/machinery/assembler.dm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
var/datum/crafting_recipe/chosen_recipe
88
var/crafting = FALSE
99

10-
var/static/list/crafting_recipes = list()
10+
var/static/list/legal_crafting_recipes = list()
1111
var/list/crafting_inventory = list()
1212

1313
icon = 'monkestation/code/modules/factory_type_beat/icons/mining_machines.dmi'
1414
icon_state = "assembler"
1515

16-
1716
/obj/machinery/assembler/Initialize(mapload)
1817
. = ..()
1918

@@ -24,7 +23,7 @@
2423
AddComponent(/datum/component/hovering_information, /datum/hover_data/assembler)
2524
register_context()
2625

27-
if(!length(crafting_recipes))
26+
if(!length(legal_crafting_recipes))
2827
create_recipes()
2928

3029
/obj/machinery/assembler/RefreshParts()
@@ -61,14 +60,14 @@
6160
. += span_notice("[initial(atom.name)]: [chosen_recipe.reqs[atom]]")
6261

6362
/obj/machinery/assembler/proc/create_recipes()
64-
for(var/datum/crafting_recipe/recipe as anything in subtypesof(/datum/crafting_recipe) - /datum/crafting_recipe/stack)
63+
for(var/datum/crafting_recipe/recipe as anything in GLOB.crafting_recipes)
6564
if(initial(recipe.non_craftable) || !initial(recipe.always_available))
6665
continue
67-
crafting_recipes += new recipe
66+
legal_crafting_recipes += recipe
6867

6968
/obj/machinery/assembler/attack_hand(mob/living/user, list/modifiers)
7069
. = ..()
71-
var/datum/crafting_recipe/choice = tgui_input_list(user, "Choose a recipe", name, crafting_recipes)
70+
var/datum/crafting_recipe/choice = tgui_input_list(user, "Choose a recipe", name, legal_crafting_recipes)
7271
if(!choice)
7372
return
7473
chosen_recipe = choice
@@ -77,19 +76,20 @@
7776
crafting_inventory -= listed
7877

7978
/obj/machinery/assembler/CanAllowThrough(atom/movable/mover, border_dir)
80-
if(!anchored)
81-
return FALSE
82-
if(!chosen_recipe)
79+
if(!anchored || !chosen_recipe)
8380
return FALSE
81+
8482
var/failed = TRUE
8583
for(var/atom/movable/movable as anything in chosen_recipe.reqs)
8684
if(istype(mover, movable))
8785
failed = FALSE
8886
break
8987
if(failed)
9088
return FALSE
89+
9190
if(!check_item(mover))
9291
return FALSE
92+
9393
return ..()
9494

9595
/obj/machinery/assembler/proc/on_entered(datum/source, atom/movable/atom_movable)

monkestation/code/modules/mech_comp/objects/_object.dm

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,32 @@
1515
configs = list()
1616
inputs = list()
1717
update_icon_state()
18+
register_context()
1819

19-
MC_ADD_CONFIG(MC_CFG_UNLINK_ALL, unlink_all)
20-
MC_ADD_CONFIG(MC_CFG_UNLINK, unlink)
2120
MC_ADD_CONFIG(MC_CFG_LINK, add_linker)
21+
MC_ADD_CONFIG(MC_CFG_UNLINK, unlink)
22+
MC_ADD_CONFIG(MC_CFG_UNLINK_ALL, unlink_all)
2223

2324
/obj/item/mcobject/Destroy(force)
2425
QDEL_NULL(interface)
2526
return ..()
2627

28+
/obj/item/mcobject/examine(mob/user)
29+
. = ..()
30+
. += span_notice("You can left-click with a multitool to put up a list of options available for linking.")
31+
. += span_notice("You can right-click with a multitool to quickly start linking the device as an output.")
32+
33+
/obj/item/mcobject/add_context(atom/source, list/context, obj/item/held_item, mob/user)
34+
. = ..()
35+
if(isnull(held_item) || held_item.tool_behaviour != TOOL_MULTITOOL)
36+
return NONE
37+
38+
context[SCREENTIP_CONTEXT_LMB] = "View available operations"
39+
if(anchored)
40+
context[SCREENTIP_CONTEXT_RMB] = "Start linking"
41+
42+
return CONTEXTUAL_SCREENTIP_SET
43+
2744
/obj/item/mcobject/update_icon_state()
2845
. = ..()
2946
icon_state = anchored ? "u[base_icon_state]" : base_icon_state
@@ -64,6 +81,14 @@
6481

6582
call(src, configs[action])(user, tool)
6683

84+
/obj/item/mcobject/multitool_act_secondary(mob/living/user, obj/item/tool)
85+
var/datum/component/mclinker/link = tool.GetComponent(/datum/component/mclinker)
86+
if(link)
87+
to_chat(user, span_warning("Previous link deleted."))
88+
qdel(link)
89+
90+
add_linker(user, tool)
91+
6792
/obj/item/mcobject/proc/unlink(mob/user, obj/item/tool)
6893
var/list/options = list()
6994

monkestation/code/modules/mech_comp/objects/interactor.dm

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
var/mob/living/carbon/human/dummy/dummy_human
1313
///image of the held item displayed over the component to see whats going on
1414
var/obj/item/held_item
15+
///The object we specifically look for when clicking
16+
var/atom/desired_path = null
1517
///the connected storage component to act as an inventory to grab from
1618
var/obj/item/mcobject/messaging/storage/connected_storage
1719
///the current stored direction used for interaction
@@ -30,6 +32,7 @@
3032
MC_ADD_CONFIG("Swap Click", swap_click)
3133
MC_ADD_CONFIG("Swap Range", set_range)
3234
MC_ADD_CONFIG("Change Direction", change_dir)
35+
MC_ADD_CONFIG("Reset Desired Object", reset_desired_path)
3336
MC_ADD_INPUT("swap click", swap_click_input)
3437
MC_ADD_INPUT("replace", replace_from_storage)
3538
MC_ADD_INPUT("drop", drop)
@@ -49,15 +52,33 @@
4952
QDEL_NULL(dummy_human)
5053
return ..()
5154

55+
/obj/item/mcobject/examine(mob/user)
56+
. = ..()
57+
. += span_notice("You can right-click with a multitool whilst having a storage component in your buffer to link it.")
58+
. += span_notice("You can drag [src] over an object whilst you're adjacent to both [src] and the object to make it only click objects of the same type as it.")
59+
5260
/obj/item/mcobject/interactor/multitool_act_secondary(mob/living/user, obj/item/tool)
5361
var/obj/item/multitool/multitool = tool
5462
if(!multitool.component_buffer)
55-
return
63+
return ..()
5664
if(!istype(multitool.component_buffer, /obj/item/mcobject/messaging/storage))
57-
return
65+
return ..()
5866
connected_storage = multitool.component_buffer
5967
say("Successfully linked to storage component")
6068

69+
/obj/item/mcobject/interactor/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params)
70+
. = ..()
71+
if(!over || !istype(over) || over == src)
72+
return
73+
74+
var/mob/living/carbon/human/user = usr
75+
if(!istype(user))
76+
return
77+
78+
if(Adjacent(user, src) && Adjacent(over, user))
79+
say("Desired object set to [over]")
80+
desired_path = over.type
81+
6182
/obj/item/mcobject/interactor/proc/drop(datum/mcmessage/input)
6283
if(!input)
6384
return
@@ -116,6 +137,11 @@
116137
stored_dir = directions_listed[direction_choice]
117138
return TRUE
118139

140+
/obj/item/mcobject/interactor/proc/reset_desired_path(mob/user, obj/item/tool)
141+
say("Desired object [desired_path ? "reset" : "not set"]!")
142+
desired_path = null
143+
return TRUE
144+
119145
/obj/item/mcobject/interactor/proc/swap_click_input(datum/mcmessage/input)
120146
if(!input)
121147
return
@@ -133,6 +159,9 @@
133159
selected_turf = get_step(src, stored_dir)
134160

135161
for(var/atom/movable/listed_atom in selected_turf)
162+
if(desired_path && (desired_path != listed_atom.type))
163+
continue
164+
136165
if(dummy_human == listed_atom || src == listed_atom)
137166
continue
138167

0 commit comments

Comments
 (0)