ecstasy-0.2.0.1: A GHC.Generics based entity component system.

Safe HaskellNone
LanguageHaskell2010

Data.Ecstasy.Internal

Synopsis

Documentation

class HasWorld' world => HasWorld world m where Source #

This class provides all of the functionality necessary to manipulate the ECS.

Methods

getEntity :: Monad m => Ent -> SystemT world m (world FieldOf) Source #

Fetches an entity from the world given its Ent.

getEntity :: (Monad m, GGetEntity m (Rep (world (WorldOf m))) (Rep (world FieldOf)), Generic (world FieldOf), Generic (world (WorldOf m))) => Ent -> SystemT world m (world FieldOf) Source #

Fetches an entity from the world given its Ent.

setEntity :: Ent -> world SetterOf -> SystemT world m () Source #

Updates an Ent in the world given its setter.

setEntity :: (GSetEntity m (Rep (world SetterOf)) (Rep (world (WorldOf m))), Generic (world (WorldOf m)), Generic (world SetterOf), Monad m) => Ent -> world SetterOf -> SystemT world m () Source #

Updates an Ent in the world given its setter.

defStorage :: world (WorldOf m) Source #

The default world, which contains only empty containers.

defStorage :: (Generic (world (WorldOf m)), GDefault True (Rep (world (WorldOf m)))) => world (WorldOf m) Source #

The default world, which contains only empty containers.

Instances

(HasWorld' world, Generic (world SetterOf), Generic (world (WorldOf m)), Generic (world FieldOf), GConvertSetter (Rep (world FieldOf)) (Rep (world SetterOf)), GDefault True (Rep (world FieldOf)), GDefault False (Rep (world SetterOf)), GDefault True (Rep (world SetterOf)), GDefault True (Rep (world (WorldOf m))), GSetEntity m (Rep (world SetterOf)) (Rep (world (WorldOf m))), GGetEntity m (Rep (world (WorldOf m))) (Rep (world FieldOf)), Monad m) => HasWorld world m Source # 

Methods

getEntity :: Ent -> SystemT world m (world FieldOf) Source #

setEntity :: Ent -> world SetterOf -> SystemT world m () Source #

defStorage :: world (WorldOf m) Source #

class HasWorld' world where Source #

Methods

convertSetter :: world FieldOf -> world SetterOf Source #

Transforms an entity into a setter to transform the default entity into the given one. Used by createEntity.

convertSetter :: (GConvertSetter (Rep (world FieldOf)) (Rep (world SetterOf)), Generic (world FieldOf), Generic (world SetterOf)) => world FieldOf -> world SetterOf Source #

Transforms an entity into a setter to transform the default entity into the given one. Used by createEntity.

newEntity :: world FieldOf Source #

The default entity, owning no components.

newEntity :: (Generic (world FieldOf), GDefault True (Rep (world FieldOf))) => world FieldOf Source #

The default entity, owning no components.

unchanged :: world SetterOf Source #

The default setter, which keeps all components with their previous value.

unchanged :: (Generic (world SetterOf), GDefault True (Rep (world SetterOf))) => world SetterOf Source #

The default setter, which keeps all components with their previous value.

delEntity :: world SetterOf Source #

A setter which will delete the entity if its QueryT matches.

delEntity :: (Generic (world SetterOf), GDefault False (Rep (world SetterOf))) => world SetterOf Source #

A setter which will delete the entity if its QueryT matches.

Instances

(Generic (world SetterOf), Generic (world FieldOf), GConvertSetter (Rep (world FieldOf)) (Rep (world SetterOf)), GDefault True (Rep (world FieldOf)), GDefault False (Rep (world SetterOf)), GDefault True (Rep (world SetterOf))) => HasWorld' world Source # 

nextEntity :: Monad m => SystemT a m Ent Source #

Retrieve a unique Ent.

createEntity :: (HasWorld world m, Monad m) => world FieldOf -> SystemT world m Ent Source #

Create a new entity.

deleteEntity :: (HasWorld world m, Monad m) => Ent -> SystemT world m () Source #

Delete an entity.

unQueryT :: QueryT world m a -> Ent -> world FieldOf -> m (Maybe a) Source #

Evaluate a QueryT.

emap :: (HasWorld world m, Monad m) => EntTarget world m -> QueryT world m (world SetterOf) -> SystemT world m () Source #

Map a QueryT transformation over all entites that match it.

efor :: (HasWorld world m, Monad m) => EntTarget world m -> QueryT world m a -> SystemT world m [a] Source #

Collect the results of a monadic computation over every entity matching a QueryT.

eover :: (HasWorld world m, Monad m) => EntTarget world m -> QueryT world m (a, world SetterOf) -> SystemT world m [a] Source #

Do an emap and an efor at the same time.

runQueryT :: (HasWorld world m, Monad m) => Ent -> QueryT world m a -> SystemT world m (Maybe a) Source #

Run a QueryT over a particular Ent.

yieldSystemT :: Monad m => SystemState world m -> SystemT world m a -> m (SystemState world m, a) Source #

Provides a resumable SystemT. This is a pretty big hack until I come up with a better formalization for everything.

runSystemT :: Monad m => world (WorldOf m) -> SystemT world m a -> m a Source #

Evaluate a SystemT.

runSystem :: world (WorldOf Identity) -> System world a -> a Source #

Evaluate a System.

with :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m () Source #

Only evaluate this QueryT for entities which have the given component.

without :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m () Source #

Only evaluate this QueryT for entities which do not have the given component.

query :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m a Source #

Get the value of a component, failing the QueryT if it isn't present.

queryMaybe :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m (Maybe a) Source #

Attempt to get the value of a component.

queryEnt :: Monad m => QueryT world m Ent Source #

Get the Ent for whom this query is running.

queryFlag :: Monad m => (world FieldOf -> Maybe ()) -> QueryT world m Bool Source #

Query a flag as a Bool.

queryDef :: Monad m => z -> (world FieldOf -> Maybe z) -> QueryT world m z Source #

Perform a query with a default.

type EntTarget world m = SystemT world m [Ent] Source #

An EntTarget is a set of Ents to iterate over.

allEnts :: Monad m => EntTarget world m Source #

Iterate over all entities.

someEnts :: Monad m => [Ent] -> EntTarget world m Source #

Iterate over some entities.

anEnt :: Monad m => Ent -> EntTarget world m Source #

Iterate over an entity.

maybeToUpdate :: Maybe a -> Update a Source #

Turn a Maybe into an Update.