DCS Continued

This commit is contained in:
CitadelStationBot
2017-07-24 16:45:14 -05:00
parent b8e741f13a
commit 50adcbb302
4 changed files with 168 additions and 18 deletions
+27 -17
View File
@@ -1,8 +1,8 @@
/datum/component
var/enabled = TRUE // Enables or disables the components
var/dupe_mode = COMPONENT_DUPE_HIGHLANDER // How components of the same type are handled in the same parent
var/list/signal_procs // list of signals -> callbacks
var/datum/parent // parent datum
var/enabled = TRUE
var/dupe_mode = COMPONENT_DUPE_HIGHLANDER
var/list/signal_procs
var/datum/parent
/datum/component/New(datum/P, ...)
var/dm = dupe_mode
@@ -11,26 +11,34 @@
if(old)
switch(dm)
if(COMPONENT_DUPE_HIGHLANDER)
P.RemoveComponent(old)
old = null //in case SendSignal() blocks
InheritComponent(old, FALSE)
qdel(old)
if(COMPONENT_DUPE_UNIQUE)
old.InheritComponent(src, TRUE)
qdel(src)
return
P.SendSignal(COMSIG_COMPONENT_ADDED, list(src), FALSE)
P.SendSignal(COMSIG_COMPONENT_ADDED, src)
LAZYADD(P.datum_components, src)
parent = P
/datum/component/Destroy()
RemoveNoSignal()
enabled = FALSE
var/datum/P = parent
if(P)
_RemoveNoSignal()
P.SendSignal(COMSIG_COMPONENT_REMOVING, src)
LAZYCLEARLIST(signal_procs)
return ..()
/datum/component/proc/RemoveNoSignal()
/datum/component/proc/_RemoveNoSignal()
var/datum/P = parent
if(P)
LAZYREMOVE(P.datum_components, src)
parent = null
/datum/component/proc/RegisterSignal(sig_type, proc_on_self, override = FALSE)
if(QDELETED(src))
return
var/list/procs = signal_procs
if(!procs)
procs = list()
@@ -79,19 +87,21 @@
if(istype(I, c_type))
. += I
/datum/proc/AddComponents(list/new_types)
for(var/new_type in new_types)
AddComponent(new_type)
/datum/proc/AddComponent(new_type, ...)
var/nt = new_type
args[1] = src
var/datum/component/C = new nt(arglist(args))
return QDELING(C) ? GetComponent(new_type) : C
/datum/proc/RemoveComponent(datum/component/C)
/datum/proc/TakeComponent(datum/component/C)
if(!C)
return
C.RemoveNoSignal()
SendSignal(COMSIG_COMPONENT_REMOVING, list(C), FALSE)
qdel(C)
var/datum/helicopter = C.parent
if(helicopter == src)
//wat
return
C._RemoveNoSignal()
helicopter.SendSignal(COMSIG_COMPONENT_REMOVING, C)
C.OnTransfer(src)
C.parent = src
SendSignal(COMSIG_COMPONENT_ADDED, C)