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

@ -2,6 +2,8 @@ package screens
import (
"fmt"
"lab.zaar.be/thefish/alchemyst-go/effects"
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
"lab.zaar.be/thefish/alchemyst-go/engine/gamestate"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
"lab.zaar.be/thefish/alchemyst-go/ui/mainwindow"
@ -9,23 +11,24 @@ import (
)
type DevmenuScreen struct {
mw *mainwindow.MainWindow
scm *types.ScreenManager
state *gamestate.GameState
mw *mainwindow.MainWindow
controller *ecs.Controller
scm *types.ScreenManager
state *gamestate.GameState
types.Rect
renderParent bool
bgColor string
fgColor string
bgColor string
fgColor string
}
func NewDevmenuScreen(mw *mainwindow.MainWindow, scm *types.ScreenManager, state *gamestate.GameState, rect types.Rect, renderParent bool) *DevmenuScreen {
func NewDevmenuScreen(mw *mainwindow.MainWindow, controller *ecs.Controller, scm *types.ScreenManager, state *gamestate.GameState, rect types.Rect, renderParent bool) *DevmenuScreen {
return &DevmenuScreen{
mw: mw,
scm: scm,
state: state,
mw: mw,
controller: controller,
scm: scm,
state: state,
Rect: rect,
renderParent: renderParent,
@ -65,6 +68,12 @@ func (devm *DevmenuScreen) HandleInput(input string) {
fmt.Printf("making everything visible!")
devm.scm.SetScreen(devm.scm.PreviousScreen)
break
case "p":
if devm.controller.HasComponent(devm.state.Player, effects.BuffPassWall) {
devm.controller.RemoveComponent(devm.state.Player, effects.BuffPassWall)
} else {
devm.controller.AddComponent(devm.state.Player, effects.PassWall{})
}
case "Escape":
fallthrough
case "Space":
@ -72,7 +81,7 @@ func (devm *DevmenuScreen) HandleInput(input string) {
break
}
}
func (devm *DevmenuScreen) Exit() {
func (devm *DevmenuScreen) Exit() {
if devm.renderParent {
devm.scm.PreviousScreen.Render()
}
@ -95,10 +104,12 @@ func (devm *DevmenuScreen) Render() {
"Dev Menu:",
"[color=green]v[/color] - set all tiles visible",
"[color=green]i[/color] - set all tiles invisible",
fmt.Sprintf("[color=green]p[/color] - toggle passwall: %v",
devm.controller.HasComponent(devm.state.Player, effects.BuffPassWall),
),
}, "\n"),
1,
)
menuLayer.Print(devm.X+2, devm.Y+devm.H-1, "[color=green]Space[/color] to close")
}
}