Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class HasWorld' world => HasWorld world m where
- class HasWorld' world where
- class StorageSurgeon t m world where
- surgery :: (Monad (t m), Monad m, StorageSurgeon t m world) => (forall x. t m x -> m (x, b)) -> SystemT world (t m) a -> SystemT world m (b, a)
- nextEntity :: Monad m => SystemT a m Ent
- createEntity :: (HasWorld world m, Monad m) => world FieldOf -> SystemT world m Ent
- deleteEntity :: (HasWorld world m, Monad m) => Ent -> SystemT world m ()
- unQueryT :: QueryT world m a -> Ent -> world FieldOf -> m (Maybe a)
- emap :: (HasWorld world m, Monad m) => EntTarget world m -> QueryT world m (world SetterOf) -> SystemT world m ()
- efor :: (HasWorld world m, Monad m) => EntTarget world m -> QueryT world m a -> SystemT world m [a]
- eover :: (HasWorld world m, Monad m) => EntTarget world m -> QueryT world m (a, world SetterOf) -> SystemT world m [a]
- runQueryT :: (HasWorld world m, Monad m) => Ent -> QueryT world m a -> SystemT world m (Maybe a)
- yieldSystemT :: Monad m => SystemState world m -> SystemT world m a -> m (SystemState world m, a)
- runSystemT :: Monad m => world (WorldOf m) -> SystemT world m a -> m a
- runSystem :: world (WorldOf Identity) -> System world a -> a
- with :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m ()
- without :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m ()
- query :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m a
- queryMaybe :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m (Maybe a)
- queryEnt :: Monad m => QueryT world m Ent
- queryFlag :: Monad m => (world FieldOf -> Maybe ()) -> QueryT world m Bool
- queryDef :: Monad m => z -> (world FieldOf -> Maybe z) -> QueryT world m z
- type EntTarget world m = SystemT world m [Ent]
- allEnts :: Monad m => EntTarget world m
- someEnts :: Monad m => [Ent] -> EntTarget world m
- anEnt :: Monad m => Ent -> EntTarget world m
- maybeToUpdate :: Maybe a -> Update a
Documentation
class HasWorld' world => HasWorld world m where Source #
This class provides all of the functionality necessary to manipulate the ECS.
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.
(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 # | |
class HasWorld' world where Source #
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.
class StorageSurgeon t m world where Source #
Utilities for defining surgery
.
hoistStorage :: world (WorldOf m) -> world (WorldOf (t m)) Source #
Hoist storage through a monad transformer.
hoistStorage :: (Generic (world (WorldOf m)), Generic (world (WorldOf (t m))), GHoistWorld t m (Rep (world (WorldOf m))) (Rep (world (WorldOf (t m)))), MonadTrans t) => world (WorldOf m) -> world (WorldOf (t m)) Source #
Hoist storage through a monad transformer.
graftStorage :: world (WorldOf m) -> world (WorldOf (t m)) -> world (WorldOf m) Source #
Grafts two worlds together, using data from the second argument and vtables from the first.
graftStorage :: (Generic (world (WorldOf m)), Generic (world (WorldOf (t m))), GGraft (Rep (world (WorldOf m))) (Rep (world (WorldOf (t m))))) => world (WorldOf m) -> world (WorldOf (t m)) -> world (WorldOf m) Source #
Grafts two worlds together, using data from the second argument and vtables from the first.
surgery :: (Monad (t m), Monad m, StorageSurgeon t m world) => (forall x. t m x -> m (x, b)) -> SystemT world (t m) a -> SystemT world m (b, a) Source #
Run a monad transformer underneath a SystemT
.
Due to the recursive interactions between SystemT
and QueryT
, we're
often unable to put a temporary monad transformer on the top of the stack.
As a result, often surgery
is our ony means of introducting ephemeral
effects.
draw ::SystemT
World IO [Graphics] draw = fmap fst .surgery
runWriterT $ for_ thingsToRender $ \thingy -> tell [thingy]
createEntity :: (HasWorld world m, Monad m) => world FieldOf -> SystemT world m Ent Source #
Create a new entity.
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 #
runQueryT :: (HasWorld world m, Monad m) => Ent -> QueryT world m a -> SystemT world m (Maybe a) Source #
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.
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.
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.