| 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
- 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, QueryType c) => Proxy c -> Entity -> m (Maybe c)
- getRAny :: forall c (m :: Type -> Type) w. (Component c, MonadSystem w m, RelExclusivity c ~ 'Inclusive) => 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, QueryType c) => Proxy c -> Entity -> m (Maybe c)
- worldGetRAny :: forall c m w. (Component c, MonadSystem w m, RelExclusivity c ~ 'Inclusive) => 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
- 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, QueryType c) => Proxy c -> Entity -> m (Maybe c) Source #
worldGetRAny :: forall c m w. (Component c, MonadSystem w m, RelExclusivity c ~ 'Inclusive) => Proxy c -> Entity -> m (Maybe [Rel c]) Source #
Systems
A System is a set of instructions applied over a World. It can be added to the App to be ran on a certain Schedule.
A system is actually a wrapper around , meaning you can ReaderT World IOask for the World,
or do IO operations by using liftIO.
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 # | |
| SystemConfig (System ()) Source # | |
Defined in Mischief.ECS.App.SystemConfig Methods systemConfigData :: System () -> SystemConfigData Source # | |
| EraseIntoStorage (System ()) [System ()] Source # | |
| SystemConfig s1 => SystemConfig (SystemConfigModifier s1 (System ())) Source # | |
Defined in Mischief.ECS.App.SystemConfig Methods systemConfigData :: SystemConfigModifier s1 (System ()) -> SystemConfigData Source # | |
| Event (e c) => EraseIntoStorage (e c -> System ()) (Hooks c) 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.