Tile-based worldbuilding library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
543 B

1 year ago
package world
import "sync"
// Entity represents an entity within the world.
type Entity struct {
t int // Type
x, y, z int
sync.RWMutex
}
// NewEntity returns a new Entity.
func NewEntity(t int) *Entity {
return &Entity{t: t}
}
// Is returns whether the Entity matches the specified type.
func (e *Entity) Is(t int) bool {
e.RLock()
defer e.RUnlock()
return e.t == t
}
// Coordinates returns the position of the entity.
func (e *Entity) Coordinates() (x, y, z int) {
e.RLock()
defer e.RUnlock()
return e.x, e.y, e.z
}