Add dormant rover data marshalled into obj data
This commit is contained in:
parent
1281713211
commit
d3c480cb04
1 changed files with 19 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
|||
package rove
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
|
||||
"github.com/mdiluz/rove/pkg/maths"
|
||||
"github.com/mdiluz/rove/proto/roveapi"
|
||||
"github.com/ojrac/opensimplex-go"
|
||||
|
@ -65,5 +68,21 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) {
|
|||
}
|
||||
}
|
||||
|
||||
// Post process any spawned objects
|
||||
switch obj.Type {
|
||||
case roveapi.Object_RoverDormant:
|
||||
// Create the rover
|
||||
r := DefaultRover()
|
||||
|
||||
// Set the rover variables
|
||||
r.Pos = v
|
||||
|
||||
// Marshal the rover data into the object data
|
||||
obj.Data, err := json.Marshal(r)
|
||||
if err == nil {
|
||||
log.Fatalf("couldn't marshal rover, should never fail: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue