Documentation ¶
Overview ¶
Package locationmanager provides all abilities to detect other entities in an environment.
Package locationmanager provides all abilities to detect other entities in an environment.
Package locationmanager provides all abilities to detect other entities in an environment.
Package locationmanager provides all abilities to detect other entities in an environment.
Index ¶
- type Combination
- type CoordDelta
- type Detection
- type LM
- type Location
- type LocationManager
- func (cm *LocationManager) AddEntAtLocation(ent entity.Entity, comb Combination)
- func (cm *LocationManager) AddEntity(ent entity.Entity)
- func (cm *LocationManager) ChangeLocation(move CoordDelta, ent entity.Entity)
- func (cm *LocationManager) ChangeRadius(radius float64, ent entity.Entity)
- func (cm *LocationManager) GetCollisions(offset CoordDelta, ent entity.Entity) []entity.Entity
- func (cm *LocationManager) GetLocation(ent entity.Entity) (bool, Combination)
- func (cm *LocationManager) NumberOwned() int
- func (cm *LocationManager) RemoveEntity(ent entity.Entity)
- func (lm *LocationManager) StartAtOrigin()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Combination ¶
type Combination struct {
X, Y, Orient float64
}
Combination represents a combination position of x, y and an orientation.
type CoordDelta ¶
CoordDelta structs represent a position relative to an entity.
type Detection ¶
type Detection interface { // Methods for querying collisions, returning the collided objects. // -- Determine which hitboxes occlude a location relative to an entity GetCollisions(loc CoordDelta, ent entity.Entity) []entity.Entity // Methods for updating state in the detector. // -- Inform the detector of a change in state AddEntity(ent entity.Entity) AddEntAtLocation(ent entity.Entity, comb Combination) RemoveEntity(ent entity.Entity) ChangeLocation(move CoordDelta, ent entity.Entity) ChangeRadius(radius float64, ent entity.Entity) }
Detection is the set of methods that entities use to access the collision detector.
type Location ¶
type Location interface { // Retrieve location of an entity. // This returns the x- and y-coordinates, as well as the orientation. // The first value is a boolean for whether the lookup was successful. // This will fail if the queried entity has not registered with the location manager. GetLocation(ent entity.Entity) (bool, Combination) }
Location is the set of methods that the graphics package uses to find the location of entities.
type LocationManager ¶
type LocationManager struct {
// contains filtered or unexported fields
}
LocationManager is an instance of a location manager. It holds all the state about entities in the environment.
func NewLocationManager ¶
func NewLocationManager(x, y float64) *LocationManager
Initialise the LocationManager. Accepts the x- and y-sizes of the tank the creatures' live in.
func (*LocationManager) AddEntAtLocation ¶
func (cm *LocationManager) AddEntAtLocation(ent entity.Entity, comb Combination)
Add an entity at a specific position and orientation.
func (*LocationManager) AddEntity ¶
func (cm *LocationManager) AddEntity(ent entity.Entity)
Add a new entity to a random position in the tank. This is added to first empty entry in the array, else append a new entry.
func (*LocationManager) ChangeLocation ¶
func (cm *LocationManager) ChangeLocation(move CoordDelta, ent entity.Entity)
Update the location of an entity.
func (*LocationManager) ChangeRadius ¶
func (cm *LocationManager) ChangeRadius(radius float64, ent entity.Entity)
Update the radius of an entity.
func (*LocationManager) GetCollisions ¶
func (cm *LocationManager) GetCollisions(offset CoordDelta, ent entity.Entity) []entity.Entity
Determine all entities which exist at a specific point.
func (*LocationManager) GetLocation ¶
func (cm *LocationManager) GetLocation(ent entity.Entity) (bool, Combination)
Get the location and orientation of a specific entity.
func (*LocationManager) NumberOwned ¶
func (cm *LocationManager) NumberOwned() int
Returns the number of hitboxes currently owned by the LocationManager.
func (*LocationManager) RemoveEntity ¶
func (cm *LocationManager) RemoveEntity(ent entity.Entity)
Remove an entity.
func (*LocationManager) StartAtOrigin ¶
func (lm *LocationManager) StartAtOrigin()
Set LM to spawn all new entities at the origin. For testing purposes.