alchemyst/engine/gamestate/gamestate.go
2019-11-04 16:30:06 +03:00

29 lines
573 B
Go

package gamestate
import (
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
"lab.zaar.be/thefish/alchemyst-go/engine/mob"
)
type GameState struct {
Mainfunc chan func()
Exit chan struct{}
Input chan string
RawInput chan int
FovRecompute chan struct{}
Redraw chan struct{}
Level *gamemap.Level
Player *mob.Player
}
// do runs f on the main thread.
func (g *GameState) Do(f func()) {
done := make(chan struct{}, 1)
g.Mainfunc <- func() {
f()
f = nil //zero pointer for closure function
done <- struct{}{}
}
<-done
}