Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Entity c = Entity Int
- newtype Slice c = Slice {}
- newtype System w a = System {}
- class (Stores (Storage c) ~ c, Store (Storage c)) => Component c where
- type Storage c = s | s -> 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 a b 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.
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
The initialization argument required by this 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. Undefined if the component does not exist
explSetMaybe :: s -> Int -> SafeRW s -> IO () Source #
Either writes or deletes a component
initStoreWith :: InitArgs s -> IO s Source #
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 #
Store (Global c) Source # | |
Store (Unique c) Source # | |
Flag c => Store (Set c) Source # | |
Store (Map c) Source # | |
(Store a, Store b) => Store (a, b) Source # | |
(KnownNat n, Cachable s) => Store (Cache n s) Source # | |
(Log l (Stores s), Cachable s) => Store (Logger l s) Source # | |
(Store a, Store b, Store c) => Store (a, b, c) Source # | |
class (SafeRW s ~ Stores s, Store s) => GlobalStore s Source #
Class of storages for global values
GlobalStore (Global c) Source # | |
(GlobalStore a, GlobalStore b) => GlobalStore (a, b) Source # | |
(GlobalStore a, GlobalStore b, GlobalStore c) => GlobalStore (a, b, c) Source # | |