mischief-ecs
Safe HaskellNone
LanguageGHC2024

Mischief.ECS.World.Query

Synopsis

Documentation

findArchetypes :: forall qd m w output. (Queryable qd output, MonadSystem w m) => qd -> m (Set ArchetypeId) Source #

entityQuery :: forall qd output m w. (Queryable qd output, MonadSystem w m) => qd -> Entity -> m (Maybe output) Source #

class GetComponentId c where Source #

Methods

getComponentId' :: forall w (m :: Type -> Type). MonadSystem w m => c -> FilterComponent Source #

tryMetaLocal :: forall c m w. (Component c, MonadSystem w m) => m (Maybe Entity) Source #

has :: forall c m w. (MonadSystem w m, ToFilterComponent c) => c -> Entity -> m Bool Source #

data Query (m :: Type -> Type) a where Source #

A Query is a chain of operations which return a list of values when ran.

Constructors

BuildQuery :: forall qd a (m :: Type -> Type). Queryable qd a => qd -> QueryFilter -> Maybe [Entity] -> Query m a 
MapQuery :: forall (m :: Type -> Type) b a. Query m b -> (Entity -> b -> m a) -> Query m a 
FilterQuery :: forall (m :: Type -> Type) a. Query m a -> (Entity -> a -> m Bool) -> Query m a 
PairEntityQuery :: forall (m :: Type -> Type) a1. Query m a1 -> Query m (Entity, a1) 
DoQuery :: forall (m :: Type -> Type) a b. Query m a -> (Entity -> a -> m b) -> Query m a 
CollectQuery :: forall (m :: Type -> Type) a1. Query m a1 -> Query m [From a1] 
PureQuery :: forall a (m :: Type -> Type). a -> Query m a 
AppQuery :: forall (m :: Type -> Type) a1 a. Query m (a1 -> a) -> Query m a1 -> Query m a 
BindQuery :: forall (m :: Type -> Type) a1 a. Query m a1 -> (a1 -> Query m a) -> Query m a 
EmptyQuery :: forall (m :: Type -> Type) a. Query m a 
RefocusQuery :: forall (m :: Type -> Type) a. Query m a -> Entity -> Query m a 
StopQuery :: forall (m :: Type -> Type) a. Query m a 
IterQuery :: forall a (m :: Type -> Type). [From a] -> Query m a 
ParQuery :: forall a (m :: Type -> Type). Query ParSystem a -> Query m a 

Instances

Instances details
MonadSystem w m => Applicative (Query m) Source # 
Instance details

Defined in Mischief.ECS.World.Query

Methods

pure :: a -> Query m a #

(<*>) :: Query m (a -> b) -> Query m a -> Query m b #

liftA2 :: (a -> b -> c) -> Query m a -> Query m b -> Query m c #

(*>) :: Query m a -> Query m b -> Query m b #

(<*) :: Query m a -> Query m b -> Query m a #

MonadSystem w m => Functor (Query m) Source # 
Instance details

Defined in Mischief.ECS.World.Query

Methods

fmap :: (a -> b) -> Query m a -> Query m b #

(<$) :: a -> Query m b -> Query m a #

MonadSystem w m => Monad (Query m) Source # 
Instance details

Defined in Mischief.ECS.World.Query

Methods

(>>=) :: Query m a -> (a -> Query m b) -> Query m b #

(>>) :: Query m a -> Query m b -> Query m b #

return :: a -> Query m a #

qrun :: MonadSystem w m => Query m out -> m [(Entity, out)] Source #

tryJoin :: (Entity, a) -> (Entity, a -> b) -> Maybe (Entity, b) Source #

query :: MonadSystem w m => Query m out -> m [out] Source #

Run a Query, returning a list of values.

query_ :: MonadSystem w m => Query m out -> m () Source #

Run a Query.

single :: MonadSystem w m => Query m out -> m (Maybe out) Source #

Run a Query, returning an element only if it was the only result.

queryOne :: MonadSystem w m => Query m out -> m (Maybe out) Source #

Run a Query, returning an arbitrary element produced by it, or nothing if the query was null.

mkQuery :: forall qd out (m :: Type -> Type). Queryable qd out => qd -> Query m out Source #

mkQuery' :: forall qd out (m :: Type -> Type). Queryable qd out => qd -> QueryFilter -> Query m out Source #

mkGet :: forall qd out (m :: Type -> Type). Queryable qd out => Entity -> qd -> Query m out Source #

mkGet' :: forall qd out (m :: Type -> Type). Queryable qd out => Entity -> qd -> QueryFilter -> Query m out Source #

check :: forall m w. MonadSystem w m => QueryFilter -> Entity -> m Bool Source #

runWhenQ :: Typeable a => Query System a -> ([a] -> System b) -> System () Source #

Same as runWhen, but runs when the provided query is not empty.

runWhenOne :: Typeable a => Query System a -> (a -> System b) -> System () Source #

Same as runWhen, but runs when the provided query is not empty. Picks an arbitrary element to pass forward.