ecs

package
v0.0.0-...-841651c Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownComponentType      uint64 = 0
	PositionComponentType     uint64 = 1 << 0
	AreaComponentType         uint64 = 1 << 1
	RangeComponentType        uint64 = 1 << 2
	DamageComponentType       uint64 = 1 << 3
	RestoreComponentType      uint64 = 1 << 4
	ItemComponentType         uint64 = 1 << 5
	AmountComponentType       uint64 = 1 << 6
	WeightComponentType       uint64 = 1 << 7
	SlotsComponentType        uint64 = 1 << 8
	LevelComponentType        uint64 = 1 << 9
	TypeComponentType         uint64 = 1 << 10
	ValutaComponentType       uint64 = 1 << 11
	ResourceComponentType     uint64 = 1 << 12
	TransportComponentType    uint64 = 1 << 13
	TurnDistanceComponentType uint64 = 1 << 14
	VisibilityComponentType   uint64 = 1 << 15
	HealthComponentType       uint64 = 1 << 16
	StatComponentType         uint64 = 1 << 17
	FactionComponentType      uint64 = 1 << 18
	CharacterComponentType    uint64 = 1 << 19
	MapComponentType          uint64 = 1 << 20
	ImageComponentType        uint64 = 1 << 21
	PlayerComponentType       uint64 = 1 << 22

	ControlsRelationComponentType uint64 = 1 << 40
	HasRelationComponentType      uint64 = 1 << 41
	RequiresRelationComponentType uint64 = 1 << 42
	CreatesRelationComponentType  uint64 = 1 << 43
	FilterRelationComponentType   uint64 = 1 << 44
	MapItemRelationComponentType  uint64 = 1 << 45
)

Variables

View Source
var TypeNameToNthBit = map[uint64]TypeTranslationStruct{
	PositionComponentType:     newTypeTranslation("Position", 0),
	AreaComponentType:         newTypeTranslation("Area", 1),
	RangeComponentType:        newTypeTranslation("Range", 2),
	DamageComponentType:       newTypeTranslation("Damage", 3),
	RestoreComponentType:      newTypeTranslation("Restore", 4),
	ItemComponentType:         newTypeTranslation("Item", 5),
	AmountComponentType:       newTypeTranslation("Amount", 6),
	WeightComponentType:       newTypeTranslation("Weight", 7),
	SlotsComponentType:        newTypeTranslation("Slots", 8),
	LevelComponentType:        newTypeTranslation("Level", 9),
	TypeComponentType:         newTypeTranslation("Type", 10),
	ValutaComponentType:       newTypeTranslation("Valuta", 11),
	ResourceComponentType:     newTypeTranslation("Resource", 12),
	TransportComponentType:    newTypeTranslation("Transport", 13),
	TurnDistanceComponentType: newTypeTranslation("TurnDistance", 14),
	VisibilityComponentType:   newTypeTranslation("Visibility", 15),
	HealthComponentType:       newTypeTranslation("Health", 16),
	StatComponentType:         newTypeTranslation("Stat", 17),
	FactionComponentType:      newTypeTranslation("Faction", 18),
	CharacterComponentType:    newTypeTranslation("Character", 19),
	MapComponentType:          newTypeTranslation("Map", 20),
	ImageComponentType:        newTypeTranslation("Image", 21),
	PlayerComponentType:       newTypeTranslation("Player", 22),

	ControlsRelationComponentType: newTypeTranslation("ControlsRelation", 40),
	HasRelationComponentType:      newTypeTranslation("HasRelation", 41),
	RequiresRelationComponentType: newTypeTranslation("RequiresRelation", 42),
	CreatesRelationComponentType:  newTypeTranslation("CreatesRelation", 43),
	FilterRelationComponentType:   newTypeTranslation("FilterRelation", 44),
	MapItemRelationComponentType:  newTypeTranslation("MapItemRelation", 45),
}

@todo merge with const? maybe...

Functions

This section is empty.

Types

type BaseComponent

type BaseComponent struct {
	Version uint      // Placeholder; take changes into account
	Id      uuid.UUID `yaml:"id"`
}

func (*BaseComponent) AllowMultipleOfType

func (c *BaseComponent) AllowMultipleOfType() bool

func (*BaseComponent) CheckValuesParsedFromRaw

func (c *BaseComponent) CheckValuesParsedFromRaw(loadedValues int, raw RawComponent) error

func (*BaseComponent) ComponentType

func (c *BaseComponent) ComponentType() uint64

func (*BaseComponent) GetId

func (c *BaseComponent) GetId() uuid.UUID

func (*BaseComponent) IsRelationalComponent

func (c *BaseComponent) IsRelationalComponent() bool

func (*BaseComponent) LoadFromRawComponent

func (c *BaseComponent) LoadFromRawComponent(raw RawComponent) error

func (*BaseComponent) ParseToRawComponent

func (c *BaseComponent) ParseToRawComponent() (RawComponent, error)

type BaseEntity

type BaseEntity struct {
	Id            uuid.UUID
	Name          string
	Version       uint // Placeholder; take changes into account
	Description   string
	ComponentFlag uint64
	Components    []Component
	RefEntities   []Entity
	// contains filtered or unexported fields
}

func NewEntity

func NewEntity() BaseEntity

func (*BaseEntity) AddComponent

func (e *BaseEntity) AddComponent(c Component) error

func (*BaseEntity) GetAllComponents

func (e *BaseEntity) GetAllComponents() []Component

func (*BaseEntity) GetAllComponentsOfType

func (e *BaseEntity) GetAllComponentsOfType(ct uint64) []Component

func (*BaseEntity) GetComponentByUuid

func (e *BaseEntity) GetComponentByUuid(uuid uuid.UUID) (Component, bool)

func (*BaseEntity) GetDescription

func (e *BaseEntity) GetDescription() string

func (*BaseEntity) GetId

func (e *BaseEntity) GetId() uuid.UUID

func (*BaseEntity) GetName

func (e *BaseEntity) GetName() string

func (*BaseEntity) GetVersion

func (e *BaseEntity) GetVersion() uint

func (*BaseEntity) HasComponentByUuid

func (e *BaseEntity) HasComponentByUuid(uuid uuid.UUID) bool

func (*BaseEntity) HasComponentType

func (e *BaseEntity) HasComponentType(ct uint64) bool

func (*BaseEntity) HasRelationWithEntityByUuid

func (e *BaseEntity) HasRelationWithEntityByUuid(uuid uuid.UUID) bool

func (*BaseEntity) LoadFromRawEntity

func (e *BaseEntity) LoadFromRawEntity(raw RawEntity) error

func (*BaseEntity) RemoveComponentByUuid

func (e *BaseEntity) RemoveComponentByUuid(uuid uuid.UUID) bool

func (*BaseEntity) WithDescription

func (e *BaseEntity) WithDescription(description string) *BaseEntity

func (*BaseEntity) WithName

func (e *BaseEntity) WithName(name string) *BaseEntity

type BaseSystem

type BaseSystem struct {
}

type BaseWorld

type BaseWorld struct {
	UuidToEntity          map[uuid.UUID]Entity
	UuidToItemEntity      map[uuid.UUID]Entity
	UuidToCharacterEntity map[uuid.UUID]Entity
	UuidToMapEntity       map[uuid.UUID]Entity
	UuidToFactionEntity   map[uuid.UUID]Entity
	UuidToInventoryEntity map[uuid.UUID]Entity
	// contains filtered or unexported fields
}

func NewBaseWorld

func NewBaseWorld() BaseWorld

func (*BaseWorld) AddEntities

func (w *BaseWorld) AddEntities(e []Entity) error

func (*BaseWorld) AddEntity

func (w *BaseWorld) AddEntity(e Entity) error

func (*BaseWorld) GetCharacterEntities

func (w *BaseWorld) GetCharacterEntities() []Entity

func (*BaseWorld) GetCharacterEntityByUuid

func (w *BaseWorld) GetCharacterEntityByUuid(uuid uuid.UUID) (Entity, bool)

func (*BaseWorld) GetEntityByUuid

func (w *BaseWorld) GetEntityByUuid(uuid uuid.UUID) (Entity, bool)

func (*BaseWorld) GetFactionEntities

func (w *BaseWorld) GetFactionEntities() []Entity

func (*BaseWorld) GetInventoryEntities

func (w *BaseWorld) GetInventoryEntities() []Entity

func (*BaseWorld) GetItemEntities

func (w *BaseWorld) GetItemEntities() []Entity

func (*BaseWorld) GetMapEntities

func (w *BaseWorld) GetMapEntities() []Entity

func (*BaseWorld) GetMapEntityByUuid

func (w *BaseWorld) GetMapEntityByUuid(uuid uuid.UUID) (Entity, bool)

type Component

type Component interface {
	ComponentType() uint64
	AllowMultipleOfType() bool
	LoadFromRawComponent(raw RawComponent) error
	ParseToRawComponent() (RawComponent, error)
	IsRelationalComponent() bool
	GetId() uuid.UUID
}

type Entity

type Entity interface {
	GetId() uuid.UUID
	GetName() string
	GetVersion() uint
	GetDescription() string
	HasComponentType(ct uint64) bool
	HasComponentByUuid(uuid uuid.UUID) bool
	GetComponentByUuid(uuid uuid.UUID) (Component, bool)
	RemoveComponentByUuid(uuid uuid.UUID) bool
	AddComponent(c Component) error
	LoadFromRawEntity(raw RawEntity) error
	GetAllComponents() []Component
	GetAllComponentsOfType(ct uint64) []Component

	HasRelationWithEntityByUuid(uuid uuid.UUID) bool
	// contains filtered or unexported methods
}

type FilterMode

type FilterMode uint64
const (
	UnknownFilterMode  FilterMode = 1 << 0
	AllowFilterMode    FilterMode = 1 << 1
	BlockFilterMode    FilterMode = 1 << 2
	LessThanFilterMode FilterMode = 1 << 3
	MoreThanFilterMode FilterMode = 1 << 4
)

type RawComponent

type RawComponent struct {
	ComponentType string            `yaml:"type"`
	Params        map[string]string `yaml:"params"`
}

type RawEntity

type RawEntity struct {
	Id          string         `yaml:"id"`
	Name        string         `yaml:"name"`
	Description string         `yaml:"description"`
	Components  []RawComponent `yaml:"components"`
}

type RawGameFile

type RawGameFile struct {
	Version         string         `yaml:"version"`
	TypeTranslation map[string]int `yaml:"type_translation"`
	Items           []RawEntity    `yaml:"base_items"`
	Maps            []RawEntity    `yaml:"base_maps"`
	Factions        []RawEntity    `yaml:"base_factions"`
	Chars           []RawEntity    `yaml:"base_characters"`
	Inventories     []RawEntity    `yaml:"base_inventories"`
}

type RelationalComponent

type RelationalComponent interface {
	Component
	LoadFromRawComponentRelation(raw RawComponent, entity Entity) error
	GetEntity() Entity
}

type System

type System interface {
}

type TypeTranslationStruct

type TypeTranslationStruct struct {
	Name  string
	BitNr uint64
}

type World

type World interface {
	AddEntity(e Entity) error
	AddEntities(e []Entity) error
	GetCharacterEntities() []Entity
	GetMapEntities() []Entity
	GetItemEntities() []Entity
	GetFactionEntities() []Entity
	GetInventoryEntities() []Entity
	GetEntityByUuid(uuid uuid.UUID) (Entity, bool)
	GetMapEntityByUuid(uuid uuid.UUID) (Entity, bool)
	GetCharacterEntityByUuid(uuid uuid.UUID) (Entity, bool)
}

Jump to

Keyboard shortcuts

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