Documentation
¶
Index ¶
- Variables
- type Child
- type Parent
- type RelationComponent
- func (r *RelationComponent) Attach(entityType string, c Child)
- func (r *RelationComponent) ConstructChild(childType string, entity Child) error
- func (r *RelationComponent) DestroyChild(childType string, entity Child) error
- func (r *RelationComponent) Detach(entityType string, c Child)
- func (r *RelationComponent) GetAllChildren() map[string][]Child
- func (r *RelationComponent) GetChildren(entityType string) []Child
- func (r *RelationComponent) GetParentID(entityType string) uint64
- func (r *RelationComponent) GetParents() map[string]uint64
- func (r *RelationComponent) Parent(entityType string) (Parent, error)
- func (r *RelationComponent) RemParent(entityType string)
- func (r *RelationComponent) SetParent(entityType string, entityID uint64)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFoundParent = errors.New("not found parent")
)
Relations errors
Functions ¶
This section is empty.
Types ¶
type Child ¶
type Child interface {
ecs.Entity
Parent(entityType string) (Parent, error)
SetParent(entityType string, entityID uint64)
RemParent(entityType string)
Construct() error
Destroy() error
}
Child describe child entity
type Parent ¶
type Parent interface {
ecs.Entity
Attach(entityType string, entity Child)
Detach(entityType string, entity Child)
GetChildren(entityType string) []Child
GetAllChildren() map[string][]Child
}
Parent describe parent entity
type RelationComponent ¶
type RelationComponent struct {
// contains filtered or unexported fields
}
RelationComponent contains parents and childs
func NewRelationComponent ¶
func NewRelationComponent(parents map[string]uint64, ignoreZeroIDs bool) *RelationComponent
NewRelationComponent return new ralation component
func (*RelationComponent) Attach ¶
func (r *RelationComponent) Attach(entityType string, c Child)
Attach attach child
func (*RelationComponent) ConstructChild ¶
func (r *RelationComponent) ConstructChild(childType string, entity Child) error
ConstructChild construct relation with parent
func (*RelationComponent) DestroyChild ¶
func (r *RelationComponent) DestroyChild(childType string, entity Child) error
DestroyChild destroy relation with parent
func (*RelationComponent) Detach ¶
func (r *RelationComponent) Detach(entityType string, c Child)
Detach detach child
func (*RelationComponent) GetAllChildren ¶
func (r *RelationComponent) GetAllChildren() map[string][]Child
GetAllChildren return all children
func (*RelationComponent) GetChildren ¶
func (r *RelationComponent) GetChildren(entityType string) []Child
GetChildren return children
func (*RelationComponent) GetParentID ¶
func (r *RelationComponent) GetParentID(entityType string) uint64
GetParentID return parent id
func (*RelationComponent) GetParents ¶
func (r *RelationComponent) GetParents() map[string]uint64
GetParents return parents
func (*RelationComponent) Parent ¶
func (r *RelationComponent) Parent(entityType string) (Parent, error)
Parent return parent entity
func (*RelationComponent) RemParent ¶
func (r *RelationComponent) RemParent(entityType string)
RemParent remove parent by type
func (*RelationComponent) SetParent ¶
func (r *RelationComponent) SetParent(entityType string, entityID uint64)
SetParent set parent by type
Click to show internal directories.
Click to hide internal directories.