Files
GS13NG/code/datums/components/_component.dm
r4d6 54b3e3603e update (#3)
* testing, further improvements. Tired.

* FLAK

* Automatic changelog generation for PR #9971 [ci skip]

* Update preferences.dm

* Automatic changelog generation for PR #9736 [ci skip]

* this cannot go wrong

* oop

* Changes required to enable for maintenance protocols

All combat mechs that are special get their internals_access increased so the pilots of the deathsquad / nuke team can fix up their mechs without having to steal a robotics ID. Also removes engineering from being able to access mech internals, seems weird to have if only robotics is allowed to handle mechs, probably remnant of engineering robotics?

* Automatic changelog generation for PR #10115 [ci skip]

* Port boops and handshakes

* Update code/modules/mob/living/carbon/carbon_defense.dm

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* Update code/modules/mob/living/carbon/carbon_defense.dm

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* AAAAA

* Add a nose boop sound

* Add a boop sound effect

* Make the boop louder.

* Fixes pubby wall meds being var-edited snowflakes.

* Commit suggestions

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* Commit suggestions

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* Commit suggestions

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* Commit suggestions

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* Commit suggestions

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* Commit suggestions

Co-Authored-By: deathride58 <deathride58@users.noreply.github.com>

* Fixes AI being unable to talk through the holopad.

* Travis had a stroke.

* ports "Standardize obj/updateicon() and update_icons() to update_icon()"

* Update supply.dm

* Update code/modules/vending/cola.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Brings carbon action intent hotkeys down to living.

* Update drink_reagents.dm

* Automatic changelog generation for PR #10180 [ci skip]

* Automatic changelog generation for PR #10181 [ci skip]

* Porting a few martial art code updates.

* Adds gas miners to all maps.

* Compress secK9

* whoops

* Hopefully this won't screw up travis.

* Two slimepeople fixes.

* Automatic changelog generation for PR #10072 [ci skip]

* Automatic changelog generation for PR #10225 [ci skip]

* Update drink_reagents.dm

* Automatic changelog generation for PR #10203 [ci skip]

* Automatic changelog generation for PR #10157 [ci skip]

* Automatic changelog generation for PR #10155 [ci skip]

* Automatic changelog generation for PR #10111 [ci skip]

* Automatic changelog generation for PR #10216 [ci skip]

* Automatic changelog generation for PR #10172 [ci skip]

* Automatic changelog generation for PR #10026 [ci skip]

* Automatic changelog generation for PR #10076 [ci skip]

* Update drinks.dm

* Automatic changelog generation for PR #10153 [ci skip]

* ??

* Update snacks.dm

* oops

* probably fixes only neutral traits existing

* Automatic changelog generation for PR #10227 [ci skip]

* argk

* Chef buffs chef buffs tastier food.

"The strong flavor of" was always in game but someone put it behind an else if statement that would never proc.
Now if there's more than 45% (or 30% if you are a lizzard, hissss) of a reagent in a beaker, you will taste a strong flavor! 
Hurrah!

* Automatic changelog generation for PR #10228 [ci skip]

* fixes the sprites

* Actually hold on

So that not everything in the game now tastes like STRONG FLAVOUR. That'd be annoying.

* Magic number man bad, also all heads can spam CC now

* im baby dumb and removed "a hint of" by accident.

Okay whoops haha there we go now both strong and weak should work.

* oh hey macros.

slightly less ugly ™

* modular man bad.

now mörge this so chefs can make delicious dish, hemk.

* Update carbon.dm

* lolman acctually knows how the stuff work

* AAAAAAAAAAAAAAAAAAAA

* Update flashbang.dm

* thank you based ghomtainer (when)

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* thank you based ghomtainer (when) 2x how did i not notice this

* Automatic changelog generation for PR #10204 [ci skip]

* Converts the main timsorts file from relative pathing to absolute pathing.

* Ports "Added TRAIT_DISK_VERIFIER, refactors how fake disk checks work slightly"

* wew

* Automatic changelog generation for PR #10090 [ci skip]

* Add the sprite for the landmark

* Make it include my files

* Automatic changelog generation for PR #10067 [ci skip]

* Automatic changelog generation for PR #10160 [ci skip]

* drop

* Automatic changelog generation for PR #10079 [ci skip]

* Automatic changelog generation for PR #10207 [ci skip]

* Automatic changelog generation for PR #10214 [ci skip]

* Update mob.dm

* Update mob.dm

* Redo my changes on Box

Hopefully this will fix the conflict with the fire alarms.

* h

* Automatic changelog generation for PR #10193 [ci skip]

* I'm a god. How can you defeat a god? What a grand and intoxicating innocence, how can you be so naive?

* Automatic changelog generation for PR #10054 [ci skip]

* Automatic changelog generation for PR #10126 [ci skip]

* Automatic changelog generation for PR #10142 [ci skip]

* Automatic changelog generation for PR #10051 [ci skip]

* Automatic changelog generation for PR #9925 [ci skip]

* Automatic changelog generation for PR #9563 [ci skip]

* Atomises out the magicnumber change

* Automatic changelog generation for PR #10231 [ci skip]

* Automatic changelog generation for PR #10235 [ci skip]

* Automatic changelog generation for PR #10200 [ci skip]

* Fix the nose boop.

* Remove extra indentations

* Update inhand_holder.dm

* hhh

* ghom help

* ff

* ff

* Automatic changelog generation for PR #10058 [ci skip]

* Automatic changelog generation for PR #10059 [ci skip]

* Automatic changelog generation for PR #9596 [ci skip]

* Automatic changelog generation for PR #9940 [ci skip]

* Automatic changelog generation for PR #10232 [ci skip]

* Automatic changelog generation for PR #10141 [ci skip]

* Begone crap.

* I gotta go fast.

* QoL Update

Move the Engines to a subfolder to be cleaner when there will be 20 submaps on different maps and change the Tesla Submap to incorporate a few changes I did for the Singulo submap.

* Magic number baaad

* Make things even more organized

* Better safe than sorry.

* Automatic changelog generation for PR #10164 [ci skip]

* Automatic changelog generation for PR #10120 [ci skip]

* Automatic changelog generation for PR #10257 [ci skip]

* typo

* Unnecessary OOC note.

* Is merging someone else's PR you personally fixed considerable as self-merging?

* I'm playing dirty because we have too many PRs to merge anyway.

* Automatic changelog generation for PR #10096 [ci skip]

* Automatic changelog generation for PR #9950 [ci skip]

* Automatic changelog generation for PR #10190 [ci skip]

* Automatic changelog generation for PR #9830 [ci skip]

* Suggestions

* Fix indentation

* lowered to 10 after i struggled to open tickets panel

* FUUUUUUUUUUUCK

* Nerfs fun

* FUUUUUUUUUCK v2

* Automatic changelog generation for PR #10263 [ci skip]

* QoL Update

- Rename the cameras and place two more

- Unanchor the shields generators and emitters because they were bugged and will save more time

- Put more rad closets on the Singulo

- Put more insuls on the Tesla since they protect

- Moved the Engineer clothing locker to Boxstation instead of having it in the Engine

- Added a button to the shutters on the north side of PA

- Added a marker to show where to place the console

- Rewire the power wire to be more in a straight line.

* Forgot a "

* Forgot a button on the Tesla

* Update supply.dm

* readds sprites

* Fills white first aid kits to the brim. Ergo how I was fooled into believing it was a tweak and not a nerf.

* Connect the fuel pipe to somewhere

* no more 40% time dilation

* Update __donator.dm

* Update modular_citadel/code/modules/client/loadout/__donator.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update modular_citadel/code/modules/client/loadout/__donator.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update modular_citadel/code/modules/client/loadout/__donator.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update custom_items.dm

* Automatic changelog generation for PR #10254 [ci skip]

* Fix areas and tiles getting ripped off

* Also give Tesla's emitters R-floors

* Automatic changelog generation for PR #10093 [ci skip]

* Automatic changelog generation for PR #10210 [ci skip]

* Automatic changelog generation for PR #10246 [ci skip]

* Update custom_items.dm

* Automatic changelog generation for PR #10218 [ci skip]

* Automatic changelog generation for PR #10274 [ci skip]

* Add the option to restrict the Engine that spawn

* Revert "Add the option to restrict the Engine that spawn"

This reverts commit e3e1f91635.

* Revert "Revert "Add the option to restrict the Engine that spawn""

This reverts commit d851beea16.

* Add config options

* Move the config up to avoid conflict

* Automatic changelog generation for PR #10245 [ci skip]

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Co-authored-by: CitadelStationBot <citadelstationcommunity@gmail.com>
Co-authored-by: Lin <linzolle@gmail.com>
Co-authored-by: kappa-sama <44128284+kappa-sama@users.noreply.github.com>
Co-authored-by: DeltaFire15 <46569814+DeltaFire15@users.noreply.github.com>
Co-authored-by: Useroth <37159550+Useroth@users.noreply.github.com>
Co-authored-by: BlackMajor <henrydyer6@hotmail.com>
Co-authored-by: deathride58 <deathride58@users.noreply.github.com>
Co-authored-by: Putnam3145 <putnam3145@gmail.com>
Co-authored-by: Trilbyspaceclone <30435998+Trilbyspaceclone@users.noreply.github.com>
Co-authored-by: GrayRachnid <Gray_icy@hotmail.com>
Co-authored-by: B1gb3ast <Yeremyrus@live.nl>
Co-authored-by: Seris02 <49109742+Seris02@users.noreply.github.com>
Co-authored-by: lolman360 <22850904+lolman360@users.noreply.github.com>
Co-authored-by: nik707 <38332985+nik707@users.noreply.github.com>
Co-authored-by: LetterJay <9606363+LetterJay@users.noreply.github.com>
2019-12-23 13:29:44 -05:00

315 lines
9.2 KiB
Plaintext

/datum/component
var/dupe_mode = COMPONENT_DUPE_HIGHLANDER
var/dupe_type
var/datum/parent
//only set to true if you are able to properly transfer this component
//At a minimum RegisterWithParent and UnregisterFromParent should be used
//Make sure you also implement PostTransfer for any post transfer handling
var/can_transfer = FALSE
/datum/component/New(datum/P, ...)
parent = P
var/list/arguments = args.Copy(2)
if(Initialize(arglist(arguments)) == COMPONENT_INCOMPATIBLE)
qdel(src, TRUE, TRUE)
CRASH("Incompatible [type] assigned to a [P.type]! args: [json_encode(arguments)]")
_JoinParent(P)
/datum/component/proc/_JoinParent()
var/datum/P = parent
//lazy init the parent's dc list
var/list/dc = P.datum_components
if(!dc)
P.datum_components = dc = list()
//set up the typecache
var/our_type = type
for(var/I in _GetInverseTypeList(our_type))
var/test = dc[I]
if(test) //already another component of this type here
var/list/components_of_type
if(!length(test))
components_of_type = list(test)
dc[I] = components_of_type
else
components_of_type = test
if(I == our_type) //exact match, take priority
var/inserted = FALSE
for(var/J in 1 to components_of_type.len)
var/datum/component/C = components_of_type[J]
if(C.type != our_type) //but not over other exact matches
components_of_type.Insert(J, I)
inserted = TRUE
break
if(!inserted)
components_of_type += src
else //indirect match, back of the line with ya
components_of_type += src
else //only component of this type, no list
dc[I] = src
RegisterWithParent()
// If you want/expect to be moving the component around between parents, use this to register on the parent for signals
/datum/component/proc/RegisterWithParent()
SEND_SIGNAL(src, COMSIG_COMPONENT_REGISTER_PARENT) //CITADEL EDIT
/datum/component/proc/Initialize(...)
return
/datum/component/Destroy(force=FALSE, silent=FALSE)
if(!force && parent)
_RemoveFromParent()
if(!silent)
SEND_SIGNAL(parent, COMSIG_COMPONENT_REMOVING, src)
parent = null
return ..()
/datum/component/proc/_RemoveFromParent()
var/datum/P = parent
var/list/dc = P.datum_components
for(var/I in _GetInverseTypeList())
var/list/components_of_type = dc[I]
if(length(components_of_type)) //
var/list/subtracted = components_of_type - src
if(subtracted.len == 1) //only 1 guy left
dc[I] = subtracted[1] //make him special
else
dc[I] = subtracted
else //just us
dc -= I
if(!dc.len)
P.datum_components = null
UnregisterFromParent()
/datum/component/proc/UnregisterFromParent()
SEND_SIGNAL(src, COMSIG_COMPONENT_UNREGISTER_PARENT) //CITADEL EDIT
/datum/proc/RegisterSignal(datum/target, sig_type_or_types, proctype, override = FALSE)
if(QDELETED(src) || QDELETED(target))
return
var/list/procs = signal_procs
if(!procs)
signal_procs = procs = list()
if(!procs[target])
procs[target] = list()
var/list/lookup = target.comp_lookup
if(!lookup)
target.comp_lookup = lookup = list()
var/list/sig_types = islist(sig_type_or_types) ? sig_type_or_types : list(sig_type_or_types)
for(var/sig_type in sig_types)
if(!override && procs[target][sig_type])
stack_trace("[sig_type] overridden. Use override = TRUE to suppress this warning")
procs[target][sig_type] = proctype
if(!lookup[sig_type]) // Nothing has registered here yet
lookup[sig_type] = src
else if(lookup[sig_type] == src) // We already registered here
continue
else if(!length(lookup[sig_type])) // One other thing registered here
lookup[sig_type] = list(lookup[sig_type]=TRUE)
lookup[sig_type][src] = TRUE
else // Many other things have registered here
lookup[sig_type][src] = TRUE
signal_enabled = TRUE
/datum/proc/UnregisterSignal(datum/target, sig_type_or_types)
var/list/lookup = target.comp_lookup
if(!signal_procs || !signal_procs[target] || !lookup)
return
if(!islist(sig_type_or_types))
sig_type_or_types = list(sig_type_or_types)
for(var/sig in sig_type_or_types)
switch(length(lookup[sig]))
if(2)
lookup[sig] = (lookup[sig]-src)[1]
if(1)
stack_trace("[target] ([target.type]) somehow has single length list inside comp_lookup")
if(src in lookup[sig])
lookup -= sig
if(!length(lookup))
target.comp_lookup = null
break
if(0)
lookup -= sig
if(!length(lookup))
target.comp_lookup = null
break
else
lookup[sig] -= src
signal_procs[target] -= sig_type_or_types
if(!signal_procs[target].len)
signal_procs -= target
/datum/component/proc/InheritComponent(datum/component/C, i_am_original)
return
/datum/component/proc/PreTransfer()
return
/datum/component/proc/PostTransfer()
return COMPONENT_INCOMPATIBLE //Do not support transfer by default as you must properly support it
/datum/component/proc/_GetInverseTypeList(our_type = type)
//we can do this one simple trick
var/current_type = parent_type
. = list(our_type, current_type)
//and since most components are root level + 1, this won't even have to run
while (current_type != /datum/component)
current_type = type2parent(current_type)
. += current_type
/datum/proc/_SendSignal(sigtype, list/arguments)
var/target = comp_lookup[sigtype]
if(!length(target))
var/datum/C = target
if(!C.signal_enabled)
return NONE
var/proctype = C.signal_procs[src][sigtype]
return NONE | CallAsync(C, proctype, arguments)
. = NONE
for(var/I in target)
var/datum/C = I
if(!C.signal_enabled)
continue
var/proctype = C.signal_procs[src][sigtype]
. |= CallAsync(C, proctype, arguments)
// The type arg is casted so initial works, you shouldn't be passing a real instance into this
/datum/proc/GetComponent(datum/component/c_type)
RETURN_TYPE(c_type)
if(initial(c_type.dupe_mode) == COMPONENT_DUPE_ALLOWED)
stack_trace("GetComponent was called to get a component of which multiple copies could be on an object. This can easily break and should be changed. Type: \[[c_type]\]")
var/list/dc = datum_components
if(!dc)
return null
. = dc[c_type]
if(length(.))
return .[1]
/datum/proc/GetExactComponent(c_type)
var/list/dc = datum_components
if(!dc)
return null
var/datum/component/C = dc[c_type]
if(C)
if(length(C))
C = C[1]
if(C.type == c_type)
return C
return null
/datum/proc/GetComponents(c_type)
var/list/dc = datum_components
if(!dc)
return null
. = dc[c_type]
if(!length(.))
return list(.)
/datum/proc/AddComponent(new_type, ...)
var/datum/component/nt = new_type
var/dm = initial(nt.dupe_mode)
var/dt = initial(nt.dupe_type)
var/datum/component/old_comp
var/datum/component/new_comp
if(ispath(nt))
if(nt == /datum/component)
CRASH("[nt] attempted instantiation!")
else
new_comp = nt
nt = new_comp.type
args[1] = src
if(dm != COMPONENT_DUPE_ALLOWED)
if(!dt)
old_comp = GetExactComponent(nt)
else
old_comp = GetComponent(dt)
if(old_comp)
switch(dm)
if(COMPONENT_DUPE_UNIQUE)
if(!new_comp)
new_comp = new nt(arglist(args))
if(!QDELETED(new_comp))
old_comp.InheritComponent(new_comp, TRUE)
QDEL_NULL(new_comp)
if(COMPONENT_DUPE_HIGHLANDER)
if(!new_comp)
new_comp = new nt(arglist(args))
if(!QDELETED(new_comp))
new_comp.InheritComponent(old_comp, FALSE)
QDEL_NULL(old_comp)
if(COMPONENT_DUPE_UNIQUE_PASSARGS)
if(!new_comp)
var/list/arguments = args.Copy(2)
old_comp.InheritComponent(null, TRUE, arguments)
else
old_comp.InheritComponent(new_comp, TRUE)
else if(!new_comp)
new_comp = new nt(arglist(args)) // There's a valid dupe mode but there's no old component, act like normal
else if(!new_comp)
new_comp = new nt(arglist(args)) // Dupes are allowed, act like normal
if(!old_comp && !QDELETED(new_comp)) // Nothing related to duplicate components happened and the new component is healthy
SEND_SIGNAL(src, COMSIG_COMPONENT_ADDED, new_comp)
return new_comp
return old_comp
/datum/proc/LoadComponent(component_type, ...)
. = GetComponent(component_type)
if(!.)
return AddComponent(arglist(args))
/datum/component/proc/RemoveComponent()
if(!parent)
return
var/datum/old_parent = parent
PreTransfer()
_RemoveFromParent()
parent = null
SEND_SIGNAL(old_parent, COMSIG_COMPONENT_REMOVING, src)
/datum/proc/TakeComponent(datum/component/target)
if(!target || target.parent == src)
return
if(target.parent)
target.RemoveComponent()
target.parent = src
var/result = target.PostTransfer()
switch(result)
if(COMPONENT_INCOMPATIBLE)
var/c_type = target.type
qdel(target)
CRASH("Incompatible [c_type] transfer attempt to a [type]!")
if(target == AddComponent(target))
target._JoinParent()
/datum/proc/TransferComponents(datum/target)
var/list/dc = datum_components
if(!dc)
return
var/comps = dc[/datum/component]
if(islist(comps))
for(var/datum/component/I in comps)
if(I.can_transfer)
target.TakeComponent(I)
else
var/datum/component/C = comps
if(C.can_transfer)
target.TakeComponent(comps)
/datum/component/ui_host()
return parent