Converts slapcrafting into a bespoke element (#84226)

## About The Pull Request

Converts slapcrafting into a bespoke element, used to be ac omponent

## Why It's Good For The Game

Noticed this was a big C and realized there was no real reason for that.
It's the same recipe shared across different items.

## Changelog
N/A

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
carlarctg
2024-07-05 22:20:30 +00:00
committed by GitHub
co-authored by Ghom
parent fa6894a61d
commit bd14e92d04
31 changed files with 110 additions and 121 deletions
@@ -18,8 +18,8 @@
/obj/item/weaponcrafting/receiver/create_slapcraft_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/pipegun)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -34,8 +34,8 @@
/obj/item/weaponcrafting/stock/create_slapcraft_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/smoothbore_disabler, /datum/crafting_recipe/laser_musket)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -48,8 +48,8 @@
/obj/item/weaponcrafting/giant_wrench/create_slapcraft_component() // slappycraft
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/giant_wrench)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -1,10 +1,11 @@
/// Slapcrafting component!
/datum/component/slapcrafting
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
/datum/element/slapcrafting
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
var/list/slapcraft_recipes = list()
/**
* Slapcraft component
* Slapcraft element
*
* Slap it onto a item to be able to slapcraft with it
*
@@ -14,35 +15,28 @@
* It will check the area near the user for the rest of the ingredients and tools.
* *
**/
/datum/component/slapcrafting/Initialize(
slapcraft_recipes = null,
)
/datum/element/slapcrafting/Attach(datum/target, slapcraft_recipes = null)
..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
var/obj/item/target_item = target
var/obj/item/parent_item = parent
if((target_item.item_flags & ABSTRACT) || (target_item.item_flags & DROPDEL))
return //Don't do anything, it just shouldn't be used in crafting.
if((parent_item.item_flags & ABSTRACT) || (parent_item.item_flags & DROPDEL))
return COMPONENT_NOTRANSFER
RegisterSignal(target, COMSIG_ATOM_ATTACKBY, PROC_REF(attempt_slapcraft))
RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(get_examine_info))
RegisterSignal(target, COMSIG_ATOM_EXAMINE_MORE, PROC_REF(get_examine_more_info))
RegisterSignal(target, COMSIG_TOPIC, PROC_REF(topic_handler))
RegisterSignal(parent, COMSIG_ATOM_ATTACKBY, PROC_REF(attempt_slapcraft))
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(get_examine_info))
RegisterSignal(parent, COMSIG_ATOM_EXAMINE_MORE, PROC_REF(get_examine_more_info))
RegisterSignal(parent, COMSIG_TOPIC, PROC_REF(topic_handler))
src.slapcraft_recipes = slapcraft_recipes
src.slapcraft_recipes += slapcraft_recipes
/datum/element/slapcrafting/Detach(datum/source, ...)
. = ..()
UnregisterSignal(source, list(COMSIG_ATOM_ATTACKBY, COMSIG_ATOM_EXAMINE, COMSIG_ATOM_EXAMINE_MORE))
/datum/component/slapcrafting/InheritComponent(datum/component/slapcrafting/new_comp, original, slapcraft_recipes)
if(!original)
return
src.slapcraft_recipes += slapcraft_recipes
/datum/component/slapcrafting/Destroy(force)
UnregisterSignal(parent, list(COMSIG_ATOM_ATTACKBY, COMSIG_ATOM_EXAMINE, COMSIG_ATOM_EXAMINE_MORE))
return ..()
/datum/component/slapcrafting/proc/attempt_slapcraft(obj/item/parent_item, obj/item/slapper, mob/user)
/datum/element/slapcrafting/proc/attempt_slapcraft(obj/item/parent_item, obj/item/slapper, mob/user)
if(isnull(slapcraft_recipes))
CRASH("NULL SLAPCRAFT RECIPES?")
@@ -71,9 +65,9 @@
return
// We might use radials so we need to split the proc chain
INVOKE_ASYNC(src, PROC_REF(slapcraft_async), valid_recipes, user, craft_sheet)
INVOKE_ASYNC(src, PROC_REF(slapcraft_async), parent_item, valid_recipes, user, craft_sheet)
/datum/component/slapcrafting/proc/slapcraft_async(list/valid_recipes, mob/user, datum/component/personal_crafting/craft_sheet)
/datum/element/slapcrafting/proc/slapcraft_async(obj/parent_item, list/valid_recipes, mob/user, datum/component/personal_crafting/craft_sheet)
var/list/recipe_choices = list()
@@ -90,7 +84,7 @@
if(!recipe_choices)
CRASH("No recipe choices despite validating in earlier proc")
string_chosen_recipe = show_radial_menu(user, parent, recipe_choices, require_near = TRUE)
string_chosen_recipe = show_radial_menu(user, parent_item, recipe_choices, require_near = TRUE)
if(isnull(string_chosen_recipe))
return // they closed the thing
@@ -118,7 +112,7 @@
to_chat(user, span_warning("crafting failed" + error_string))
/// Alerts any examiners to the recipe, if they wish to know more.
/datum/component/slapcrafting/proc/get_examine_info(atom/source, mob/user, list/examine_list)
/datum/element/slapcrafting/proc/get_examine_info(atom/source, mob/user, list/examine_list)
SIGNAL_HANDLER
var/list/string_results = list()
@@ -132,17 +126,17 @@
already_used_names += initial(result.name)
string_results += list("\a [initial(result.name)]")
examine_list += span_notice("You think [parent] could be used to make [english_list(string_results)]! Examine again to look at the details...")
examine_list += span_notice("You think [source] could be used to make [english_list(string_results)]! Examine again to look at the details...")
/// Alerts any examiners to the details of the recipe.
/datum/component/slapcrafting/proc/get_examine_more_info(atom/source, mob/user, list/examine_list)
/datum/element/slapcrafting/proc/get_examine_more_info(atom/source, mob/user, list/examine_list)
SIGNAL_HANDLER
for(var/datum/crafting_recipe/recipe as anything in slapcraft_recipes)
var/atom/result = initial(recipe.result)
examine_list += "<a href='?src=[REF(source)];check_recipe=[REF(recipe)]'>See Recipe For [initial(result.name)]</a>"
/datum/component/slapcrafting/proc/topic_handler(atom/source, user, href_list)
/datum/element/slapcrafting/proc/topic_handler(atom/source, user, href_list)
SIGNAL_HANDLER
if(!href_list["check_recipe"])
@@ -176,7 +170,7 @@
var/amount = initial(cur_recipe.reqs[ingredient])
// If we're about to describe the ingredient that the component is based on, lower the described amount by 1 or remove it outright.
if(parent.type == valid_type)
if(source.type == valid_type)
if(amount > 1)
amount--
else
+2 -2
View File
@@ -120,8 +120,8 @@ Buildable meters
return ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/ghettojetpack, /datum/crafting_recipe/pipegun, /datum/crafting_recipe/smoothbore_disabler, /datum/crafting_recipe/improvised_pneumatic_cannon)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -763,8 +763,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/improvised_coolant)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
register_context()
@@ -46,8 +46,8 @@
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/flashlight_eyes)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -116,9 +116,7 @@
// No subtypes
if(type != /obj/item/radio)
return
AddComponent(/datum/component/slapcrafting,\
slapcraft_recipes = list(/datum/crafting_recipe/improv_explosive)\
)
AddElement(/datum/element/slapcrafting, string_list(list(/datum/crafting_recipe/improv_explosive)))
RegisterSignal(src, COMSIG_HIT_BY_SABOTEUR, PROC_REF(on_saboteur))
@@ -37,8 +37,8 @@
return
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/material_sniffer)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -52,8 +52,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/ghettojetpack)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -40,8 +40,8 @@
AddElement(/datum/element/update_icon_updates_onmob)
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/flamethrower)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -214,8 +214,8 @@
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/bola, /datum/crafting_recipe/gonbola)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -37,8 +37,8 @@
/datum/crafting_recipe/pillow_suit, /datum/crafting_recipe/pillow_hood,\
)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -145,8 +145,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/strobeshield)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+8 -8
View File
@@ -61,8 +61,8 @@
/obj/item/spear/proc/add_headpike_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/headpike)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -231,8 +231,8 @@
/obj/item/spear/military/add_headpike_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/headpikemilitary)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -255,8 +255,8 @@
/obj/item/spear/bonespear/add_headpike_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/headpikebone)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -279,7 +279,7 @@
/obj/item/spear/bamboospear/add_headpike_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/headpikebamboo)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -58,8 +58,8 @@ GLOBAL_LIST_INIT(rod_recipes, list ( \
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/spear, /datum/crafting_recipe/stunprod, /datum/crafting_recipe/teleprod) // snatcher prod isn't here as a spoopy secret
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -251,8 +251,8 @@ GLOBAL_LIST_INIT(leather_recipes, list ( \
/datum/crafting_recipe/goliathcloak, /datum/crafting_recipe/skilt, /datum/crafting_recipe/drakecloak,\
)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -311,8 +311,8 @@ GLOBAL_LIST_INIT(sinew_recipes, list ( \
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/drakecloak)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -549,8 +549,8 @@ GLOBAL_LIST_INIT(durathread_recipes, list ( \
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/durathread_helmet, /datum/crafting_recipe/durathread_vest)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -683,8 +683,8 @@ GLOBAL_LIST_INIT(cardboard_recipes, list ( \
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/cardboard_id)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -824,8 +824,8 @@ GLOBAL_LIST_INIT(bronze_recipes, list ( \
/datum/crafting_recipe/skullhelm,
)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
GLOBAL_LIST_INIT(plastic_recipes, list(
+2 -3
View File
@@ -47,9 +47,8 @@
/obj/item/bag_of_holding_inert/Initialize(mapload)
. = ..()
AddComponent(/datum/component/slapcrafting,\
slapcraft_recipes = list(/datum/crafting_recipe/boh)\
)
var/static/list/recipes = list(/datum/crafting_recipe/boh)
AddElement(/datum/element/slapcrafting, recipes)
/obj/item/storage/backpack/holding
name = "bag of holding"
+4 -4
View File
@@ -326,8 +326,8 @@
/obj/item/clothing/glasses/sunglasses/proc/add_glasses_slapcraft_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/hudsunsec, /datum/crafting_recipe/hudsunmed, /datum/crafting_recipe/hudsundiag, /datum/crafting_recipe/scienceglasses)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -346,8 +346,8 @@
/obj/item/clothing/glasses/sunglasses/chemical/add_glasses_slapcraft_component()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/scienceglassesremoval)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+7 -7
View File
@@ -4,7 +4,7 @@
flags_1 = null //doesn't protect eyes because it's a monocle, duh
var/hud_type = null
// NOTE: Just because you have a HUD display doesn't mean you should be able to interact with stuff on examine, that's where the associated trait (TRAIT_MEDICAL_HUD, TRAIT_SECURITY_HUD, etc) is necessary.
// NOTE: Just because you have a HUD display doesn't mean you should be able to interact with stuff on examine, that's where the associated trait (TRAIT_MEDICAL_HUD, TRAIT_SECURITY_HUD, etc) is necessary.
/obj/item/clothing/glasses/hud/equipped(mob/living/carbon/human/user, slot)
..()
@@ -94,8 +94,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/hudsunmedremoval)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -131,8 +131,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/hudsundiagremoval)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -175,8 +175,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/hudsunsecremoval)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -13,8 +13,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/extendohand_l, /datum/crafting_recipe/extendohand_r)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+4 -4
View File
@@ -15,8 +15,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/radiogloves)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -37,8 +37,8 @@
. = ..()
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/gripperoffbrand)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+2 -2
View File
@@ -412,8 +412,8 @@
/datum/crafting_recipe/sturdy_shako,\
)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -100,7 +100,8 @@
/obj/item/aquarium_kit/Initialize(mapload)
. = ..()
AddComponent(/datum/component/slapcrafting, /datum/crafting_recipe/aquarium)
var/static/list/recipes = list(/datum/crafting_recipe/aquarium)
AddElement(/datum/element/slapcrafting, recipes)
/obj/item/aquarium_prop
name = "generic aquarium prop"
@@ -140,8 +140,8 @@
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/meteorslug, /datum/crafting_recipe/pulseslug, /datum/crafting_recipe/dragonsbreath, /datum/crafting_recipe/ionslug)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -16,8 +16,8 @@
return
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/advancedegun, /datum/crafting_recipe/tempgun, /datum/crafting_recipe/beam_rifle)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -27,8 +27,8 @@
return
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/ebow)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -16,8 +16,8 @@
return
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/xraylaser, /datum/crafting_recipe/hellgun, /datum/crafting_recipe/ioncarbine)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
@@ -42,9 +42,8 @@
/obj/item/reagent_containers/cup/glass/bottle/Initialize(mapload, vol)
. = ..()
AddComponent(/datum/component/slapcrafting,\
slapcraft_recipes = list(/datum/crafting_recipe/molotov)\
)
var/static/list/recipes = list(/datum/crafting_recipe/molotov)
AddElement(/datum/element/slapcrafting, recipes)
/obj/item/reagent_containers/cup/glass/bottle/small
name = "small glass bottle"
@@ -23,9 +23,7 @@
/obj/item/reagent_containers/cup/soda_cans/Initialize(mapload, vol)
. = ..()
AddComponent(/datum/component/slapcrafting,\
slapcraft_recipes = list(/datum/crafting_recipe/improv_explosive)\
)
AddElement(/datum/element/slapcrafting, string_list(list(/datum/crafting_recipe/improv_explosive)))
/obj/item/reagent_containers/cup/soda_cans/random/Initialize(mapload)
..()
+2 -2
View File
@@ -286,8 +286,8 @@
//saws are very accurate and fast at butchering
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/chainsaw)
AddComponent(
/datum/component/slapcrafting,\
AddElement(
/datum/element/slapcrafting,\
slapcraft_recipes = slapcraft_recipe_list,\
)
+1 -1
View File
@@ -1272,7 +1272,6 @@
#include "code\datums\components\crafting\misc.dm"
#include "code\datums\components\crafting\ranged_weapon.dm"
#include "code\datums\components\crafting\robot.dm"
#include "code\datums\components\crafting\slapcrafting.dm"
#include "code\datums\components\crafting\structures.dm"
#include "code\datums\components\crafting\tailoring.dm"
#include "code\datums\components\crafting\tiles.dm"
@@ -1504,6 +1503,7 @@
#include "code\datums\elements\simple_flying.dm"
#include "code\datums\elements\skill_reward.dm"
#include "code\datums\elements\skittish.dm"
#include "code\datums\elements\slapcrafting.dm"
#include "code\datums\elements\soft_landing.dm"
#include "code\datums\elements\spooky.dm"
#include "code\datums\elements\squish.dm"