| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Mischief.ECS.World
Synopsis
- data World = World {
- archetypes :: Archetypes
- components :: Components
- entities :: Entities
- tables :: Tables
- events :: IORef [ErasedEvent]
- deferred :: IORef [System ()]
- deferredAsync :: TVar [System ()]
- tick :: IORef Tick
- systemId :: SystemId
- frame :: IORef Frame
- prefs :: WorldPrefs
- logger :: LogAction IO Message
- loggerErr :: LogAction IO Message
- tools :: SystemTools
- newWorld :: SystemTools -> IO World
- setSystemId :: SystemId -> World -> World
- setDeferred :: IORef [System ()] -> World -> World
- setPrefs :: WorldPrefs -> World -> World
- forkPrefs :: (WorldPrefs -> WorldPrefs) -> System a -> System a
- newtype Frame = Frame Int
- data SystemTools = SystemTools {
- get :: forall c (m :: Type -> Type) w. (MonadSystem w m, Component c) => Proxy c -> Entity -> m (Maybe c)
- getRAny :: forall c (m :: Type -> Type) w. (Component c, MonadSystem w m, IsExclusiveRel c ~ 'False) => Proxy c -> Entity -> m (Maybe [Rel c])
- set :: forall c. Bundle c => c -> Entity -> System ()
- spawnByInsert :: forall b. Bundle b => Entity -> b -> System ()
- worldGet :: forall c m w. (MonadSystem w m, Component c) => Proxy c -> Entity -> m (Maybe c)
- worldGetRAny :: forall c m w. (Component c, MonadSystem w m, IsExclusiveRel c ~ 'False) => Proxy c -> Entity -> m (Maybe [Rel c])
- worldSet :: Bundle c => c -> Entity -> System ()
- worldSpawnByInsert :: Bundle b => Entity -> b -> System ()
- newtype System a = System (ReaderT (Hidden World) IO a)
- newtype SystemId = SystemId {}
- runSystem :: System a -> World -> IO a
- class (GetWorld w, MonadReader w a, Applicative a, MonadFail a, Functor a, Monad a, MonadIO a, PrimMonad a, PrimState a ~ RealWorld) => MonadSystem w (a :: Type -> Type)
- unsafeGetWorld :: MonadSystem w m => m World
- sysUnliftIO :: System (System a -> IO a)
- newtype ParSystem a = ParSystem (ReaderT ParWorld IO a)
- data ParWorld = ParWorld {
- world :: Hidden World
- parDeferred :: IORef [System ()]
World
The World is the main data structure storing the entities, components, archetypes, and everything else that lives in our app.
Constructors
| World | |
Fields
| |
setDeferred :: IORef [System ()] -> World -> World Source #
Set the list of deferred systems of the World.
forkPrefs :: (WorldPrefs -> WorldPrefs) -> System a -> System a Source #
Run a System with changed WorldPrefs.
data SystemTools Source #
Constructors
| SystemTools | |
Fields
| |
worldGet :: forall c m w. (MonadSystem w m, Component c) => Proxy c -> Entity -> m (Maybe c) Source #
worldGetRAny :: forall c m w. (Component c, MonadSystem w m, IsExclusiveRel c ~ 'False) => Proxy c -> Entity -> m (Maybe [Rel c]) Source #
Systems
A System is a monad that mutates the World.
It can be added to a certain schedule and ordered with other systems.
It also offers IO access via liftIO.
Read the tutorial on systems for more details.
Instances
| Applicative System Source # | |
| Functor System Source # | |
| Monad System Source # | |
| MonadFail System Source # | |
Defined in Mischief.ECS.World | |
| MonadIO System Source # | |
Defined in Mischief.ECS.World | |
| Defer System Source # | |
| PrimMonad System Source # | |
| EraseIntoStorage (System ()) Systems Source # | |
| EraseIntoStorage (System ()) [System ()] Source # | |
| type PrimState System Source # | |
Defined in Mischief.ECS.World | |
Unique id assigned to each system that's added to a schedule. Just a wrapper around Entity.
class (GetWorld w, MonadReader w a, Applicative a, MonadFail a, Functor a, Monad a, MonadIO a, PrimMonad a, PrimState a ~ RealWorld) => MonadSystem w (a :: Type -> Type) Source #
Typeclass that can be used to generalize systems to both and System.ParSystem
Used mainly by queries and other operations which don't mutate the World.
Instances
| MonadSystem ParWorld ParSystem Source # | |
Defined in Mischief.ECS.World | |
unsafeGetWorld :: MonadSystem w m => m World Source #
Parallel
A variant of System that contains a ParWorld instead of World.
Parallel systems will only be able to run systems that are either specifically intended for them or
are made to work with any (such as queries).MonadSystem
To run a normal System (), you need to defer!
Instances
| Applicative ParSystem Source # | |
| Functor ParSystem Source # | |
| Monad ParSystem Source # | |
| MonadFail ParSystem Source # | |
Defined in Mischief.ECS.World | |
| MonadIO ParSystem Source # | |
Defined in Mischief.ECS.World | |
| Defer ParSystem Source # | |
| PrimMonad ParSystem Source # | |
| MonadSystem ParWorld ParSystem Source # | |
Defined in Mischief.ECS.World | |
| MonadReader ParWorld ParSystem Source # | |
| type PrimState ParSystem Source # | |
Special wrapper around World given to ParSystems.