2020-06-03 18:12:08 +01:00
|
|
|
package game
|
|
|
|
|
|
|
|
import "github.com/google/uuid"
|
|
|
|
|
|
|
|
// A command is simply a function that acts on the a given instance in the world
|
|
|
|
type Command func() error
|
|
|
|
|
|
|
|
// CommandMove will move the instance in question
|
2020-06-04 18:54:33 +01:00
|
|
|
func (w *World) CommandMove(id uuid.UUID, bearing float64, duration int64) Command {
|
2020-06-03 18:12:08 +01:00
|
|
|
return func() error {
|
2020-06-04 18:54:33 +01:00
|
|
|
// TODO: Calculate the move itself
|
|
|
|
|
|
|
|
//_, err := w.MovePosition(id, vec)
|
|
|
|
return nil
|
2020-06-03 18:12:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CommandSpawn
|
|
|
|
// TODO: Two spawn commands with the same id could trigger a fail later on, we should prevent that somehow
|
|
|
|
func (w *World) CommandSpawn(id uuid.UUID) Command {
|
|
|
|
return func() error {
|
|
|
|
return w.Spawn(id)
|
|
|
|
}
|
|
|
|
}
|