46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package systems
|
|
|
|
import (
|
|
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
|
|
"lab.zaar.be/thefish/alchemyst-go/engine/fov"
|
|
"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
|
|
Fov fov.Fov
|
|
*gamemap.Level
|
|
}
|
|
|
|
func (mrs MobRenderSystem) Process() {
|
|
//if redraw {
|
|
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 fov check
|
|
//if !mrs.Fov.IsInFov(pos) {
|
|
// continue
|
|
//}
|
|
|
|
vpc, err := mrs.Viewport.ToVPCoords(pos)
|
|
if err != nil {
|
|
continue //we cant see it? no problem.
|
|
}
|
|
mrs.Layer.WithRawColor(appearance.ColorSet.Fg.GetColor()).Put(vpc.X, vpc.Y, appearance.Glyph.GetGlyph())
|
|
}
|
|
}
|
|
//}
|
|
}
|
|
|
|
func (mrs MobRenderSystem) SystemType() string {
|
|
return ecs.MobRenderSystem
|
|
}
|