Move object into atlas
This commit is contained in:
parent
f40f7123d4
commit
f0ab2abf6e
8 changed files with 66 additions and 72 deletions
53
pkg/atlas/objects.go
Normal file
53
pkg/atlas/objects.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
package atlas
|
||||
|
||||
// Type represents an object type
|
||||
type Type byte
|
||||
|
||||
// Types of objects
|
||||
const (
|
||||
// ObjectNone represents no object at all
|
||||
ObjectNone = Type(0)
|
||||
|
||||
// ObjectRover represents a live rover
|
||||
ObjectRover = Type('R')
|
||||
|
||||
// ObjectSmallRock is a small stashable rock
|
||||
ObjectSmallRock = Type('o')
|
||||
|
||||
// ObjectLargeRock is a large blocking rock
|
||||
ObjectLargeRock = Type('O')
|
||||
)
|
||||
|
||||
// Object represents an object in the world
|
||||
type Object struct {
|
||||
Type Type `json:"type"`
|
||||
}
|
||||
|
||||
// IsBlocking checks if an object is a blocking object
|
||||
func (o *Object) IsBlocking() bool {
|
||||
var blocking = [...]Type{
|
||||
ObjectRover,
|
||||
ObjectLargeRock,
|
||||
}
|
||||
|
||||
for _, t := range blocking {
|
||||
if o.Type == t {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsStashable checks if an object is stashable
|
||||
func (o *Object) IsStashable() bool {
|
||||
var stashable = [...]Type{
|
||||
ObjectSmallRock,
|
||||
}
|
||||
|
||||
for _, t := range stashable {
|
||||
if o.Type == t {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue