Component: the raw data for one aspect of the object, and how it interacts with the world. "Labels the Entity as possessing this particular aspect".
Example:
type alias Velocity =
{ x : Float, y : Float }
spec : Component.Spec Velocity { world | v : Component.Set Velocity }
spec =
Component.Spec .v (\comps world -> { world | v = comps })
empty : Component.Set Velocity
empty =
Component.emptyComponent specification, how to get Component.Set from world and set back into world (mainly used by Systems)
Create empty Component.Set - mostly used to init component sets in world.
Set the component at a particular index. Returns an updated Component.Set. If the index is out of range, the Component.Set is unaltered.
test =
-- Nothing
empty |> set 5 10 |> get 5Safe way to create component, same as set, only if index is out of range Component.Set will be stretched.
test =
-- Just 5
empty |> spawn 5 10 |> get 5Remove component from Component.Set by EntityID, or return unchanged if component not in Set.
Get component for EntityId.
Get components Tuple for EntityId.
Update Component by EntityID.
Apply a function on every component in an Component.Set.
map sqrt (fromList [ ( 0, 1 ), ( 1, 4 ), ( 2, 9 ) ])
|> (==) fromList [ ( 0, 1 ), ( 1, 2 ), ( 2, 3 ) ]Filter out certain components.
Create a Component.Set from a List.
Note: Useful for data serialization.
Convert a Component.Set into an association list of id-component pairs, sorted by id.
Note: Useful for data deserialization.
Create a Component.Set from a dictionary.
Note: Useful for data serialization.
Create a dictionary from a Component.Set.
Note: Useful for data deserialization.
Component storage, main building block of world