mischief-ecs
Safe HaskellNone
LanguageGHC2024

Mischief.ECS.World

Synopsis

World

data World Source #

The World is the main data structure storing the entities, components, archetypes, and everything else that lives in our app.

Constructors

World 

Fields

newWorld :: SystemTools -> IO World Source #

Create a new World in IO.

setSystemId :: SystemId -> World -> World Source #

Change the current SystemId of the World.

setDeferred :: IORef [System ()] -> World -> World Source #

Set the list of deferred systems of the World.

setPrefs :: WorldPrefs -> World -> World Source #

Set new WorldPrefs for the World.

forkPrefs :: (WorldPrefs -> WorldPrefs) -> System a -> System a Source #

Run a System with changed WorldPrefs.

newtype Frame Source #

Constructors

Frame Int 

Instances

Instances details
Show Frame Source # 
Instance details

Defined in Mischief.ECS.World

Methods

showsPrec :: Int -> Frame -> ShowS #

show :: Frame -> String #

showList :: [Frame] -> ShowS #

Eq Frame Source # 
Instance details

Defined in Mischief.ECS.World

Methods

(==) :: Frame -> Frame -> Bool #

(/=) :: Frame -> Frame -> Bool #

Ord Frame Source # 
Instance details

Defined in Mischief.ECS.World

Methods

compare :: Frame -> Frame -> Ordering #

(<) :: Frame -> Frame -> Bool #

(<=) :: Frame -> Frame -> Bool #

(>) :: Frame -> Frame -> Bool #

(>=) :: Frame -> Frame -> Bool #

max :: Frame -> Frame -> Frame #

min :: Frame -> Frame -> Frame #

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 #

worldSet :: Bundle c => c -> Entity -> System () Source #

Systems

newtype System a Source #

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 ReaderT World IO, meaning you can ask for the World, or do IO operations by using liftIO.

Constructors

System (ReaderT (Hidden World) IO a) 

Instances

Instances details
Applicative System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

pure :: a -> System a #

(<*>) :: System (a -> b) -> System a -> System b #

liftA2 :: (a -> b -> c) -> System a -> System b -> System c #

(*>) :: System a -> System b -> System b #

(<*) :: System a -> System b -> System a #

Functor System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

fmap :: (a -> b) -> System a -> System b #

(<$) :: a -> System b -> System a #

Monad System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

(>>=) :: System a -> (a -> System b) -> System b #

(>>) :: System a -> System b -> System b #

return :: a -> System a #

MonadFail System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

fail :: String -> System a #

MonadIO System Source # 
Instance details

Defined in Mischief.ECS.World

Methods

liftIO :: IO a -> System a #

Defer System Source # 
Instance details

Defined in Mischief.ECS.World.Defer

Methods

defer :: System a -> System () Source #

PrimMonad System Source # 
Instance details

Defined in Mischief.ECS.World

Associated Types

type PrimState System 
Instance details

Defined in Mischief.ECS.World

Methods

primitive :: (State# (PrimState System) -> (# State# (PrimState System), a #)) -> System a #

SystemConfig (System ()) Source # 
Instance details

Defined in Mischief.ECS.App.SystemConfig

EraseIntoStorage (System ()) [System ()] Source # 
Instance details

Defined in Mischief.ECS.World

Methods

erase :: System () -> [System ()] Source #

SystemConfig s1 => SystemConfig (SystemConfigModifier s1 (System ())) Source # 
Instance details

Defined in Mischief.ECS.App.SystemConfig

Event (e c) => EraseIntoStorage (e c -> System ()) (Hooks c) Source # 
Instance details

Defined in Mischief.ECS.Hooks

Methods

erase :: (e c -> System ()) -> Hooks c Source #

type PrimState System Source # 
Instance details

Defined in Mischief.ECS.World

newtype SystemId Source #

Unique id assigned to each system that's added to a schedule. Just a wrapper around Entity.

Constructors

SystemId 

Fields

Instances

Instances details
Show SystemId Source # 
Instance details

Defined in Mischief.ECS.World

Eq SystemId Source # 
Instance details

Defined in Mischief.ECS.World

Ord SystemId Source # 
Instance details

Defined in Mischief.ECS.World

runSystem :: System a -> World -> IO a Source #

Run a System with the given World inside IO

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 System and ParSystem.

Used mainly by queries and other operations which don't mutate the World.

Instances

Instances details
MonadSystem ParWorld ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

Parallel

newtype ParSystem a Source #

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 MonadSystem (such as queries).

To run a normal System (), you need to defer!

Constructors

ParSystem (ReaderT ParWorld IO a) 

Instances

Instances details
Applicative ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

Methods

pure :: a -> ParSystem a #

(<*>) :: ParSystem (a -> b) -> ParSystem a -> ParSystem b #

liftA2 :: (a -> b -> c) -> ParSystem a -> ParSystem b -> ParSystem c #

(*>) :: ParSystem a -> ParSystem b -> ParSystem b #

(<*) :: ParSystem a -> ParSystem b -> ParSystem a #

Functor ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

Methods

fmap :: (a -> b) -> ParSystem a -> ParSystem b #

(<$) :: a -> ParSystem b -> ParSystem a #

Monad ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

Methods

(>>=) :: ParSystem a -> (a -> ParSystem b) -> ParSystem b #

(>>) :: ParSystem a -> ParSystem b -> ParSystem b #

return :: a -> ParSystem a #

MonadFail ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

Methods

fail :: String -> ParSystem a #

MonadIO ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

Methods

liftIO :: IO a -> ParSystem a #

Defer ParSystem Source # 
Instance details

Defined in Mischief.ECS.World.Defer

Methods

defer :: System a -> ParSystem () Source #

PrimMonad ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

Associated Types

type PrimState ParSystem 
Instance details

Defined in Mischief.ECS.World

MonadSystem ParWorld ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

MonadReader ParWorld ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

type PrimState ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

data ParWorld Source #

Special wrapper around World given to ParSystems.

Constructors

ParWorld 

Fields

  • world :: Hidden World

    Hidden ensures users cannot access and mutate the World.

  • parDeferred :: IORef [System ()]

    Deferred systems will be collected in this dedicated list and then merged back into the main deferred list once the parallel systems are joined.

Instances

Instances details
MonadSystem ParWorld ParSystem Source # 
Instance details

Defined in Mischief.ECS.World

MonadReader ParWorld ParSystem Source # 
Instance details

Defined in Mischief.ECS.World