Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- class HasWorld world where
- nextEntity :: Monad m => SystemT a m Ent
- newEntity :: (HasWorld world, Monad m) => world FieldOf -> SystemT world m Ent
- deleteEntity :: (HasWorld world, Monad m) => Ent -> SystemT world m ()
- unQueryT :: QueryT world m a -> world FieldOf -> m (Maybe a)
- emap :: (HasWorld world, Monad m) => QueryT world m (world SetterOf) -> SystemT world m ()
- efor :: (HasWorld world, Monad m) => (Ent -> QueryT world m a) -> SystemT world m [a]
- runQueryT :: (HasWorld world, Monad m) => Ent -> QueryT world m a -> SystemT world m (Maybe a)
- yieldSystemT :: Monad m => SystemState world -> SystemT world m a -> m (SystemState world, a)
- runSystemT :: Monad m => world WorldOf -> SystemT world m a -> m a
- runSystem :: world WorldOf -> System world a -> a
- getWorld :: Monad m => SystemT world m (world WorldOf)
- with :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m ()
- without :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m ()
- get :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m a
- getMaybe :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m (Maybe a)
- newtype Ent = Ent {}
- type SystemState w = (Int, w WorldOf)
- type SystemT w = StateT (SystemState w)
- type System w = SystemT w Identity
- type QueryT w m = ReaderT (w FieldOf) (MaybeT m)
- data StorageType
- data ComponentType
- data Update a
- type family Component (s :: StorageType) (c :: ComponentType) (a :: *) :: * where ...
- class Generic a
Documentation
class HasWorld world 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 :: (GGetEntity (Rep (world WorldOf)) (Rep (world FieldOf)), Generic (world FieldOf), Generic (world WorldOf), Monad m) => Ent -> SystemT world m (world FieldOf) Source #
Fetches an entity from the world given its Ent
.
setEntity :: Monad m => Ent -> world SetterOf -> SystemT world m () Source #
Updates an Ent
in the world given its setter.
setEntity :: (GSetEntity (Rep (world SetterOf)) (Rep (world WorldOf)), Generic (world WorldOf), Generic (world SetterOf), Monad m) => Ent -> world SetterOf -> SystemT world m () Source #
Updates an Ent
in the world given its setter.
convertSetter :: world FieldOf -> world SetterOf Source #
Transforms an entity into a setter to transform the default entity into
the given one. Used by newEntity
.
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 newEntity
.
defEntity :: world FieldOf Source #
The default entity, owning no components.
defEntity :: (Generic (world FieldOf), GDefault True (Rep (world FieldOf))) => world FieldOf Source #
The default entity, owning no components.
defEntity' :: world SetterOf Source #
The default setter, which keeps all components with their previous value.
defEntity' :: (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.
defWorld :: world WorldOf Source #
The default world, which contains only empty containers.
defWorld :: (Generic (world WorldOf), GDefault True (Rep (world WorldOf))) => world WorldOf Source #
The default world, which contains only empty containers.
(Generic (world SetterOf), Generic (world WorldOf), Generic (world FieldOf), GSetEntity (Rep (world SetterOf)) (Rep (world WorldOf)), GGetEntity (Rep (world WorldOf)) (Rep (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))) => HasWorld world Source # | |
newEntity :: (HasWorld world, Monad m) => world FieldOf -> SystemT world m Ent Source #
Create a new entity.
emap :: (HasWorld world, Monad m) => QueryT world m (world SetterOf) -> SystemT world m () Source #
Map a QueryT
transformation over all entites that match it.
efor :: (HasWorld world, Monad m) => (Ent -> QueryT world m a) -> SystemT world m [a] Source #
Collect the results of a monadic computation over every entity matching
a QueryT
.
runQueryT :: (HasWorld world, Monad m) => Ent -> QueryT world m a -> SystemT world m (Maybe a) Source #
yieldSystemT :: Monad m => SystemState world -> SystemT world m a -> m (SystemState world, 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.
get :: 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.
getMaybe :: Monad m => (world FieldOf -> Maybe a) -> QueryT world m (Maybe a) Source #
Attempt to get the value of a component.
The key for an entity.
type SystemT w = StateT (SystemState w) Source #
A monad transformer over an ECS given a world w
.
type QueryT w m = ReaderT (w FieldOf) (MaybeT m) Source #
A computation to run over a particular entity.
data StorageType Source #
Data kind used to parameterize the ECS record.
data ComponentType Source #
Data kind used to parameterize the fields of the ECS record.
Describes how we can change an a
.
type family Component (s :: StorageType) (c :: ComponentType) (a :: *) :: * where ... Source #
A type family to be used in your ECS recrod.
Representable types of kind *. This class is derivable in GHC with the DeriveGeneric flag on.
Generic Bool | |
Generic Ordering | |
Generic () | |
Generic Fixity | |
Generic Associativity | |
Generic SourceUnpackedness | |
Generic SourceStrictness | |
Generic DecidedStrictness | |
Generic [a] | |
Generic (Maybe a) | |
Generic (Par1 p) | |
Generic (Identity a) | |
Generic (Either a b) | |
Generic (V1 k p) | |
Generic (U1 k p) | |
Generic (a, b) | |
Generic (Proxy k t) | |
Generic (Rec1 k f p) | |
Generic (URec k (Ptr ()) p) | |
Generic (URec k Char p) | |
Generic (URec k Double p) | |
Generic (URec k Float p) | |
Generic (URec k Int p) | |
Generic (URec k Word p) | |
Generic (a, b, c) | |
Generic (K1 k i c p) | |
Generic ((:+:) k f g p) | |
Generic ((:*:) k f g p) | |
Generic (a, b, c, d) | |
Generic (M1 k i c f p) | |
Generic ((:.:) k2 k1 f g p) | |
Generic (a, b, c, d, e) | |
Generic (a, b, c, d, e, f) | |
Generic (a, b, c, d, e, f, g) | |