[MIRROR] Componentizes loomability [MDB IGNORE] (#20424)

* Componentizes loomability (#74552)

## About The Pull Request

As shrimple as the title might imply, the ability for an item to be
processed in a loom is now a component.

Behavior on looming cotton, durathread, and wool, should all be the
exact same in terms of cost, time, results, etc.
## Why It's Good For The Game

If, for any reason, someone might want to extend the behavior of "this
thing can be loomed" to other items, it can be done.
## Changelog
🆑
code: The ability for objects to be loomed is now a component, with all
of the looming behavior moved off of the structure and into said
component. The actual behavior for looming cotton (clicking on a loom
with cotton) is completely unchanged.
/🆑

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@ users.noreply.github.com>

* Componentizes loomability

---------

Co-authored-by: Paxilmaniac <82386923+Paxilmaniac@users.noreply.github.com>
Co-authored-by: Zephyr <12817816+ZephyrTFA@ users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-04-09 02:29:51 +01:00
committed by GitHub
co-authored by Zephyr Paxilmaniac
parent b11ff5a47d
commit fc5d5a9fe3
4 changed files with 82 additions and 27 deletions
-26
View File
@@ -1,6 +1,3 @@
#define FABRIC_PER_SHEET 4
///This is a loom. It's usually made out of wood and used to weave fabric like durathread or cotton into their respective cloth types.
/obj/structure/loom
name = "loom"
@@ -21,30 +18,7 @@
AddElement(/datum/element/contextual_screentip_item_typechecks, hovering_item_typechecks)
/obj/structure/loom/attackby(obj/item/I, mob/user)
if(weave(I, user))
return
return ..()
/obj/structure/loom/wrench_act(mob/living/user, obj/item/tool)
. = ..()
default_unfasten_wrench(user, tool, time = 0.5 SECONDS)
return TOOL_ACT_TOOLTYPE_SUCCESS
///Handles the weaving.
/obj/structure/loom/proc/weave(obj/item/stack/sheet/cotton/W, mob/user)
if(!istype(W))
return FALSE
if(!anchored)
user.show_message(span_notice("The loom needs to be wrenched down."), MSG_VISUAL)
return FALSE
if(W.amount < FABRIC_PER_SHEET)
user.show_message(span_notice("You need at least [FABRIC_PER_SHEET] units of fabric before using this."), MSG_VISUAL)
return FALSE
user.show_message(span_notice("You start weaving \the [W.name] through the loom.."), MSG_VISUAL)
while(W.use_tool(src, user, W.pull_effort) && W.use(FABRIC_PER_SHEET))
new W.loom_result(drop_location())
user.show_message(span_notice("You weave \the [W.name] into a workable fabric."), MSG_VISUAL)
return TRUE
#undef FABRIC_PER_SHEET