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

[MIRROR] [PORT] Synths Update: The ID Reckoning #2155

Merged
merged 1 commit into from
Feb 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,27 @@
/obj/item/organ/internal/brain/synth/Destroy()
QDEL_NULL(internal_computer)
return ..()

/obj/item/organ/internal/brain/synth/on_mob_insert(mob/living/carbon/human/brain_owner, special, movement_flags)
. = ..()
if(!istype(brain_owner))
return
RegisterSignal(brain_owner, COMSIG_MOB_EQUIPPED_ITEM, PROC_REF(on_equip_signal))
if(internal_computer && brain_owner.wear_id)
internal_computer.handle_id_slot(brain_owner, brain_owner.wear_id)

/obj/item/organ/internal/brain/synth/on_mob_remove(mob/living/carbon/human/brain_owner, special)
. = ..()
if(!istype(brain_owner))
return
UnregisterSignal(brain_owner, COMSIG_MOB_EQUIPPED_ITEM)
if(internal_computer)
internal_computer.handle_id_slot(brain_owner)
internal_computer.clear_id_slot_signals(brain_owner.wear_id)

/obj/item/organ/internal/brain/synth/proc/on_equip_signal(datum/source, obj/item/item, slot)
SIGNAL_HANDLER
if(isnull(internal_computer))
return
if(slot == ITEM_SLOT_ID)
internal_computer.handle_id_slot(owner, item)
Original file line number Diff line number Diff line change
Expand Up @@ -44,60 +44,97 @@
)
return ..()

/obj/item/modular_computer/pda/synth/RemoveID(mob/user)
/// Id card arg is optional. Leaving it null causes the id to become unpaired from the synth computer
/obj/item/modular_computer/pda/synth/proc/update_id_slot(obj/item/card/id/id_card)
var/obj/item/organ/internal/brain/synth/brain_loc = loc
if(!istype(brain_loc))
return ..()
return
if(isnull(brain_loc.internal_computer))
return
brain_loc.internal_computer.handle_id_slot(brain_loc.owner, id_card)

/// Called when id slot item is unequipped from the id slot
/obj/item/modular_computer/pda/synth/proc/on_id_item_unequipped(datum/source)
SIGNAL_HANDLER
clear_id_slot_signals(source)
update_id_slot()

/// Called when id slot item's contained id is moved out of the id slot item
/obj/item/modular_computer/pda/synth/proc/on_id_item_moved(datum/source)
SIGNAL_HANDLER
clear_id_slot_signals(source)
update_id_slot()

/// Called when something is inserted into an id slot wallet or pda
/obj/item/modular_computer/pda/synth/proc/on_id_item_stored(datum/source, obj/item/card/id/to_insert)
SIGNAL_HANDLER
if(!istype(to_insert))
return

if(!computer_id_slot)
return ..()
UnregisterSignal(source, COMSIG_STORAGE_STORED_ITEM)
update_id_slot(to_insert)

if(crew_manifest_update)
GLOB.manifest.modify(computer_id_slot.registered_name, computer_id_slot.assignment, computer_id_slot.get_trim_assignment())
/obj/item/modular_computer/pda/synth/proc/clear_id_slot_signals(obj/item/id_slot_item)
if(!istype(id_slot_item))
return

UnregisterSignal(id_slot_item, list(
COMSIG_ITEM_POST_UNEQUIP,
COMSIG_MOVABLE_MOVED,
COMSIG_ITEM_UNSTORED,
COMSIG_STORAGE_STORED_ITEM,
COMSIG_MODULAR_COMPUTER_INSERTED_ID,
))

// make sure we clear all the signals on the contained id too
var/obj/item/card/id/contained_id_item
if(istype(id_slot_item, /obj/item/modular_computer/pda))
var/obj/item/modular_computer/pda/id_slot_pda = id_slot_item
contained_id_item = id_slot_pda.computer_id_slot
else if(istype(id_slot_item, /obj/item/storage/wallet))
var/obj/item/storage/wallet/id_slot_wallet = id_slot_item
contained_id_item = id_slot_wallet.GetID()

if(contained_id_item)
UnregisterSignal(contained_id_item, list(COMSIG_MOVABLE_MOVED, COMSIG_ITEM_UNSTORED))

/obj/item/modular_computer/pda/synth/proc/handle_id_slot(mob/living/carbon/human/synth, obj/item/id_item)
if(!istype(synth))
return
if(isnull(id_item))
if(computer_id_slot)
to_chat(synth, span_notice("Persocom RFID link disconnected."))
computer_id_slot = null
return
if(istype(id_item, /obj/item/card/id))
computer_id_slot = id_item
to_chat(synth, span_notice("Persocom establishing new RFID link with [id_item]."))
RegisterSignal(id_item, COMSIG_ITEM_POST_UNEQUIP, PROC_REF(on_id_item_unequipped))
else if(istype(id_item, /obj/item/modular_computer))
var/obj/item/modular_computer/pda = id_item
computer_id_slot = pda.computer_id_slot
to_chat(synth, span_notice("Persocom establishing new RFID link with [pda]."))
RegisterSignal(pda, COMSIG_ITEM_POST_UNEQUIP, PROC_REF(on_id_item_unequipped))
RegisterSignal(pda, COMSIG_MODULAR_COMPUTER_INSERTED_ID, PROC_REF(on_id_item_stored))
RegisterSignal(pda.computer_id_slot, COMSIG_MOVABLE_MOVED, PROC_REF(on_id_item_moved))
else if(istype(id_item, /obj/item/storage/wallet))
var/obj/item/storage/wallet/your_wallet = id_item
computer_id_slot = your_wallet.GetID()
to_chat(synth, span_notice("Persocom establishing new RFID link with [your_wallet]."))
RegisterSignal(your_wallet, COMSIG_ITEM_POST_UNEQUIP, PROC_REF(on_id_item_unequipped))
RegisterSignal(your_wallet, COMSIG_STORAGE_STORED_ITEM, PROC_REF(on_id_item_stored))
RegisterSignal(your_wallet.GetID(), COMSIG_ITEM_UNSTORED, PROC_REF(on_id_item_moved))

if(user && !issilicon(user) && in_range(brain_loc.owner || brain_loc, user))
user.put_in_hands(computer_id_slot)
else
computer_id_slot.forceMove(brain_loc.owner ? brain_loc.owner.drop_location() : brain_loc.drop_location()) //We actually update the physical on brain removal/insert
computer_id_slot = null

computer_id_slot = null
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
balloon_alert(user, "removed ID")
/obj/item/modular_computer/pda/synth/RemoveID(mob/user)
return

/obj/item/modular_computer/pda/synth/get_ntnet_status()
. = NTNET_NO_SIGNAL
// NTNet is down and we are not connected via wired connection. The synth is no more
var/obj/item/organ/internal/brain/synth/brain_loc = loc
if(!istype(brain_loc))
return
if(!find_functional_ntnet_relay() || isnull(brain_loc.owner))
return
var/turf/current_turf = get_turf(brain_loc.owner || brain_loc)
if(is_station_level(current_turf.z))
return NTNET_GOOD_SIGNAL
else if(long_ranged && !is_centcom_level(current_turf.z)) // Centcom is excluded because cafe
return NTNET_LOW_SIGNAL

/*
So, I am not snowflaking more code.. except this
Attacking a synth with an id loads it into its slot.. pain and probably shitcode
*/

/obj/item/card/id/attack(mob/living/target_mob, mob/living/user, params)
var/mob/living/carbon/human/targetmachine = target_mob
if(!istype(targetmachine))
return ..()

var/obj/item/organ/internal/brain/synth/robotbrain = targetmachine.get_organ_slot(ORGAN_SLOT_BRAIN)
if(istype(robotbrain))
if(user.zone_selected == BODY_ZONE_PRECISE_EYES)
balloon_alert(user, "Inserting ID into persocom slot...")
if(do_after(user, 5 SECONDS))
balloon_alert(user, "ID slot interface registered!")
to_chat(targetmachine, span_notice("[user] inserts [src] into your persocom's card slot."))
robotbrain.internal_computer.InsertID(src, user)
return
return ..()
. = ..()
if(is_centcom_level(loc.z)) // Centcom is excluded because cafe
return NTNET_NO_SIGNAL

/obj/item/modular_computer/pda/attack(mob/living/target_mob, mob/living/user, params)
var/mob/living/carbon/human/targetmachine = target_mob
Expand Down
Loading