Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- runGC :: System w ()
- global :: Entity
- newtype EntityCounter = EntityCounter {
- getCounter :: Sum Int
- nextEntity :: (MonadIO m, Get w m EntityCounter) => SystemT w m Entity
- newEntity :: (MonadIO m, Set w m c, Get w m EntityCounter) => c -> SystemT w m Entity
- quantize :: (Fractional (v a), Integral b, RealFrac a, Functor v) => v a -> v a -> v b
- flatten :: (Applicative v, Integral a, Foldable v) => v a -> v a -> Maybe a
- inbounds :: (Num a, Ord a, Applicative v, Foldable v) => v a -> v a -> Bool
- region :: (Enum a, Applicative v, Traversable v) => v a -> v a -> [v a]
- flatten' :: (Applicative v, Integral a, Foldable v) => v a -> v a -> a
Utility
Convenience entity, for use in places where the entity value does not matter, i.e. a global store.
EntityCounter
newtype EntityCounter Source #
Component used by newEntity to track the number of issued entities.
Automatically added to any world created with makeWorld
Instances
Eq EntityCounter Source # | |
Defined in Apecs.Util (==) :: EntityCounter -> EntityCounter -> Bool # (/=) :: EntityCounter -> EntityCounter -> Bool # | |
Show EntityCounter Source # | |
Defined in Apecs.Util showsPrec :: Int -> EntityCounter -> ShowS # show :: EntityCounter -> String # showList :: [EntityCounter] -> ShowS # | |
Semigroup EntityCounter Source # | |
Defined in Apecs.Util (<>) :: EntityCounter -> EntityCounter -> EntityCounter # sconcat :: NonEmpty EntityCounter -> EntityCounter # stimes :: Integral b => b -> EntityCounter -> EntityCounter # | |
Monoid EntityCounter Source # | |
Defined in Apecs.Util mempty :: EntityCounter # mappend :: EntityCounter -> EntityCounter -> EntityCounter # mconcat :: [EntityCounter] -> EntityCounter # | |
Component EntityCounter Source # | |
Defined in Apecs.Util type Storage EntityCounter :: Type Source # | |
type Storage EntityCounter Source # | |
Defined in Apecs.Util |
nextEntity :: (MonadIO m, Get w m EntityCounter) => SystemT w m Entity Source #
Bumps the EntityCounter and yields its value
newEntity :: (MonadIO m, Set w m c, Get w m EntityCounter) => c -> SystemT w m Entity Source #
Writes the given components to a new entity, and yields that entity. The return value is often ignored.
Spatial hashing
The following are helper functions for spatial hashing. Your spatial hash is defined by two vectors;
- The cell size vector contains real components and dictates
how large each cell in your table is in world space units.
It is used by
quantize
to translate a world space coordinate into a table space index vector - The table size vector contains integral components and dictates how
many cells your field consists of in each direction.
It is used by
flatten
to translate a table-space index vector into a flat integer
:: (Fractional (v a), Integral b, RealFrac a, Functor v) | |
=> v a | Quantization cell size |
-> v a | Vector to be quantized |
-> v b |
Quantize turns a world-space coordinate into a table-space coordinate by dividing by the given cell size and rounding towards negative infinity.
flatten :: (Applicative v, Integral a, Foldable v) => v a -> v a -> Maybe a Source #
Turns a table-space vector into an integral index, given some table size vector. Yields Nothing for out-of-bounds queries
inbounds :: (Num a, Ord a, Applicative v, Foldable v) => v a -> v a -> Bool Source #
Tests whether a vector is in the region given by 0 and the size vector (inclusive)
:: (Enum a, Applicative v, Traversable v) | |
=> v a | Lower bound for the region |
-> v a | Higher bound for the region |
-> [v a] |
For two table-space vectors indicating a region's bounds, gives a list of the vectors contained between them. This is useful for querying a spatial hash.