mischief-ecs
Safe HaskellNone
LanguageGHC2024

Mischief.ECS.Entities

Synopsis

Entity

data Entity Source #

UNLIFTED

Points to an unique entity. The first Word# is an id, the second is a generation.

It is guaranteed that there can't be two alive entities with the same id.

Constructors

Entity (# Word#, Word# #) 

Instances

Instances details
Show Entity Source # 
Instance details

Defined in Mischief.ECS.EntityDef

Eq Entity Source # 
Instance details

Defined in Mischief.ECS.EntityDef

Methods

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

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

Ord Entity Source # 
Instance details

Defined in Mischief.ECS.EntityDef

Queryable E Entity Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => IntoQueryFilter (CheckR Entity c) Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Component c => EraseIntoStorage (R c Entity, c -> Bool) CheckFilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: (R c Entity, c -> Bool) -> CheckFilterType Source #

Component c => EraseIntoStorage (R c Entity) FilterType Source # 
Instance details

Defined in Mischief.ECS.World.Query.QueryFilter

Methods

erase :: R c Entity -> FilterType Source #

Component c => Queryable (HasR c Entity) Bool Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => Queryable (MR c Entity) (Maybe (Result (Rel c))) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

Component c => Queryable (R c Entity) (Result (Rel c)) Source # 
Instance details

Defined in Mischief.ECS.World.Query.Queryable

data EntityPointer Source #

A pointer to the exact table and row that an entity is in.

The first Int# is the id of its archetype. The second is the index of the row it's in.

Constructors

EntityPointer (# Int#, Int# #) 

getPointer :: Entity -> Entities -> IO (Maybe (IORef EntityPointer)) Source #

Get the pointer to an entity.

isAliveIO :: Entity -> Entities -> IO Bool Source #

Check if an Entity is alive through IO.

Storage

data Entities Source #

A storage for entity ids and pointers.

data EntityCounter Source #

A counter and a list for recycling entities.

getNewEntity :: Entities -> IO Entity Source #

Create a new entity.

removeEntity :: Entity -> Entities -> IO () Source #

Remove an entity from storage.

insertPointer :: Entity -> IORef EntityPointer -> Entities -> IO () Source #

Associate an Entity with a new pointer.

getNewEntityComp :: Entities -> IO Entity Source #

Creates a new entity using a fresh id, never incrementing the generation of a previous one.

emptyEntities :: IO Entities Source #

Create a new storage for entities.