Safe Haskell | None |
---|---|
Language | Haskell98 |
Common Elements for HGamer3D
- data Component
- type Entity = Map Component Dynamic
- (#:) :: Typeable a => Component -> a -> (Component, Dynamic)
- entity :: [(Component, Dynamic)] -> Entity
- (#?) :: Entity -> Component -> Bool
- (#) :: Typeable a => Entity -> Component -> a
- (?#) :: Typeable a => Entity -> Component -> Maybe a
- updateEntity :: Typeable a => Entity -> Component -> (a -> a) -> Entity
- _setComponent :: Typeable a => Entity -> Component -> a -> Entity
- type Listeners = TVar (Map Component [Entity -> Entity -> IO ()])
- addListener :: Listeners -> Component -> (Entity -> Entity -> IO ()) -> IO ()
- clearAllListeners :: Listeners -> IO ()
- fireListeners :: Listeners -> Component -> Entity -> Entity -> IO ()
- data ERef = ERef (TVar Entity) Listeners
- newE :: [(Component, Dynamic)] -> IO ERef
- readE :: ERef -> IO Entity
- updateE :: Typeable a => ERef -> Component -> (a -> a) -> IO ()
- _setE :: Typeable a => ERef -> Component -> a -> IO ()
- sendCmd :: Typeable a => ERef -> a -> IO ()
- sendEvt :: Typeable a => ERef -> a -> IO ()
- regEvtH :: Typeable a => ERef -> (a -> IO ()) -> IO ()
- type ComponentListener = TVar (Maybe (Entity, Entity))
- componentListener :: ERef -> Component -> IO ComponentListener
- queryComponentListener :: ComponentListener -> IO (Maybe (Entity, Entity))
- type OnUpdateFunction = Entity -> Entity -> IO ()
- type OnDeleteFunction = IO ()
- type SystemRecord = (ComponentListener, OnUpdateFunction, OnDeleteFunction)
- type SystemFunction a = a -> ERef -> IO [SystemRecord]
- data SystemData a = SystemData {
- sdLock :: MVar ()
- sdNewERefs :: IORef [ERef]
- sdDelERefs :: IORef [ERef]
- sdRecords :: [SystemRecord]
- sdSystem :: a
- sdSystemFunction :: SystemFunction a
- class System a where
- initializeSystem :: IO (SystemData a)
- stepSystem :: SystemData a -> IO Bool
- addERef :: SystemData a -> ERef -> IO ()
- removeERef :: SystemData a -> ERef -> IO ()
- runSystem :: GameTime -> IO (SystemData a)
- shutdownSystem :: SystemData a -> IO ()
- stepSystem' :: SystemData a -> IO (SystemData a, Bool)
- data SomeSystem = forall a . System a => SomeSystem (SystemData a)
- (#+) :: [SomeSystem] -> [SomeSystem] -> [SomeSystem]
- addToWorld :: [SomeSystem] -> ERef -> IO ()
- removeFromWorld :: [SomeSystem] -> ERef -> IO ()
- module HGamer3D.Common.FileLocation
- module HGamer3D.Common.UniqueName
Documentation
Possible Components, which are known, this list needs to be extended, if additional components are introduced. Each component can occur only once in an Entity.
(#:) :: Typeable a => Component -> a -> (Component, Dynamic) Source
Pair builder for nice construction syntax, allows [ ct #: val, ...] syntax
entity :: [(Component, Dynamic)] -> Entity Source
Builder for entities, allows newE = entity [ct #: val, ...] syntax
(#) :: Typeable a => Entity -> Component -> a Source
get the component, throws exception, if component not present, or wrong type
(?#) :: Typeable a => Entity -> Component -> Maybe a Source
get the component as an maybe, in case wrong type
updateEntity :: Typeable a => Entity -> Component -> (a -> a) -> Entity Source
modification function, throws exception, if component not present
_setComponent :: Typeable a => Entity -> Component -> a -> Entity Source
modification function, sets entity component, needed for events
clearAllListeners :: Listeners -> IO () Source
type ComponentListener = TVar (Maybe (Entity, Entity)) Source
ComponentListener are tracking the change of a component of a specific entity. Ones this component changes, they contain the latest value of the entity. ComponentListener are implemented with the Listener mechanism for ERefs
componentListener :: ERef -> Component -> IO ComponentListener Source
queryComponentListener :: ComponentListener -> IO (Maybe (Entity, Entity)) Source
type OnUpdateFunction = Entity -> Entity -> IO () Source
type OnDeleteFunction = IO () Source
type SystemFunction a = a -> ERef -> IO [SystemRecord] Source
data SystemData a Source
SystemData | |
|
initializeSystem :: IO (SystemData a) Source
stepSystem :: SystemData a -> IO Bool Source
addERef :: SystemData a -> ERef -> IO () Source
removeERef :: SystemData a -> ERef -> IO () Source
runSystem :: GameTime -> IO (SystemData a) Source
shutdownSystem :: SystemData a -> IO () Source
stepSystem' :: SystemData a -> IO (SystemData a, Bool) Source
data SomeSystem Source
forall a . System a => SomeSystem (SystemData a) |
(#+) :: [SomeSystem] -> [SomeSystem] -> [SomeSystem] infixr 9 Source
addToWorld :: [SomeSystem] -> ERef -> IO () Source
removeFromWorld :: [SomeSystem] -> ERef -> IO () Source
module HGamer3D.Common.FileLocation
module HGamer3D.Common.UniqueName