aztecs-0.16.0: A modular game engine and Entity-Component-System (ECS) for Haskell.
Copyright(c) Matt Hunzinger 2025
LicenseBSD-style (see the LICENSE file in the distribution)
Maintainermatt@hunzinger.me
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Aztecs.ECS.World.Archetype

Description

 
Synopsis

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 

Fields

Instances

Instances details
Monoid (Archetype m) Source # 
Instance details

Defined in Aztecs.ECS.World.Archetype.Internal

Semigroup (Archetype m) Source # 
Instance details

Defined in Aztecs.ECS.World.Archetype.Internal

Methods

(<>) :: Archetype m -> Archetype m -> Archetype m #

sconcat :: NonEmpty (Archetype m) -> Archetype m #

stimes :: Integral b => b -> Archetype m -> Archetype m #

Generic (Archetype m) Source # 
Instance details

Defined in Aztecs.ECS.World.Archetype.Internal

Associated Types

type Rep (Archetype m) 
Instance details

Defined in Aztecs.ECS.World.Archetype.Internal

type Rep (Archetype m) = D1 ('MetaData "Archetype" "Aztecs.ECS.World.Archetype.Internal" "aztecs-0.16.0-1t3LRuVnzUqKpg58E4sSVq" 'False) (C1 ('MetaCons "Archetype" 'PrefixI 'True) (S1 ('MetaSel ('Just "storages") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (IntMap DynamicStorage)) :*: S1 ('MetaSel ('Just "entities") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set EntityID))))

Methods

from :: Archetype m -> Rep (Archetype m) x #

to :: Rep (Archetype m) x -> Archetype m #

Show (Archetype m) Source # 
Instance details

Defined in Aztecs.ECS.World.Archetype.Internal

type Rep (Archetype m) Source # 
Instance details

Defined in Aztecs.ECS.World.Archetype.Internal

type Rep (Archetype m) = D1 ('MetaData "Archetype" "Aztecs.ECS.World.Archetype.Internal" "aztecs-0.16.0-1t3LRuVnzUqKpg58E4sSVq" 'False) (C1 ('MetaCons "Archetype" 'PrefixI 'True) (S1 ('MetaSel ('Just "storages") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (IntMap DynamicStorage)) :*: S1 ('MetaSel ('Just "entities") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set EntityID))))

empty :: forall (m :: Type -> Type). Archetype m Source #

Empty archetype.

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.