Component
The component datum
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
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 |
dupe_type | The type to check for duplication |
parent | The datum this components belongs to |
Procs | |
CheckDupeComponent | Called on a component when a component of the same type was added to the same parent with COMPONENT_DUPE_SELECTIVE |
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 |
RemoveComponent | Removes the component from parent, ends up with a null parent |
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 |
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
dupe_type
The type to check for duplication
null
means exact match on type
(default)
Any other type means that and all subtypes
parent
The datum this components belongs to
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
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
- silent - deletes the component without sending a COMSIG_COMPONENT_REMOVING signal
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
RemoveComponent
Removes the component from parent, ends up with a null 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