dev menu, buffs

This commit is contained in:
anton.gurov
2019-11-12 15:57:20 +03:00
parent 7837051e80
commit 6197e3be8e
9 changed files with 94 additions and 76 deletions

View File

@ -3,6 +3,7 @@ package movement
import (
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
"lab.zaar.be/thefish/alchemyst-go/engine/gamestate"
"lab.zaar.be/thefish/alchemyst-go/engine/mob"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
)
@ -45,3 +46,23 @@ func (mov Moveable) IsBlocked(c types.Coords) bool {
}
return false
}
func Walk(entity ecs.Entity, state *gamestate.GameState, dx, dy int) {
controller := state.Controller
coords := controller.GetComponent(state.Player, ecs.CoordsComponent).(types.Coords)
newCoords := types.Coords{coords.X + dx, coords.Y + dy}
if !state.Level.InBounds(newCoords) {
return
}
movable := controller.GetComponent(entity, ecs.MoveableComponent)
if movable == nil {
return
}
if !movable.(Moveable).IsBlocked(newCoords) ||
controller.GetComponent(entity, "pass_wall") != nil {
controller.UpdateComponent(state.Player, ecs.CoordsComponent, newCoords)
}
state.Redraw <- struct{}{}
state.FovRecompute <- struct{}{}
}