Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Entity c = Entity {}
- newtype Slice c = Slice {}
- newtype System w a = System {}
- class (Stores (Storage c) ~ c, Store (Storage c)) => Component c where
- type Storage c
- class Component c => Has w c where
- newtype Safe c = Safe {}
- class Store s where
- class (SafeRW s ~ Stores s, Store s) => GlobalStore s
- class Cast m where
Documentation
An Entity is really just an Int. The type variable is used to keep track of reads and writes, but can be freely cast.
A slice is a list of entities, represented by a Data.Unbox.Vector of Ints.
A system is a newtype around `ReaderT w IO a`, where w
is the game world variable.
class (Stores (Storage c) ~ c, Store (Storage c)) => Component c Source #
A component is defined by the type of its storage The storage in turn supplies runtime types for the component. For the component to be valid, its Storage must be in instance of Store.
Component EntityCounter Source # | |
(Component t_0, Component t_1) => Component (t_0, t_1) Source # | |
(Component t_0, Component t_1, Component t_2) => Component (t_0, t_1, t_2) Source # | |
(Component t_0, Component t_1, Component t_2, Component t_3) => Component (t_0, t_1, t_2, t_3) Source # | |
(Component t_0, Component t_1, Component t_2, Component t_3, Component t_4) => Component (t_0, t_1, t_2, t_3, t_4) Source # | |
(Component t_0, Component t_1, Component t_2, Component t_3, Component t_4, Component t_5) => Component (t_0, t_1, t_2, t_3, t_4, t_5) Source # | |
class Component c => Has w c where Source #
A world Has
a component if it can produce its Storage
(Has w t_0, Has w t_1) => Has w (t_0, t_1) Source # | |
(Has w t_0, Has w t_1, Has w t_2) => Has w (t_0, t_1, t_2) Source # | |
(Has w t_0, Has w t_1, Has w t_2, Has w t_3) => Has w (t_0, t_1, t_2, t_3) Source # | |
(Has w t_0, Has w t_1, Has w t_2, Has w t_3, Has w t_4) => Has w (t_0, t_1, t_2, t_3, t_4) Source # | |
(Has w t_0, Has w t_1, Has w t_2, Has w t_3, Has w t_4, Has w t_5) => Has w (t_0, t_1, t_2, t_3, t_4, t_5) Source # | |
Represents a safe access to c
. A safe access is either a read that might fail, or a write that might delete.
Holds components indexed by entities
The type of components stored by this Store
Return type for safe reads writes to the store
explGet :: s -> Int -> IO (SafeRW s) Source #
Retrieves a component from the store
explSet :: s -> Int -> Stores s -> IO () Source #
Writes a component
explDestroy :: s -> Int -> IO () Source #
Destroys the component for the given index.
explExists :: s -> Int -> IO Bool Source #
Returns whether there is a component for the given index
explMembers :: s -> IO (Vector Int) Source #
Returns an unboxed vector of member indices
explGetUnsafe :: s -> Int -> IO (Stores s) Source #
Unsafe index to the store. What happens if the component does not exist is left undefined.
explSetMaybe :: s -> Int -> SafeRW s -> IO () Source #
Either writes or deletes a component
explReset :: s -> IO () Source #
Removes all components.
Equivalent to calling explDestroy
on each member
explImapM_ :: MonadIO m => s -> (Int -> m a) -> m () Source #
Monadically iterates over member indices
explImapM :: MonadIO m => s -> (Int -> m a) -> m [a] Source #
Monadically iterates over member indices
explModify :: s -> Int -> (Stores s -> Stores s) -> IO () Source #
Modifies an element in the store. Equivalent to reading a value, and then writing the result of the function application.
explCmap :: s -> (Stores s -> Stores s) -> IO () Source #
Maps over all elements of this store. Equivalent to getting a list of all entities with this component, and then explModifying each of them.
explCmapM_ :: MonadIO m => s -> (Stores s -> m a) -> m () Source #
explCimapM_ :: MonadIO m => s -> ((Int, Stores s) -> m a) -> m () Source #
explCmapM :: MonadIO m => s -> (Stores s -> m a) -> m [a] Source #
explCimapM :: MonadIO m => s -> ((Int, Stores s) -> m a) -> m [a] Source #
Monoid c => Store (Global c) Source # | |
Store (Unique c) Source # | |
Flag c => Store (Set c) Source # | |
Store (Map c) Source # | |
(Store t_0, Store t_1) => Store (t_0, t_1) Source # | |
(KnownNat n, Cachable s) => Store (Cache n s) Source # | |
(Log l (Stores s), Cachable s) => Store (Logger l s) Source # | |
(Store t_0, Store t_1, Store t_2) => Store (t_0, t_1, t_2) Source # | |
(Store t_0, Store t_1, Store t_2, Store t_3) => Store (t_0, t_1, t_2, t_3) Source # | |
(Store t_0, Store t_1, Store t_2, Store t_3, Store t_4) => Store (t_0, t_1, t_2, t_3, t_4) Source # | |
(Store t_0, Store t_1, Store t_2, Store t_3, Store t_4, Store t_5) => Store (t_0, t_1, t_2, t_3, t_4, t_5) Source # | |
class (SafeRW s ~ Stores s, Store s) => GlobalStore s Source #
Class of storages for global values
Monoid c => GlobalStore (Global c) Source # | |
(GlobalStore a, GlobalStore b) => GlobalStore (a, b) Source # | |
(GlobalStore a, GlobalStore b, GlobalStore c) => GlobalStore (a, b, c) Source # | |