use gogues ecs, not working, needs rethinking

This commit is contained in:
2019-11-04 19:07:16 +03:00
parent fd27dfd636
commit f9ebcefc86
13 changed files with 490 additions and 33 deletions

View File

@ -2,7 +2,9 @@ package mob
import (
"fmt"
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
"reflect"
)
type Mob struct {
@ -11,8 +13,14 @@ type Mob struct {
BlocksPass bool
}
func (m *Mob) Walk(dx, dy int) {
m.Coords = types.Coords{m.X + dx, m.Y + dy}
func (m *Mob) Walk(level *gamemap.Level, dx, dy int) {
newCoords := types.Coords{m.X + dx, m.Y + dy}
if level.GetTile(newCoords).BlocksPass {
return
}
if level.Objects.At(newCoords).HasComponent("block_pass") {
}
fmt.Printf("new coords: %d, %d\n", m.Coords.X, m.Coords.Y)
}
@ -22,4 +30,8 @@ func (m *Mob) Render() {
func (m *Mob) MoveToCoords(c types.Coords) {
}
func (mob Mob) TypeOf() reflect.Type {
return reflect.TypeOf(mob)
}

View File

@ -0,0 +1,29 @@
package mob
import (
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
)
type MobRenderSystem struct {
EntityController *ecs.Controller
}
func (mrs MobRenderSystem) Process(){
for e := range mrs.EntityController.GetEntities() {
if mrs.EntityController.HasComponent(e, types.Coords{}.TypeOf()) &&
mrs.EntityController.HasComponent(e, types.Appearance{}.TypeOf()) {
pos := mrs.EntityController.GetComponent(e, types.Coords{}.TypeOf()).(types.Coords)
appearance := mrs.EntityController.GetComponent(e, types.Appearance{}.TypeOf()).(types.Appearance)
// Clear the cell this entity occupies, so it is the only glyph drawn there
for i := 0; i <= 2; i++ {
//fixme
gogue.ClearArea(pos.X, pos.Y, 1, 1, i)
}
//fixme
gogue.PrintGlyph(pos.X, pos.Y, appearance.Glyph, "", appearance.Layer)
}
}
}