The Child component wraps the parent entity and the child entity's underlying component value.
If you want a Foo component in your game to be treated as a child
component, specify the component type as Child Foo when declaring your
world:
newtype Hitbox = Hitbox AABB deriving Show
instance Component Hitbox where type Storage Hitbox = Map Hitbox
-- A type alias solely for TH quoting's sake.
type ChildHitbox = Child Hitbox
makeWorld "World" [''ChildHitbox]If your system is iterating over the Child component but does not need the parent entity, use the ChildValue pseudocomponent instead for better performance.
Note that if you delete a parent entity (i.e. destroy all of the parent entity's components), consider a destroy on the parent entity's children too. See ChildList for assistance on this. This is more from a memory management point of view than one of safety: nothing via standard usage of this library will break if a child "outlives" its parent. However, both trying to directly get some component value of a child's non-existent parent or trying to directly get a parent's non-existent ChildList will result in runtime errors. Raw use of get is inherently dangerous and its risk is not specific to the behavior provided by this module.
Instances4Eq, Show, Component, Storage
Eq c => Eq (Child c)Defined in apecs-0.9.6 · Apecs.Experimental.ChildrenShow c => Show (Child c)Defined in apecs-0.9.6 · Apecs.Experimental.ChildrenComponent c => Component (Child c)Defined in apecs-0.9.6 · Apecs.Experimental.Childrentype Storage (Child c) = Children (Storage c)Defined in apecs-0.9.6 · Apecs.Experimental.Children