2020-07-10 18:39:33 +01:00
|
|
|
package atlas
|
2020-06-26 19:45:24 +01:00
|
|
|
|
2020-07-19 12:26:57 +01:00
|
|
|
import (
|
|
|
|
"github.com/mdiluz/rove/proto/roveapi"
|
2020-06-26 19:45:24 +01:00
|
|
|
)
|
|
|
|
|
2020-07-03 17:00:04 +01:00
|
|
|
// Object represents an object in the world
|
|
|
|
type Object struct {
|
2020-07-19 11:47:19 +01:00
|
|
|
// The type of the object
|
2020-07-19 12:26:57 +01:00
|
|
|
Type roveapi.Object `json:"type"`
|
2020-07-19 13:27:29 +01:00
|
|
|
|
|
|
|
// Data is an internal type used for certain types of object
|
|
|
|
Data []byte `json:"data"`
|
2020-07-03 17:00:04 +01:00
|
|
|
}
|
|
|
|
|
2020-06-30 23:59:58 +01:00
|
|
|
// IsBlocking checks if an object is a blocking object
|
2020-07-03 17:00:04 +01:00
|
|
|
func (o *Object) IsBlocking() bool {
|
2020-07-19 12:26:57 +01:00
|
|
|
var blocking = [...]roveapi.Object{
|
|
|
|
roveapi.Object_RoverLive,
|
2020-07-19 13:49:43 +01:00
|
|
|
roveapi.Object_RoverDormant,
|
2020-07-19 12:26:57 +01:00
|
|
|
roveapi.Object_RockLarge,
|
2020-06-26 19:45:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, t := range blocking {
|
2020-07-03 17:00:04 +01:00
|
|
|
if o.Type == t {
|
2020-06-26 19:45:24 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-06-30 23:59:58 +01:00
|
|
|
// IsStashable checks if an object is stashable
|
2020-07-03 17:00:04 +01:00
|
|
|
func (o *Object) IsStashable() bool {
|
2020-07-19 12:26:57 +01:00
|
|
|
var stashable = [...]roveapi.Object{
|
|
|
|
roveapi.Object_RockSmall,
|
2020-06-26 19:45:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, t := range stashable {
|
2020-07-03 17:00:04 +01:00
|
|
|
if o.Type == t {
|
2020-06-26 19:45:24 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|