Files
GS13NG/datum/component.html
2025-02-05 06:19:18 +00:00

46 lines
14 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/component - /tg/ Station 13</title></head><body><header><a href="index.html">/tg/ 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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/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
At a minimum RegisterWithParent and UnregisterFromParent should be used
Make sure you also implement PostTransfer for any post transfer handling</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
See <code>COMPONENT_DUPE_*</code> definitions for available options</td></tr><tr><th><a href="datum/component.html#var/dupe_type">dupe_type</a></th><td>The type to check for duplication
<code>null</code> means exact match on <code>type</code> (default)
Any other type means that and all subtypes</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/CheckDupeComponent">CheckDupeComponent</a></th><td>Called on a component when a component of the same type was added to the same parent with COMPONENT_DUPE_SELECTIVE
See <code>/datum/component/var/dupe_mode</code>
<code>C</code>'s type will always be the same of the called component
return TRUE if you are absorbing the component, otherwise FALSE if you are fine having it exist as a duplicate component</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
See <code>/datum/component/var/dupe_mode</code>
<code>C</code>'s type will always be the same of the called component</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.
Do not call <code>qdel(src)</code> from this function, <code>return COMPONENT_INCOMPATIBLE</code> instead</td></tr><tr><th><a href="datum/component.html#proc/New">New</a></th><td>Create a new component.
Additional arguments are passed to <code>Initialize()</code></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>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 <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L28"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 28"></a></h3><p>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</p><h3 id="var/dupe_mode"><aside class="declaration">var </aside>dupe_mode <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L15"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 15"></a></h3><p>Defines how duplicate existing components are handled when added to a datum
See <code>COMPONENT_DUPE_*</code> definitions for available options</p><h3 id="var/dupe_type"><aside class="declaration">var </aside>dupe_type <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L20"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 20"></a></h3><p>The type to check for duplication
<code>null</code> means exact match on <code>type</code> (default)
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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L23"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 23"></a></h3><p>The datum this components belongs to</p><h2 id="proc">Proc Details</h2><h3 id="proc/CheckDupeComponent"><aside class="declaration">proc </aside>CheckDupeComponent<aside>(/<a href="datum.html">datum</a>/<a href="datum/component.html">component</a>/C, ...) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L250"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 250"></a></aside></h3><p>Called on a component when a component of the same type was added to the same parent with COMPONENT_DUPE_SELECTIVE
See <code>/datum/component/var/dupe_mode</code>
<code>C</code>'s type will always be the same of the called component
return TRUE if you are absorbing the component, otherwise FALSE if you are fine having it exist as a duplicate component</p><h3 id="proc/Destroy"><aside class="parent"><a title="/datum" href="datum.html#proc/Destroy"></a></aside>Destroy<aside>(force, silent) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L61"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 61"></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/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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L240"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 240"></a></aside></h3><p>Called on a component when a component of the same type was added to the same parent
See <code>/datum/component/var/dupe_mode</code>
<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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L51"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 51"></a></aside></h3><p>Called during component creation with the same arguments as in new excluding parent.
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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L37"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 37"></a></aside></h3><p>Create a new component.
Additional arguments are passed to <code>Initialize()</code></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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L270"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 270"></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
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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L260"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 260"></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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L136"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 136"></a></aside></h3><p>Register the component with the parent object</p>
<p>Use this proc to register with your parent object
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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L452"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 452"></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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L146"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 146"></a></aside></h3><p>Unregister from our parent object</p>
<p>Use this proc to unregister from your parent object
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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L276"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 276"></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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/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>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/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L112"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 112"></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="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/_component.dm#L510"><img src="git.png" width="16" height="16" title="code/datums/components/_component.dm 510"></a></aside></h3><p>Return the object that is the host of any UI's that this component has</p></main><footer>tgstation.dme <a href="https://github.com/evilew/GS13-Citadel/tree/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e">e8e0068</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.9.0</a></footer></body></html>