dev menu, buffs
This commit is contained in:
@ -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{}{}
|
||||
}
|
||||
|
Reference in New Issue
Block a user