| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Mischief.ECS.World.Query.Markers
Synopsis
- data E = E
- data C (a :: k) = C
- data M (a :: k) = M
- data Has (a :: k) = Has
- data Any = Any
- newtype R (a :: k) b = R b
- newtype MR (a :: k) b = MR b
- newtype HasR (a :: k) b = HasR b
- newtype Q a = Q a
- data Q' a b = Q' a b
- newtype Val a = Val a
- newtype R' (a :: k) b = R' b
- data MRes (a :: k) = MRes
- data HasRes (a :: k) = HasRes
Documentation
Used to query for the Entity.
Example
x <- query E
Quasi Notation
Entity
entity
E
e
For instance:
x <- [q|Entity|]
Constructors
| E |
Used to query for a component or to remove a component. Forces queries to only include entities which have the component.
Example
Querying:
x <- query (C @Name)
Removing:
remove (C @Name)
Quasi Notation
None, you just write the component name directly. For instance:
x <- [q|Name|]
Constructors
| C |
Instances
| Component c => ToFilterComponent (C c) Source # | |
Defined in Mischief.ECS.World.Query.QueryFilter Methods toFilterComponent :: C c -> FilterComponent Source # | |
| Component c => Queryable (C c) c Source # | |
Defined in Mischief.ECS.World.Query.Queryable | |
Used to query for a component that an entity may or may not have.
Example
x <- query (M @Name)
Quasi Notation
Maybe
maybe
M
m
For instance:
x <- [q|Maybe Name|]
Constructors
| M |
Used in queries to return a Bool which indicates whether a component exists on the entity or not.
Example
x <- query (Has @Name)
Quasi Notation
Has
has
H
h
For instance:
x <- [q|Has Name|]
Constructors
| Has |
Wildcard used when querying for relationships to indicate that you're querying for relationships with any target.
In the case of exclusive relationships, Any returns a single relationship rather than a list of relationships.
Constructors
| Any |
Instances
| Component c => RelQuery 'False (MR c Any) (Maybe [Rel c]) Source # | |
Defined in Mischief.ECS.World.Query.Queryable | |
| Component c => RelQuery 'False (R c Any) [Rel c] Source # | |
| Component c => RelQuery 'True (MR c Any) (Maybe (Rel c)) Source # | |
Defined in Mischief.ECS.World.Query.Queryable | |
| Component c => RelQuery 'True (R c Any) (Rel c) Source # | |
| Component c => ToFilterComponent (R c Any) Source # | |
Defined in Mischief.ECS.World.Query.QueryFilter Methods toFilterComponent :: R c Any -> FilterComponent Source # | |
| Component c => Queryable (HasR c Any) Bool Source # | |
| RelQuery (IsExclusiveRel c) (MR c Any) out => Queryable (MR c Any) out Source # | |
| RelQuery (IsExclusiveRel c) (R c Any) out => Queryable (R c Any) out Source # | |
Used to query for a relationships. Can be used in three different ways:
1. R c e
Queries for a relationship with a specific target. Forces queries to only include entities which have such a relationship.
Example
x <- query (R @Likes alice)
x :: [Result (Rel Likes)]
Quasi Notation
It is written with an arrow like so:
x <- [q|Likes -> alice|]
2. R c Any
Queries for all relationships with any target. Forces queries to only include entities which have at least one such relationship.
Example
x <- query (R @Likes Any)
x :: [[Result (Rel Likes)]]
Quasi Notation
x <- [q|Likes -> *|]
3. R c q
Runs a transitive query on the targets of all such relationships.
q can either be Q d or Q' d f, depending if you want to also run a filter or not.
Similar to the previous case, it will limit the query to only entities which have such a relationship with at least one entity which matches the transitive query.
Example
x <- query (R @Likes (Q (C @Name))
x <- query (R @Likes (Q' (C @Name) (With (C @Enemy))))
x :: [[Result Name]]
Quasi Notation
You just write the given query in the () following the arrow. / can be used to give it a filter.
For instance:
x <- [q|Likes -> (Name)|]
x <- [q|Likes -> (Name / With Enemy)|]
Constructors
| R b |
Instances
newtype MR (a :: k) b Source #
Exactly like R, except that it wraps the result in a Maybe, also including entities that don't have such a relationship.
Example
x <- query (MR @Likes Any)
Quasi Notation
Maybe
maybe
M
m
For instance:
x <- [q|Maybe Likes -> *|]
Constructors
| MR b |
Instances
newtype HasR (a :: k) b Source #
Exactly like R, except that it returns a Bool depending on whether the entity has such a relationship or not.
Example
x <- query (HasR @Likes Any)
Quasi Notation
Has
has
H
h
For instance:
x <- [q|Has Likes -> *|]
Constructors
| HasR b |
Instances
| Component c => Queryable (HasR c Entity) Bool Source # | |
| Component c => Queryable (HasR c Any) Bool Source # | |
| (Component c, Queryable q out) => Queryable (HasR c (Q q)) Bool Source # | |
| (Component c, Queryable q out) => Queryable (HasR c (Q' q (QueryFilter 'ArchetypeFilter))) Bool Source # | |
Defined in Mischief.ECS.World.Query.Queryable Methods runQueryEntity :: HasR c (Q' q (QueryFilter 'ArchetypeFilter)) -> World -> Entity -> IO (Maybe Bool) Source # runQueryInternal :: HasR c (Q' q (QueryFilter 'ArchetypeFilter)) -> [ArchetypeId] -> World -> IO [(Entity, Bool, Bool)] Source # queryTypes :: HasR c (Q' q (QueryFilter 'ArchetypeFilter)) -> Set (TypeRep, TypeQuery) Source # | |
Used when writing transitive queries. See R.
Constructors
| Q a |
Instances
| (Component c, Queryable q out) => RelQuery 'False (MR c (Q q)) (Maybe [From out]) Source # | |
Defined in Mischief.ECS.World.Query.Queryable | |
| (Component c, Queryable q out) => RelQuery 'False (R c (Q q)) [From out] Source # | |
Defined in Mischief.ECS.World.Query.Queryable | |
| (Component c, Queryable q out) => RelQuery 'True (MR c (Q q)) (Maybe (From out)) Source # | |
Defined in Mischief.ECS.World.Query.Queryable | |
| (Component c, Queryable q out) => RelQuery 'True (R c (Q q)) (From out) Source # | |
| (Component c, Queryable q out) => Queryable (HasR c (Q q)) Bool Source # | |
| RelQuery (IsExclusiveRel c) (MR c (Q q)) out => Queryable (MR c (Q q)) out Source # | |
| RelQuery (IsExclusiveRel c) (R c (Q q)) out => Queryable (R c (Q q)) out Source # | |
Used when writing transitive queries with filters. See R.
Constructors
| Q' a b |
Instances
Can be wrapped around any queryable marker to unwrap the inner value from the Results.
Example
x <- query (C @Name, Val (C @Name))
x :: [(Result Name, Name)]
y <- query (Val (C @Name, R @Likes Any))
y :: [(Name, [Rel Likes])]
Quasi Notation
Val
val
V
v
*
For instance:
x <- [q|Name, *Name|]
x <- [q|*(Name, Likes -> *)|]
Constructors
| Val a |
newtype R' (a :: k) b Source #
Constructors
| R' b |