EntityFactory
Factory class that produces Entity
objects and the IComponent
instances with which they are associated.@@TODO: describe configuration
-
A dictionary of
Config
s used to instantiateEntity
objects. TheConfig
s are keyed by template name.Declaration
Swift
public var entityTemplates = [String: Config]()
-
An object implementing
IComponentFactory
that is used by theEntityFactory
to create eachEntity
’s components. By default,EntityFactory
instantiates aComponentFactory
, but this property can be set to a customIComponentFactory
instance at any time.Declaration
Swift
public var createComponentFromConfig: (Config -> Result<IComponent>)?
-
The designated initializer.
Declaration
Swift
public init()
-
Call
configure()
with aConfig
containing your entity templates. See the mainEntityFactory
description for more information on configuration.Declaration
Swift
public func configure(config: Config)
-
Attempts to create an
Entity
and its associatedIComponent
s from a template with the providedtemplateName
(which must be available in theConfig
that was passed toconfigure()
).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 theEntity
and an array ofIComponent
s.