| Copyright | (c) Matt Hunzinger 2025 |
|---|---|
| License | BSD-style (see the LICENSE file in the distribution) |
| Maintainer | matt@hunzinger.me |
| Stability | provisional |
| Portability | non-portable (GHC extensions) |
| Safe Haskell | None |
| Language | Haskell2010 |
Aztecs.ECS.World.Archetype
Description
Synopsis
- data Archetype (m :: Type -> Type) = Archetype {}
- empty :: forall (m :: Type -> Type). Archetype m
- singleton :: forall (m :: Type -> Type). EntityID -> Archetype m
- lookupComponent :: forall (m :: Type -> Type) a. Component m a => EntityID -> ComponentID -> Archetype m -> Maybe a
- lookupComponents :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Map EntityID a
- lookupComponentsAsc :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Vector a
- lookupComponentsAscMaybe :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Maybe (Vector a)
- lookupStorage :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Maybe (StorageT a)
- member :: forall (m :: Type -> Type). ComponentID -> Archetype m -> Bool
- remove :: forall (m :: Type -> Type). EntityID -> Archetype m -> (IntMap Dynamic, Archetype m)
- removeStorages :: forall (m :: Type -> Type). EntityID -> Archetype m -> (IntMap DynamicStorage, Archetype m)
- insertComponent :: forall (m :: Type -> Type) a. Component m a => EntityID -> ComponentID -> a -> Archetype m -> (Archetype m, Access m ())
- insertComponentUntracked :: forall (m :: Type -> Type) a. Component m a => EntityID -> ComponentID -> a -> Archetype m -> Archetype m
- insertComponents :: forall (m :: Type -> Type). EntityID -> IntMap Dynamic -> Archetype m -> Archetype m
- insertAscVector :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Vector a -> Archetype m -> Archetype m
- zipWith :: forall (m :: Type -> Type) a c. (Monad m, Component m c) => Vector a -> (a -> c -> c) -> ComponentID -> Archetype m -> (Vector c, Archetype m, Access m ())
- zipWith_ :: forall (m :: Type -> Type) a c. (Monad m, Component m c) => Vector a -> (a -> c -> c) -> ComponentID -> Archetype m -> (Archetype m, Access m ())
- zipWithM :: forall m a c. (Monad m, Component m c) => Vector a -> (a -> c -> m c) -> ComponentID -> Archetype m -> m (Vector c, Archetype m, Access m ())
- zipWithAccum :: forall (m :: Type -> Type) a c o. (Monad m, Component m c) => Vector a -> (a -> c -> (o, c)) -> ComponentID -> Archetype m -> (Vector (o, c), Archetype m, Access m ())
- zipWithAccumM :: forall m a c o. (Monad m, Component m c) => Vector a -> (a -> c -> m (o, c)) -> ComponentID -> Archetype m -> m (Vector (o, c), Archetype m, Access m ())
Documentation
data Archetype (m :: Type -> Type) Source #
Archetype of entities and components. An archetype is guranteed to contain one of each stored component per entity.
Constructors
| Archetype | |
Instances
singleton :: forall (m :: Type -> Type). EntityID -> Archetype m Source #
Archetype with a single entity.
lookupComponent :: forall (m :: Type -> Type) a. Component m a => EntityID -> ComponentID -> Archetype m -> Maybe a Source #
Lookup a component by its EntityID and ComponentID.
lookupComponents :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Map EntityID a Source #
Lookup all components by their ComponentID.
lookupComponentsAsc :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Vector a Source #
Lookup all components by their ComponentID, in ascending order by their EntityID.
lookupComponentsAscMaybe :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Maybe (Vector a) Source #
Lookup all components by their ComponentID, in ascending order by their EntityID.
lookupStorage :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Archetype m -> Maybe (StorageT a) Source #
Lookup a component Storage by its ComponentID.
member :: forall (m :: Type -> Type). ComponentID -> Archetype m -> Bool Source #
True if this archetype contains an entity with the provided ComponentID.
remove :: forall (m :: Type -> Type). EntityID -> Archetype m -> (IntMap Dynamic, Archetype m) Source #
Remove an entity from an archetype, returning its components.
removeStorages :: forall (m :: Type -> Type). EntityID -> Archetype m -> (IntMap DynamicStorage, Archetype m) Source #
Remove an entity from an archetype, returning its component storages.
insertComponent :: forall (m :: Type -> Type) a. Component m a => EntityID -> ComponentID -> a -> Archetype m -> (Archetype m, Access m ()) Source #
Insert a component into the archetype.
insertComponentUntracked :: forall (m :: Type -> Type) a. Component m a => EntityID -> ComponentID -> a -> Archetype m -> Archetype m Source #
Insert a component into an archetype without running lifecycle hooks.
insertComponents :: forall (m :: Type -> Type). EntityID -> IntMap Dynamic -> Archetype m -> Archetype m Source #
Insert a map of component storages and their EntityID into the archetype.
insertAscVector :: forall (m :: Type -> Type) a. Component m a => ComponentID -> Vector a -> Archetype m -> Archetype m Source #
Insert a vector of components into the archetype, sorted in ascending order by their EntityID.
zipWith :: forall (m :: Type -> Type) a c. (Monad m, Component m c) => Vector a -> (a -> c -> c) -> ComponentID -> Archetype m -> (Vector c, Archetype m, Access m ()) Source #
Zip a vector of components with a function and a component storage. Returns the result vector, updated archetype, and the onChange hooks to run.
zipWith_ :: forall (m :: Type -> Type) a c. (Monad m, Component m c) => Vector a -> (a -> c -> c) -> ComponentID -> Archetype m -> (Archetype m, Access m ()) Source #
Zip a vector of components with a function and a component storage. Returns the updated archetype and the onChange hooks to run.
zipWithM :: forall m a c. (Monad m, Component m c) => Vector a -> (a -> c -> m c) -> ComponentID -> Archetype m -> m (Vector c, Archetype m, Access m ()) Source #
Zip a vector of components with a monadic function and a component storage. Returns the result vector, updated archetype, and the onChange hooks to run.
zipWithAccum :: forall (m :: Type -> Type) a c o. (Monad m, Component m c) => Vector a -> (a -> c -> (o, c)) -> ComponentID -> Archetype m -> (Vector (o, c), Archetype m, Access m ()) Source #
Zip a vector of components with a function returning a tuple.
zipWithAccumM :: forall m a c o. (Monad m, Component m c) => Vector a -> (a -> c -> m (o, c)) -> ComponentID -> Archetype m -> m (Vector (o, c), Archetype m, Access m ()) Source #
Zip a vector of components with a monadic function returning a tuple.