Stability | experimental |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Apecs.Experimental.Reactive
Description
This module is experimental, and its API might change between point releases. Use at your own risk.
Adds the Reactive r s
store, which when wrapped around store s
, will call the react
on its r
.
Show c => Reactive (Printer c) (Map c)
will print a message every time a c
value is set.
Enum c => Reactive (EnumMap c) (Map c)
allows you to look up entities by component value.
Use e.g. rget >>= mapLookup True
to retrieve a list of entities that have a True
component.
Synopsis
- class Monad m => Reacts m r where
- data Reactive r s
- withReactive :: forall w m r s a. (Component (Elem r), Has w m (Elem r), Storage (Elem r) ~ Reactive r s) => (r -> m a) -> SystemT w m a
- data EnumMap c
- enumLookup :: (MonadIO m, Enum c) => c -> EnumMap c -> m [Entity]
- data OrdMap c
- ordLookup :: (MonadIO m, Ord c) => c -> OrdMap c -> m [Entity]
- data IxMap c
- ixLookup :: (MonadIO m, Ix c) => c -> IxMap c -> m [Entity]
Documentation
class Monad m => Reacts m r where Source #
Class required by Reactive
.
Given some r
and update information about some component, will run a side-effect in monad m
.
Note that there are also instances for (,)
.
Wrapper for reactivity around some store s.
Instances
ExplMembers m s => ExplMembers m (Reactive r s) Source # | |
Defined in Apecs.Experimental.Reactive | |
(Reacts m r, ExplDestroy m s, ExplGet m s, Elem s ~ Elem r) => ExplDestroy m (Reactive r s) Source # | |
Defined in Apecs.Experimental.Reactive Methods explDestroy :: Reactive r s -> Int -> m () Source # | |
(Reacts m r, ExplSet m s, ExplGet m s, Elem s ~ Elem r) => ExplSet m (Reactive r s) Source # | |
ExplGet m s => ExplGet m (Reactive r s) Source # | |
(Reacts m r, ExplInit m s) => ExplInit m (Reactive r s) Source # | |
Defined in Apecs.Experimental.Reactive | |
type Elem (Reactive r s) Source # | |
Defined in Apecs.Experimental.Reactive |
withReactive :: forall w m r s a. (Component (Elem r), Has w m (Elem r), Storage (Elem r) ~ Reactive r s) => (r -> m a) -> SystemT w m a Source #
Performs an action with a reactive state token.
Allows you to look up entities by component value.
Use e.g. withReactive $ mapLookup True
to retrieve a list of entities that have a True
component.
Based on an IntMap IntSet
internally.
Allows you to look up entities by component value.
Based on a Map c IntSet
internally