Documentation ¶
Index ¶
- type BasicEntity
- func (e *BasicEntity) CreateCollidersFromComponent(c *component.Component)
- func (e *BasicEntity) GetID() uint64
- func (e *BasicEntity) GetLocation() mgl.Vec3
- func (e *BasicEntity) GetName() string
- func (e *BasicEntity) GetOrientation() mgl.Quat
- func (e *BasicEntity) SetLocation(p mgl.Vec3)
- func (e *BasicEntity) SetOrientation(q mgl.Quat)
- type BasicSceneManager
- func (sm *BasicSceneManager) AddEntity(newEntity Entity)
- func (sm *BasicSceneManager) AddSystem(newSystem System)
- func (sm *BasicSceneManager) GetNextID() uint64
- func (sm *BasicSceneManager) GetSystemByName(name string) System
- func (sm *BasicSceneManager) MapEntities(fn func(uint64, Entity))
- func (sm *BasicSceneManager) RemoveEntity(oldEntity Entity)
- func (sm *BasicSceneManager) RemoveSystem(oldSystem System)
- func (sm *BasicSceneManager) Update(frameDelta float32)
- type Entity
- type Manager
- type System
- type SystemsByPriority
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicEntity ¶
type BasicEntity struct { ID uint64 Name string CoarseColliders []glider.Collider // contains filtered or unexported fields }
BasicEntity represents any type of object in a scene from a moving character to a stationary crate.
func NewBasicEntity ¶
func NewBasicEntity() *BasicEntity
NewBasicEntity creates a new BasicEntity object with sane defaults and empty slices.
func (*BasicEntity) CreateCollidersFromComponent ¶ added in v0.3.1
func (e *BasicEntity) CreateCollidersFromComponent(c *component.Component)
CreateCollidersFromComponent will create the coarse collision objects for the basic entity based on the component definition.
func (*BasicEntity) GetID ¶
func (e *BasicEntity) GetID() uint64
GetID should return an identifier that no other Entity has.
func (*BasicEntity) GetLocation ¶
func (e *BasicEntity) GetLocation() mgl.Vec3
GetLocation returns the location of the entity in world space.
func (*BasicEntity) GetName ¶
func (e *BasicEntity) GetName() string
GetName should return a user readable name for the Entity, which does not have to be unique.
func (*BasicEntity) GetOrientation ¶
func (e *BasicEntity) GetOrientation() mgl.Quat
GetOrientation gets the local rotation of the entity as a quaternion.
func (*BasicEntity) SetLocation ¶
func (e *BasicEntity) SetLocation(p mgl.Vec3)
SetLocation sets the world space location of the entity.
func (*BasicEntity) SetOrientation ¶
func (e *BasicEntity) SetOrientation(q mgl.Quat)
SetOrientation sets the local rotation of the entity from a quaternion.
type BasicSceneManager ¶
type BasicSceneManager struct {
// contains filtered or unexported fields
}
BasicSceneManager is a basic scene manager to serve as a default impelmentation of the Manager interface.
func NewBasicSceneManager ¶
func NewBasicSceneManager() *BasicSceneManager
NewBasicSceneManager creates a new BasicSceneManager manager object and initializes internal data structures.
func (*BasicSceneManager) AddEntity ¶
func (sm *BasicSceneManager) AddEntity(newEntity Entity)
AddEntity should be called to register an entity with the scene Manager. The Manager should also inform all Systems it knows of with OnAddEntity().
func (*BasicSceneManager) AddSystem ¶
func (sm *BasicSceneManager) AddSystem(newSystem System)
AddSystem adds a new system to the scene manager.
func (*BasicSceneManager) GetNextID ¶
func (sm *BasicSceneManager) GetNextID() uint64
GetNextID should return the next ID integer available. This is not necessarilly be guaranteed to be unique -- but it will be until the uint64 overflows after roughly 1.8e+19 increments.
func (*BasicSceneManager) GetSystemByName ¶
func (sm *BasicSceneManager) GetSystemByName(name string) System
GetSystemByName returns a System, if found, that matches the name supplied.
func (*BasicSceneManager) MapEntities ¶ added in v0.3.1
func (sm *BasicSceneManager) MapEntities(fn func(uint64, Entity))
MapEntities takes a function that accepts a uint64 ID value and an Entity interface and will get called for each entity in the scene in an undefined order.
func (*BasicSceneManager) RemoveEntity ¶
func (sm *BasicSceneManager) RemoveEntity(oldEntity Entity)
RemoveEntity should be called to unregister an entity with the scene Manager. The Manager should also inform all Systems it knows of with OnRemoveEntity().
func (*BasicSceneManager) RemoveSystem ¶
func (sm *BasicSceneManager) RemoveSystem(oldSystem System)
RemoveSystem removes a system from the scene manager.
func (*BasicSceneManager) Update ¶
func (sm *BasicSceneManager) Update(frameDelta float32)
Update should be called each frame to update the scene manager.
type Entity ¶
type Entity interface { // GetID should return an identifier that no other Entity has. GetID() uint64 // GetName should return a user readable name for the Entity, which does // not have to be unique. GetName() string // GetLocation returns the location of the entity in world space. GetLocation() mgl.Vec3 // SetLocation sets the world space location of the entity. SetLocation(mgl.Vec3) // GetOrientation gets the local rotation of the entity as a quaternion. GetOrientation() mgl.Quat // SetOrientation sets the local rotation of the entity from a quaternion. SetOrientation(mgl.Quat) }
Entity is a common interface that represents any object in the scene.
type Manager ¶
type Manager interface { // AddEntity should be called to register an entity with the scene Manager. // The Manager should also inform all Systems it knows of with OnAddEntity(). AddEntity(newEntity Entity) // RemoveEntity should be called to unregister an entity with the scene Manager. // The Manager should also inform all Systems it knows of with OnRemoveEntity(). RemoveEntity(oldEntity Entity) // AddSystem adds a new system to the scene manager. AddSystem(newSystem System) // RemoveSystem removes a system from the scene manager. RemoveSystem(oldSystem System) // GetSystemByName returns a System, if found, that matches the name supplied. GetSystemByName(name string) System // Update should be called each frame to update the scene manager. Update(frameDelta float32) // GetNextID should return the next ID integer available. This is not necessarilly // be guaranteed to be unique (a naive implemention simply increments it as the // overflow case will take a significant amount of time to get to under likely loads). GetNextID() uint64 }
Manager is an interface for scene Manager objects that contain systems and entities and helps coordinate how those interact.
type System ¶
type System interface { // Update should get called to run updates for the system every frame // by the owning Manager object. Update(frameDelta float32) // OnAddEntity should get called by the scene Manager each time a new entity // has been added to the scene. OnAddEntity(newEntity Entity) // OnRemoveEntity should get called by the scene Manager each time an entity // has been removed from the scene. OnRemoveEntity(oldEntity Entity) // GetRequestedPriority returns the requested priority level for the System // which may be of significance to a Manager if they want to order Update() calls. GetRequestedPriority() float32 // GetName returns the name of the system that can be used to identify // the System within Manager. GetName() string }
System describes the basic interface for a 'controller' type object that gets executed from the scene manager.
type SystemsByPriority ¶
type SystemsByPriority []System
SystemsByPriority is a type alias that will implement sort.Interface to sort the slice of Systems by priority.
func (SystemsByPriority) Less ¶
func (s SystemsByPriority) Less(i, j int) bool
Less returns true if the priority of system i is less than system j.
func (SystemsByPriority) Swap ¶
func (s SystemsByPriority) Swap(i, j int)
Swap changes the values at the two indices.