-
-
Notifications
You must be signed in to change notification settings - Fork 11
EntityState
Represents a state for an EntityStateMachine. The state contains any number of ComponentProviders which are used to add components to the entity when this state is entered.
public class EntityState
public init()
Add a new StateComponentMapping to this state. The mapping is a utility class that is used to map a component type to the provider that provides the component.
@discardableResult public func addMapping(for type: ComponentInitializable.Type) -> StateComponentMapping
- type: The type of component to be mapped
The component mapping to use when setting the provider for the component
Get the ComponentProvider for a particular component type.
public func provider(for type: ComponentInitializable.Type) -> ComponentProvider?
- type: The type of component to get the provider for
The ComponentProvider
To determine whether this state has a provider for a specific component type.
public func hasProvider(for type: ComponentInitializable.Type) -> Bool
- type: The type of component to look for a provider for
true if there is a provider for the given type, false otherwise
Creates a mapping for the component type to a specific component instance. ComponentInstanceProvider is used for the mapping.
@discardableResult @inline(__always) public func addInstance<C: ComponentInitializable>(_ component: C) -> Self
- component: The component instance to use for the mapping
This EntityState, so more modifications can be applied
Creates a mapping for the component type to new instances of the provided type. A ComponentTypeProvider is used for the mapping.
@inline(__always) @discardableResult public func addType(_ type: ComponentInitializable.Type) -> Self
- type: The type of components to be created by this mapping
This EntityState, so more modifications can be applied
Creates a mapping for the component type to a single instance of the provided type. The instance is not created until it is first requested. A ComponentSingletonProvider is used for the mapping.
@inline(__always) @discardableResult public func addSingleton(_ type: ComponentInitializable.Type) -> Self
- type: The type of the single instance to be created.
This EntityState, so more modifications can be applied
Creates a mapping for the component type to a method call. A DynamicComponentProvider is used for the mapping.
@inline(__always) @discardableResult public func addMethod<C: ComponentInitializable>(closure: DynamicComponentProvider<C>.Closure) -> Self
- closure: The Closure instance to return the component instance
This EntityState, so more modifications can be applied
Creates a mapping for the component type to any ComponentProvider.
@inline(__always) @discardableResult public func addProvider<C: ComponentInitializable>(type: C.Type, provider: ComponentProvider) -> Self
- type: The type of component to be mapped
- provider: The component provider to use.
This EntityState, so more modifications can be applied.
Generated at 2020-11-25T10:28:11+0000 using swift-doc 1.0.0-beta.5.
Types
- ComponentAdded
- ComponentIdentifier
- ComponentInstanceProvider
- ComponentRemoved
- ComponentSingletonProvider
- ComponentTypeProvider
- ComponentsBuilder.Context
- ComponentsBuilderPreview
- DefaultCodingStrategy
- DynamicCodingKey
- DynamicComponentProvider
- DynamicComponentProvider.Closure
- Entity
- Entity.ComponentsIterator
- EntityCreated
- EntityDestroyed
- EntityIdentifier
- EntityState
- EntityStateMachine
- Family
- Family.ComponentsIterator
- Family.EntityComponentIterator
- Family.EntityIterator
- FamilyMemberAdded
- FamilyMemberBuilderPreview
- FamilyMemberRemoved
- FamilyTraitSet
- LinearIncrementingEntityIdGenerator
- ManagedContiguousArray
- Nexus
- Nexus.EntitiesIterator
- Requires1
- Requires2
- Requires3
- Requires4
- Requires5
- Requires6
- Requires7
- Requires8
- Single
- StateComponentMapping
- StringHashing
- UnorderedSparseSet
- UnorderedSparseSet.ElementIterator
Protocols
- CodingStrategy
- Component
- ComponentProvider
- DefaultInitializable
- EntityIdentifierGenerator
- FamilyDecoding
- FamilyEncoding
- FamilyRequirementsManaging
- NexusEvent
- NexusEventDelegate
- RequiringComponents1
- RequiringComponents2
- RequiringComponents3
- RequiringComponents4
- RequiringComponents5
- RequiringComponents6
- RequiringComponents7
- RequiringComponents8
- SingleComponent
- TopLevelDecoder
- TopLevelEncoder