package game

import (
	"time"

	"edgaru089.ml/go/gl01/internal/entity"
	"edgaru089.ml/go/gl01/internal/render"
	"edgaru089.ml/go/gl01/internal/util/itype"
	"edgaru089.ml/go/gl01/internal/world"
	"github.com/inkyblackness/imgui-go/v4"

	_ "edgaru089.ml/go/gl01/internal/entity/entities"
)

// Game holds a game scene.
type Game struct {
	world *world.World

	player *entity.Entity

	view   *render.View
	render renderData

	prevCursorPos itype.Vec2d
	cameraPos     itype.Vec3d
	rotY          itype.Angle
	rotZ          float32 // Degrees in range (-90, 90)

	fbSize            itype.Vec2i
	fullscreen        bool
	lastPos, lastSize itype.Vec2i // Window size before entering fullscreen

	runtime time.Duration

	io     imgui.IO
	gui    guiState
	paused bool
}

// NewGame creates a new, empty Game.
func NewGame() (g *Game) {
	return &Game{
		world:     world.NewWorld(),
		player:    entity.NewEntity("player", itype.Vec3d{18, 80, 18}),
		cameraPos: itype.Vec3d{18, 80, 18},
		rotY:      0,
		rotZ:      0,
	}
}

// LoadGameFromPath loads a saved game from a filesystem folder in a read-write fashion.
func LoadGameFromPath(path string) (g *Game, err error) {

	return
}