Skip to content
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

Ports and improves accessable_storage.dm #30

Merged
merged 11 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions code/__DEFINES/~doppler_defines/item.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// From base of /obj/item/mob_can_equip. (mob/living/M, slot, disable_warning, bypass_equip_delay_self, ignore_equipped, indirect_action)
#define COMSIG_ITEM_MOB_CAN_EQUIP "item_mob_can_equip"
/// Forces mob_can_equip to return FALSE.
#define COMPONENT_ITEM_CANT_EQUIP (1<<10) // high to avoid flag conflict
2 changes: 2 additions & 0 deletions code/__DEFINES/~doppler_defines/strippable.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// All of these must be matched in StripMenu.js.
#define STRIPPABLE_ITEM_TAIL "tail"
4 changes: 2 additions & 2 deletions code/datums/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,12 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
return open_storage_on_signal(source, user) ? CLICK_ACTION_SUCCESS : NONE

/// Opens the storage to the mob, showing them the contents to their UI.
/datum/storage/proc/open_storage(mob/to_show)
/datum/storage/proc/open_storage(mob/to_show, can_reach_target = parent) // DOPPLER EDIT ADDITION -- Original: /datum/storage/proc/open_storage(mob/to_show)
if(isobserver(to_show))
show_contents(to_show)
return FALSE

if(!isliving(to_show) || !to_show.can_perform_action(parent, ALLOW_RESTING | FORBID_TELEKINESIS_REACH))
if(!isliving(to_show) || !to_show.can_perform_action(can_reach_target, ALLOW_RESTING | FORBID_TELEKINESIS_REACH)) // DOPPLER EDIT CHANGE -- ORIGINAL: if(!isliving(to_show) || !to_show.can_perform_action(parent, ALLOW_RESTING | FORBID_TELEKINESIS_REACH))
return FALSE

if(locked)
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/human/human_stripping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GLOBAL_LIST_INIT(strippable_human_items, create_strippable_list(list(
/datum/strippable_item/mob_item_slot/belt,
/datum/strippable_item/mob_item_slot/pocket/left,
/datum/strippable_item/mob_item_slot/pocket/right,
/datum/strippable_item/mob_item_slot/tail, // Doppler station edit - tail slot for strip menu!
/datum/strippable_item/hand/left,
/datum/strippable_item/hand/right,
/datum/strippable_item/mob_item_slot/handcuffs,
Expand Down
100 changes: 100 additions & 0 deletions modular_doppler/accessable_storage/accessable_storage.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Any item with this component can have its storage accessed by alt clicking the wearer.
/datum/component/accessable_storage

/datum/component/accessable_storage/Initialize()
if (!isitem(parent))
return COMPONENT_INCOMPATIBLE

/datum/component/accessable_storage/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(parent_equipped))
RegisterSignal(parent, COMSIG_ATOM_STORED_ITEM, PROC_REF(parent_stored_item))
RegisterSignal(parent, COMSIG_ATOM_REMOVED_ITEM, PROC_REF(parent_removed_item))

/datum/component/accessable_storage/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ATOM_STORED_ITEM, COMSIG_ATOM_REMOVED_ITEM))

/// Subtype specifically for organs that offer the ability to hold 1 item and gain a text prompt on examine
// Unlike its parent, this can only be accessed by the owner, unless its added to stripmenu
/datum/component/accessable_storage/organ

/datum/component/accessable_storage/organ/Initialize()
. = ..()
var/obj/item/organ/organ_target = parent
if(!isorgan(organ_target))
return COMPONENT_INCOMPATIBLE

RegisterSignal(organ_target, COMSIG_ORGAN_IMPLANTED, PROC_REF(parent_equipped))

/datum/component/accessable_storage/organ/RegisterWithParent()
RegisterSignal(parent, COMSIG_ATOM_STORED_ITEM, PROC_REF(parent_stored_item))
RegisterSignal(parent, COMSIG_ATOM_REMOVED_ITEM, PROC_REF(parent_removed_item))

/datum/component/accessable_storage/organ/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ATOM_STORED_ITEM, COMSIG_ATOM_REMOVED_ITEM))

/// Signal handler for COMSIG_ITEM_EQUIPPED. Handles registering signals.
/datum/component/accessable_storage/proc/parent_equipped(datum/signal_source, mob/equipper, slot)
SIGNAL_HANDLER

if (isliving(equipper) && !(equipper.get_slot_by_item(parent) & (ITEM_SLOT_HANDS|ITEM_SLOT_POCKETS)))
RegisterSignal(equipper, COMSIG_MOB_UNEQUIPPED_ITEM, PROC_REF(mob_unequipped_item))
RegisterSignal(equipper, COMSIG_CLICK_ALT, PROC_REF(mob_alt_clicked_on))

/// Signal handler for COMSIG_CLICK_ALT. Handles the actual opening of storage.
/datum/component/accessable_storage/proc/mob_alt_clicked_on(mob/signal_source, mob/clicker)
SIGNAL_HANDLER

var/obj/item/item_parent = parent
if(isorgan(item_parent))
var/mob/organ_owner = item_parent.loc.loc
if(organ_owner != clicker)
return NONE
else
animate_target(signal_source)

item_parent.atom_storage?.open_storage(clicker, signal_source)

return CLICK_ACTION_SUCCESS

/// Signal handler for COMSIG_MOB_UNEQUIPPED_ITEM. Handles unregistering signals.
/datum/component/accessable_storage/proc/mob_unequipped_item(mob/signal_source, obj/item/item, force, atom/newloc, no_move, invdrop, silent)
SIGNAL_HANDLER

if (item == parent)
UnregisterSignal(signal_source, list(COMSIG_MOB_UNEQUIPPED_ITEM, COMSIG_CLICK_ALT))

/// Signal handler for COMSIG_ATOM_STORED_ITEM. Handles animating our parent's wearer.
/datum/component/accessable_storage/proc/parent_stored_item(obj/item/signal_source, obj/item/inserted, mob/user, force)
SIGNAL_HANDLER

if(isorgan(signal_source))
var/obj/item/organ/visible_organ = signal_source
RegisterSignal(visible_organ.owner, COMSIG_ATOM_EXAMINE, PROC_REF(on_receiver_examine))
if (isliving(signal_source.loc))
animate_target(signal_source.loc)

/// Signal handler for COMSIG_ATOM_REMOVED_ITEM. Handles animating our parent's wearer.
/datum/component/accessable_storage/proc/parent_removed_item(obj/item/signal_source, obj/item/thing, atom/remove_to_loc, silent)
SIGNAL_HANDLER

if(isorgan(signal_source))
var/obj/item/organ/visible_organ = signal_source
UnregisterSignal(visible_organ.owner, COMSIG_ATOM_EXAMINE)
if (isliving(signal_source.loc))
animate_target(signal_source.loc)

/// Gives a spiffy animation to the target to represent opening and closing. Copy pasted from storage.dm, please change if that proc ever changes
/datum/component/accessable_storage/proc/animate_target(atom/target = parent)
var/matrix/old_matrix = target.transform
animate(target, time = 1.5, loop = 0, transform = target.transform.Scale(1.07, 0.9))
animate(time = 2, transform = old_matrix)

/datum/component/accessable_storage/proc/on_receiver_examine(mob/living/carbon/examined, mob/user, list/examine_list)
SIGNAL_HANDLER

var/obj/item/organ/visible_organ = parent
if(!length(visible_organ.contents))
return
var/examine_text = span_notice("[user.p_Theyre()] holding [icon2html(visible_organ.contents[1], examined)] \a <b>[visible_organ.contents[1].name]</b> with [user.p_their()] [visible_organ.name].")

examine_list += examine_text
10 changes: 10 additions & 0 deletions modular_doppler/accessable_storage/item.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/obj/item/mob_can_equip(mob/living/M, slot, disable_warning, bypass_equip_delay_self, ignore_equipped, indirect_action)
. = ..()

if (!.)
return FALSE

if (SEND_SIGNAL(src, COMSIG_ITEM_MOB_CAN_EQUIP, M, slot, disable_warning, bypass_equip_delay_self, ignore_equipped, indirect_action) & COMPONENT_ITEM_CANT_EQUIP)
return FALSE

return TRUE
62 changes: 62 additions & 0 deletions modular_doppler/accessable_storage/strippable.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#define TAIL_EQUIP_DELAY 2 SECONDS

/datum/strippable_item/mob_item_slot/tail
key = STRIPPABLE_ITEM_TAIL

/datum/strippable_item/mob_item_slot/tail/should_show(atom/source, mob/user)
if(!iscarbon(source))
return FALSE
var/mob/living/carbon/carbon_source = source
var/obj/item/organ/external/tail/tail = carbon_source.get_organ_slot(ORGAN_SLOT_EXTERNAL_TAIL)
if(!tail || !tail.atom_storage)
return FALSE
return TRUE

/datum/strippable_item/mob_item_slot/tail/get_item(atom/source)
if(!iscarbon(source))
return null
var/mob/living/carbon/carbon_source = source
var/obj/item/organ/external/tail/tail = carbon_source.get_organ_slot(ORGAN_SLOT_EXTERNAL_TAIL)
if(tail && tail.atom_storage && length(tail.contents))
return tail.contents[1]

/datum/strippable_item/mob_item_slot/tail/try_equip(atom/source, obj/item/equipping, mob/user)
if(!iscarbon(source))
return FALSE
if(equipping.w_class >= WEIGHT_CLASS_NORMAL)
to_chat(user, span_warning("\The [equipping] is too big!"))
return FALSE
return TRUE

/datum/strippable_item/mob_item_slot/tail/start_equip(atom/source, obj/item/equipping, mob/user)
if(!iscarbon(source))
return FALSE
warn_owner(source)
if(!do_after(user, TAIL_EQUIP_DELAY, source))
return FALSE
if(!user.temporarilyRemoveItemFromInventory(equipping))
return FALSE
return TRUE

/datum/strippable_item/mob_item_slot/tail/finish_equip(atom/source, obj/item/equipping, mob/user)
if(!iscarbon(source))
return FALSE
var/mob/living/carbon/carbon_source = source
var/obj/item/organ/external/tail/tail = carbon_source.get_organ_slot(ORGAN_SLOT_EXTERNAL_TAIL)
tail.atom_storage?.attempt_insert(equipping, user)

return finish_equip_mob(equipping, source, user)

/datum/strippable_item/mob_item_slot/tail/start_unequip(atom/source, mob/user)
var/obj/item/item = get_item(source)
if(isnull(item))
return FALSE
warn_owner(source)
if(!do_after(user, TAIL_EQUIP_DELAY, source))
return FALSE
return TRUE

/datum/strippable_item/mob_item_slot/tail/proc/warn_owner(atom/owner)
to_chat(owner, span_warning("You feel your tail being toyed with!"))

#undef TAIL_EQUIP_DELAY
5 changes: 5 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
#include "code\__DEFINES\traits\sources.dm"
#include "code\__DEFINES\~doppler_defines\enterprise_resource_planning.dm"
#include "code\__DEFINES\~doppler_defines\is_helpers.dm"
#include "code\__DEFINES\~doppler_defines\item.dm"
#include "code\__DEFINES\~doppler_defines\keybindings.dm"
#include "code\__DEFINES\~doppler_defines\living.dm"
#include "code\__DEFINES\~doppler_defines\loadout.dm"
Expand All @@ -409,6 +410,7 @@
#include "code\__DEFINES\~doppler_defines\sound.dm"
#include "code\__DEFINES\~doppler_defines\span.dm"
#include "code\__DEFINES\~doppler_defines\species.dm"
#include "code\__DEFINES\~doppler_defines\strippable.dm"
#include "code\__DEFINES\~doppler_defines\techweb_nodes.dm"
#include "code\__DEFINES\~doppler_defines\traits.dm"
#include "code\__HELPERS\_auxtools_api.dm"
Expand Down Expand Up @@ -6412,6 +6414,9 @@
#include "interface\fonts\spess_font.dm"
#include "interface\fonts\tiny_unicode.dm"
#include "interface\fonts\vcr_osd_mono.dm"
#include "modular_doppler\accessable_storage\accessable_storage.dm"
#include "modular_doppler\accessable_storage\item.dm"
#include "modular_doppler\accessable_storage\strippable.dm"
#include "modular_doppler\advanced_reskin\code\advanced_reskin.dm"
#include "modular_doppler\cryosleep\code\admin.dm"
#include "modular_doppler\cryosleep\code\ai.dm"
Expand Down
7 changes: 7 additions & 0 deletions tgui/packages/tgui/interfaces/StripMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ const SLOTS: Record<
gridSpot: getGridSpotKey([4, 5]),
image: 'inventory-pocket.png',
},
/* Doppler station addition start */
tail: {
displayName: 'tail',
gridSpot: getGridSpotKey([3, 3]),
image: 'inventory-belt.png',
},
/* Doppler station addition end */
};

enum ObscuringLevel {
Expand Down
Loading