Makes RemoveComponent more sane (#26877)

* Makes RemoveComponent more sane

* An even better wrapper

* Update code/datums/components/surgery_initiator.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>

* Update code/datums/components/_component.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>

* Update code/datums/components/_component.dm

Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>

* Update code/datums/components/_component.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>

* Update code/datums/components/_component.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>

---------

Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
This commit is contained in:
DGamerL
2024-10-09 18:46:04 +00:00
committed by GitHub
co-authored by Contrabang
parent 3e640bd2c0
commit 89796a055b
20 changed files with 45 additions and 32 deletions
+17 -2
View File
@@ -441,6 +441,14 @@
return new_comp
return old_comp
/**
* Removes the component from the datum
*/
/datum/proc/DeleteComponent(component_to_nuke)
var/datum/component/removing = GetComponent(component_to_nuke)
if(istype(removing, component_to_nuke) && !QDELETED(removing))
qdel(removing)
/**
* Get existing component of type, or create it and return a reference to it
*
@@ -458,7 +466,7 @@
/**
* Removes the component from parent, ends up with a null parent
*/
/datum/component/proc/RemoveComponent()
/datum/component/proc/UnlinkComponent()
if(!parent)
return
var/datum/old_parent = parent
@@ -467,6 +475,13 @@
parent = null
SEND_SIGNAL(old_parent, COMSIG_COMPONENT_REMOVING, src)
/**
* Deletes the component and removes it from parent.
*/
/datum/component/proc/RemoveComponent() // This really is just a wrapper to pretend that we're using sane procs to fully remove a component
if(!QDELETED(src))
qdel(src)
/**
* Transfer this component to another parent
*
@@ -479,7 +494,7 @@
if(!target || target.parent == src)
return
if(target.parent)
target.RemoveComponent()
target.UnlinkComponent()
target.parent = src
var/result = target.PostTransfer()
switch(result)
+1 -1
View File
@@ -67,8 +67,8 @@
SIGNAL_HANDLER // COMSIG_ATOM_UPDATE_SHARPNESS
var/obj/item/P = parent
if(!P.sharp)
UnlinkComponent()
RemoveComponent()
qdel(src)
/// Does the surgery initiation.
/datum/component/surgery_initiator/proc/initiate_surgery_moment(datum/source, atom/target, mob/user)
+1 -1
View File
@@ -148,7 +148,7 @@
/datum/disease/zombie/cure()
affected_mob.mind?.remove_antag_datum(/datum/antagonist/zombie)
REMOVE_TRAIT(affected_mob, TRAIT_I_WANT_BRAINS, ZOMBIE_TRAIT)
qdel(affected_mob.GetComponent(/datum/component/zombie_regen))
affected_mob.DeleteComponent(/datum/component/zombie_regen)
affected_mob.med_hud_set_health()
affected_mob.med_hud_set_status()
return ..()
+2 -1
View File
@@ -1572,7 +1572,8 @@
if(istype(I))
apply_to_card(I, H, list(ACCESS_MAINT_TUNNELS), "Solar Federation Infilitrator", "lifetimeid")
qdel(H.GetComponent(/datum/component/footstep)) // they're literally stealth
H.DeleteComponent(/datum/component/footstep)
var/datum/martial_art/cqc/CQC = new()
CQC.teach(H)