mischief-ecs
Safe HaskellNone
LanguageGHC2024

Mischief.ECS.Prelude

Synopsis

Documentation

class (Typeable c, IsExclusive (RelExclusivity c)) => Component c where Source #

The Component typeclass.

Minimal complete definition

Nothing

Associated Types

type RelExclusivity c :: Exclusivity Source #

Methods

required :: Set DefaultComponentType Source #

List of components required by this one. All required components must be Default

Example

data A = A
instance Component A where
  required = require @(B, C)

data B = B Int deriving (Component, Generic, Default)

data C = C String deriving (Component)
instance Default C where
  def = C "Default String"

hooks :: Hooks c Source #

Instances

Instances details
Component ScheduleLabel Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

Associated Types

type RelExclusivity ScheduleLabel 
Instance details

Defined in Mischief.ECS.App.Schedules

Component Schedules Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

Associated Types

type RelExclusivity Schedules 
Instance details

Defined in Mischief.ECS.App.Schedules

Component StartupSchedule Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

Associated Types

type RelExclusivity StartupSchedule 
Instance details

Defined in Mischief.ECS.App.Schedules

Component UpdateSchedule Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

Associated Types

type RelExclusivity UpdateSchedule 
Instance details

Defined in Mischief.ECS.App.Schedules

Component LastSystemTick Source # 
Instance details

Defined in Mischief.ECS.App.SystemDef

Associated Types

type RelExclusivity LastSystemTick 
Instance details

Defined in Mischief.ECS.App.SystemDef

Component SystemTick Source # 
Instance details

Defined in Mischief.ECS.App.SystemDef

Associated Types

type RelExclusivity SystemTick 
Instance details

Defined in Mischief.ECS.App.SystemDef

Component ScheduledIn Source # 
Instance details

Defined in Mischief.ECS.App.Systems

Associated Types

type RelExclusivity ScheduledIn 
Instance details

Defined in Mischief.ECS.App.Systems

Component SystemFunction Source # 
Instance details

Defined in Mischief.ECS.App.Systems

Associated Types

type RelExclusivity SystemFunction 
Instance details

Defined in Mischief.ECS.App.Systems

Component Systems Source # 
Instance details

Defined in Mischief.ECS.App.Systems

Associated Types

type RelExclusivity Systems 
Instance details

Defined in Mischief.ECS.App.Systems

Component ComponentArchetypes Source # 
Instance details

Defined in Mischief.ECS.Components

Component ComponentPairs Source # 
Instance details

Defined in Mischief.ECS.Components

Associated Types

type RelExclusivity ComponentPairs 
Instance details

Defined in Mischief.ECS.Components

Component ComponentType Source # 
Instance details

Defined in Mischief.ECS.Components

Associated Types

type RelExclusivity ComponentType 
Instance details

Defined in Mischief.ECS.Components

Component DefaultValue Source # 
Instance details

Defined in Mischief.ECS.Components

Associated Types

type RelExclusivity DefaultValue 
Instance details

Defined in Mischief.ECS.Components

Component RequiredBy Source # 
Instance details

Defined in Mischief.ECS.Components

Associated Types

type RelExclusivity RequiredBy 
Instance details

Defined in Mischief.ECS.Components

Component Requires Source # 
Instance details

Defined in Mischief.ECS.Components

Associated Types

type RelExclusivity Requires 
Instance details

Defined in Mischief.ECS.Components

Component Name Source # 
Instance details

Defined in Mischief.ECS.Components.Common

Associated Types

type RelExclusivity Name 
Instance details

Defined in Mischief.ECS.Components.Common

Component ObserverOrder Source # 
Instance details

Defined in Mischief.ECS.Observer

Associated Types

type RelExclusivity ObserverOrder 
Instance details

Defined in Mischief.ECS.Observer

Component IsExclusiveRelationship Source # 
Instance details

Defined in Mischief.ECS.Relationships

Component ChildOf Source # 
Instance details

Defined in Mischief.ECS.Relationships.ChildOf

Associated Types

type RelExclusivity ChildOf 
Instance details

Defined in Mischief.ECS.Relationships.ChildOf

Component Before Source # 
Instance details

Defined in Mischief.ECS.Relationships.Order

Associated Types

type RelExclusivity Before 
Instance details

Defined in Mischief.ECS.Relationships.Order

Component Visited Source # 
Instance details

Defined in Mischief.ECS.Relationships.Order

Associated Types

type RelExclusivity Visited 
Instance details

Defined in Mischief.ECS.Relationships.Order

Component Time Source # 
Instance details

Defined in Mischief.ECS.Time

Associated Types

type RelExclusivity Time 
Instance details

Defined in Mischief.ECS.Time

Typeable e => Component (Observer e) Source # 
Instance details

Defined in Mischief.ECS.Observer

Associated Types

type RelExclusivity (Observer e) 
Instance details

Defined in Mischief.ECS.Observer

(Typeable e, Typeable k) => Component (EventProxy e) Source # 
Instance details

Defined in Mischief.ECS.Observer

Associated Types

type RelExclusivity (EventProxy e) 
Instance details

Defined in Mischief.ECS.Observer

(Typeable a, Typeable b, Typeable k1, Typeable k2) => Component (TestG a b) Source # 
Instance details

Defined in Mischief.ECS.World.Query.TH.QD

Associated Types

type RelExclusivity (TestG a b) 
Instance details

Defined in Mischief.ECS.World.Query.TH.QD

data Rel c Source #

Type used for querying and inserting relationships.

Constructors

Rel 

Fields

Instances

Instances details
Component c => Updateable' 'False (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Insert

Methods

updateInner' :: Result (Rel c) -> System (Maybe (Result (Rel c))) Source #

Component c => GetResultComponentId' 'False (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query

DeepValue' 'False (Result (Rel c)) c Source # 
Instance details

Defined in Mischief.ECS.Tables

Methods

deepValue' :: Result (Rel c) -> c Source #

Component c => Settable' 'False (Result (Rel c)) c Source # 
Instance details

Defined in Mischief.ECS.World.Insert

Methods

setInner' :: Result (Rel c) -> c -> System () Source #

setIfNeqInner' :: Result (Rel c) -> c -> System () Source #

Component c => RelQuery 'Exclusive (MR c Any) (Maybe (Result (Rel c))) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => RelQuery 'Exclusive (R c Any) (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => RelQuery 'Inclusive (MR c Any) (Maybe [Result (Rel c)]) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => RelQuery 'Inclusive (R c Any) [Result (Rel c)] Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Show c => Show (Rel c) Source # 
Instance details

Defined in Mischief.ECS.Components

Methods

showsPrec :: Int -> Rel c -> ShowS #

show :: Rel c -> String #

showList :: [Rel c] -> ShowS #

Component c => EraseIntoStorage (Rel c) (BundleData ErasedComponent) Source # 
Instance details

Defined in Mischief.ECS.Components

(Component c, Eq c) => EraseIntoStorage (Rel c) (BundleData ErasedComponentEq) Source # 
Instance details

Defined in Mischief.ECS.Components

Component c => Queryable (MR c Entity) (Maybe (Result (Rel c))) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => Queryable (R c Entity) (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

type family RelExclusivity c :: Exclusivity Source #

Instances

Instances details
type RelExclusivity ScheduleLabel Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

type RelExclusivity Schedules Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

type RelExclusivity StartupSchedule Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

type RelExclusivity UpdateSchedule Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

type RelExclusivity LastSystemTick Source # 
Instance details

Defined in Mischief.ECS.App.SystemDef

type RelExclusivity SystemTick Source # 
Instance details

Defined in Mischief.ECS.App.SystemDef

type RelExclusivity ScheduledIn Source # 
Instance details

Defined in Mischief.ECS.App.Systems

type RelExclusivity SystemFunction Source # 
Instance details

Defined in Mischief.ECS.App.Systems

type RelExclusivity Systems Source # 
Instance details

Defined in Mischief.ECS.App.Systems

type RelExclusivity ComponentArchetypes Source # 
Instance details

Defined in Mischief.ECS.Components

type RelExclusivity ComponentPairs Source # 
Instance details

Defined in Mischief.ECS.Components

type RelExclusivity ComponentType Source # 
Instance details

Defined in Mischief.ECS.Components

type RelExclusivity DefaultValue Source # 
Instance details

Defined in Mischief.ECS.Components

type RelExclusivity RequiredBy Source # 
Instance details

Defined in Mischief.ECS.Components

type RelExclusivity Requires Source # 
Instance details

Defined in Mischief.ECS.Components

type RelExclusivity Name Source # 
Instance details

Defined in Mischief.ECS.Components.Common

type RelExclusivity ObserverOrder Source # 
Instance details

Defined in Mischief.ECS.Observer

type RelExclusivity IsExclusiveRelationship Source # 
Instance details

Defined in Mischief.ECS.Relationships

type RelExclusivity ChildOf Source # 
Instance details

Defined in Mischief.ECS.Relationships.ChildOf

type RelExclusivity Before Source # 
Instance details

Defined in Mischief.ECS.Relationships.Order

type RelExclusivity Visited Source # 
Instance details

Defined in Mischief.ECS.Relationships.Order

type RelExclusivity Time Source # 
Instance details

Defined in Mischief.ECS.Time

type RelExclusivity (Observer e) Source # 
Instance details

Defined in Mischief.ECS.Observer

type RelExclusivity (EventProxy e) Source # 
Instance details

Defined in Mischief.ECS.Observer

type RelExclusivity (TestG a b) Source # 
Instance details

Defined in Mischief.ECS.World.Query.TH.QD

require :: forall {k} (b :: k). RequiredBundle b => Set DefaultComponentType Source #

data Entity Source #

UNLIFTED

Points to an unique entity. The first Word# is an id, the second is a generation.

It is guaranteed that there can't be two alive entities with the same id.

Instances

Instances details
Show Entity Source # 
Instance details

Defined in Mischief.ECS.EntityDef

Eq Entity Source # 
Instance details

Defined in Mischief.ECS.EntityDef

Methods

(==) :: Entity -> Entity -> Bool #

(/=) :: Entity -> Entity -> Bool #

Ord Entity Source # 
Instance details

Defined in Mischief.ECS.EntityDef

Queryable E Entity Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => IntoQueryFilter (CheckR Entity c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Component c => EraseIntoStorage (R c Entity, c -> Bool) CheckFilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: (R c Entity, c -> Bool) -> CheckFilterType Source #

Component c => EraseIntoStorage (R c Entity) FilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: R c Entity -> FilterType Source #

Component c => Queryable (HasR c Entity) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => Queryable (MR c Entity) (Maybe (Result (Rel c))) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => Queryable (R c Entity) (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

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

get' :: forall qd m w out qf. (Queryable qd out, MonadSystem w m, Collectable qf QueryFilter) => qd -> qf -> Entity -> m (Maybe out) Source #

query :: forall qd output m w. (Queryable qd output, MonadSystem w m) => qd -> m [output] Source #

query' :: forall qd m w out qf. (Queryable qd out, MonadSystem w m, Collectable qf QueryFilter) => qd -> qf -> m [out] Source #

single :: forall qd m w out. (Queryable qd out, MonadSystem w m) => qd -> m (Maybe out) Source #

single' :: forall qd m w out qf. (Queryable qd out, MonadSystem w m, Collectable qf QueryFilter) => qd -> qf -> m (Maybe out) Source #

(|.) :: a -> b -> Or a b infix 9 Source #

newtype Added c Source #

Constructors

Added c 

Instances

Instances details
Collectable c FilterType => IntoQueryFilter (Added c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

newtype Changed c Source #

Constructors

Changed c 

Instances

Instances details
Collectable c FilterType => IntoQueryFilter (Changed c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

newtype Check c Source #

Constructors

Check (c -> Bool) 

Instances

Instances details
Component c => IntoQueryFilter (Check c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

data CheckR e c Source #

Constructors

CheckR e (c -> Bool) 

newtype Not c Source #

Constructors

Not c 

Instances

Instances details
IntoQueryFilter q => IntoQueryFilter (Not q) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

newtype With c Source #

Constructors

With c 

Instances

Instances details
Collectable c FilterType => IntoQueryFilter (With c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

newtype Without c Source #

Constructors

Without c 

Instances

Instances details
Collectable c FilterType => IntoQueryFilter (Without c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

data Any Source #

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

Instances details
Component c => RelQuery 'Exclusive (MR c Any) (Maybe (Result (Rel c))) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => RelQuery 'Exclusive (R c Any) (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => RelQuery 'Inclusive (MR c Any) (Maybe [Result (Rel c)]) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => RelQuery 'Inclusive (R c Any) [Result (Rel c)] Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => IntoQueryFilter (CheckR Any c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Component c => EraseIntoStorage (R c Any, c -> Bool) CheckFilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: (R c Any, c -> Bool) -> CheckFilterType Source #

Component c => EraseIntoStorage (R c Any) FilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: R c Any -> FilterType Source #

Component c => Queryable (HasR c Any) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

RelQuery (RelExclusivity c) (MR c Any) out => Queryable (MR c Any) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

RelQuery (RelExclusivity c) (R c Any) out => Queryable (R c Any) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

data C (a :: k) Source #

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

Instances details
Component c => EraseIntoStorage (C c) FilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: C c -> FilterType Source #

Component c => EraseIntoStorage (C c, c -> Bool) CheckFilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: (C c, c -> Bool) -> CheckFilterType Source #

Component c => Queryable (C c) (Result c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

data E Source #

Used to query for the Entity.

Example

x <- query E

Quasi Notation

  • Entity
  • entity
  • E
  • e

For instance:

x <- [q|Entity|]

Constructors

E 

Instances

Instances details
Queryable E Entity Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

data Has (a :: k) Source #

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 

Instances

Instances details
Component c => Queryable (Has c) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

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

Instances details
Component c => Queryable (HasR c Entity) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => Queryable (HasR c Any) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

(Component c, Queryable q out) => Queryable (HasR c (Q q)) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

(Component c, Queryable q out, Collectable f QueryFilter) => Queryable (HasR c (Q' q f)) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

data M (a :: k) Source #

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 

Instances

Instances details
Component c => Queryable (M c) (Maybe (Result c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

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

Instances details
Component c => RelQuery 'Exclusive (MR c Any) (Maybe (Result (Rel c))) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

(Component c, Queryable q out) => RelQuery 'Exclusive (MR c (Q q)) (Maybe out) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: MR c (Q q) -> World -> Entity -> IO (Maybe (Maybe out)) Source #

relRunQueryInternal :: MR c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, Maybe out)] Source #

relQueryTypes :: MR c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out, Collectable f QueryFilter) => RelQuery 'Exclusive (MR c (Q' q f)) (Maybe out) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: MR c (Q' q f) -> World -> Entity -> IO (Maybe (Maybe out)) Source #

relRunQueryInternal :: MR c (Q' q f) -> [ArchetypeId] -> World -> IO [(Entity, Bool, Maybe out)] Source #

relQueryTypes :: MR c (Q' q f) -> Set (TypeRep, TypeQuery) Source #

Component c => RelQuery 'Inclusive (MR c Any) (Maybe [Result (Rel c)]) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

(Component c, Queryable q out) => RelQuery 'Inclusive (MR c (Q q)) (Maybe [out]) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: MR c (Q q) -> World -> Entity -> IO (Maybe (Maybe [out])) Source #

relRunQueryInternal :: MR c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, Maybe [out])] Source #

relQueryTypes :: MR c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out, Collectable f QueryFilter) => RelQuery 'Inclusive (MR c (Q' q f)) (Maybe [out]) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: MR c (Q' q f) -> World -> Entity -> IO (Maybe (Maybe [out])) Source #

relRunQueryInternal :: MR c (Q' q f) -> [ArchetypeId] -> World -> IO [(Entity, Bool, Maybe [out])] Source #

relQueryTypes :: MR c (Q' q f) -> Set (TypeRep, TypeQuery) Source #

RelQuery (RelExclusivity c) (MR c Any) out => Queryable (MR c Any) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

RelQuery (RelExclusivity c) (MR c (Q q)) out => Queryable (MR c (Q q)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

runQueryEntity :: MR c (Q q) -> World -> Entity -> IO (Maybe out) Source #

runQueryInternal :: MR c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

queryTypes :: MR c (Q q) -> Set (TypeRep, TypeQuery) Source #

RelQuery (RelExclusivity c) (MR c (Q' q f)) out => Queryable (MR c (Q' q f)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

runQueryEntity :: MR c (Q' q f) -> World -> Entity -> IO (Maybe out) Source #

runQueryInternal :: MR c (Q' q f) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

queryTypes :: MR c (Q' q f) -> Set (TypeRep, TypeQuery) Source #

Component c => Queryable (MR c Entity) (Maybe (Result (Rel c))) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

newtype Q a Source #

Used when writing transitive queries. See R.

Constructors

Q a 

Instances

Instances details
(Component c, Queryable q out) => RelQuery 'Exclusive (R c (Q q)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: R c (Q q) -> World -> Entity -> IO (Maybe out) Source #

relRunQueryInternal :: R c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

relQueryTypes :: R c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out) => RelQuery 'Exclusive (MR c (Q q)) (Maybe out) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: MR c (Q q) -> World -> Entity -> IO (Maybe (Maybe out)) Source #

relRunQueryInternal :: MR c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, Maybe out)] Source #

relQueryTypes :: MR c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out) => RelQuery 'Inclusive (MR c (Q q)) (Maybe [out]) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: MR c (Q q) -> World -> Entity -> IO (Maybe (Maybe [out])) Source #

relRunQueryInternal :: MR c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, Maybe [out])] Source #

relQueryTypes :: MR c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out) => RelQuery 'Inclusive (R c (Q q)) [out] Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: R c (Q q) -> World -> Entity -> IO (Maybe [out]) Source #

relRunQueryInternal :: R c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, [out])] Source #

relQueryTypes :: R c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out) => Queryable (HasR c (Q q)) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

RelQuery (RelExclusivity c) (MR c (Q q)) out => Queryable (MR c (Q q)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

runQueryEntity :: MR c (Q q) -> World -> Entity -> IO (Maybe out) Source #

runQueryInternal :: MR c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

queryTypes :: MR c (Q q) -> Set (TypeRep, TypeQuery) Source #

RelQuery (RelExclusivity c) (R c (Q q)) out => Queryable (R c (Q q)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

runQueryEntity :: R c (Q q) -> World -> Entity -> IO (Maybe out) Source #

runQueryInternal :: R c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

queryTypes :: R c (Q q) -> Set (TypeRep, TypeQuery) Source #

newtype R (a :: k) b 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

Instances details
(Component c, Queryable q out) => RelQuery 'Exclusive (R c (Q q)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: R c (Q q) -> World -> Entity -> IO (Maybe out) Source #

relRunQueryInternal :: R c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

relQueryTypes :: R c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out, Collectable f QueryFilter) => RelQuery 'Exclusive (R c (Q' q f)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: R c (Q' q f) -> World -> Entity -> IO (Maybe out) Source #

relRunQueryInternal :: R c (Q' q f) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

relQueryTypes :: R c (Q' q f) -> Set (TypeRep, TypeQuery) Source #

Component c => RelQuery 'Exclusive (R c Any) (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => RelQuery 'Inclusive (R c Any) [Result (Rel c)] Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

(Component c, Queryable q out) => RelQuery 'Inclusive (R c (Q q)) [out] Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: R c (Q q) -> World -> Entity -> IO (Maybe [out]) Source #

relRunQueryInternal :: R c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, [out])] Source #

relQueryTypes :: R c (Q q) -> Set (TypeRep, TypeQuery) Source #

(Component c, Queryable q out, Collectable f QueryFilter) => RelQuery 'Inclusive (R c (Q' q f)) [out] Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

relRunQueryEntity :: R c (Q' q f) -> World -> Entity -> IO (Maybe [out]) Source #

relRunQueryInternal :: R c (Q' q f) -> [ArchetypeId] -> World -> IO [(Entity, Bool, [out])] Source #

relQueryTypes :: R c (Q' q f) -> Set (TypeRep, TypeQuery) Source #

Component c => EraseIntoStorage (R c Entity, c -> Bool) CheckFilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: (R c Entity, c -> Bool) -> CheckFilterType Source #

Component c => EraseIntoStorage (R c Any, c -> Bool) CheckFilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: (R c Any, c -> Bool) -> CheckFilterType Source #

Component c => EraseIntoStorage (R c Entity) FilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: R c Entity -> FilterType Source #

Component c => EraseIntoStorage (R c Any) FilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: R c Any -> FilterType Source #

RelQuery (RelExclusivity c) (R c Any) out => Queryable (R c Any) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

RelQuery (RelExclusivity c) (R c (Q q)) out => Queryable (R c (Q q)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

runQueryEntity :: R c (Q q) -> World -> Entity -> IO (Maybe out) Source #

runQueryInternal :: R c (Q q) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

queryTypes :: R c (Q q) -> Set (TypeRep, TypeQuery) Source #

RelQuery (RelExclusivity c) (R c (Q' q f)) out => Queryable (R c (Q' q f)) out Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

runQueryEntity :: R c (Q' q f) -> World -> Entity -> IO (Maybe out) Source #

runQueryInternal :: R c (Q' q f) -> [ArchetypeId] -> World -> IO [(Entity, Bool, out)] Source #

queryTypes :: R c (Q' q f) -> Set (TypeRep, TypeQuery) Source #

Component c => Queryable (R c Entity) (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

newtype Val a Source #

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 

Instances

Instances details
(Queryable qd out, Mappable MapQueryVal out out') => Queryable (Val qd) out' Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Methods

runQueryEntity :: Val qd -> World -> Entity -> IO (Maybe out') Source #

runQueryInternal :: Val qd -> [ArchetypeId] -> World -> IO [(Entity, Bool, out')] Source #

queryTypes :: Val qd -> Set (TypeRep, TypeQuery) Source #

insert :: HasCallStack => forall b. Bundle b => b -> Entity -> System () Source #

Insert a bundle of components on an Entity.

If the entity already contains these components, their values will be updated in-place instead of causing an archetype change.

insertNew :: Bundle b => b -> Entity -> System () Source #

Insert a bundle of components on an Entity.

Only the components that the entity doesn't already have will be inserted, and the rest ignored.

set :: Settable c i => c -> i -> System () Source #

Set the value of a component obtained as query result.

Note that the local Result won't be mutated. You'll need to query the component again or use update to update the current result.

setIfNeq :: (Eq i, Settable c i) => c -> i -> System () Source #

update :: Updateable (Result c) => Result c -> System (Maybe (Result c)) Source #

Update the value of a Result.

Useful if you've done changed to the component and want to grab the live value without re-querying.

remove :: Collectable c ToRemove => c -> Entity -> System () Source #

modify :: (Updateable (Result c), Settable (Result c) i, DeepValue (Result c) i) => Result c -> (i -> i) -> System () Source #

Modifies the value of the component with the given function.

The function will be applied over the live value of the component, adding some overhead.

If you are confident the value in the Result is the live one, or otherwise do not care of updating the live value, you are encouraged to use modify' instead.

Note that this will trigger change detection even if the provided function is id.

modify' :: (Settable (Result c) i, DeepValue (Result c) i) => Result c -> (i -> i) -> System () Source #

Modifies the value of the component with the given function.

The function will be applied over the value contained within the Result, which is not guaranteed to be the live value of the component.

If you wish to apply the function over the live value, use modify instead.

Note that this will trigger change detection even if the provided function is id.

despawn :: Entity -> System () Source #

Despawn an entity.

spawn :: (HasCallStack, Bundle b) => b -> System Entity Source #

Spawn an entity given a bundle of components.

class Typeable e => Event e Source #

Event typeclass.

Instances

Instances details
(Typeable c, Typeable k) => Event (OnInsert c) Source # 
Instance details

Defined in Mischief.ECS.Events

(Typeable c, Typeable k) => Event (OnInsertRel c) Source # 
Instance details

Defined in Mischief.ECS.Events

(Typeable c, Typeable k) => Event (OnRemove c) Source # 
Instance details

Defined in Mischief.ECS.Events

(Typeable c, Typeable k) => Event (OnRemoveRel c) Source # 
Instance details

Defined in Mischief.ECS.Events

data System a Source #

A System is a set of instructions applied over a World. It can be added to the App to be ran on a certain Schedule.

A system is actually a wrapper around ReaderT World IO, meaning you can ask for the World, or do IO operations by using liftIO.

Instances

Instances details
Applicative System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

pure :: a -> System a #

(<*>) :: System (a -> b) -> System a -> System b #

liftA2 :: (a -> b -> c) -> System a -> System b -> System c #

(*>) :: System a -> System b -> System b #

(<*) :: System a -> System b -> System a #

Functor System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

fmap :: (a -> b) -> System a -> System b #

(<$) :: a -> System b -> System a #

Monad System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

(>>=) :: System a -> (a -> System b) -> System b #

(>>) :: System a -> System b -> System b #

return :: a -> System a #

MonadFail System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

fail :: String -> System a #

MonadIO System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

liftIO :: IO a -> System a #

Defer System Source # 
Instance details

Defined in Mischief.ECS.World.Defer

Methods

defer :: System a -> System () Source #

PrimMonad System Source # 
Instance details

Defined in Mischief.ECS.World

Associated Types

type PrimState System 
Instance details

Defined in Mischief.ECS.World

Methods

primitive :: (State# (PrimState System) -> (# State# (PrimState System), a #)) -> System a #

SystemConfig (System ()) Source # 
Instance details

Defined in Mischief.ECS.App.SystemConfig

EraseIntoStorage (System ()) [System ()] Source # 
Instance details

Defined in Mischief.ECS.World

Methods

erase :: System () -> [System ()] Source #

SystemConfig s1 => SystemConfig (SystemConfigModifier s1 (System ())) Source # 
Instance details

Defined in Mischief.ECS.App.SystemConfig

Event (e c) => EraseIntoStorage (e c -> System ()) (Hooks c) Source # 
Instance details

Defined in Mischief.ECS.Hooks

Methods

erase :: (e c -> System ()) -> Hooks c Source #

type PrimState System Source # 
Instance details

Defined in Mischief.ECS.World

data Time Source #

Instances

Instances details
Show Time Source # 
Instance details

Defined in Mischief.ECS.Time

Methods

showsPrec :: Int -> Time -> ShowS #

show :: Time -> String #

showList :: [Time] -> ShowS #

Component Time Source # 
Instance details

Defined in Mischief.ECS.Time

Associated Types

type RelExclusivity Time 
Instance details

Defined in Mischief.ECS.Time

type RelExclusivity Time Source # 
Instance details

Defined in Mischief.ECS.Time

data TimePlugin Source #

Constructors

TimePlugin 

Instances

Instances details
Eq TimePlugin Source # 
Instance details

Defined in Mischief.ECS.Time

Plugin TimePlugin Source # 
Instance details

Defined in Mischief.ECS.Time

delay :: MonadSystem w m => Int -> System () -> m () Source #

runAfter :: MonadSystem w m => IO a -> (a -> System ()) -> m () Source #

defer :: Defer m => System a -> m () Source #

newApp :: Plugin p => p -> IO App Source #

runApp :: App -> IO () Source #

class (Typeable p, Eq p) => Plugin p where Source #

Minimal complete definition

Nothing

Methods

plugins :: p -> Plugins Source #

init :: p -> System () Source #

Instances

Instances details
Plugin TimePlugin Source # 
Instance details

Defined in Mischief.ECS.Time

data First Source #

Constructors

First 

Instances

Instances details
Show First Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

Methods

showsPrec :: Int -> First -> ShowS #

show :: First -> String #

showList :: [First] -> ShowS #

Schedule First Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

data PostStartup Source #

Constructors

PostStartup 

Instances

Instances details
Schedule PostStartup Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

data PostUpdate Source #

Constructors

PostUpdate 

Instances

Instances details
Schedule PostUpdate Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

data PreStartup Source #

Constructors

PreStartup 

Instances

Instances details
Schedule PreStartup Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

data PreUpdate Source #

Constructors

PreUpdate 

Instances

Instances details
Schedule PreUpdate Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

data Startup Source #

Constructors

Startup 

Instances

Instances details
Show Startup Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

Schedule Startup Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

data Update Source #

Constructors

Update 

Instances

Instances details
Show Update Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

Schedule Update Source # 
Instance details

Defined in Mischief.ECS.App.Schedules

expect :: HasCallStack => forall (m :: Type -> Type) w a. MonadSystem w m => Text -> Maybe a -> m a Source #

trigger :: Event e => e -> System () Source #