mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 13:37:58 +01:00
31 lines
13 KiB
HTML
31 lines
13 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/component - Space Station 13</title></head><body><header><a href="index.html">Space Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a> — <a href="datum/component.html#var">Var Details</a> - <a href="datum/component.html#proc">Proc Details</a></header><main><h1>Component <aside>/<a href="datum.html">datum</a>/<a href="datum/component.html">component</a></aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L12"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 12"></a></h1><p>The component datum</p>
|
||
<p>A component should be a single standalone unit
|
||
of functionality, that works by receiving signals from it's parent
|
||
object to provide some single functionality (i.e a slippery component)
|
||
that makes the object it's attached to cause people to slip over.
|
||
Useful when you want shared behaviour independent of type inheritance</p><table class="summary" cellspacing="0"><tr><td colspan="2"><h2>Vars</h2></td></tr><tr><th><a href="datum/component.html#var/can_transfer">can_transfer</a></th><td>Only set to true if you are able to properly transfer this component</td></tr><tr><th><a href="datum/component.html#var/dupe_mode">dupe_mode</a></th><td>Defines how duplicate existing components are handled when added to a datum</td></tr><tr><th><a href="datum/component.html#var/dupe_type">dupe_type</a></th><td>The type to check for duplication</td></tr><tr><th><a href="datum/component.html#var/parent">parent</a></th><td>The datum this components belongs to</td></tr><tr><td colspan="2"><h2>Procs</h2></td></tr><tr><th><a href="datum/component.html#proc/Destroy">Destroy</a></th><td>Properly removes the component from <code>parent</code> and cleans up references</td></tr><tr><th><a href="datum/component.html#proc/InheritComponent">InheritComponent</a></th><td>Called on a component when a component of the same type was added to the same parent</td></tr><tr><th><a href="datum/component.html#proc/Initialize">Initialize</a></th><td>Called during component creation with the same arguments as in new excluding parent.</td></tr><tr><th><a href="datum/component.html#proc/New">New</a></th><td>Create a new component.</td></tr><tr><th><a href="datum/component.html#proc/PostTransfer">PostTransfer</a></th><td>Callback Just after a component is transferred</td></tr><tr><th><a href="datum/component.html#proc/PreTransfer">PreTransfer</a></th><td>Callback Just before this component is transferred</td></tr><tr><th><a href="datum/component.html#proc/RegisterWithParent">RegisterWithParent</a></th><td>Register the component with the parent object</td></tr><tr><th><a href="datum/component.html#proc/RemoveComponent">RemoveComponent</a></th><td>Deletes the component and removes it from parent.</td></tr><tr><th><a href="datum/component.html#proc/UnlinkComponent">UnlinkComponent</a></th><td>Removes the component from parent, ends up with a null parent</td></tr><tr><th><a href="datum/component.html#proc/UnregisterFromParent">UnregisterFromParent</a></th><td>Unregister from our parent object</td></tr><tr><th><a href="datum/component.html#proc/_GetInverseTypeList">_GetInverseTypeList</a></th><td>Internal proc to create a list of our type and all parent types</td></tr><tr><th><a href="datum/component.html#proc/_JoinParent">_JoinParent</a></th><td>Internal proc to handle behaviour of components when joining a parent</td></tr><tr><th><a href="datum/component.html#proc/_RemoveFromParent">_RemoveFromParent</a></th><td>Internal proc to handle behaviour when being removed from a parent</td></tr><tr><th><a href="datum/component.html#proc/ui_host">ui_host</a></th><td>Return the object that is the host of any UI's that this component has</td></tr></table><h2 id="var">Var Details</h2><h3 id="var/can_transfer"><aside class="declaration">var </aside>can_transfer <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L39"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 39"></a></h3><p>Only set to true if you are able to properly transfer this component</p>
|
||
<p>At a minimum <a href="datum/component.html#proc/RegisterWithParent" title="/datum/component">RegisterWithParent</a> and <a href="datum/component.html#proc/UnregisterFromParent" title="/datum/component">UnregisterFromParent</a> should be used</p>
|
||
<p>Make sure you also implement <a href="datum/component.html#proc/PostTransfer" title="/datum/component">PostTransfer</a> for any post transfer handling</p><h3 id="var/dupe_mode"><aside class="declaration">var </aside>dupe_mode <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L18"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 18"></a></h3><p>Defines how duplicate existing components are handled when added to a datum</p>
|
||
<p>See <a href="code/__DEFINES/dcs/dcs_flags.html#define/COMPONENT_DUPE_ALLOWED" title="COMPONENT_DUPE_ALLOWED">COMPONENT_DUPE_*</a> definitions for available options</p><h3 id="var/dupe_type"><aside class="declaration">var </aside>dupe_type <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L27"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 27"></a></h3><p>The type to check for duplication</p>
|
||
<p><code>null</code> means exact match on <code>type</code> (default)</p>
|
||
<p>Any other type means that and all subtypes</p><h3 id="var/parent"><aside class="declaration">var </aside>parent <aside>– /<a href="datum.html">datum</a></aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L30"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 30"></a></h3><p>The datum this components belongs to</p><h2 id="proc">Proc Details</h2><h3 id="proc/Destroy">Destroy<aside>(force, silent) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L74"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 74"></a></aside></h3><p>Properly removes the component from <code>parent</code> and cleans up references</p>
|
||
<p>Arguments:</p>
|
||
<ul>
|
||
<li>force - makes it not check for and remove the component from the parent</li>
|
||
<li>silent - deletes the component without sending a <a href="code/__DEFINES/dcs/datum_signals.html#define/COMSIG_COMPONENT_REMOVING" title="COMSIG_COMPONENT_REMOVING">COMSIG_COMPONENT_REMOVING</a> signal</li>
|
||
</ul><h3 id="proc/InheritComponent"><aside class="declaration">proc </aside>InheritComponent<aside>(/<a href="datum.html">datum</a>/<a href="datum/component.html">component</a>/C, i_am_original) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L259"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 259"></a></aside></h3><p>Called on a component when a component of the same type was added to the same parent</p>
|
||
<p>See <a href="datum/component.html#var/dupe_mode" title="/datum/component">/datum/component/var/dupe_mode</a></p>
|
||
<p><code>C</code>'s type will always be the same of the called component</p><h3 id="proc/Initialize"><aside class="declaration">proc </aside>Initialize<aside>(...) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L64"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 64"></a></aside></h3><p>Called during component creation with the same arguments as in new excluding parent.</p>
|
||
<p>Do not call <code>qdel(src)</code> from this function, <code>return COMPONENT_INCOMPATIBLE</code> instead</p><h3 id="proc/New">New<aside>(/list/raw_args) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L49"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 49"></a></aside></h3><p>Create a new component.</p>
|
||
<p>Additional arguments are passed to <a href="datum/component.html#proc/Initialize" title="/datum/component">Initialize()</a></p>
|
||
<p>Arguments:</p>
|
||
<ul>
|
||
<li>datum/P the parent datum this component reacts to signals from</li>
|
||
</ul><h3 id="proc/PostTransfer"><aside class="declaration">proc </aside>PostTransfer<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L277"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 277"></a></aside></h3><p>Callback Just after a component is transferred</p>
|
||
<p>Use this to do any special setup you need to do after being moved to a new object</p>
|
||
<p>Do not call <code>qdel(src)</code> from this function, <code>return COMPONENT_INCOMPATIBLE</code> instead</p><h3 id="proc/PreTransfer"><aside class="declaration">proc </aside>PreTransfer<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L267"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 267"></a></aside></h3><p>Callback Just before this component is transferred</p>
|
||
<p>Use this to do any special cleanup you might need to do before being deregged from an object</p><h3 id="proc/RegisterWithParent"><aside class="declaration">proc </aside>RegisterWithParent<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L148"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 148"></a></aside></h3><p>Register the component with the parent object</p>
|
||
<p>Use this proc to register with your parent object</p>
|
||
<p>Overridable proc that's called when added to a new parent</p><h3 id="proc/RemoveComponent"><aside class="declaration">proc </aside>RemoveComponent<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L490"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 490"></a></aside></h3><p>Deletes the component and removes it from parent.</p><h3 id="proc/UnlinkComponent"><aside class="declaration">proc </aside>UnlinkComponent<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L478"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 478"></a></aside></h3><p>Removes the component from parent, ends up with a null parent</p><h3 id="proc/UnregisterFromParent"><aside class="declaration">proc </aside>UnregisterFromParent<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L159"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 159"></a></aside></h3><p>Unregister from our parent object</p>
|
||
<p>Use this proc to unregister from your parent object</p>
|
||
<p>Overridable proc that's called when removed from a parent</p><h3 id="proc/_GetInverseTypeList"><aside class="declaration">proc </aside>_GetInverseTypeList<aside>(our_type) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L283"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 283"></a></aside></h3><p>Internal proc to create a list of our type and all parent types</p><h3 id="proc/_JoinParent"><aside class="declaration">proc </aside>_JoinParent<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L85"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 85"></a></aside></h3><p>Internal proc to handle behaviour of components when joining a parent</p><h3 id="proc/_RemoveFromParent"><aside class="declaration">proc </aside>_RemoveFromParent<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L123"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 123"></a></aside></h3><p>Internal proc to handle behaviour when being removed from a parent</p><h3 id="proc/ui_host"><aside class="parent"><a title="/datum" href="datum.html#proc/ui_host">↑</a></aside>ui_host<aside>(/<a href="mob.html">mob</a>/user) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/components/_component.dm#L565"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 565"></a></aside></h3><p>Return the object that is the host of any UI's that this component has</p></main><footer>paradise.dme <a href="https://github.com/ParadiseSS13/Paradise/tree/8a8a00a2a9bec485351e5f219982b7315d3504fa">8a8a00a</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.11.0</a></footer></body></html> |