Files
Bubberstation/code/modules/modular_computers/hardware/ai_slot.dm
SkyratBot 80d6870000 [MIRROR] Tool act superpack 2 [MDB IGNORE] (#11947)
* Tool act superpack 2 (#64428)

About The Pull Request

Continuation of #64375, extracting tool behavior from attackby() and moving it into discrete _act procs. This is about as many files as I had in the last version, as I still want this to be reviewable.

As before, I've tested everything in game and it works as it previously did.
Why It's Good For The Game

The more code moved out of attackby, the more modular things become.
Changelog

cl
refactor: Moves more tool behavior out of attackby().
/cl

* Tool act superpack 2

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
2022-03-07 22:11:04 -07:00

67 lines
2.1 KiB
Plaintext

/obj/item/computer_hardware/ai_slot
name = "intelliCard interface slot"
desc = "A module allowing this computer to interface with most common intelliCard modules. Necessary for some programs to run properly."
power_usage = 100 //W
icon_state = "card_mini"
w_class = WEIGHT_CLASS_SMALL
device_type = MC_AI
expansion_hw = TRUE
var/obj/item/aicard/stored_card
var/locked = FALSE
///What happens when the intellicard is removed (or deleted) from the module, through try_eject() or not.
/obj/item/computer_hardware/ai_slot/Exited(atom/movable/gone, direction)
if(stored_card == gone)
stored_card = null
return ..()
/obj/item/computer_hardware/ai_slot/examine(mob/user)
. = ..()
if(stored_card)
. += "There appears to be an intelliCard loaded. There appears to be a pinhole protecting a manual eject button. A screwdriver could probably press it."
/obj/item/computer_hardware/ai_slot/try_insert(obj/item/I, mob/living/user = null)
if(!holder)
return FALSE
if(!istype(I, /obj/item/aicard))
return FALSE
if(stored_card)
to_chat(user, span_warning("You try to insert \the [I] into \the [src], but the slot is occupied."))
return FALSE
if(user && !user.transferItemToLoc(I, src))
return FALSE
stored_card = I
to_chat(user, span_notice("You insert \the [I] into \the [src]."))
return TRUE
/obj/item/computer_hardware/ai_slot/try_eject(mob/living/user = null, forced = FALSE)
if(!stored_card)
to_chat(user, span_warning("There is no card in \the [src]."))
return FALSE
if(locked && !forced)
to_chat(user, span_warning("Safeties prevent you from removing the card until reconstruction is complete..."))
return FALSE
if(stored_card)
to_chat(user, span_notice("You remove [stored_card] from [src]."))
locked = FALSE
if(Adjacent(user))
user.put_in_hands(stored_card)
else
stored_card.forceMove(drop_location())
return TRUE
return FALSE
/obj/item/computer_hardware/ai_slot/screwdriver_act(mob/living/user, obj/item/tool)
to_chat(user, span_notice("You press down on the manual eject button with [tool]."))
try_eject(user, TRUE)
return TOOL_ACT_TOOLTYPE_SUCCESS