Skip to content

Commit

Permalink
Getting brains rewrite working.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 22, 2024
1 parent 983159c commit 6b65202
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 48 deletions.
3 changes: 3 additions & 0 deletions code/modules/brain_interface/_brain_interface.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
var/locked = FALSE
var/obj/item/organ/internal/brain/holding_brain = /obj/item/organ/internal/brain

/obj/item/organ/internal/brain_interface/is_preserved()
return TRUE

/obj/item/organ/internal/brain_interface/empty
holding_brain = null

Expand Down
15 changes: 2 additions & 13 deletions code/modules/organs/external/_external.dm
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,8 @@
//
//If we contain any child organs add them to the owner
//
for(var/obj/item/organ/organ in implants)
owner.add_organ(organ, src, in_place, update_icon, detached)

for(var/obj/item/organ/external/organ in children)
owner.add_organ(organ, src, in_place, update_icon, detached)
for(var/obj/item/organ/organ in (implants|children|internal_organs))
owner.add_organ(organ, src, in_place, update_icon, FALSE)

//
//Add any existing organs in the owner that have us as parent
Expand Down Expand Up @@ -521,10 +518,6 @@
if(!in_place)
parent.update_wounds()

// Notify our children.
for(var/obj/item/organ/internal/I in internal_organs)
I.on_holding_organ_installed(src)

/obj/item/organ/external/proc/drop_equipped_clothing()
if(!owner)
return
Expand Down Expand Up @@ -1417,10 +1410,6 @@ Note that amputating the affected organ does in fact remove the infection from t
LAZYREMOVE(parent.children, src)
parent = null

// Notify our children.
for(var/obj/item/organ/internal/I in internal_organs)
I.on_holding_organ_uninstalled(src)

/obj/item/organ/external/on_remove_effects(mob/living/last_owner)
. = ..()
drop_equipped_clothing()
Expand Down
34 changes: 4 additions & 30 deletions code/modules/organs/internal/_internal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,38 +287,12 @@
/obj/item/organ/internal/do_install(mob/living/carbon/human/target, obj/item/organ/external/affected, in_place, update_icon, detached)
. = ..()
if(transfer_brainmob_with_organ && istype(owner))
var/mob/living/brainmob = get_brainmob(create_if_missing = TRUE)
if(brainmob)
if(status & ORGAN_CUT_AWAY)
transfer_key_to_brainmob(owner, update_brainmob = TRUE)
else
transfer_key_from_mob_to_mob(brainmob, owner)
var/mob/living/brainmob = get_brainmob(create_if_missing = FALSE)
if(brainmob?.key)
transfer_key_from_mob_to_mob(brainmob, owner)

/obj/item/organ/internal/do_uninstall(in_place, detach, ignore_children, update_icon)
var/mob/living/victim = owner // cleared in parent proc
. = ..()
if(transfer_brainmob_with_organ && istype(victim))
var/mob/living/brainmob = get_brainmob(create_if_missing = TRUE)
if(brainmob)
if(status & ORGAN_CUT_AWAY)
transfer_key_to_brainmob(victim, update_brainmob = TRUE)
else
transfer_key_from_mob_to_mob(brainmob, victim)

/obj/item/organ/internal/proc/on_holding_organ_installed(var/obj/item/organ/external/holding)
if(istype(holding) && transfer_brainmob_with_organ && istype(owner))
var/mob/living/brainmob = get_brainmob(create_if_missing = TRUE)
if(brainmob)
if(holding.status & ORGAN_CUT_AWAY)
transfer_key_to_brainmob(owner, update_brainmob = TRUE)
else
transfer_key_from_mob_to_mob(brainmob, owner)

/obj/item/organ/internal/proc/on_holding_organ_uninstalled(var/obj/item/organ/external/holding)
if(istype(holding) && transfer_brainmob_with_organ && istype(owner))
var/mob/living/brainmob = get_brainmob(create_if_missing = TRUE)
if(brainmob)
if(holding.status & ORGAN_CUT_AWAY)
transfer_key_to_brainmob(owner, update_brainmob = TRUE)
else
transfer_key_from_mob_to_mob(brainmob, owner)
transfer_key_to_brainmob(victim, update_brainmob = TRUE)
12 changes: 10 additions & 2 deletions code/modules/organs/organ.dm
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,18 @@
ailment.was_treated_by_chem_effect()

/obj/item/organ/proc/is_preserved()
if(istype(loc,/obj/item/organ))
if(istype(loc, /obj/item/organ))
var/obj/item/organ/O = loc
return O.is_preserved()
return (istype(loc,/obj/item/organ/internal/brain_interface) || istype(loc,/obj/structure/closet/body_bag/cryobag) || istype(loc,/obj/structure/closet/crate/freezer) || istype(loc,/obj/item/storage/box/freezer))
var/static/list/preserved_types = list(
/obj/item/storage/box/freezer,
/obj/structure/closet/crate/freezer,
/obj/structure/closet/body_bag/cryobag
)
for(var/preserved_type in preserved_types)
if(istype(loc, preserved_type))
return TRUE
return FALSE

/obj/item/organ/examine(mob/user)
. = ..(user)
Expand Down
6 changes: 3 additions & 3 deletions code/modules/surgery/organs_internal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@
/decl/surgery_step/internal/remove_organ/end_step(mob/living/user, mob/living/target, target_zone, obj/item/tool)
user.visible_message("<span class='notice'>\The [user] has removed \the [target]'s [LAZYACCESS(global.surgeries_in_progress["\ref[target]"], target_zone)] with \the [tool].</span>", \
"<span class='notice'>You have removed \the [target]'s [LAZYACCESS(global.surgeries_in_progress["\ref[target]"], target_zone)] with \the [tool].</span>")

// Extract the organ!
var/obj/item/organ/O = LAZYACCESS(global.surgeries_in_progress["\ref[target]"], target_zone)
var/obj/item/organ/external/affected = GET_EXTERNAL_ORGAN(target, target_zone)
if(istype(O) && istype(affected))
//Now call remove again with detach = FALSE so we fully remove it
target.remove_organ(O, TRUE, FALSE)
..()

/decl/surgery_step/internal/remove_organ/fail_step(mob/living/user, mob/living/target, target_zone, obj/item/tool)
var/obj/item/organ/external/affected = GET_EXTERNAL_ORGAN(target, target_zone)
Expand Down Expand Up @@ -316,8 +316,8 @@
var/list/attachable_organs
var/obj/item/organ/external/affected = GET_EXTERNAL_ORGAN(target, target_zone)

for(var/obj/item/organ/I in affected.implants)
if(I && (I.status & ORGAN_CUT_AWAY))
for(var/obj/item/organ/I in (affected.implants|affected.internal_organs))
if(I.status & ORGAN_CUT_AWAY)
var/image/radial_button = image(icon = I.icon, icon_state = I.icon_state)
radial_button.name = "Attach \the [I.name]"
LAZYSET(attachable_organs, I, radial_button)
Expand Down

0 comments on commit 6b65202

Please sign in to comment.