Component
The component datum
A component should be a single standalone unit of functionality, that works by receiving signals from its 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
Vars | |
can_transfer | Only set to true if you are able to properly transfer this component |
---|---|
dupe_mode | Defines how duplicate existing components are handled when added to a datum |
parent | The datum this components belongs to |
sources | A lazy list of the sources for this component |
Procs | |
CheckDupeComponent | Called on a component when a component of the same type was added to the same parent with COMPONENT_DUPE_SELECTIVE |
ClearFromParent | Removes the component from parent, ends up with a null parent Used as a helper proc by the component transfer proc, does not clean up the component like Destroy does |
Destroy | Properly removes the component from parent and cleans up references |
InheritComponent | Called on a component when a component of the same type was added to the same parent |
Initialize | Called during component creation with the same arguments as in new excluding parent. |
New | Create a new component. |
PostTransfer | Callback Just after a component is transferred |
PreTransfer | Callback Just before this component is transferred |
RegisterWithParent | Register the component with the parent object |
UnregisterFromParent | Unregister from our parent object |
_GetInverseTypeList | Internal proc to create a list of our type and all parent types |
_JoinParent | Internal proc to handle behaviour of components when joining a parent |
_RemoveFromParent | Internal proc to handle behaviour when being removed from a parent |
on_source_add | Called when the component has a new source registered. Return COMPONENT_INCOMPATIBLE to signal that the source is incompatible and should not be added |
on_source_remove | Called when the component has a source removed. You probably want to call parent after you do your logic because at the end of this we qdel if we have no sources remaining! |
ui_host | Return the object that is the host of any UI's that this component has |
Var Details
can_transfer
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
dupe_mode
Defines how duplicate existing components are handled when added to a datum
See COMPONENT_DUPE_* definitions for available options
parent
The datum this components belongs to
sources
A lazy list of the sources for this component
Proc Details
CheckDupeComponent
Called on a component when a component of the same type was added to the same parent with COMPONENT_DUPE_SELECTIVE
See /datum/component/var/dupe_mode
C
'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
ClearFromParent
Removes the component from parent, ends up with a null parent Used as a helper proc by the component transfer proc, does not clean up the component like Destroy does
Destroy
Properly removes the component from parent
and cleans up references
Arguments:
- force - makes it not check for and remove the component from the parent
InheritComponent
Called on a component when a component of the same type was added to the same parent
See /datum/component/var/dupe_mode
C
's type will always be the same of the called component
Initialize
Called during component creation with the same arguments as in new excluding parent.
Do not call qdel(src)
from this function, return COMPONENT_INCOMPATIBLE
instead
New
Create a new component.
Additional arguments are passed to Initialize()
Arguments:
- datum/P the parent datum this component reacts to signals from
PostTransfer
Callback Just after a component is transferred
Use this to do any special setup you need to do after being moved to a new object
Do not call qdel(src)
from this function, return COMPONENT_INCOMPATIBLE
instead
PreTransfer
Callback Just before this component is transferred
Use this to do any special cleanup you might need to do before being deregged from an object
RegisterWithParent
Register the component with the parent object
Use this proc to register with your parent object
Overridable proc that's called when added to a new parent
UnregisterFromParent
Unregister from our parent object
Use this proc to unregister from your parent object
Overridable proc that's called when removed from a parent
_GetInverseTypeList
Internal proc to create a list of our type and all parent types
_JoinParent
Internal proc to handle behaviour of components when joining a parent
_RemoveFromParent
Internal proc to handle behaviour when being removed from a parent
on_source_add
Called when the component has a new source registered. Return COMPONENT_INCOMPATIBLE to signal that the source is incompatible and should not be added
on_source_remove
Called when the component has a source removed. You probably want to call parent after you do your logic because at the end of this we qdel if we have no sources remaining!
ui_host
Return the object that is the host of any UI's that this component has