Documentation ¶
Overview ¶
Package event contains a mask type and bit switches for listener subscriptions.
See also github.com/mlange-42/arche/ecs.Listener and github.com/mlange-42/arche/ecs.EntityEvent.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Subscription ¶
type Subscription uint8
Subscription bits for an github.com/mlange-42/arche/ecs.Listener
Example ¶
package main import ( "fmt" "github.com/mlange-42/arche/ecs/event" ) func main() { mask := event.EntityCreated | event.EntityRemoved fmt.Printf("%08b contains\n%08b -> %t\n\n", mask, event.EntityRemoved, mask.Contains(event.EntityRemoved)) fmt.Printf("%08b contains\n%08b -> %t\n\n", mask, event.ComponentAdded, mask.Contains(event.ComponentAdded)) fmt.Printf("%08b contains any\n%08b -> %t\n\n", mask, event.EntityRemoved|event.ComponentAdded, mask.ContainsAny(event.EntityRemoved|event.ComponentAdded)) fmt.Printf("%08b contains any\n%08b -> %t\n\n", mask, event.ComponentAdded|event.ComponentRemoved, mask.ContainsAny(event.ComponentAdded|event.ComponentRemoved)) }
Output: 00000011 contains 00000010 -> true 00000011 contains 00000100 -> false 00000011 contains any 00000110 -> true 00000011 contains any 00001100 -> false
const ( // EntityCreated subscription bit. // // Without component subscription: // - Creation of an entity with or without any components // With component subscription: // - Creation of an entity with any of the given components EntityCreated Subscription = 1 // EntityRemoved subscription bit. // // Without component subscription: // - Removal of an entity, with or without any components // With component subscription: // - Removal of an entity with any of the given components EntityRemoved Subscription = 1 << 1 // ComponentAdded subscription bit. // // Without component subscription: // - Addition of any component(s) to an entity // - Creation of an entity with any components // With component subscription: // - Addition of any of the given components to an entity // - Creation of an entity with any of the given components ComponentAdded Subscription = 1 << 2 // ComponentRemoved subscription bit. // // Without component subscription: // - Removal of any component(s) from an entity // - Removal of an entity with any components // With component subscription: // - Removal of any of the given components from an entity // - Removal of an entity with any of the given components ComponentRemoved Subscription = 1 << 3 // RelationChanged subscription bit. // // Without component subscription: // - Addition of a relation component // - Removal of a relation component // - Exchange of a relation component with another // With component subscription: // - Addition of any of the given relation components // - Removal of any of the given relation components // - Exchange if any of the two is among the given components RelationChanged Subscription = 1 << 4 // TargetChanged subscription bit. // // Without component subscription: // - Whenever RelationChanged is triggered // - Change of the target entity of any relation component // With component subscription: // - Whenever RelationChanged is triggered // - Change of the target entity of any of the given (relation) components TargetChanged Subscription = 1 << 5 )
Subscription bits for individual events.
const ( // Entities subscription for entity creation or removal Entities Subscription = EntityCreated | EntityRemoved // Components subscription for component addition or removal Components Subscription = ComponentAdded | ComponentRemoved // Relations subscription for relation and target changes Relations Subscription = RelationChanged | TargetChanged // All subscriptions All Subscription = Entities | Components | Relations )
Subscription bits for groups of events
func (Subscription) Contains ¶
func (s Subscription) Contains(bits Subscription) bool
Contains checks whether all the argument's bits are contained in this Subscription.
func (Subscription) ContainsAny ¶
func (s Subscription) ContainsAny(bits Subscription) bool
ContainsAny checks whether any of the argument's bits are contained in this Subscription.
Click to show internal directories.
Click to hide internal directories.