alchemyst/engine/ecs/systems/mob_render_system.go

64 lines
1.8 KiB
Go

package systems
import (
"fmt"
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
"lab.zaar.be/thefish/alchemyst-go/ui/mainwindow"
)
type MobRenderSystem struct {
Controller *ecs.Controller
Layer *mainwindow.Layer
Viewport *mainwindow.ViewPort
*gamemap.Level
}
func (mrs MobRenderSystem) Process(){
for e := range mrs.Controller.GetEntities() {
if mrs.Controller.HasComponent(e, ecs.CoordsComponent) &&
mrs.Controller.HasComponent(e, ecs.AppearanceComponent) {
pos := mrs.Controller.GetComponent(e, ecs.CoordsComponent).(types.Coords)
appearance := mrs.Controller.GetComponent(e, ecs.AppearanceComponent).(types.Appearance)
//fixme
// if vp.Rect.InBounds(pos) {
// Clear the cell this entity occupies, so it is the only glyph drawn there
//for i := 0; i <= 2; i++ {
//mrs.Layer.ClearArea(pos.X, pos.Y,1,1) //WHY?!
//gogue.ClearArea(pos.X, pos.Y, 1, 1, i)
//}
//fixme
//for y := 0; y < mrs.Viewport.H; y++ {
// for x := 0; x < mrs.Viewport.W; x++ {
// mapCoords := types.Coords{mrs.Viewport.CameraCoords.X + x, mrs.Viewport.CameraCoords.Y + y}
// if mrs.Level.InBounds(mapCoords) {
// mrs.Layer.WithRawColor(appearance.ColorSet.Fg.GetColor()).Put(
// x+mrs.Viewport.X,
// y+mrs.Viewport.Y,
// appearance.Glyph.GetGlyph(),
// )
// }
// }
//}
vpc, err := mrs.Viewport.ToVPCoords(pos)
if err != nil {
fmt.Printf("Err: " , err)
}
mrs.Layer.WithRawColor(appearance.ColorSet.Fg.GetColor()).Put(vpc.X, vpc.Y, appearance.Glyph.GetGlyph())
//gogue.PrintGlyph(pos.X, pos.Y, appearance.Glyph, "", appearance.Layer)
//}
}
}
}
func (mrs MobRenderSystem) SystemType() string {
return ecs.MobRenderSystem
}