mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-31 00:58:26 +01:00
Refactor modular computer (and application) attackby into item_interaction (#84245)
## About The Pull Request Sooooooooo I was recently notified of an issue (#84185) that popped up from me replacing the `attackby(...)` chain on id cards, where it's no longer possible to put money into IDs inside of PDAs by slapping it against the PDA. As I expected, this is because modular computers both still use `attackby(...)`, and would call `attackby(...)` on the ID they contained if hit with cash. https://github.com/tgstation/tgstation/blob/24a23009e8ee4d056b6671c70c41feab1a18590b/code/modules/modular_computers/computers/item/computer.dm#L799 Now this could've been an easy one line no-gbp fix where I just replace it with a direct call to `insert_money(...)` on the ID and call it a day! But hey. Might as well get rid of the `attackby(...)` altogether while we're at it. First off, because the `attackby(...)` proc was getting quite bloated, we split off all the specific item behaviours into `[X]_act(...)` type procs to clean it up. We then make those return item interaction flags, so we can call them on `item_interaction(...)` after the right typecheck passes and immediately return their results. This also involves replacing the `application_attackby(...)` on applications with an `application_item_interaction(...)`, and making it return the item interaction flags too. The code of each subsection isn't significantly different, though reorganized a bit in some cases. Like inserting a computer disks now tries to move it into the computer _first_ before swapping out whichever disk is already in there, so it doesn't swap out the disk if putting the new one in fails. ## Why It's Good For The Game Fixes #84185. Having more stuff be updated to the proper `item_interaction(...)` system is cool and good.
This commit is contained in:
@@ -66,9 +66,9 @@
|
||||
/datum/computer_file/proc/on_examine(obj/item/modular_computer/source, mob/user)
|
||||
return null
|
||||
|
||||
/// Called when attacking a tablet with an item, checking if any application uses it. Return TRUE to cancel the attack chain.
|
||||
/datum/computer_file/proc/application_attackby(obj/item/attacking_item, mob/living/user)
|
||||
return FALSE
|
||||
/// Called on modular computer item_interaction, checking if any application uses the given item. Uses the item interaction chain flags.
|
||||
/datum/computer_file/proc/application_item_interaction(mob/living/user, obj/item/tool, list/modifiers)
|
||||
return NONE
|
||||
|
||||
/**
|
||||
* Implement this when your program has an object that the user can eject.
|
||||
|
||||
Reference in New Issue
Block a user