Copyright | (C) 2020 Sophie Taylor |
---|---|
License | AGPL-3.0-or-later |
Maintainer | Sophie Taylor <sophie@spacekitteh.moe> |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | GHC2021 |
Games.ECS.System
Description
Infrastructure for defining ECS Systems.
Synopsis
- class (World w, Monad m, KnownSymbol (AppendSymbol name " started"), KnownSymbol (AppendSymbol name " finished")) => System (name :: Symbol) (sys :: k) (w :: Access -> Type) (m :: Type -> Type) | name -> sys, sys -> name where
- type RunsAfter (sys :: k) :: [Symbol]
- type RunsBefore (sys :: k) :: [Symbol]
- type ComponentFilters (name :: Symbol) (sys :: k) (w :: Access -> Type) (m :: Type -> Type)
- componentFilter :: (ComponentFilters name sys w m, Monoid r) => Getting r (w 'Storing) IntersectionOfEntities
- processPredicate :: w 'Individual -> Bool
- processEntity :: w 'Individual -> m (w 'Individual)
- initialiseSystem :: w 'Storing -> m (w 'Storing)
- runSystem :: w 'Storing -> m (w 'Storing)
- postTickCleanup :: w 'Storing -> m (w 'Storing)
- runAfterEffects :: w 'Storing -> m (w 'Storing)
Documentation
class (World w, Monad m, KnownSymbol (AppendSymbol name " started"), KnownSymbol (AppendSymbol name " finished")) => System (name :: Symbol) (sys :: k) (w :: Access -> Type) (m :: Type -> Type) | name -> sys, sys -> name where Source #
A system which operates on entities which matches certain constraints on components.
Minimal complete definition
Nothing
Associated Types
type RunsAfter (sys :: k) :: [Symbol] Source #
What this systems runs after
type RunsBefore (sys :: k) :: [Symbol] Source #
What this systems runs before
type RunsBefore (sys :: k) = '[] :: [Symbol]
type ComponentFilters (name :: Symbol) (sys :: k) (w :: Access -> Type) (m :: Type -> Type) Source #
Constraints required to run the system.
Methods
componentFilter :: (ComponentFilters name sys w m, Monoid r) => Getting r (w 'Storing) IntersectionOfEntities Source #
The filter on components which the system affects
processPredicate :: w 'Individual -> Bool Source #
Should this entity be processed?
processEntity :: w 'Individual -> m (w 'Individual) Source #
Process a single entity
initialiseSystem :: w 'Storing -> m (w 'Storing) Source #
Initialise the system with preliminary data based on a fresh world. The system is allowed to modify the world if it wishes.
runSystem :: w 'Storing -> m (w 'Storing) Source #
Run the system. By default, it runs processEntity
for each entity.
postTickCleanup :: w 'Storing -> m (w 'Storing) Source #
Run any cleanup necessary at the end of a tick, such as clearing cached data only necessary for the tick, or marking things as dirty.
runAfterEffects :: w 'Storing -> m (w 'Storing) Source #
Ran after the effect system has finished. This is so that one can, for example, collect all effects to apply during the effect system processing; and once all effects are collected, apply them all at once. This can eliminate redundant processing, as well as later effects not overriding previously-processed effects.