Skip to content

Makes advanced factories possible -- Bunch of changes to mech component and the assembler #5121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,3 @@
time = 8 SECONDS
category = CAT_WEAPON_MELEE
always_available = FALSE

/datum/crafting_recipe/coffin
name = "Coffin"
result = /obj/structure/closet/crate/coffin
reqs = list(
/obj/item/stack/sheet/mineral/wood = 5,
)
time = 15 SECONDS
category = CAT_STRUCTURE
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var/datum/crafting_recipe/chosen_recipe
var/crafting = FALSE

var/static/list/crafting_recipes = list()
var/static/list/legal_crafting_recipes = list()
var/list/crafting_inventory = list()

icon = 'monkestation/code/modules/factory_type_beat/icons/mining_machines.dmi'
Expand All @@ -24,7 +24,7 @@
AddComponent(/datum/component/hovering_information, /datum/hover_data/assembler)
register_context()

if(!length(crafting_recipes))
if(!length(legal_crafting_recipes))
create_recipes()

/obj/machinery/assembler/RefreshParts()
Expand Down Expand Up @@ -61,14 +61,14 @@
. += span_notice("[initial(atom.name)]: [chosen_recipe.reqs[atom]]")

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

/obj/machinery/assembler/attack_hand(mob/living/user, list/modifiers)
. = ..()
var/datum/crafting_recipe/choice = tgui_input_list(user, "Choose a recipe", name, crafting_recipes)
var/datum/crafting_recipe/choice = tgui_input_list(user, "Choose a recipe", name, legal_crafting_recipes)
if(!choice)
return
chosen_recipe = choice
Expand All @@ -77,19 +77,20 @@
crafting_inventory -= listed

/obj/machinery/assembler/CanAllowThrough(atom/movable/mover, border_dir)
if(!anchored)
return FALSE
if(!chosen_recipe)
if(!anchored || !chosen_recipe)
return FALSE

var/failed = TRUE
for(var/atom/movable/movable as anything in chosen_recipe.reqs)
if(istype(mover, movable))
failed = FALSE
break
if(failed)
return FALSE

if(!check_item(mover))
return FALSE

return ..()

/obj/machinery/assembler/proc/on_entered(datum/source, atom/movable/atom_movable)
Expand Down
17 changes: 15 additions & 2 deletions monkestation/code/modules/mech_comp/objects/_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
inputs = list()
update_icon_state()

MC_ADD_CONFIG(MC_CFG_UNLINK_ALL, unlink_all)
MC_ADD_CONFIG(MC_CFG_UNLINK, unlink)
MC_ADD_CONFIG(MC_CFG_LINK, add_linker)
MC_ADD_CONFIG(MC_CFG_UNLINK, unlink)
MC_ADD_CONFIG(MC_CFG_UNLINK_ALL, unlink_all)

/obj/item/mcobject/Destroy(force)
QDEL_NULL(interface)
return ..()

/obj/item/mcobject/examine(mob/user)
. = ..()
. += span_notice("You can left-click with a multitool to put up a list of options available for linking.")
. += span_notice("You can right-click with a multitool to quickly start linking the device as an output.")

/obj/item/mcobject/update_icon_state()
. = ..()
icon_state = anchored ? "u[base_icon_state]" : base_icon_state
Expand Down Expand Up @@ -64,6 +69,14 @@

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

/obj/item/mcobject/multitool_act_secondary(mob/living/user, obj/item/tool)
var/datum/component/mclinker/link = tool.GetComponent(/datum/component/mclinker)
if(link)
to_chat(user, span_warning("Previous link deleted."))
qdel(link)

add_linker(user, tool)

/obj/item/mcobject/proc/unlink(mob/user, obj/item/tool)
var/list/options = list()

Expand Down
33 changes: 31 additions & 2 deletions monkestation/code/modules/mech_comp/objects/interactor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
var/mob/living/carbon/human/dummy/dummy_human
///image of the held item displayed over the component to see whats going on
var/obj/item/held_item
///The object we specifically look for when clicking
var/atom/desired_path = null
///the connected storage component to act as an inventory to grab from
var/obj/item/mcobject/messaging/storage/connected_storage
///the current stored direction used for interaction
Expand All @@ -24,6 +26,7 @@
MC_ADD_CONFIG("Swap Click", swap_click)
MC_ADD_CONFIG("Swap Range", set_range)
MC_ADD_CONFIG("Change Direction", change_dir)
MC_ADD_CONFIG("Reset Desired Object", reset_desired_path)
MC_ADD_INPUT("swap click", swap_click_input)
MC_ADD_INPUT("replace", replace_from_storage)
MC_ADD_INPUT("drop", drop)
Expand All @@ -43,15 +46,33 @@
QDEL_NULL(dummy_human)
return ..()

/obj/item/mcobject/examine(mob/user)
. = ..()
. += span_notice("You can right-click with a multitool whilst having a storage component in your buffer to link it.")
. += 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.")

/obj/item/mcobject/interactor/multitool_act_secondary(mob/living/user, obj/item/tool)
var/obj/item/multitool/multitool = tool
if(!multitool.component_buffer)
return
return ..()
if(!istype(multitool.component_buffer, /obj/item/mcobject/messaging/storage))
return
return ..()
connected_storage = multitool.component_buffer
say("Successfully linked to storage component")

/obj/item/mcobject/interactor/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params)
. = ..()
if(!over || !istype(over) || over == src)
return

var/mob/living/carbon/human/user = usr
if(!istype(user))
return

if(Adjacent(user, src) && Adjacent(over, user))
say("Desired object set to [over]")
desired_path = over.type

/obj/item/mcobject/interactor/proc/drop(datum/mcmessage/input)
if(!input)
return
Expand Down Expand Up @@ -110,6 +131,11 @@
stored_dir = directions_listed[direction_choice]
return TRUE

/obj/item/mcobject/interactor/proc/reset_desired_path(mob/user, obj/item/tool)
say("Desired object [desired_path ? "reset" : "not set"]!")
desired_path = null
return TRUE

/obj/item/mcobject/interactor/proc/swap_click_input(datum/mcmessage/input)
if(!input)
return
Expand All @@ -127,6 +153,9 @@
selected_turf = get_step(src, stored_dir)

for(var/atom/movable/listed_atom in selected_turf)
if(desired_path && (desired_path != listed_atom.type))
continue

if(dummy_human == listed_atom || src == listed_atom)
continue

Expand Down
Loading