relations

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL