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 instantiateEntityobjects. TheConfigs are keyed by template name.Declaration
Swift
public var entityTemplates = [String: Config]() -
An object implementing
IComponentFactorythat is used by theEntityFactoryto create eachEntity’s components. By default,EntityFactoryinstantiates aComponentFactory, but this property can be set to a customIComponentFactoryinstance at any time.Declaration
Swift
public var createComponentFromConfig: (Config -> Result<IComponent>)? -
The designated initializer.
Declaration
Swift
public init() -
Call
configure()with aConfigcontaining your entity templates. See the mainEntityFactorydescription for more information on configuration.Declaration
Swift
public func configure(config: Config) -
Attempts to create an
Entityand its associatedIComponents from a template with the providedtemplateName(which must be available in theConfigthat was passed toconfigure()).Declaration
Swift
public func createEntityFromTemplate(templateName:String) -> Result<(Entity, [IComponent])>Parameters
templateNameThe name of the template with which to instantiate the
Entity.Return Value
A
Resultcontaining a tuple. The tuple contains theEntityand an array ofIComponents.
View on GitHub
EntityFactory Class Reference