plugin

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Plugin = plugin{}

Functions

func AddBoolComponent

func AddBoolComponent(id string, component string, value bool) error

AddBoolComponent adds a boolean component to an entity. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name already exists, an error will be thrown.

func AddBoolToMapComponent

func AddBoolToMapComponent(id string, component string, key string, value bool) error

AddBoolToMapComponent adds a boolean component to a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key already exists an error will be thrown. Once a value is added to the map, the type of that key is enforced. Attempting to change // the type of a key will result in an error in later updated.

func AddEntity

func AddEntity(entityType string, args map[string]interface{}) (string, error)

AddEntity adds an entity to the entity registry. It takes the entity id, and a map of arguments to be passed to the entity type's constructor. If the entity type is not registered, an error will be returned. If the entity already exists, an error will be returned.

func AddEntityWithID

func AddEntityWithID(entityType string, id string, args map[string]interface{}) error

AddEntityWithID adds an entity with the provided id to the entity registry. It takes the entity id, and a map of arguments to be passed to the entity type's constructor. If the entity type is not registered, an error will be returned. If the entity already exists, an error will be returned.

func AddInt64ComponentToEntity

func AddInt64ComponentToEntity(id string, component string, value int64) error

AddInt64ComponentToEntity adds an integer64 component to an entity. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name already exists, an error will be thrown.

func AddInt64ToMapComponent

func AddInt64ToMapComponent(id string, component string, key string, value int64) error

AddInt64ToMapComponent adds an integer64 component to a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key already exists an error will be thrown. Once a value is added to the map, the type of that key is enforced. Attempting to change the type of a key will result in an error in later updated.

func AddIntComponent

func AddIntComponent(id string, component string, value int) error

AddIntComponent adds an integer component to an entity. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name already exists, an error will be thrown.

func AddIntToMapComponent

func AddIntToMapComponent(id string, component string, key string, value int) error

AddIntToMapComponent adds an integer component to a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key already exists an error will be thrown. Once a value is added to the map, the type of that key is enforced. Attempting to change the type of a key will result in an error in later updated.

func AddMapComponentToEntity

func AddMapComponentToEntity(id string, component string, value map[string]interface{}) error

AddMapComponentToEntity adds a map component to an entity. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name already exists, an error will be thrown. Once a value is added to the map, the type of that key is enforced. Attempting to change the type of a key will result in an error in later updated.

func AddOrUpdateIntInMapComponent

func AddOrUpdateIntInMapComponent(id string, component string, key string, value int) error

AddOrUpdateIntInMapComponent adds or updates an integer component to a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key already exists, the value will be updated. Once a value is added to the map, the type of that key is enforced. Attempting to change the type of key will result in an error in later updated.

func AddOrUpdateStringComponentToEntity

func AddOrUpdateStringComponentToEntity(id string, component string, value string) error

AddOrUpdateStringComponentToEntity adds or updates a string component to an entity. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name already exists, it will be updated.

func AddOrUpdateStringInMapComponent

func AddOrUpdateStringInMapComponent(id string, component string, key string, value string) error

AddOrUpdateStringInMapComponent adds or updates a string component to a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key already exists, the value will be updated. Once a value is added to the map, the type of that key is enforced. Attempting to change the type of key will result in an error in later updated.

func AddSetComponent

func AddSetComponent(id string, component string, value []interface{}) error

AddSetComponent adds a set component to an entity. It takes the entity ID, component name, and the value of the component. If an entity with the same id already exists error will be thrown. If a component with the same name already exists, an error will be thrown. Once a value is added to the set, the type of that value is enforced for all members of the set. Attempting to change the type of a value will result in an error in later updates.

func AddStringComponentToEntity

func AddStringComponentToEntity(id string, component string, value string) error

AddStringComponentToEntity adds a string component to an entity. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name already exists, an error will be thrown.

func AddStringToMapComponent

func AddStringToMapComponent(id string, component string, key string, value string) error

AddStringToMapComponent adds a string component to a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key already exists an error will be thrown. Once a value is added to the map, the type of that key is enforced. Attempting to change // the type of a key will result in an error in later updated.

func AddToInt64SetComponent

func AddToInt64SetComponent(id string, component string, value int64) error

AddToInt64SetComponent adds an integer64 value to a set component. It takes the entity ID, component name, and the value to add to the set. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the value type is not an integer64, an error will be thrown.

func AddToIntSetComponent

func AddToIntSetComponent(id string, component string, value int) error

AddToIntSetComponent adds an integer value to a set component. It takes the entity ID, component name, and the value to add to the set. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the value type is not an integer, an error will be thrown.

func AddToStringSetComponent

func AddToStringSetComponent(id string, component string, value string) error

AddToStringSetComponent adds a string value to a set component. It takes the entity ID, component name, and the value to add to the set. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the value type is not a string, an error will be thrown.

func ComponentExists

func ComponentExists(id string, component string) (bool, error)

ComponentExists checks if a component exists. It takes the entity ID and the component name.

func CreateEntity

func CreateEntity(entityType string, args map[string]interface{}) (map[string]interface{}, error)

func EntitiesWithComponent

func EntitiesWithComponent(component string) ([]string, error)

func EntitiesWithComponentValue

func EntitiesWithComponentValue(component string, value interface{}) ([]string, error)

func EntityExists

func EntityExists(id string) (bool, error)

func GetBoolComponent

func GetBoolComponent(id string, component string) (bool, error)

GetBoolComponent returns a boolean component from an entity. It takes the entity ID and component name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not a boolean, an error will be thrown.

func GetHashComponent

func GetHashComponent(id string, component string) (map[string]interface{}, error)

GetHashComponent returns a hash component from an entity. It takes the entity ID and component name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not a hash, an error will be thrown.

func GetInt64Component

func GetInt64Component(id string, component string) (int64, error)

GetInt64Component returns an integer64 component from an entity. It takes the entity ID and component name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not an integer64, an error will be thrown.

func GetInt64FromMapComponent

func GetInt64FromMapComponent(id string, component string, element string) (int64, error)

GetInt64FromMapComponent returns the int64 value of an element in a map component. It takes the entity ID, component name, and the element name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not a map, an error will be thrown. If the element does not exist, an error will be thrown. If the element is not an integer64, an error will be thrown.

func GetIntComponent

func GetIntComponent(id string, component string) (int, error)

GetIntComponent returns an integer component from an entity. It takes the entity ID and component name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not an integer, an error will be thrown.

func GetIntFromMapComponent

func GetIntFromMapComponent(id string, component string, element string) (int, error)

GetIntFromMapComponent returns the int value of an element in a map component. It takes the entity ID, component name, and the element name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not a map, an error will be thrown. If the element does not exist, an error will be thrown. If the element is not an integer, an error will be thrown.

func GetStringComponent

func GetStringComponent(id string, component string) (string, error)

GetStringComponent returns the value of the string component. It takes the entity ID and component name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not a string, an error will be thrown.

func GetStringFromMapComponent

func GetStringFromMapComponent(id string, component string, element string) (string, error)

GetStringFromMapComponent returns the string value of an element in a map component. It takes the entity ID, component name, and the element name. If the entity does not exist or the component does not exist, an error will be thrown. If the component is not a map, an error will be thrown. If the element does not exist, an error will be thrown. If the element is not a string, an error will be thrown.

func IsEntityTypeRegistered

func IsEntityTypeRegistered(entityType string) bool

IsEntityTypeRegistered checks if an entity type is registered. It takes the entity type name.

func RegisterEntityType

func RegisterEntityType(entityType entity_type.EntityType)

RegisterEntityType registers an entity type. Entity Types must implmeent the `EntityType` interface. It is expected that developers can override default EntityType implementations with their own implementations.Q

func RegisterSystem

func RegisterSystem(system system.System)

RegisterSystem registers a system with the registry. If a system with the same name is already registered, it will be overwritten.

func RemoveComponent

func RemoveComponent(id string, name string) error

RemoveComponent removes the component from the entity. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown.

func RemoveEntity

func RemoveEntity(id string) error

RemoveEntity removes an entity from the entity registry. It takes the entity type and id. If an entity with the same id does not exist an error will be thrown.

func RemoveFromInt64SetComponent

func RemoveFromInt64SetComponent(id string, component string, value int64) error

RemoveFromInt64SetComponent removes an integer64 value from a set component. It takes the entity ID, component name, and the value to remove from the set. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the value type is not an integer64, an error will be thrown.

func RemoveFromIntSetComponent

func RemoveFromIntSetComponent(id string, component string, value int) error

RemoveFromIntSetComponent removes an integer value from a set component. It takes the entity ID, component name, and the value to remove from the set. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the value type is not an integer, an error will be thrown.

func RemoveFromStringSetComponent

func RemoveFromStringSetComponent(id string, component string, value string) error

RemoveFromStringSetComponent removes a string value from a set component. It takes the entity ID, component name, and the value to remove from the set. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the value type is not a string, an error will be thrown.

func ReplaceEntity

func ReplaceEntity(id string, args map[string]interface{}) error

ReplaceEntity removes and then replaces an entity in the entity registry. It takes the entity type, id, and a map of components. It will remove the entity with the provided id and then add the provided components to the entity. If an entity with the same id does not exist, or the entity type does not match an error will be thrown.

func UpdateBoolComponent

func UpdateBoolComponent(id string, component string, value bool) error

UpdateBoolComponent updates a bool component in the entity registry. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown.

func UpdateBoolInMapComponent

func UpdateBoolInMapComponent(id string, component string, key string, value bool) error

UpdateBoolInMapComponent updates a bool component in a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key soes not already exist an error will be thrown. Once a value is added to the map, the type of that key is enforced. If the value is not the correct type an error will be thrown.

func UpdateEntity

func UpdateEntity(id string, args map[string]interface{}) error

UpdateEntity updates an entity in the entity registry. It takes the entity type, id, and a map of components. It will apply the provided components to the entity. If an entity with the same id does not exist, or the entity type does not match an error will be thrown. If the entity type does not match the existing an error will be thrown. Any components that are not provided will be removed from the entity.

func UpdateInt64Component

func UpdateInt64Component(id string, component string, value int64) error

UpdateInt64Component updates an integer64 component in the entity registry. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown.

func UpdateInt64InMapComponent

func UpdateInt64InMapComponent(id string, component string, key string, value int64) error

UpdateInt64InMapComponent updates an integer64 component in a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key soes not already exist an error will be thrown. Once a value is added to the map, the type of that key is enforced. If the value is not the correct type an error will be thrown.

func UpdateIntComponent

func UpdateIntComponent(id string, component string, value int) error

UpdateIntComponent updates an integer component in the entity registry. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown.

func UpdateIntInMapComponent

func UpdateIntInMapComponent(id string, component string, key string, value int) error

UpdateIntInMapComponent updates an integer component in a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key soes not already exist an error will be thrown. Once a value is added to the map, the type of that key is enforced. If the value is not the correct type an error will be thrown.

func UpdateOrAddEntity

func UpdateOrAddEntity(entityType string, id string, args map[string]interface{}) error

UpdateOrAddEntity updates an entity in the entity registry. It takes the entity type, id, and a map of components. It will apply the provided components to the entity. If an entity with the same id does not exist, it will add the entity with the provided id and components. If the entity type does not match the existing an error will be thrown. Any components that are not provided will be removed from the entity.

func UpdateStringComponent

func UpdateStringComponent(id string, component string, value string) error

UpdateStringComponent updates a string component in the entity registry. It takes the entity ID, component name, and the value of the component. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown.

func UpdateStringInMapComponent

func UpdateStringInMapComponent(id string, component string, key string, value string) error

UpdateStringInMapComponent updates a string component in a map component. It takes the entity ID, component name, the key to which to add the value, and the value to add to the map. If an entity with the same id does not exist an error will be thrown. If a component with the same name does not exist, an error will be thrown. If the key soes not already exist an error will be thrown. Once a value is added to the map, the type of that key is enforced. If the value is not the correct type an error will be thrown.

Types

This section is empty.

Jump to

Keyboard shortcuts

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