| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Mischief.ECS.World
Synopsis
- data World = World {
- archetypes :: Archetypes
- components :: Components
- entities :: Entities
- tables :: Tables
- deferred :: IORef [System ()]
- deferredAsync :: TVar [System ()]
- trySystems :: IORef [(System (Maybe ErasedValue), ErasedValue -> System ())]
- tick :: IORef Tick
- systemId :: SystemId
- frame :: IORef Frame
- prefs :: Prefs
- logger :: LogAction IO Message
- loggerErr :: LogAction IO Message
- tools :: SystemTools
- newWorld :: SystemTools -> IO World
- setSystemId :: SystemId -> World -> World
- setDeferred :: IORef [System ()] -> World -> World
- 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 ()
- class (Typeable a, Typeable b) => PrefType (a :: k) (b :: k1) | a -> b
- setPref :: forall {k} (a :: k) b c. PrefType a b => b -> System c -> System c
- getPref :: forall {k} (a :: k) m b w. (PrefType a b, MonadSystem w m) => m (Maybe b)
- data SupressEventsPref
- newtype System a = System (ReaderT (Hidden World) IO a)
- newtype SystemId = SystemId {}
- runWhen :: Typeable a => System (Maybe a) -> (a -> System b) -> System ()
- 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, MonadThrow a, SystemAny a) => MonadSystem w (a :: Type -> Type)
- unsafeGetWorld :: MonadSystem w m => m World
- sysUnliftIO :: System (System a -> IO a)
- class SystemAny (m :: Type -> Type) where
- newtype ParSystem a = ParSystem (ReaderT ParWorld IO a)
- data ParWorld = ParWorld {
- world :: Hidden World
- parDeferred :: IORef [System ()]
- parLift :: ParSystem a -> System a
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.
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 #
Prefs
class (Typeable a, Typeable b) => PrefType (a :: k) (b :: k1) | a -> b Source #
Instances
| PrefType TimeTypePref TimeTag Source # | |
Defined in Mischief.ECS.Time | |
| PrefType SupressEventsPref Bool Source # | |
Defined in Mischief.ECS.World | |
data SupressEventsPref Source #
Instances
| PrefType SupressEventsPref Bool Source # | |
Defined in Mischief.ECS.World | |
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
| MonadThrow System Source # | |
Defined in Mischief.ECS.World Methods throwM :: (HasCallStack, Exception e) => e -> System a # | |
| 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 | |
| SystemAny 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.
runWhen :: Typeable a => System (Maybe a) -> (a -> System b) -> System () Source #
Primitive that allows you to set a system to run at every sync point until it returns a Just a, at which point
it will run the second system with the obtained a and stop running.
It will run once on the spot, meaning it has no overhead if the first system immediately succeed.
You should only use this in one-time logic, such as Events or the Startup schedule. You should not use it in logic that runs continuously, such as in Update, as it will keep queueing up a new system to check without removing the old one.
class (GetWorld w, MonadReader w a, Applicative a, MonadFail a, Functor a, Monad a, MonadIO a, PrimMonad a, PrimState a ~ RealWorld, MonadThrow a, SystemAny a) => 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
| MonadThrow ParSystem Source # | |
Defined in Mischief.ECS.World Methods throwM :: (HasCallStack, Exception e) => e -> ParSystem a # | |
| 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 | |
| SystemAny 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.