Documentation
¶
Overview ¶
Package that describe an Entity-Component-System World
Index ¶
- type Component
- type Composition
- type Entity
- func (entity *Entity) AddComponent(cmp Component) error
- func (entity *Entity) GetComponent(id Identifier) (cmp *Component)
- func (entity *Entity) GetComponents() (components []*Component)
- func (entity *Entity) GetComposition() (composition []string)
- func (entity *Entity) GetId() uuid.UUID
- func (entity *Entity) GetOwnerID() uuid.UUID
- func (entity *Entity) GetPossessedID() uuid.UUID
- func (entity *Entity) GetStructure() *Entity
- func (entity *Entity) GetTypeID() Identifier
- func (entity *Entity) GetWorld() *IWorld
- func (entity *Entity) HaveComponent(cn Identifier) bool
- func (entity *Entity) HaveComponentByIdString(cn string) bool
- func (entity *Entity) HaveComposition(composition []string) bool
- func (entity *Entity) UpdateComponents(components []*Component)
- type EntityNoCycle
- type FeedBack
- type FeedBackType
- type IComponent
- type IEntity
- func CEntity(world *IWorld, id uuid.UUID, components []*Component) *IEntity
- func CEntityPossessed(world *IWorld, id uuid.UUID, possessedByID uuid.UUID, components []*Component) *IEntity
- func CEntityWithOwner(world *IWorld, id uuid.UUID, ownerId uuid.UUID, components []*Component) *IEntity
- func EntityNoCycleToEntity(world *IWorld, entityNoCycle EntityNoCycle) *IEntity
- type ISystem
- type IWorld
- type Identifier
- type SIDE
- type System
- type World
- func (world *World) AddEntities(entities []Entity) (fb *FeedBack)
- func (world *World) AddEntitiesFromEntitiesNoCycle(entitiesNoCycle []EntityNoCycle)
- func (world *World) AddEntity(entity *IEntity) (err *FeedBack)
- func (world *World) AddSystem(sys *ISystem)
- func (world *World) GetEntities() (entities []*IEntity)
- func (world *World) GetEntitiesByComponentId(id Identifier) (entities []*IEntity)
- func (world *World) GetEntitiesNoCycle() (entities []EntityNoCycle)
- func (world *World) GetEntitiesPossessedBy(possessedId uuid.UUID) (entities []*IEntity)
- func (world *World) GetEntitiesWithComponents(v ...Identifier) (entities []*IEntity)
- func (world *World) GetEntitiesWithComponentsIdString(v ...string) (entities []*IEntity)
- func (world *World) GetEntitiesWithComposition(composition Composition) (entities []*IEntity)
- func (world *World) GetEntitiesWithStrictComposition(composition Composition) (entities []*IEntity)
- func (world *World) GetEntity(id uuid.UUID) (ent *IEntity)
- func (world *World) GetId() Identifier
- func (world *World) GetSystemById(id Identifier) *ISystem
- func (world *World) GetSystems() []*ISystem
- func (world *World) RemoveEntity(id uuid.UUID) (err *FeedBack)
- func (world *World) RemoveSystem(id Identifier) (err *FeedBack)
- func (world *World) UpdateClient()
- func (world *World) UpdateEntityComponents(id uuid.UUID, components []*Component) *FeedBack
- func (world *World) UpdateServer()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct { Id Identifier `json:"id"` Data interface{} `json:"data"` }
func CreateComponent ¶
func CreateComponent(id Identifier, data interface{}) *Component
func (*Component) GetId ¶
func (p *Component) GetId() Identifier
func (*Component) GetStructure ¶
type Composition ¶
type Composition struct { Id Identifier Value []string }
func (Composition) Equals ¶
func (source Composition) Equals(target Composition) bool
func (Composition) Len ¶
func (source Composition) Len() int
type Entity ¶
type Entity struct { Id uuid.UUID `json:"id"` OwnerID uuid.UUID `json:"ownerId"` // ClientID TypeID Identifier PossessedID uuid.UUID `json:"possessedId"` World *IWorld Components []*Component `json:"components"` }
func EntityNoCycleArrayToEntityArray ¶
func EntityNoCycleArrayToEntityArray(world IWorld, entitiesNoCycle []EntityNoCycle) (entities []Entity)
func (*Entity) AddComponent ¶
func (*Entity) GetComponent ¶
func (entity *Entity) GetComponent(id Identifier) (cmp *Component)
func (*Entity) GetComponents ¶
func (*Entity) GetComposition ¶
func (*Entity) GetOwnerID ¶
func (*Entity) GetPossessedID ¶
func (*Entity) GetStructure ¶
func (*Entity) GetTypeID ¶
func (entity *Entity) GetTypeID() Identifier
func (*Entity) HaveComponent ¶
func (entity *Entity) HaveComponent(cn Identifier) bool
func (*Entity) HaveComponentByIdString ¶
func (*Entity) HaveComposition ¶
func (*Entity) UpdateComponents ¶
Si un composant spécifié dans l'argument n'existe pas alors on en crée un sur l'entité cible
type EntityNoCycle ¶
type EntityNoCycle struct { Id uuid.UUID `json:"id"` OwnerID uuid.UUID `json:"ownerId"` PossessedID uuid.UUID `json:"possessedId"` Components []*Component `json:"components"` }
Remove Cyclique Structure from type Entity caused by *World qui contient lui même l'entité
func EntityToNoCycle ¶
func EntityToNoCycle(entity *IEntity) EntityNoCycle
type FeedBack ¶
type FeedBack struct { Host string // Le nom du bloc ou plus précisément le nom de la fonction qui host les jobs Job string // Le nom de la fonction qui a provoqué le feedback Label string Type FeedBackType Comment string Data interface{} }
type FeedBackType ¶
type FeedBackType string
var ( FB_ERROR FeedBackType = "FB_ERROR" FB_SUCCESS FeedBackType = "FB_SUCCESS" )
type IComponent ¶
type IComponent interface { GetId() Identifier GetData() interface{} SetData(v interface{}) GetStruct() *Component }
type IEntity ¶
type IEntity interface { GetTypeID() Identifier GetWorld() *IWorld GetId() uuid.UUID GetOwnerID() uuid.UUID GetPossessedID() uuid.UUID AddComponent(cmp Component) error HaveComponent(cn Identifier) bool HaveComponentByIdString(cn string) bool GetComponent(id Identifier) *Component GetComponents() []*Component GetComposition() []string UpdateComponents([]*Component) HaveComposition([]string) bool GetStructure() *Entity }
func CEntityPossessed ¶
func CEntityWithOwner ¶
func EntityNoCycleToEntity ¶
func EntityNoCycleToEntity(world *IWorld, entityNoCycle EntityNoCycle) *IEntity
type IWorld ¶
type IWorld interface { GetId() Identifier // Ajoute une entité AddEntity(*IEntity) *FeedBack // Ajoute une liste d'entité AddEntities([]Entity) *FeedBack // Retourne une entité par son instance ID GetEntity(uuid.UUID) *IEntity // Get all entities instantiated in the world GetEntities() []*IEntity // Return des une copie de toute les entité sans cycle (sans référence au monde qui référence encore toute les entité, c'est infini pour type *IEntity) GetEntitiesNoCycle() []EntityNoCycle // Add entities in the world from an array of Entity without cycle reference AddEntitiesFromEntitiesNoCycle(entitiesNoCycle []EntityNoCycle) // UUID should be an external ID maybe a ClientID GetEntitiesPossessedBy(uuid.UUID) []*IEntity GetEntitiesByComponentId(Identifier) []*IEntity // EN: Get entities which have at least the specified components name. // Returns a slice of IEntity pointers. // FR: Obtiens les entités qui ont au moins les composants spécifiés. // Retourne une tranche de pointeurs IEntity. GetEntitiesWithComponents(...Identifier) []*IEntity GetEntitiesWithComponentsIdString(...string) []*IEntity // Get entities wich have the components specified by the array of component name. GetEntitiesWithStrictComposition(Composition) []*IEntity // EN: Get entities which at least the specified composition // Returns a slice of IEntity pointers // FR: Obtiens les entités qui ont au moins la composition spécifié // Retourne une tranche de pointeurs IEntity. GetEntitiesWithComposition(Composition) []*IEntity // Update a list of component of the entity UpdateEntityComponents(uuid.UUID, []*Component) *FeedBack // Remove an entity by his instanceId RemoveEntity(uuid.UUID) *FeedBack // Ajoute un système, veuillez ajouter une structure Système qui implémente l'interface ISystem AddSystem(*ISystem) // GetSystemById(Identifier) *ISystem RemoveSystem(Identifier) *FeedBack // Execute toutes les methods UpdateClient des systèmes lié à ce monde UpdateClient() // Execute toutes les methods UpdateServer des systèmes lié à ce monde UpdateServer() }
type Identifier ¶
Identifier enable the possibility to have two object with the same path but with a different namespace
Example, a mod could add "mymod:position" and "anothermod:position" You can call World.GetEntityByComponentId("mymod:position")
func (Identifier) Equals ¶
func (id Identifier) Equals(other Identifier) bool
func (Identifier) String ¶
func (id Identifier) String() string
type System ¶
type System struct { Id Identifier Name string Type SIDE World *IWorld // contains filtered or unexported fields }
func (*System) GetId ¶
func (ss *System) GetId() Identifier
type World ¶
type World struct { Id Identifier Entities []*IEntity Systems []*ISystem // contains filtered or unexported fields }
func (*World) AddEntities ¶
func (*World) AddEntitiesFromEntitiesNoCycle ¶
func (world *World) AddEntitiesFromEntitiesNoCycle(entitiesNoCycle []EntityNoCycle)
func (*World) GetEntities ¶
func (*World) GetEntitiesByComponentId ¶
func (world *World) GetEntitiesByComponentId(id Identifier) (entities []*IEntity)
func (*World) GetEntitiesNoCycle ¶
func (world *World) GetEntitiesNoCycle() (entities []EntityNoCycle)
func (*World) GetEntitiesPossessedBy ¶
func (*World) GetEntitiesWithComponents ¶
func (world *World) GetEntitiesWithComponents(v ...Identifier) (entities []*IEntity)
func (*World) GetEntitiesWithComponentsIdString ¶
func (*World) GetEntitiesWithComposition ¶
func (world *World) GetEntitiesWithComposition(composition Composition) (entities []*IEntity)
func (*World) GetEntitiesWithStrictComposition ¶
func (world *World) GetEntitiesWithStrictComposition(composition Composition) (entities []*IEntity)
func (*World) GetId ¶
func (world *World) GetId() Identifier
func (*World) GetSystemById ¶
func (world *World) GetSystemById(id Identifier) *ISystem
func (*World) GetSystems ¶
func (*World) RemoveSystem ¶
func (world *World) RemoveSystem(id Identifier) (err *FeedBack)
func (*World) UpdateClient ¶
func (world *World) UpdateClient()
func (*World) UpdateEntityComponents ¶
func (*World) UpdateServer ¶
func (world *World) UpdateServer()
Click to show internal directories.
Click to hide internal directories.