byond - Modules - TypesVar Details - Proc Details

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_transferOnly set to true if you are able to properly transfer this component
dupe_modeDefines how duplicate existing components are handled when added to a datum
dupe_typeThe type to check for duplication
parentThe datum this components belongs to

Procs

CheckDupeComponentCalled on a component when a component of the same type was added to the same parent with COMPONENT_DUPE_SELECTIVE
DestroyProperly removes the component from parent and cleans up references
InheritComponentCalled on a component when a component of the same type was added to the same parent
InitializeCalled during component creation with the same arguments as in new excluding parent.
NewCreate a new component.
PostTransferCallback Just after a component is transferred
PreTransferCallback Just before this component is transferred
RegisterWithParentRegister the component with the parent object
RemoveComponentRemoves the component from parent, ends up with a null parent
UnregisterFromParentUnregister from our parent object
_GetInverseTypeListInternal proc to create a list of our type and all parent types
_JoinParentInternal proc to handle behaviour of components when joining a parent
_RemoveFromParentInternal 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:

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:

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