From 1265e804c5c880b80ec92e65a708a90d761f8003 Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Sat, 28 Oct 2017 03:19:48 -0500 Subject: [PATCH] [MIRROR] Adds a method to transfer all components from one datum to another (#3661) * Merge pull request #31941 from tgstation/Cyberboss-patch-2 Adds a method to transfer all components from one datum to another * Adds a method to transfer all components from one datum to another --- code/datums/components/_component.dm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 2f70713c32..9978b01955 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -220,3 +220,14 @@ C.OnTransfer(src) C.parent = src SendSignal(COMSIG_COMPONENT_ADDED, C) + +/datum/proc/TransferComponents(datum/target) + var/list/dc = datum_components + if(!dc) + return + var/comps = dc[/datum/component] + if(islist(comps)) + for(var/I in comps) + target.TakeComponent(I) + else + target.TakeComponent(comps)