apecs-0.2.1.0: A fast ECS for game engine programming

Safe HaskellNone
LanguageHaskell2010

Apecs.System

Synopsis

Documentation

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

Run a system with a game world

runWith :: w -> System w a -> IO a Source #

Run a system with a game world

owners :: forall w c. (Has w c, HasMembers (Storage c)) => System w (Slice c) Source #

A slice containing all entities with component c

exists :: forall w c. (Has w c, HasMembers (Storage c)) => Entity c -> System w Bool Source #

Returns whether the given entity has component c For composite components, this indicates whether the component has all its constituents

destroy :: forall w c. (Has w c, HasMembers (Storage c)) => Entity c -> System w () Source #

Destroys the component c for the given entity

resetStore :: forall w c p. (Has w c, HasMembers (Storage c)) => p c -> System w () Source #

Removes all components. Equivalent to manually iterating and deleting, but usually optimized.

get :: forall w c. (Store (Storage c), Has w c) => Entity c -> System w (Safe c) Source #

Gets the component for a given entity. This is a safe access, because the entity might not have the requested components.

set :: forall w c e. (IsRuntime c, Has w c) => Entity e -> c -> System w () Source #

Writes a component to a given entity. Will overwrite existing components.

set' :: forall w c. (IsRuntime c, Has w c) => Entity c -> Safe c -> System w () Source #

Same as set, but uses Safe to possibly delete a component

modify :: forall w c. (IsRuntime c, Has w c) => Entity c -> (c -> c) -> System w () Source #

Applies a function if possible. Equivalent to reading, mapping, and writing, but stores can provide optimized implementations.

imapM_ :: forall w c. (Has w c, HasMembers (Storage c)) => (Entity c -> System w ()) -> System w () Source #

Monadically iterate a system over all entities that have that component. Note that writing to the store while iterating over it is undefined behaviour.

imapM :: forall w c a. (Has w c, HasMembers (Storage c)) => (Entity c -> System w a) -> System w [a] Source #

Monadically iterate a system over all entities that have that component. Note that writing to the store while iterating over it is undefined behaviour.

cmap :: forall world c. (IsRuntime c, Has world c) => (c -> c) -> System world () Source #

Maps a pure function over all components

cmapM_ :: forall w c. (Has w c, IsRuntime c) => (c -> System w ()) -> System w () Source #

mapM_ version of cmap

cimapM_ :: forall w c. (Has w c, IsRuntime c) => ((Entity c, c) -> System w ()) -> System w () Source #

indexed cmapM_, also gives the current entity.

cmapM :: forall w c a. (Has w c, IsRuntime c) => (c -> System w a) -> System w [a] Source #

mapM version of cmap. Can be used to get a list of entities

cimapM :: forall w c a. (Has w c, IsRuntime c) => ((Entity c, c) -> System w a) -> System w [a] Source #

indexed cmapM, also gives the current entity.

cmap' :: forall world c. (Has world c, IsRuntime c) => (c -> Safe c) -> System world () Source #

Maps a function that might delete its components

rmap :: forall world r w. (Has world w, Has world r, IsRuntime w, IsRuntime r) => (r -> w) -> System world () Source #

Maps a function over all entities with a r, and writes their w

rmap' :: forall world r w. (Has world w, Has world r, Store (Storage w), IsRuntime r) => (r -> Safe w) -> System world () Source #

Maps a function over all entities with a r, and writes or deletes their w

wmap :: forall world r w. (Has world w, Has world r, IsRuntime w, IsRuntime r) => (Safe r -> w) -> System world () Source #

For all entities with a w, this map reads their r and writes their w

wmap' :: forall world r w. (Has world w, Has world r, Store (Storage w), IsRuntime r) => (Safe r -> Safe w) -> System world () Source #

For all entities with a w, this map reads their r and writes or deletes their w

readGlobal :: forall w c. (Has w c, GlobalRW (Storage c) c) => System w c Source #

Reads a global value

writeGlobal :: forall w c. (Has w c, GlobalRW (Storage c) c) => c -> System w () Source #

Writes a global value

modifyGlobal :: forall w c. (Has w c, GlobalRW (Storage c) c) => (c -> c) -> System w () Source #

Modifies a global value