Entish Docs (35% documented)

Entish Reference EntityFactory Class Reference

EntityFactory

Factory class that produces Entity objects and the IComponent instances with which they are associated.@@TODO: describe configuration

  • A dictionary of Configs used to instantiate Entity objects. The Configs are keyed by template name.

    Declaration

    Swift

    public var entityTemplates  = [String: Config]()
  • An object implementing IComponentFactory that is used by the EntityFactory to create each Entity’s components. By default, EntityFactory instantiates a ComponentFactory, but this property can be set to a custom IComponentFactory instance at any time.

    Declaration

    Swift

    public var createComponentFromConfig: (Config -> Result<IComponent>)?
  • The designated initializer.

    Declaration

    Swift

    public init()
  • Call configure() with a Config containing your entity templates. See the main EntityFactory description for more information on configuration.

    Declaration

    Swift

    public func configure(config: Config)
  • Attempts to create an Entity and its associated IComponents from a template with the provided templateName (which must be available in the Config that was passed to configure()).

    Declaration

    Swift

    public func createEntityFromTemplate(templateName:String) -> Result<(Entity, [IComponent])>

    Parameters

    templateName

    The name of the template with which to instantiate the Entity.

    Return Value

    A Result containing a tuple. The tuple contains the Entity and an array of IComponents.