justgook/elm-game-logic/3.0.0

Logic.Entity

Entity: The entity is a general-purpose object. It only consists of a unique ID. They "tag every coarse game object as a separate item". Example:

Entity.create id world
    |> Entity.with ( positionSpec, positionComponent )
    |> Entity.with ( velocitySpec, velocityComponent )
type alias EntityID =
Int
create : EntityID -> world -> ( EntityID, world )

Start point for spawning Entity

Entity.create id world
    |> Entity.with ( positionSpec, positionComponent )
    |> Entity.with ( velocitySpec, velocityComponent )
( Spec comp world, comp )
-> ( EntityID, world )
-> ( EntityID, world )

Set component to spawn with a new entity

Entity.create ( id, world )
    |> Entity.with ( positionSpec, positionComponent )
    |> Entity.with ( velocitySpec, velocityComponent )
remove : Spec comp world -> ( EntityID, world ) -> ( EntityID, world )

Way to create Entity destruction functions, should pipe in all possible component specs. It also can be used to just disable (remove) some components from an entity.

remove =
    Entity.remove positionSpec
        >> Entity.remove velocitySpec


newWorld =
    remove ( id, world )