# evennia.contrib.base_systems.components.component

Components - ChrisLR 2022

This file contains the base class to inherit for creating new components.

class `evennia.contrib.base_systems.components.component.``Component`(host=None)

  Bases: `object`

  This is the base class for components. Any component must inherit from this class to be considered for usage.

  Each Component must supply the name, it is used as a slot name but also part of the attribute key.

  `name` = ''
  `__init__`(host=None)

    Initialize self. See help(type(self)) for accurate signature.

  classmethod `default_create`(host)
    This is called when the host is created

      and should return the base initialized state of a component.

    Parameters

      host (object) – The host typeclass instance

    Returns

      Component – The created instance of the component

  classmethod `create`(host, **kwargs)

    This is the method to call when supplying kwargs to initialize a component.

    Parameters

      - host (object) – The host typeclass instance

      - **kwargs – Key-Value of default values to replace. To persist the value, the key must correspond to a DBField.

    Returns

      Component – The created instance of the component

  `cleanup`()

    This deletes all component attributes from the host’s db

  classmethod `load`(host)
    Loads a component instance

      This is called whenever a component is loaded (ex: Server Restart)

    Parameters

      host (object) – The host typeclass instance

    Returns

      Component – The loaded instance of the component

  `at_added`(host)

    This is the method called when a component is registered on a host.

    Parameters

      host (object) – The host typeclass instance

  `at_removed`(host)

    This is the method called when a component is removed from a host.

    Parameters

      host (object) – The host typeclass instance

  property `attributes`

    Shortcut property returning the host’s AttributeHandler.

    Returns

      AttributeHandler – The Host’s AttributeHandler

  property `nattributes`

    Shortcut property returning the host’s In-Memory AttributeHandler (Non Persisted).

    Returns

      AttributeHandler – The Host’s In-Memory AttributeHandler

  property `db_field_names`
  property `ndb_field_names`
  property `tag_field_names`

exception `evennia.contrib.base_systems.components.component.``ComponentRegisterError`

  Bases: `Exception`