mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 11:37:40 +01:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 ..()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user